Skip to content

Commit

Permalink
Revert fancy pants changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jdfreder committed Mar 30, 2016
1 parent 705992b commit 255e588
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
11 changes: 0 additions & 11 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,6 @@ def load_handlers(name):
mod = __import__(name, fromlist=['default_handlers'])
return mod.default_handlers


class DeprecationHandler(IPythonHandler):
def get(self, url_path):
self.set_header("Content-Type", 'text/javascript')
self.finish("""
console.warn('`/static/widgets/js` is deprecated. Use `nbextensions/widgets/widgets/js` instead.');
define(['%s'], function(x) { return x; });
""" % url_path_join('nbextensions', 'widgets', 'widgets', url_path.rstrip('.js')))
self.log.warning('Deprecated widget Javascript path /static/widgets/js/*.js was used')

#-----------------------------------------------------------------------------
# The Tornado web application
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -262,7 +252,6 @@ def init_handlers(self, settings):

# Order matters. The first handler to match the URL will handle the request.
handlers = []
handlers.append((r'/deprecatedwidgets/(.*)', DeprecationHandler))
handlers.extend(load_handlers('tree.handlers'))
handlers.extend([(r"/login", settings['login_handler_class'])])
handlers.extend([(r"/logout", settings['logout_handler_class'])])
Expand Down
14 changes: 7 additions & 7 deletions notebook/static/base/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ define([
requirejs([ext_path], function(module) {
if (!is_loaded(extension)) {
console.log("Loading extension: " + extension);
Promise.resolve(module.load_ipython_extension()).then(function() {
resolve(module);
}).catch(reject);
if (module.load_ipython_extension) {
Promise.resolve(module.load_ipython_extension()).then(function() {
resolve(module);
}).catch(reject);
}
extensions_loaded.push(ext_path);
} else {
console.log("Loaded extension already: " + extension);
Expand All @@ -55,9 +57,7 @@ define([
*/
var load_extensions = function () {
console.log('load_extensions', arguments);

var args = Array.prototype.splice.apply(arguments);
return Promise.all(args.map(load_extension)).catch(function(err) {
return Promise.all(Array.prototype.map.call(arguments, load_extension)).catch(function(err) {
console.error("Failed to load extension" + (err.requireModules.length>1?'s':'') + ":", err.requireModules, err);
});
};
Expand Down Expand Up @@ -87,7 +87,7 @@ define([
var active = filter_extensions(section.data.load_extensions);
return load_extensions.apply(this, active);
}
});
}).catch(utils.reject('Could not load nbextensions from ' + section.section_name + ' config file'));
}

//============================================================================
Expand Down
15 changes: 11 additions & 4 deletions notebook/static/notebook/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,27 @@ require([
configurable: false
});

// Now actually load nbextensions
// Now actually load nbextensionsload_extensions_from_config
Promise.all([
utils.load_extensions_from_config(config_section),
utils.load_extensions_from_config(common_config),
]).then(function() {
// BEGIN HARDCODED WIDGETS HACK
])
.catch(function(error) {
console.error('Could not load nbextensions from user config files', error);
})
// BEGIN HARDCODED WIDGETS HACK
.then(function() {
if (!utils.is_loaded('widgets/extension')) {
// Fallback to the ipywidgets extension
utils.load_extension('widgets/notebook/js/extension').catch(function () {
console.warn('Widgets are not available. Please install widgetsnbextension or ipywidgets 4.0');
});
}
// END HARDCODED WIDGETS HACK
})
.catch(function(error) {
console.error('Could not load ipywidgets', error);
});
// END HARDCODED WIDGETS HACK

notebook.load_notebook(common_options.notebook_path);

Expand Down

0 comments on commit 255e588

Please sign in to comment.