Show More
@@ -62,10 +62,22 b' class NotebookHandler(IPythonHandler):' | |||
|
62 | 62 | # List notebooks in 'path' |
|
63 | 63 | notebooks = nbm.list_notebooks(path) |
|
64 | 64 | self.finish(json.dumps(notebooks, default=date_default)) |
|
65 | return | |
|
66 | # get and return notebook representation | |
|
67 | model = nbm.get_notebook_model(name, path) | |
|
68 | self.set_header(u'Last-Modified', model[u'last_modified']) | |
|
69 | ||
|
70 | if self.get_argument('download', default='False') == 'True': | |
|
71 | format = self.get_argument('format', default='json') | |
|
72 | if format == u'json': | |
|
73 | self.set_header('Content-Type', 'application/json') | |
|
74 | raise web.HTTPError(400, "Unrecognized format: %s" % ext) | |
|
75 | ||
|
76 | self.set_header('Content-Disposition', | |
|
77 | 'attachment; filename="%s"' % name | |
|
78 | ) | |
|
79 | self.finish(json.dumps(model['content'], default=date_default)) | |
|
65 | 80 | else: |
|
66 | # get and return notebook representation | |
|
67 | model = nbm.get_notebook_model(name, path) | |
|
68 | self.set_header(u'Last-Modified', model[u'last_modified']) | |
|
69 | 81 | self.finish(json.dumps(model, default=date_default)) |
|
70 | 82 | |
|
71 | 83 | @web.authenticated |
@@ -18,6 +18,8 b'' | |||
|
18 | 18 | |
|
19 | 19 | var IPython = (function (IPython) { |
|
20 | 20 | "use strict"; |
|
21 | ||
|
22 | var utils = IPython.utils; | |
|
21 | 23 | |
|
22 | 24 | /** |
|
23 | 25 | * A MenuBar Class to generate the menubar of IPython notebook |
@@ -83,14 +85,29 b' var IPython = (function (IPython) {' | |||
|
83 | 85 | }); |
|
84 | 86 | this.element.find('#download_ipynb').click(function () { |
|
85 | 87 | var notebook_name = IPython.notebook.get_notebook_name(); |
|
86 | var url = that.baseProjectUrl() + 'api/notebooks' + that.notebookPath() + | |
|
87 | notebook_name + '?format=json'+ '&download=True'; | |
|
88 | if (IPython.notebook.dirty) { | |
|
89 | IPython.notebook.save_notebook({async : false}); | |
|
90 | } | |
|
91 | ||
|
92 | var url = utils.url_path_join( | |
|
93 | that.baseProjectUrl(), | |
|
94 | 'api/notebooks', | |
|
95 | that.notebookPath(), | |
|
96 | notebook_name + '.ipynb?format=json&download=True' | |
|
97 | ); | |
|
88 | 98 | window.location.assign(url); |
|
89 | 99 | }); |
|
90 | 100 | this.element.find('#download_py').click(function () { |
|
91 | 101 | var notebook_name = IPython.notebook.get_notebook_name(); |
|
92 | var url = that.baseProjectUrl() + 'api/notebooks' + that.notebookPath() + | |
|
93 | notebook_name + '?format=py' + '&download=True'; | |
|
102 | if (IPython.notebook.dirty) { | |
|
103 | IPython.notebook.save_notebook({async : false}); | |
|
104 | } | |
|
105 | var url = utils.url_path_join( | |
|
106 | that.baseProjectUrl(), | |
|
107 | 'api/notebooks', | |
|
108 | that.notebookPath(), | |
|
109 | notebook_name + '.ipynb?format=py&download=True' | |
|
110 | ); | |
|
94 | 111 | window.location.assign(url); |
|
95 | 112 | }); |
|
96 | 113 | this.element.find('#rename_notebook').click(function () { |
@@ -1660,7 +1660,7 b' var IPython = (function (IPython) {' | |||
|
1660 | 1660 | * |
|
1661 | 1661 | * @method save_notebook |
|
1662 | 1662 | */ |
|
1663 | Notebook.prototype.save_notebook = function () { | |
|
1663 | Notebook.prototype.save_notebook = function (extra_settings) { | |
|
1664 | 1664 | // Create a JSON model to be sent to the server. |
|
1665 | 1665 | var model = {}; |
|
1666 | 1666 | model.name = this.notebook_name; |
@@ -1680,6 +1680,11 b' var IPython = (function (IPython) {' | |||
|
1680 | 1680 | success : $.proxy(this.save_notebook_success, this, start), |
|
1681 | 1681 | error : $.proxy(this.save_notebook_error, this) |
|
1682 | 1682 | }; |
|
1683 | if (extra_settings) { | |
|
1684 | for (var key in extra_settings) { | |
|
1685 | settings[key] = extra_settings[key]; | |
|
1686 | } | |
|
1687 | } | |
|
1683 | 1688 | $([IPython.events]).trigger('notebook_saving.Notebook'); |
|
1684 | 1689 | var url = utils.url_path_join( |
|
1685 | 1690 | this.baseProjectUrl(), |
General Comments 0
You need to be logged in to leave comments.
Login now