Show More
@@ -19,6 +19,8 b' Authors:' | |||||
19 | import os |
|
19 | import os | |
20 | from tornado import web |
|
20 | from tornado import web | |
21 | HTTPError = web.HTTPError |
|
21 | HTTPError = web.HTTPError | |
|
22 | from zmq.utils import jsonapi | |||
|
23 | ||||
22 |
|
24 | |||
23 | from ..base.handlers import IPythonHandler |
|
25 | from ..base.handlers import IPythonHandler | |
24 | from ..utils import url_path_join |
|
26 | from ..utils import url_path_join | |
@@ -29,20 +31,12 b' from urllib import quote' | |||||
29 | #----------------------------------------------------------------------------- |
|
31 | #----------------------------------------------------------------------------- | |
30 |
|
32 | |||
31 |
|
33 | |||
32 |
class N |
|
34 | class NotebookHandler(IPythonHandler): | |
33 |
|
||||
34 | @web.authenticated |
|
|||
35 | def get(self, notebook_path): |
|
|||
36 | notebook_name = self.notebook_manager.new_notebook(notebook_path) |
|
|||
37 | self.redirect(url_path_join(self.base_project_url,"notebooks", notebook_path, notebook_name)) |
|
|||
38 |
|
||||
39 |
|
||||
40 | class NewHandler(IPythonHandler): |
|
|||
41 |
|
35 | |||
42 | @web.authenticated |
|
36 | @web.authenticated | |
43 |
def |
|
37 | def post(self): | |
44 | notebook_name = self.notebook_manager.new_notebook() |
|
38 | notebook_name = self.notebook_manager.new_notebook() | |
45 | self.redirect(url_path_join(self.base_project_url, "notebooks", notebook_name)) |
|
39 | self.finish(jsonapi.dumps({"name": notebook_name})) | |
46 |
|
40 | |||
47 |
|
41 | |||
48 | class NamedNotebookHandler(IPythonHandler): |
|
42 | class NamedNotebookHandler(IPythonHandler): | |
@@ -68,11 +62,11 b' class NamedNotebookHandler(IPythonHandler):' | |||||
68 | mathjax_url=self.mathjax_url, |
|
62 | mathjax_url=self.mathjax_url, | |
69 | ) |
|
63 | ) | |
70 | ) |
|
64 | ) | |
71 |
|
65 | |||
72 | @web.authenticated |
|
66 | @web.authenticated | |
73 | def post(self, notebook_path): |
|
67 | def post(self, notebook_path): | |
74 | nbm =self.notebook_manager |
|
68 | notebook_name = self.notebook_manager.new_notebook(notebook_path) | |
75 | notebook_name = nbm.new_notebook() |
|
69 | self.finish(jsonapi.dumps({"name": notebook_name})) | |
76 |
|
70 | |||
77 |
|
71 | |||
78 | class NotebookCopyHandler(IPythonHandler): |
|
72 | class NotebookCopyHandler(IPythonHandler): | |
@@ -96,8 +90,7 b' class NotebookCopyHandler(IPythonHandler):' | |||||
96 | _notebook_path_regex = r"(?P<notebook_path>.+)" |
|
90 | _notebook_path_regex = r"(?P<notebook_path>.+)" | |
97 |
|
91 | |||
98 | default_handlers = [ |
|
92 | default_handlers = [ | |
99 | (r"/notebooks/%s/new" % _notebook_path_regex, NewPathHandler), |
|
|||
100 | (r"/notebooks/new", NewHandler), |
|
|||
101 | (r"/notebooks/%s/copy" % _notebook_path_regex, NotebookCopyHandler), |
|
93 | (r"/notebooks/%s/copy" % _notebook_path_regex, NotebookCopyHandler), | |
102 | (r"/notebooks/%s" % _notebook_path_regex, NamedNotebookHandler) |
|
94 | (r"/notebooks/%s" % _notebook_path_regex, NamedNotebookHandler), | |
|
95 | (r"/notebooks/", NotebookHandler) | |||
103 | ] |
|
96 | ] |
@@ -78,7 +78,7 b' var IPython = (function (IPython) {' | |||||
78 | // File |
|
78 | // File | |
79 | var that = this; |
|
79 | var that = this; | |
80 | this.element.find('#new_notebook').click(function () { |
|
80 | this.element.find('#new_notebook').click(function () { | |
81 | window.open(that.baseProjectUrl() + 'notebooks/' + that.notebookPath() +'new'); |
|
81 | IPython.notebook.new_notebook(); | |
82 | }); |
|
82 | }); | |
83 | this.element.find('#open_notebook').click(function () { |
|
83 | this.element.find('#open_notebook').click(function () { | |
84 | window.open(that.baseProjectUrl() + 'tree/' + that.notebookPath()); |
|
84 | window.open(that.baseProjectUrl() + 'tree/' + that.notebookPath()); |
@@ -89,7 +89,7 b' var IPython = (function (IPython) {' | |||||
89 | if (path != 'None') { |
|
89 | if (path != 'None') { | |
90 | if (path[path.length-1] != '/') { |
|
90 | if (path[path.length-1] != '/') { | |
91 | path = path.substring(0,path.length); |
|
91 | path = path.substring(0,path.length); | |
92 | }; |
|
92 | }; | |
93 | return path; |
|
93 | return path; | |
94 | } else { |
|
94 | } else { | |
95 | return ''; |
|
95 | return ''; | |
@@ -1743,6 +1743,22 b' var IPython = (function (IPython) {' | |||||
1743 | $([IPython.events]).trigger('notebook_save_failed.Notebook'); |
|
1743 | $([IPython.events]).trigger('notebook_save_failed.Notebook'); | |
1744 | }; |
|
1744 | }; | |
1745 |
|
1745 | |||
|
1746 | Notebook.prototype.new_notebook = function(){ | |||
|
1747 | var path = this.notebookPath(); | |||
|
1748 | var settings = { | |||
|
1749 | processData : false, | |||
|
1750 | cache : false, | |||
|
1751 | type : "POST", | |||
|
1752 | dataType : "json", | |||
|
1753 | success:$.proxy(function (data, status, xhr){ | |||
|
1754 | notebook_name = data.name; | |||
|
1755 | window.open(this._baseProjectUrl +'notebooks/' + this.notebookPath()+ notebook_name); | |||
|
1756 | }, this) | |||
|
1757 | }; | |||
|
1758 | var url = this._baseProjectUrl + 'notebooks/' + path; | |||
|
1759 | $.ajax(url,settings); | |||
|
1760 | }; | |||
|
1761 | ||||
1746 |
|
1762 | |||
1747 | Notebook.prototype.notebook_rename = function (nbname) { |
|
1763 | Notebook.prototype.notebook_rename = function (nbname) { | |
1748 | var that = this; |
|
1764 | var that = this; |
@@ -13,18 +13,11 b'' | |||||
13 | $(document).ready(function () { |
|
13 | $(document).ready(function () { | |
14 |
|
14 | |||
15 | IPython.page = new IPython.Page(); |
|
15 | IPython.page = new IPython.Page(); | |
16 |
|
16 | |||
17 | if ($('body').data('notebookPath') == "") { |
|
17 | $('#new_notebook').button().click(function (e) { | |
18 | $('#new_notebook').button().click(function (e) { |
|
18 | IPython.notebook_list.new_notebook($('body').data('baseProjectUrl')) | |
19 | window.open($('body').data('baseProjectUrl')+'notebooks/'+'new'); |
|
19 | }); | |
20 | }); |
|
20 | ||
21 | } |
|
|||
22 | else { |
|
|||
23 | $('#new_notebook').button().click(function (e) { |
|
|||
24 | window.open($('body').data('baseProjectUrl')+'notebooks/'+$('body').data('notebookPath') + '/new'); |
|
|||
25 | }); |
|
|||
26 | } |
|
|||
27 |
|
||||
28 | IPython.notebook_list = new IPython.NotebookList('#notebook_list'); |
|
21 | IPython.notebook_list = new IPython.NotebookList('#notebook_list'); | |
29 | IPython.cluster_list = new IPython.ClusterList('#cluster_list'); |
|
22 | IPython.cluster_list = new IPython.ClusterList('#cluster_list'); | |
30 | IPython.login_widget = new IPython.LoginWidget('#login_widget'); |
|
23 | IPython.login_widget = new IPython.LoginWidget('#login_widget'); |
General Comments 0
You need to be logged in to leave comments.
Login now