##// END OF EJS Templates
support 1.0-style `files/` relative URLs...
MinRK -
Show More
@@ -16,6 +16,7 b' Authors:'
16 # Imports
16 # Imports
17 #-----------------------------------------------------------------------------
17 #-----------------------------------------------------------------------------
18
18
19 import os
19 from tornado import web
20 from tornado import web
20 HTTPError = web.HTTPError
21 HTTPError = web.HTTPError
21
22
@@ -61,7 +62,18 b' class NotebookRedirectHandler(IPythonHandler):'
61 url = url_path_join(self.base_project_url, 'tree', path)
62 url = url_path_join(self.base_project_url, 'tree', path)
62 else:
63 else:
63 # otherwise, redirect to /files
64 # otherwise, redirect to /files
64 # TODO: This should check if it's actually a file
65 if '/files/' in path:
66 # redirect without files/ iff it would 404
67 # this preserves pre-2.0-style 'files/' links
68 # FIXME: this is hardcoded based on notebook_path,
69 # but so is the files handler itself,
70 # so it should work until both are cleaned up.
71 parts = path.split('/')
72 files_path = os.path.join(nbm.notebook_dir, *parts)
73 self.log.warn("filespath: %s", files_path)
74 if not os.path.exists(files_path):
75 path = path.replace('/files/', '/', 1)
76
65 url = url_path_join(self.base_project_url, 'files', path)
77 url = url_path_join(self.base_project_url, 'files', path)
66 url = url_escape(url)
78 url = url_escape(url)
67 self.log.debug("Redirecting %s to %s", self.request.path, url)
79 self.log.debug("Redirecting %s to %s", self.request.path, url)
General Comments 0
You need to be logged in to leave comments. Login now