Show More
@@ -69,16 +69,21 b' class NotebookHandler(IPythonHandler):' | |||||
69 | self.finish(jsonapi.dumps(notebooks)) |
|
69 | self.finish(jsonapi.dumps(notebooks)) | |
70 | else: |
|
70 | else: | |
71 | format = self.get_argument('format', default='json') |
|
71 | format = self.get_argument('format', default='json') | |
|
72 | download = self.get_argument('download', default='False') | |||
72 | model = nbm.notebook_model(name,path) |
|
73 | model = nbm.notebook_model(name,path) | |
73 | last_mod, representation, name = nbm.get_notebook(name, path, format) |
|
74 | last_mod, representation, name = nbm.get_notebook(name, path, format) | |
|
75 | self.set_header('Last-Modified', last_mod) | |||
74 |
|
76 | |||
|
77 | if download == 'True': | |||
75 | if format == u'json': |
|
78 | if format == u'json': | |
76 | self.set_header('Content-Type', 'application/json') |
|
79 | self.set_header('Content-Type', 'application/json') | |
77 | self.set_header('Content-Disposition','attachment; filename="%s.ipynb"' % name) |
|
80 | self.set_header('Content-Disposition','attachment; filename="%s.ipynb"' % name) | |
|
81 | self.finish(representation) | |||
78 | elif format == u'py': |
|
82 | elif format == u'py': | |
79 | self.set_header('Content-Type', 'application/x-python') |
|
83 | self.set_header('Content-Type', 'application/x-python') | |
80 | self.set_header('Content-Disposition','attachment; filename="%s.py"' % name) |
|
84 | self.set_header('Content-Disposition','attachment; filename="%s.py"' % name) | |
81 | #self.set_header('Last-Modified', last_mod) |
|
85 | self.finish(representation) | |
|
86 | else: | |||
82 | self.finish(jsonapi.dumps(model)) |
|
87 | self.finish(jsonapi.dumps(model)) | |
83 |
|
88 | |||
84 | @web.authenticated |
|
89 | @web.authenticated |
@@ -91,14 +91,14 b' var IPython = (function (IPython) {' | |||||
91 | }); |
|
91 | }); | |
92 | this.element.find('#download_ipynb').click(function () { |
|
92 | this.element.find('#download_ipynb').click(function () { | |
93 | var notebook_name = IPython.notebook.get_notebook_name(); |
|
93 | var notebook_name = IPython.notebook.get_notebook_name(); | |
94 | var url = that.baseProjectUrl() + 'api/notebooks/' + |
|
94 | var url = that.baseProjectUrl() + 'api/notebooks/' + that.notebookPath() + | |
95 | notebook_name + '?format=json'; |
|
95 | notebook_name + '?format=json'+ '&download=True'; | |
96 | window.location.assign(url); |
|
96 | window.location.assign(url); | |
97 | }); |
|
97 | }); | |
98 | this.element.find('#download_py').click(function () { |
|
98 | this.element.find('#download_py').click(function () { | |
99 | var notebook_name = IPython.notebook.get_notebook_name(); |
|
99 | var notebook_name = IPython.notebook.get_notebook_name(); | |
100 | var url = that.baseProjectUrl() + 'api/notebooks/' + |
|
100 | var url = that.baseProjectUrl() + 'api/notebooks/' + that.notebookPath() + | |
101 | notebook_name + '?format=py'; |
|
101 | notebook_name + '?format=py' + '&download=True'; | |
102 | window.location.assign(url); |
|
102 | window.location.assign(url); | |
103 | }); |
|
103 | }); | |
104 | this.element.find('#rename_notebook').click(function () { |
|
104 | this.element.find('#rename_notebook').click(function () { |
General Comments 0
You need to be logged in to leave comments.
Login now