Skip to content

Commit

Permalink
Merge pull request #120 from jdfreder/widgets
Browse files Browse the repository at this point in the history
Hardcode widgets
  • Loading branch information
minrk committed Jul 22, 2015
2 parents 454a581 + fddd29f commit c0f3b0a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,20 @@ def init_handlers(self, settings):
handlers.extend(load_handlers('services.nbconvert.handlers'))
handlers.extend(load_handlers('services.kernelspecs.handlers'))
handlers.extend(load_handlers('services.security.handlers'))

# BEGIN HARDCODED WIDGETS HACK
try:
import ipywidgets
handlers.append(
(r"/nbextensions/widgets/(.*)", FileFindHandler, {
'path': ipywidgets.find_static_assets(),
'no_cache_paths': ['/'], # don't cache anything in nbextensions
}),
)
except:
app_log.warn('ipywidgets package not installed. Widgets are unavailable.')
# END HARDCODED WIDGETS HACK

handlers.append(
(r"/nbextensions/(.*)", FileFindHandler, {
'path': settings['nbextensions_path'],
Expand Down
8 changes: 8 additions & 0 deletions notebook/static/notebook/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ require([
) {
"use strict";

// BEGIN HARDCODED WIDGETS HACK
// Don't include in above require call, avoiding r.js
// and crash on import failure.
require(['nbextensions/widgets/notebook/js/extension'], function(){}, function(err) {
console.error('ipywidgets package not installed. Widgets are not available.');
});
// END HARDCODED WIDGETS HACK

// compat with old IPython, remove for IPython > 3.0
window.CodeMirror = CodeMirror;

Expand Down

0 comments on commit c0f3b0a

Please sign in to comment.