Show More
@@ -609,6 +609,20 b' class ShellHandler(AuthenticatedZMQStreamHandler):' | |||
|
609 | 609 | # Notebook web service handlers |
|
610 | 610 | #----------------------------------------------------------------------------- |
|
611 | 611 | |
|
612 | class NotebookRedirectHandler(AuthenticatedHandler): | |
|
613 | ||
|
614 | @authenticate_unless_readonly | |
|
615 | def get(self, notebook_name): | |
|
616 | app = self.application | |
|
617 | # strip trailing .ipynb: | |
|
618 | notebook_name = os.path.splitext(notebook_name)[0] | |
|
619 | notebook_id = app.notebook_manager.rev_mapping.get(notebook_name, '') | |
|
620 | if notebook_id: | |
|
621 | url = self.settings.get('base_project_url', '/') + notebook_id | |
|
622 | return self.redirect(url) | |
|
623 | else: | |
|
624 | raise HTTPError(404) | |
|
625 | ||
|
612 | 626 | class NotebookRootHandler(AuthenticatedHandler): |
|
613 | 627 | |
|
614 | 628 | @authenticate_unless_readonly |
@@ -52,7 +52,7 b' from .handlers import (LoginHandler, LogoutHandler,' | |||
|
52 | 52 | ShellHandler, NotebookRootHandler, NotebookHandler, NotebookCopyHandler, |
|
53 | 53 | RSTHandler, AuthenticatedFileHandler, PrintNotebookHandler, |
|
54 | 54 | MainClusterHandler, ClusterProfileHandler, ClusterActionHandler, |
|
55 | FileFindHandler, | |
|
55 | FileFindHandler, NotebookRedirectHandler, | |
|
56 | 56 | ) |
|
57 | 57 | from .nbmanager import NotebookManager |
|
58 | 58 | from .filenbmanager import FileNotebookManager |
@@ -86,6 +86,7 b' from IPython.utils.path import filefind' | |||
|
86 | 86 | _kernel_id_regex = r"(?P<kernel_id>\w+-\w+-\w+-\w+-\w+)" |
|
87 | 87 | _kernel_action_regex = r"(?P<action>restart|interrupt)" |
|
88 | 88 | _notebook_id_regex = r"(?P<notebook_id>\w+-\w+-\w+-\w+-\w+)" |
|
89 | _notebook_name_regex = r"(?P<notebook_name>.+\.ipynb)" | |
|
89 | 90 | _profile_regex = r"(?P<profile>[^\/]+)" # there is almost no text that is invalid |
|
90 | 91 | _cluster_action_regex = r"(?P<action>start|stop)" |
|
91 | 92 | |
@@ -136,6 +137,7 b' class NotebookWebApplication(web.Application):' | |||
|
136 | 137 | (r"/logout", LogoutHandler), |
|
137 | 138 | (r"/new", NewHandler), |
|
138 | 139 | (r"/%s" % _notebook_id_regex, NamedNotebookHandler), |
|
140 | (r"/%s" % _notebook_name_regex, NotebookRedirectHandler), | |
|
139 | 141 | (r"/%s/copy" % _notebook_id_regex, NotebookCopyHandler), |
|
140 | 142 | (r"/%s/print" % _notebook_id_regex, PrintNotebookHandler), |
|
141 | 143 | (r"/kernels", MainKernelHandler), |
@@ -170,6 +172,7 b' class NotebookWebApplication(web.Application):' | |||
|
170 | 172 | cookie_secret=os.urandom(1024), |
|
171 | 173 | login_url=url_path_join(base_project_url,'/login'), |
|
172 | 174 | cookie_name='username-%s' % uuid.uuid4(), |
|
175 | base_project_url = base_project_url, | |
|
173 | 176 | ) |
|
174 | 177 | |
|
175 | 178 | # allow custom overrides for the tornado web app. |
General Comments 0
You need to be logged in to leave comments.
Login now