##// END OF EJS Templates
/texteditor/ in URLs -> /edit/
Thomas Kluyver -
Show More
@@ -1,29 +1,29 b''
1 #encoding: utf-8
1 #encoding: utf-8
2 """Tornado handlers for the terminal emulator."""
2 """Tornado handlers for the terminal emulator."""
3
3
4 # Copyright (c) IPython Development Team.
4 # Copyright (c) IPython Development Team.
5 # Distributed under the terms of the Modified BSD License.
5 # Distributed under the terms of the Modified BSD License.
6
6
7 from tornado import web
7 from tornado import web
8 from ..base.handlers import IPythonHandler, path_regex
8 from ..base.handlers import IPythonHandler, path_regex
9 from ..utils import url_escape
9 from ..utils import url_escape
10
10
11 class EditorHandler(IPythonHandler):
11 class EditorHandler(IPythonHandler):
12 """Render the text editor interface."""
12 """Render the text editor interface."""
13 @web.authenticated
13 @web.authenticated
14 def get(self, path):
14 def get(self, path):
15 path = path.strip('/')
15 path = path.strip('/')
16 if not self.contents_manager.file_exists(path):
16 if not self.contents_manager.file_exists(path):
17 raise web.HTTPError(404, u'File does not exist: %s' % path)
17 raise web.HTTPError(404, u'File does not exist: %s' % path)
18
18
19 basename = path.rsplit('/', 1)[-1]
19 basename = path.rsplit('/', 1)[-1]
20 self.write(self.render_template('texteditor.html',
20 self.write(self.render_template('texteditor.html',
21 file_path=url_escape(path),
21 file_path=url_escape(path),
22 basename=basename,
22 basename=basename,
23 page_title=basename + " (editing)",
23 page_title=basename + " (editing)",
24 )
24 )
25 )
25 )
26
26
27 default_handlers = [
27 default_handlers = [
28 (r"/texteditor%s" % path_regex, EditorHandler),
28 (r"/edit%s" % path_regex, EditorHandler),
29 ] No newline at end of file
29 ]
General Comments 0
You need to be logged in to leave comments. Login now