##// END OF EJS Templates
removed '/new' URL and added POST notebook request
Zachary Sailer -
Show More
@@ -19,6 +19,8 b' Authors:'
19 19 import os
20 20 from tornado import web
21 21 HTTPError = web.HTTPError
22 from zmq.utils import jsonapi
23
22 24
23 25 from ..base.handlers import IPythonHandler
24 26 from ..utils import url_path_join
@@ -29,20 +31,12 b' from urllib import quote'
29 31 #-----------------------------------------------------------------------------
30 32
31 33
32 class NewPathHandler(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):
34 class NotebookHandler(IPythonHandler):
41 35
42 36 @web.authenticated
43 def get(self):
37 def post(self):
44 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 42 class NamedNotebookHandler(IPythonHandler):
@@ -71,8 +65,8 b' class NamedNotebookHandler(IPythonHandler):'
71 65
72 66 @web.authenticated
73 67 def post(self, notebook_path):
74 nbm =self.notebook_manager
75 notebook_name = nbm.new_notebook()
68 notebook_name = self.notebook_manager.new_notebook(notebook_path)
69 self.finish(jsonapi.dumps({"name": notebook_name}))
76 70
77 71
78 72 class NotebookCopyHandler(IPythonHandler):
@@ -96,8 +90,7 b' class NotebookCopyHandler(IPythonHandler):'
96 90 _notebook_path_regex = r"(?P<notebook_path>.+)"
97 91
98 92 default_handlers = [
99 (r"/notebooks/%s/new" % _notebook_path_regex, NewPathHandler),
100 (r"/notebooks/new", NewHandler),
101 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 78 // File
79 79 var that = this;
80 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 83 this.element.find('#open_notebook').click(function () {
84 84 window.open(that.baseProjectUrl() + 'tree/' + that.notebookPath());
@@ -1743,6 +1743,22 b' var IPython = (function (IPython) {'
1743 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 1763 Notebook.prototype.notebook_rename = function (nbname) {
1748 1764 var that = this;
@@ -14,16 +14,9 b' $(document).ready(function () {'
14 14
15 15 IPython.page = new IPython.Page();
16 16
17 if ($('body').data('notebookPath') == "") {
18 17 $('#new_notebook').button().click(function (e) {
19 window.open($('body').data('baseProjectUrl')+'notebooks/'+'new');
18 IPython.notebook_list.new_notebook($('body').data('baseProjectUrl'))
20 19 });
21 }
22 else {
23 $('#new_notebook').button().click(function (e) {
24 window.open($('body').data('baseProjectUrl')+'notebooks/'+$('body').data('notebookPath') + '/new');
25 });
26 }
27 20
28 21 IPython.notebook_list = new IPython.NotebookList('#notebook_list');
29 22 IPython.cluster_list = new IPython.ClusterList('#cluster_list');
@@ -338,6 +338,8 b' var IPython = (function (IPython) {'
338 338 };
339 339
340 340
341
342
341 343 IPython.NotebookList = NotebookList;
342 344
343 345 return IPython;
General Comments 0
You need to be logged in to leave comments. Login now