From 142ae515bce8cb9433caca2d80b1070bb62128d7 Mon Sep 17 00:00:00 2001 From: "Brian E. Granger" Date: Wed, 16 Dec 2015 22:32:05 -0800 Subject: [PATCH] Adding prototype nbextensions argument to NotebookApp --- notebook/base/handlers.py | 4 ++++ notebook/notebook/handlers.py | 3 +++ notebook/notebookapp.py | 5 +++++ notebook/templates/notebook.html | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/notebook/base/handlers.py b/notebook/base/handlers.py index 39c705627..cea25f5f9 100644 --- a/notebook/base/handlers.py +++ b/notebook/base/handlers.py @@ -292,6 +292,10 @@ class IPythonHandler(AuthenticatedHandler): # template rendering #--------------------------------------------------------------- + @property + def nbextensions(self): + return self.settings.get('nbextensions', []) + def get_template(self, name): """Return the jinja template object for a given name""" return self.settings['jinja2_env'].get_template(name) diff --git a/notebook/notebook/handlers.py b/notebook/notebook/handlers.py index 72bbd5a82..ab1b068ad 100644 --- a/notebook/notebook/handlers.py +++ b/notebook/notebook/handlers.py @@ -4,6 +4,7 @@ # Distributed under the terms of the Modified BSD License. import os +import json from tornado import web HTTPError = web.HTTPError @@ -21,6 +22,7 @@ class NotebookHandler(IPythonHandler): redirects to the '/files/' handler if the name is not given.""" path = path.strip('/') cm = self.contents_manager + nbextensions = json.dumps(self.nbextensions) # will raise 404 on not found try: @@ -40,6 +42,7 @@ class NotebookHandler(IPythonHandler): notebook_name=name, kill_kernel=False, mathjax_url=self.mathjax_url, + nbextensions=nbextensions ) ) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index ddca04e36..c4aca44be 100644 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -219,6 +219,8 @@ class NotebookWebApplication(web.Application): iopub_data_rate_limit=ipython_app.iopub_data_rate_limit, rate_limit_window=ipython_app.rate_limit_window, + nbextensions=ipython_app.nbextensions, + # authentication cookie_secret=ipython_app.cookie_secret, login_url=url_path_join(base_url,'/login'), @@ -691,6 +693,9 @@ class NotebookApp(JupyterApp): path.append(os.path.join(get_ipython_dir(), 'nbextensions')) return path + nbextensions = List(Unicode(), config=True, + help="A list of nbextensions to enable.") + websocket_url = Unicode("", config=True, help="""The base URL for websockets, if it differs from the HTTP server (hint: it almost certainly doesn't). diff --git a/notebook/templates/notebook.html b/notebook/templates/notebook.html index 31fd510f6..cbc06fdff 100644 --- a/notebook/templates/notebook.html +++ b/notebook/templates/notebook.html @@ -30,7 +30,7 @@ data-base-url="{{base_url | urlencode}}" data-ws-url="{{ws_url | urlencode}}" data-notebook-name="{{notebook_name | urlencode}}" data-notebook-path="{{notebook_path | urlencode}}" - +data-nbextensions="{{nbextensions}}" {% endblock %}