Skip to content

Commit

Permalink
Add some of the labextension pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Sep 9, 2016
1 parent ab3834d commit b72af1c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
24 changes: 16 additions & 8 deletions jupyterlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from jinja2 import FileSystemLoader
from notebook.utils import url_path_join as ujoin


#-----------------------------------------------------------------------------
# Module globals
#-----------------------------------------------------------------------------
Expand All @@ -19,9 +18,9 @@
npm run watch
from the JupyterLab repo directory in another terminal window to have the system
incrementally watch and build JupyterLab's TypeScript for you, as you make
changes.
from the JupyterLab repo directory in another terminal window to have the
system incrementally watch and build JupyterLab's TypeScript for you, as you
make changes.
"""

HERE = os.path.dirname(__file__)
Expand Down Expand Up @@ -54,9 +53,10 @@ def get_template(self, name):

default_handlers = [
(PREFIX + r'/?', LabHandler),
(PREFIX+r"/(.+)", FileFindHandler,
(PREFIX + r"/(.*)", FileFindHandler,
{'path': BUILT_FILES}),
]
]


def _jupyter_server_extension_paths():
return [{
Expand All @@ -69,7 +69,15 @@ def load_jupyter_server_extension(nbapp):
dev_mode = os.path.exists(os.path.join(base_dir, '.git'))
if dev_mode:
nbapp.log.info(DEV_NOTE_NPM)
nbapp.log.info('JupyterLab alpha preview extension loaded from %s'%HERE)
nbapp.log.info('JupyterLab alpha preview extension loaded from %s' % HERE)
webapp = nbapp.web_app
base_url = webapp.settings['base_url']
webapp.add_handlers(".*$", [(ujoin(base_url, h[0]),) + h[1:] for h in default_handlers])
webapp.add_handlers(".*$",
[(ujoin(base_url, h[0]),) + h[1:] for h in default_handlers])
lab_extension_handler = (
r"/labextensions/(.*)", FileFindHandler, {
'path': nbapp.labextensions_path,
'no_cache_paths': ['/'], # don't cache anything in labbextensions
}
)
webapp.add_handlers(".*$", [lab_extension_handler])
12 changes: 11 additions & 1 deletion jupyterlab/labapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
# Distributed under the terms of the Modified BSD License.

# TODO: import base server app
from jupyter_core.paths import jupyter_path
from notebook.notebookapp import NotebookApp
from traitlets import Unicode
from traitlets import List, Unicode


class LabApp(NotebookApp):
Expand All @@ -15,6 +16,15 @@ class LabApp(NotebookApp):
help="The default URL to redirect to from `/`"
)

extra_labextensions_path = List(Unicode(), config=True,
help="""extra paths to look for JupyterLab extensions"""
)

@property
def labextensions_path(self):
"""The path to look for JupyterLab extensions"""
return self.extra_labextensions_path + jupyter_path('labextensions')

#-----------------------------------------------------------------------------
# Main entry point
#-----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def run(self):
'entry_points': {
'console_scripts': [
'jupyter-lab = jupyterlab.labapp:main',
'jupyter-labextension = jupyterlab.labextensions:main',
]
},
'author': 'Jupyter Development Team',
Expand Down

0 comments on commit b72af1c

Please sign in to comment.