allow setting base_project_url and base_kernel_url to non-default values

Andrew Straw 14 years ago
parent c706d6ed99
commit bd7f1f941c

@ -192,7 +192,8 @@ class ProjectDashboardHandler(AuthenticatedHandler):
project = nbm.notebook_dir
self.render(
'projectdashboard.html', project=project,
base_project_url=u'/', base_kernel_url=u'/',
base_project_url=self.application.ipython_app.base_project_url,
base_kernel_url=self.application.ipython_app.base_kernel_url,
read_only=self.read_only,
logged_in=self.logged_in,
login_available=self.login_available
@ -255,7 +256,8 @@ class NewHandler(AuthenticatedHandler):
self.render(
'notebook.html', project=project,
notebook_id=notebook_id,
base_project_url=u'/', base_kernel_url=u'/',
base_project_url=self.application.ipython_app.base_project_url,
base_kernel_url=self.application.ipython_app.base_kernel_url,
kill_kernel=False,
read_only=False,
logged_in=self.logged_in,
@ -276,7 +278,8 @@ class NamedNotebookHandler(AuthenticatedHandler):
self.render(
'notebook.html', project=project,
notebook_id=notebook_id,
base_project_url=u'/', base_kernel_url=u'/',
base_project_url=self.application.ipython_app.base_project_url,
base_kernel_url=self.application.ipython_app.base_kernel_url,
kill_kernel=False,
read_only=self.read_only,
logged_in=self.logged_in,
@ -297,7 +300,8 @@ class PrintNotebookHandler(AuthenticatedHandler):
self.render(
'printnotebook.html', project=project,
notebook_id=notebook_id,
base_project_url=u'/', base_kernel_url=u'/',
base_project_url=self.application.ipython_app.base_project_url,
base_kernel_url=self.application.ipython_app.base_kernel_url,
kill_kernel=False,
read_only=self.read_only,
logged_in=self.logged_in,
@ -637,7 +641,8 @@ class NotebookCopyHandler(AuthenticatedHandler):
self.render(
'notebook.html', project=project,
notebook_id=notebook_id,
base_project_url=u'/', base_kernel_url=u'/',
base_project_url=self.application.ipython_app.base_project_url,
base_kernel_url=self.application.ipython_app.base_kernel_url,
kill_kernel=False,
read_only=False,
logged_in=self.logged_in,

@ -84,13 +84,24 @@ ipython notebook --certfile=mycert.pem # use SSL/TLS certificate
ipython notebook --port=5555 --ip=* # Listen on port 5555, all interfaces
"""
#-----------------------------------------------------------------------------
# Helper functions
#-----------------------------------------------------------------------------
def url_path_join(a,b):
if a.endswith('/') and b.startswith('/'):
return a[:-1]+b
else:
return a+b
#-----------------------------------------------------------------------------
# The Tornado web application
#-----------------------------------------------------------------------------
class NotebookWebApplication(web.Application):
def __init__(self, ipython_app, kernel_manager, notebook_manager, log, settings_overrides):
def __init__(self, ipython_app, kernel_manager, notebook_manager, log,
base_project_url, settings_overrides):
handlers = [
(r"/", ProjectDashboardHandler),
(r"/login", LoginHandler),
@ -119,7 +130,14 @@ class NotebookWebApplication(web.Application):
# allow custom overrides for the tornado web app.
settings.update(settings_overrides)
super(NotebookWebApplication, self).__init__(handlers, **settings)
# prepend base_project_url onto the patterns that we match
new_handlers = []
for handler in handlers:
pattern = url_path_join(base_project_url, handler[0])
new_handler = tuple([pattern]+list(handler[1:]))
new_handlers.append( new_handler )
super(NotebookWebApplication, self).__init__(new_handlers, **settings)
self.kernel_manager = kernel_manager
self.log = log
@ -278,6 +296,11 @@ class NotebookApp(BaseIPythonApplication):
if not new:
self.mathjax_url = u''
base_project_url = Unicode('/', config=True,
help='''The base URL for the notebook server''')
base_kernel_url = Unicode('/', config=True,
help='''The base URL for the kernel server''')
mathjax_url = Unicode("", config=True,
help="""The url for MathJax.js."""
)
@ -333,7 +356,7 @@ class NotebookApp(BaseIPythonApplication):
"""initialize tornado webapp and httpserver"""
self.web_app = NotebookWebApplication(
self, self.kernel_manager, self.notebook_manager, self.log,
self.webapp_settings
self.base_project_url, self.webapp_settings
)
if self.certfile:
ssl_options = dict(certfile=self.certfile)

Loading…
Cancel
Save