-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow voila to run a server extension for notebook <5
- Loading branch information
1 parent
9f51f17
commit 6e772b4
Showing
3 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
|
||
|
||
def get_server_root_dir(settings): | ||
# notebook >= 5.0.0 has this in the settings | ||
if 'server_root_dir' in settings: | ||
return settings['server_root_dir'] | ||
|
||
# This copies the logic added in the notebook in | ||
# https://github.com/jupyter/notebook/pull/2234 | ||
contents_manager = settings['contents_manager'] | ||
root_dir = contents_manager.root_dir | ||
home = os.path.expanduser('~') | ||
if root_dir.startswith(home + os.path.sep): | ||
# collapse $HOME to ~ | ||
root_dir = '~' + root_dir[len(home):] | ||
return root_dir |