From ae2edd0e51bcd98e8d970d8b9cd90acae452f4f1 2014-02-09 07:09:24 From: MinRK Date: 2014-02-09 07:09:24 Subject: [PATCH] s/base_project_url/base_url/ deprecate NotebookApp.base_project_url --- diff --git a/IPython/html/auth/login.py b/IPython/html/auth/login.py index 51ab621..1ad4673 100644 --- a/IPython/html/auth/login.py +++ b/IPython/html/auth/login.py @@ -32,13 +32,13 @@ class LoginHandler(IPythonHandler): def _render(self, message=None): self.write(self.render_template('login.html', - next=url_escape(self.get_argument('next', default=self.base_project_url)), + next=url_escape(self.get_argument('next', default=self.base_url)), message=message, )) def get(self): if self.current_user: - self.redirect(self.get_argument('next', default=self.base_project_url)) + self.redirect(self.get_argument('next', default=self.base_url)) else: self._render() @@ -51,7 +51,7 @@ class LoginHandler(IPythonHandler): self._render(message={'error': 'Invalid password'}) return - self.redirect(self.get_argument('next', default=self.base_project_url)) + self.redirect(self.get_argument('next', default=self.base_url)) #----------------------------------------------------------------------------- diff --git a/IPython/html/base/handlers.py b/IPython/html/base/handlers.py index 4cb674b..5941d11 100644 --- a/IPython/html/base/handlers.py +++ b/IPython/html/base/handlers.py @@ -133,8 +133,8 @@ class IPythonHandler(AuthenticatedHandler): return self.settings.get('mathjax_url', '') @property - def base_project_url(self): - return self.settings.get('base_project_url', '/') + def base_url(self): + return self.settings.get('base_url', '/') @property def base_kernel_url(self): @@ -180,7 +180,7 @@ class IPythonHandler(AuthenticatedHandler): @property def template_namespace(self): return dict( - base_project_url=self.base_project_url, + base_url=self.base_url, base_kernel_url=self.base_kernel_url, logged_in=self.logged_in, login_available=self.login_available, diff --git a/IPython/html/notebook/handlers.py b/IPython/html/notebook/handlers.py index e442d00..fe415e6 100644 --- a/IPython/html/notebook/handlers.py +++ b/IPython/html/notebook/handlers.py @@ -58,7 +58,7 @@ class NotebookRedirectHandler(IPythonHandler): nbm = self.notebook_manager if nbm.path_exists(path): # it's a *directory*, redirect to /tree - url = url_path_join(self.base_project_url, 'tree', path) + url = url_path_join(self.base_url, 'tree', path) else: # otherwise, redirect to /files if '/files/' in path: @@ -73,7 +73,7 @@ class NotebookRedirectHandler(IPythonHandler): if not os.path.exists(files_path): path = path.replace('/files/', '/', 1) - url = url_path_join(self.base_project_url, 'files', path) + url = url_path_join(self.base_url, 'files', path) url = url_escape(url) self.log.debug("Redirecting %s to %s", self.request.path, url) self.redirect(url) diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index 51902a2..1168451 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -133,42 +133,42 @@ def load_handlers(name): class NotebookWebApplication(web.Application): def __init__(self, ipython_app, kernel_manager, notebook_manager, - cluster_manager, session_manager, log, base_project_url, + cluster_manager, session_manager, log, base_url, settings_overrides): settings = self.init_settings( ipython_app, kernel_manager, notebook_manager, cluster_manager, - session_manager, log, base_project_url, settings_overrides) + session_manager, log, base_url, settings_overrides) handlers = self.init_handlers(settings) super(NotebookWebApplication, self).__init__(handlers, **settings) def init_settings(self, ipython_app, kernel_manager, notebook_manager, - cluster_manager, session_manager, log, base_project_url, + cluster_manager, session_manager, log, base_url, settings_overrides): # Python < 2.6.5 doesn't accept unicode keys in f(**kwargs), and - # base_project_url will always be unicode, which will in turn + # base_url will always be unicode, which will in turn # make the patterns unicode, and ultimately result in unicode # keys in kwargs to handler._execute(**kwargs) in tornado. - # This enforces that base_project_url be ascii in that situation. + # This enforces that base_url be ascii in that situation. # # Note that the URLs these patterns check against are escaped, # and thus guaranteed to be ASCII: 'héllo' is really 'h%C3%A9llo'. - base_project_url = py3compat.unicode_to_str(base_project_url, 'ascii') + base_url = py3compat.unicode_to_str(base_url, 'ascii') template_path = settings_overrides.get("template_path", os.path.join(os.path.dirname(__file__), "templates")) settings = dict( # basics log_function=log_request, - base_project_url=base_project_url, + base_url=base_url, base_kernel_url=ipython_app.base_kernel_url, template_path=template_path, static_path=ipython_app.static_file_path, static_handler_class = FileFindHandler, - static_url_prefix = url_path_join(base_project_url,'/static/'), + static_url_prefix = url_path_join(base_url,'/static/'), # authentication cookie_secret=ipython_app.cookie_secret, - login_url=url_path_join(base_project_url,'/login'), + login_url=url_path_join(base_url,'/login'), password=ipython_app.password, # managers @@ -206,10 +206,10 @@ class NotebookWebApplication(web.Application): (r"/files/(.*)", AuthenticatedFileHandler, {'path' : settings['notebook_manager'].notebook_dir}), (r"/nbextensions/(.*)", FileFindHandler, {'path' : settings['nbextensions_path']}), ]) - # prepend base_project_url onto the patterns that we match + # prepend base_url onto the patterns that we match new_handlers = [] for handler in handlers: - pattern = url_path_join(settings['base_project_url'], handler[0]) + pattern = url_path_join(settings['base_url'], handler[0]) new_handler = tuple([pattern] + list(handler[1:])) new_handlers.append(new_handler) # add 404 on the end, which will catch everything that falls through @@ -414,17 +414,22 @@ class NotebookApp(BaseIPythonApplication): if not new: self.mathjax_url = u'' - base_project_url = Unicode('/', config=True, + base_url = Unicode('/', config=True, help='''The base URL for the notebook server. Leading and trailing slashes can be omitted, and will automatically be added. ''') - def _base_project_url_changed(self, name, old, new): + def _base_url_changed(self, name, old, new): if not new.startswith('/'): - self.base_project_url = '/'+new + self.base_url = '/'+new elif not new.endswith('/'): - self.base_project_url = new+'/' + self.base_url = new+'/' + + base_project_url = Unicode('/', config=True, help="""DEPRECATED use base_url""") + def _base_project_url_changed(self, name, old, new): + self.log.warn("base_project_url is deprecated, use base_url") + self.base_url = new base_kernel_url = Unicode('/', config=True, help='''The base URL for the kernel server @@ -473,12 +478,12 @@ class NotebookApp(BaseIPythonApplication): if not self.enable_mathjax: return u'' static_url_prefix = self.webapp_settings.get("static_url_prefix", - url_path_join(self.base_project_url, "static") + url_path_join(self.base_url, "static") ) # try local mathjax, either in nbextensions/mathjax or static/mathjax for (url_prefix, search_path) in [ - (url_path_join(self.base_project_url, "nbextensions"), self.nbextensions_path), + (url_path_join(self.base_url, "nbextensions"), self.nbextensions_path), (static_url_prefix, self.static_file_path), ]: self.log.debug("searching for local mathjax in %s", search_path) @@ -586,7 +591,7 @@ class NotebookApp(BaseIPythonApplication): self.web_app = NotebookWebApplication( self, self.kernel_manager, self.notebook_manager, self.cluster_manager, self.session_manager, - self.log, self.base_project_url, self.webapp_settings + self.log, self.base_url, self.webapp_settings ) if self.certfile: ssl_options = dict(certfile=self.certfile) @@ -639,7 +644,7 @@ class NotebookApp(BaseIPythonApplication): def _url(self, ip): proto = 'https' if self.certfile else 'http' - return "%s://%s:%i%s" % (proto, ip, self.port, self.base_project_url) + return "%s://%s:%i%s" % (proto, ip, self.port, self.base_url) def init_signal(self): if not sys.platform.startswith('win'): @@ -745,7 +750,7 @@ class NotebookApp(BaseIPythonApplication): 'hostname': self.ip if self.ip else 'localhost', 'port': self.port, 'secure': bool(self.certfile), - 'base_project_url': self.base_project_url, + 'base_url': self.base_url, 'notebook_dir': os.path.abspath(self.notebook_manager.notebook_dir), } diff --git a/IPython/html/services/notebooks/handlers.py b/IPython/html/services/notebooks/handlers.py index ac44dd6..dc34c88 100644 --- a/IPython/html/services/notebooks/handlers.py +++ b/IPython/html/services/notebooks/handlers.py @@ -47,7 +47,7 @@ class NotebookHandler(IPythonHandler): The URL path of the notebook. """ return url_escape(url_path_join( - self.base_project_url, 'api', 'notebooks', path, name + self.base_url, 'api', 'notebooks', path, name )) def _finish_model(self, model, location=True): @@ -242,7 +242,7 @@ class NotebookCheckpointsHandler(IPythonHandler): nbm = self.notebook_manager checkpoint = nbm.create_checkpoint(name, path) data = json.dumps(checkpoint, default=date_default) - location = url_path_join(self.base_project_url, 'api/notebooks', + location = url_path_join(self.base_url, 'api/notebooks', path, name, 'checkpoints', checkpoint['id']) self.set_header('Location', url_escape(location)) self.set_status(201) diff --git a/IPython/html/static/auth/js/loginwidget.js b/IPython/html/static/auth/js/loginwidget.js index 739b8b5..ade2c8c 100644 --- a/IPython/html/static/auth/js/loginwidget.js +++ b/IPython/html/static/auth/js/loginwidget.js @@ -14,7 +14,7 @@ var IPython = (function (IPython) { var LoginWidget = function (selector, options) { options = options || {}; - this.base_project_url = options.base_project_url || IPython.utils.get_data("baseProjectUrl"); + this.base_url = options.base_url || IPython.utils.get_data("baseUrl"); this.selector = selector; if (this.selector !== undefined) { this.element = $(selector); @@ -32,13 +32,13 @@ var IPython = (function (IPython) { var that = this; this.element.find("button#logout").click(function () { window.location = IPythin.utils.url_join_encode( - that.base_project_url, + that.base_url, "logout" ); }); this.element.find("button#login").click(function () { window.location = IPythin.utils.url_join_encode( - that.base_project_url, + that.base_url, "login" ); }); diff --git a/IPython/html/static/notebook/js/main.js b/IPython/html/static/notebook/js/main.js index 73f8c09..1ff67f4 100644 --- a/IPython/html/static/notebook/js/main.js +++ b/IPython/html/static/notebook/js/main.js @@ -47,7 +47,7 @@ function (marked) { $('div#notebook_panel').addClass('border-box-sizing'); var opts = { - base_project_url : IPython.utils.get_data("baseProjectUrl"), + base_url : IPython.utils.get_data("baseUrl"), base_kernel_url : IPython.utils.get_data("baseKernelUrl"), notebook_path : IPython.utils.get_data("notebookPath"), notebook_name : IPython.utils.get_data('notebookName') diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js index aebe262..fd0ca15 100644 --- a/IPython/html/static/notebook/js/menubar.js +++ b/IPython/html/static/notebook/js/menubar.js @@ -30,14 +30,14 @@ var IPython = (function (IPython) { * * @param selector {string} selector for the menubar element in DOM * @param {object} [options] - * @param [options.base_project_url] {String} String to use for the + * @param [options.base_url] {String} String to use for the * base project url. Default is to inspect - * $('body').data('baseProjectUrl'); + * $('body').data('baseUrl'); * does not support change for now is set through this option */ var MenuBar = function (selector, options) { options = options || {}; - this.base_project_url = options.base_project_url || IPython.utils.get_data("baseProjectUrl"); + this.base_url = options.base_url || IPython.utils.get_data("baseUrl"); this.selector = selector; if (this.selector !== undefined) { this.element = $(selector); @@ -64,7 +64,7 @@ var IPython = (function (IPython) { IPython.notebook.save_notebook({async : false}); } var url = utils.url_join_encode( - this.base_project_url, + this.base_url, 'nbconvert', format, this.notebook_path, diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index f7a8355..e4c45c7 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -24,7 +24,7 @@ var IPython = (function (IPython) { */ var Notebook = function (selector, options) { this.options = options = options || {}; - this.base_project_url = options.base_project_url; + this.base_url = options.base_url; this.notebook_path = options.notebook_path; this.notebook_name = options.notebook_name; this.element = $(selector); @@ -1683,7 +1683,7 @@ var IPython = (function (IPython) { } $([IPython.events]).trigger('notebook_saving.Notebook'); var url = utils.url_join_encode( - this.base_project_url, + this.base_url, 'api/notebooks', this.notebook_path, this.notebook_name @@ -1744,7 +1744,7 @@ var IPython = (function (IPython) { Notebook.prototype.new_notebook = function(){ var path = this.notebook_path; - var base_project_url = this.base_project_url; + var base_url = this.base_url; var settings = { processData : false, cache : false, @@ -1755,7 +1755,7 @@ var IPython = (function (IPython) { var notebook_name = data.name; window.open( utils.url_join_encode( - base_project_url, + base_url, 'notebooks', path, notebook_name @@ -1765,7 +1765,7 @@ var IPython = (function (IPython) { } }; var url = utils.url_join_encode( - base_project_url, + base_url, 'api/notebooks', path ); @@ -1775,7 +1775,7 @@ var IPython = (function (IPython) { Notebook.prototype.copy_notebook = function(){ var path = this.notebook_path; - var base_project_url = this.base_project_url; + var base_url = this.base_url; var settings = { processData : false, cache : false, @@ -1785,7 +1785,7 @@ var IPython = (function (IPython) { async : false, success : function (data, status, xhr) { window.open(utils.url_join_encode( - base_project_url, + base_url, 'notebooks', data.path, data.name @@ -1793,7 +1793,7 @@ var IPython = (function (IPython) { } }; var url = utils.url_join_encode( - base_project_url, + base_url, 'api/notebooks', path ); @@ -1818,7 +1818,7 @@ var IPython = (function (IPython) { }; $([IPython.events]).trigger('rename_notebook.Notebook', data); var url = utils.url_join_encode( - this.base_project_url, + this.base_url, 'api/notebooks', this.notebook_path, this.notebook_name @@ -1835,7 +1835,7 @@ var IPython = (function (IPython) { dataType: "json", }; var url = utils.url_join_encode( - this.base_project_url, + this.base_url, 'api/notebooks', this.notebook_path, this.notebook_name @@ -1903,7 +1903,7 @@ var IPython = (function (IPython) { }; $([IPython.events]).trigger('notebook_loading.Notebook'); var url = utils.url_join_encode( - this.base_project_url, + this.base_url, 'api/notebooks', this.notebook_path, this.notebook_name @@ -2054,7 +2054,7 @@ var IPython = (function (IPython) { */ Notebook.prototype.list_checkpoints = function () { var url = utils.url_join_encode( - this.base_project_url, + this.base_url, 'api/notebooks', this.notebook_path, this.notebook_name, @@ -2105,7 +2105,7 @@ var IPython = (function (IPython) { */ Notebook.prototype.create_checkpoint = function () { var url = utils.url_join_encode( - this.base_project_url, + this.base_url, 'api/notebooks', this.notebook_path, this.notebook_name, @@ -2192,7 +2192,7 @@ var IPython = (function (IPython) { Notebook.prototype.restore_checkpoint = function (checkpoint) { $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint); var url = utils.url_join_encode( - this.base_project_url, + this.base_url, 'api/notebooks', this.notebook_path, this.notebook_name, @@ -2240,7 +2240,7 @@ var IPython = (function (IPython) { Notebook.prototype.delete_checkpoint = function (checkpoint) { $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint); var url = utils.url_join_encode( - this.base_project_url, + this.base_url, 'api/notebooks', this.notebook_path, this.notebook_name, diff --git a/IPython/html/static/services/sessions/js/session.js b/IPython/html/static/services/sessions/js/session.js index 664c3ba..eea7fd9 100644 --- a/IPython/html/static/services/sessions/js/session.js +++ b/IPython/html/static/services/sessions/js/session.js @@ -20,7 +20,7 @@ var IPython = (function (IPython) { this.notebook = notebook; this.name = notebook.notebook_name; this.path = notebook.notebook_path; - this.base_project_url = notebook.base_project_url; + this.base_url = notebook.base_url; this.base_kernel_url = options.base_kernel_url || utils.get_data("baseKernelUrl"); }; @@ -45,7 +45,7 @@ var IPython = (function (IPython) { } }, }; - var url = utils.url_join_encode(this.base_project_url, 'api/sessions'); + var url = utils.url_join_encode(this.base_url, 'api/sessions'); $.ajax(url, settings); }; @@ -65,7 +65,7 @@ var IPython = (function (IPython) { data: JSON.stringify(model), dataType : "json", }; - var url = utils.url_join_encode(this.base_project_url, 'api/sessions', this.id); + var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id); $.ajax(url, settings); }; @@ -77,7 +77,7 @@ var IPython = (function (IPython) { dataType : "json", }; this.kernel.running = false; - var url = utils.url_join_encode(this.base_project_url, 'api/sessions', this.id); + var url = utils.url_join_encode(this.base_url, 'api/sessions', this.id); $.ajax(url, settings); }; diff --git a/IPython/html/static/tree/js/clusterlist.js b/IPython/html/static/tree/js/clusterlist.js index dc6134c..8c6b43c 100644 --- a/IPython/html/static/tree/js/clusterlist.js +++ b/IPython/html/static/tree/js/clusterlist.js @@ -23,7 +23,7 @@ var IPython = (function (IPython) { } options = options || {}; this.options = options; - this.base_project_url = options.base_project_url || utils.get_data("baseProjectUrl"); + this.base_url = options.base_url || utils.get_data("baseUrl"); this.notebook_path = options.notebook_path || utils.get_data("notebookPath"); }; @@ -51,7 +51,7 @@ var IPython = (function (IPython) { dataType : "json", success : $.proxy(this.load_list_success, this) }; - var url = utils.url_join_encode(this.base_project_url, 'clusters'); + var url = utils.url_join_encode(this.base_url, 'clusters'); $.ajax(url, settings); }; @@ -75,7 +75,7 @@ var IPython = (function (IPython) { var ClusterItem = function (element, options) { this.element = $(element); - this.base_project_url = options.base_project_url || utils.get_data("baseProjectUrl"); + this.base_url = options.base_url || utils.get_data("baseUrl"); this.notebook_path = options.notebook_path || utils.get_data("notebookPath"); this.data = null; this.style(); @@ -135,7 +135,7 @@ var IPython = (function (IPython) { }; status_col.text('starting'); var url = utils.url_join_encode( - that.base_project_url, + that.base_url, 'clusters', that.data.profile, 'start' @@ -177,7 +177,7 @@ var IPython = (function (IPython) { }; status_col.text('stopping'); var url = utils.url_join_encode( - that.base_project_url, + that.base_url, 'clusters', that.data.profile, 'stop' diff --git a/IPython/html/static/tree/js/main.js b/IPython/html/static/tree/js/main.js index 9531041..f31cc5d 100644 --- a/IPython/html/static/tree/js/main.js +++ b/IPython/html/static/tree/js/main.js @@ -19,7 +19,7 @@ $(document).ready(function () { }); var opts = { - base_project_url : IPython.utils.get_data("baseProjectUrl"), + base_url : IPython.utils.get_data("baseUrl"), notebook_path : IPython.utils.get_data("notebookPath"), }; IPython.notebook_list = new IPython.NotebookList('#notebook_list', opts); diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index 1161adb..1cc881a 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -23,7 +23,7 @@ var IPython = (function (IPython) { } this.notebooks_list = []; this.sessions = {}; - this.base_project_url = options.base_project_url || utils.get_data("baseProjectUrl"); + this.base_url = options.base_url || utils.get_data("baseUrl"); this.notebook_path = options.notebook_path || utils.get_data("notebookPath"); }; @@ -106,7 +106,7 @@ var IPython = (function (IPython) { dataType : "json", success : $.proxy(that.sessions_loaded, this) }; - var url = utils.url_join_encode(this.base_project_url, 'api/sessions'); + var url = utils.url_join_encode(this.base_url, 'api/sessions'); $.ajax(url,settings); }; @@ -146,7 +146,7 @@ var IPython = (function (IPython) { }; var url = utils.url_join_encode( - this.base_project_url, + this.base_url, 'api', 'notebooks', this.notebook_path @@ -227,7 +227,7 @@ var IPython = (function (IPython) { item.find("a.item_link") .attr('href', utils.url_join_encode( - this.base_project_url, + this.base_url, "tree", path, name @@ -244,7 +244,7 @@ var IPython = (function (IPython) { item.find("a.item_link") .attr('href', utils.url_join_encode( - this.base_project_url, + this.base_url, "notebooks", path, nbname @@ -285,7 +285,7 @@ var IPython = (function (IPython) { } }; var url = utils.url_join_encode( - that.base_project_url, + that.base_url, 'api/sessions', session ); @@ -325,7 +325,7 @@ var IPython = (function (IPython) { } }; var url = utils.url_join_encode( - notebooklist.base_project_url, + notebooklist.base_url, 'api/notebooks', notebooklist.notebook_path, nbname @@ -374,7 +374,7 @@ var IPython = (function (IPython) { }; var url = utils.url_join_encode( - that.base_project_url, + that.base_url, 'api/notebooks', that.notebook_path, nbname @@ -397,7 +397,7 @@ var IPython = (function (IPython) { NotebookList.prototype.new_notebook = function(){ var path = this.notebook_path; - var base_project_url = this.base_project_url; + var base_url = this.base_url; var settings = { processData : false, cache : false, @@ -408,7 +408,7 @@ var IPython = (function (IPython) { var notebook_name = data.name; window.open( utils.url_join_encode( - base_project_url, + base_url, 'notebooks', path, notebook_name), @@ -417,7 +417,7 @@ var IPython = (function (IPython) { } }; var url = utils.url_join_encode( - base_project_url, + base_url, 'api/notebooks', path ); diff --git a/IPython/html/templates/login.html b/IPython/html/templates/login.html index f388c6e..7244bee 100644 --- a/IPython/html/templates/login.html +++ b/IPython/html/templates/login.html @@ -20,7 +20,7 @@
- diff --git a/IPython/html/templates/logout.html b/IPython/html/templates/logout.html index 5efbe8b..35c65c5 100644 --- a/IPython/html/templates/logout.html +++ b/IPython/html/templates/logout.html @@ -21,9 +21,9 @@ {% endif %} {% if not login_available %} - Proceed to the dashboard. + Proceed to the dashboard. {% else %} - Proceed to the login page. + Proceed to the login page. {% endif %} diff --git a/IPython/html/templates/notebook.html b/IPython/html/templates/notebook.html index 5020713..b05ec42 100644 --- a/IPython/html/templates/notebook.html +++ b/IPython/html/templates/notebook.html @@ -22,7 +22,7 @@ window.mathjax_url = "{{mathjax_url}}"; {% block params %} data-project="{{project}}" -data-base-project-url="{{base_project_url}}" +data-base-url="{{base_url}}" data-base-kernel-url="{{base_kernel_url}}" data-notebook-name="{{notebook_name}}" data-notebook-path="{{notebook_path}}" diff --git a/IPython/html/templates/page.html b/IPython/html/templates/page.html index a9751b6..4d882f4 100644 --- a/IPython/html/templates/page.html +++ b/IPython/html/templates/page.html @@ -21,7 +21,7 @@ require.config({ baseUrl: '{{static_url("")}}', paths: { - nbextensions : '{{ base_project_url }}nbextensions', + nbextensions : '{{ base_url }}nbextensions', underscore : '{{static_url("components/underscore/underscore-min")}}', backbone : '{{static_url("components/backbone/backbone-min")}}', }, @@ -54,7 +54,7 @@