##// END OF EJS Templates
use FileFindHandler in NotebookApp...
MinRK -
Show More
@@ -48,7 +48,8 b' from .handlers import (LoginHandler, LogoutHandler,'
48 MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler,
48 MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler,
49 ShellHandler, NotebookRootHandler, NotebookHandler, NotebookCopyHandler,
49 ShellHandler, NotebookRootHandler, NotebookHandler, NotebookCopyHandler,
50 RSTHandler, AuthenticatedFileHandler, PrintNotebookHandler,
50 RSTHandler, AuthenticatedFileHandler, PrintNotebookHandler,
51 MainClusterHandler, ClusterProfileHandler, ClusterActionHandler
51 MainClusterHandler, ClusterProfileHandler, ClusterActionHandler,
52 FileFindHandler,
52 )
53 )
53 from .notebookmanager import NotebookManager
54 from .notebookmanager import NotebookManager
54 from .clustermanager import ClusterManager
55 from .clustermanager import ClusterManager
@@ -67,6 +68,7 b' from IPython.zmq.ipkernel import ('
67 )
68 )
68 from IPython.utils.traitlets import Dict, Unicode, Integer, List, Enum, Bool
69 from IPython.utils.traitlets import Dict, Unicode, Integer, List, Enum, Bool
69 from IPython.utils import py3compat
70 from IPython.utils import py3compat
71 from IPython.utils.path import filefind
70
72
71 #-----------------------------------------------------------------------------
73 #-----------------------------------------------------------------------------
72 # Module globals
74 # Module globals
@@ -154,6 +156,7 b' class NotebookWebApplication(web.Application):'
154 settings = dict(
156 settings = dict(
155 template_path=os.path.join(os.path.dirname(__file__), "templates"),
157 template_path=os.path.join(os.path.dirname(__file__), "templates"),
156 static_path=os.path.join(os.path.dirname(__file__), "static"),
158 static_path=os.path.join(os.path.dirname(__file__), "static"),
159 static_handler_class = FileFindHandler,
157 cookie_secret=os.urandom(1024),
160 cookie_secret=os.urandom(1024),
158 login_url="%s/login"%(base_project_url.rstrip('/')),
161 login_url="%s/login"%(base_project_url.rstrip('/')),
159 )
162 )
@@ -355,6 +358,20 b' class NotebookApp(BaseIPythonApplication):'
355 websocket_host = Unicode("", config=True,
358 websocket_host = Unicode("", config=True,
356 help="""The hostname for the websocket server."""
359 help="""The hostname for the websocket server."""
357 )
360 )
361
362 extra_static_paths = List(Unicode, config=True,
363 help="""Extra paths to search for serving static files.
364
365 This allows adding javascript/css to be available from the notebook server machine,
366 or overriding individual files in the IPython"""
367 )
368 def _extra_static_paths_default(self):
369 return [os.path.join(self.profile_dir.location, 'static')]
370
371 @property
372 def static_file_path(self):
373 """return extra paths + the default location"""
374 return self.extra_static_paths + [os.path.join(os.path.dirname(__file__), "static")]
358
375
359 mathjax_url = Unicode("", config=True,
376 mathjax_url = Unicode("", config=True,
360 help="""The url for MathJax.js."""
377 help="""The url for MathJax.js."""
@@ -362,13 +379,11 b' class NotebookApp(BaseIPythonApplication):'
362 def _mathjax_url_default(self):
379 def _mathjax_url_default(self):
363 if not self.enable_mathjax:
380 if not self.enable_mathjax:
364 return u''
381 return u''
365 static_path = self.webapp_settings.get("static_path", os.path.join(os.path.dirname(__file__), "static"))
366 static_url_prefix = self.webapp_settings.get("static_url_prefix",
382 static_url_prefix = self.webapp_settings.get("static_url_prefix",
367 "/static/")
383 "/static/")
368 if os.path.exists(os.path.join(static_path, 'mathjax', "MathJax.js")):
384 try:
369 self.log.info("Using local MathJax")
385 filefind(os.path.join('mathjax', 'MathJax.js'), self.static_file_path)
370 return static_url_prefix+u"mathjax/MathJax.js"
386 except IOError:
371 else:
372 if self.certfile:
387 if self.certfile:
373 # HTTPS: load from Rackspace CDN, because SSL certificate requires it
388 # HTTPS: load from Rackspace CDN, because SSL certificate requires it
374 base = u"https://c328740.ssl.cf1.rackcdn.com"
389 base = u"https://c328740.ssl.cf1.rackcdn.com"
@@ -378,6 +393,9 b' class NotebookApp(BaseIPythonApplication):'
378 url = base + u"/mathjax/latest/MathJax.js"
393 url = base + u"/mathjax/latest/MathJax.js"
379 self.log.info("Using MathJax from CDN: %s", url)
394 self.log.info("Using MathJax from CDN: %s", url)
380 return url
395 return url
396 else:
397 self.log.info("Using local MathJax")
398 return static_url_prefix+u"mathjax/MathJax.js"
381
399
382 def _mathjax_url_changed(self, name, old, new):
400 def _mathjax_url_changed(self, name, old, new):
383 if new and not self.enable_mathjax:
401 if new and not self.enable_mathjax:
General Comments 0
You need to be logged in to leave comments. Login now