diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index c07bedb3c..5736fc8e4 100644 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -238,6 +238,20 @@ class NotebookWebApplication(web.Application): 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: + self.log.warn('ipywidgets package not installed. Widgets are unavailable.') + # END HARDCODED WIDGETS HACK + handlers.append( (r"/nbextensions/(.*)", FileFindHandler, { 'path': settings['nbextensions_path'], diff --git a/notebook/static/notebook/js/main.js b/notebook/static/notebook/js/main.js index de288401b..d69d125bb 100644 --- a/notebook/static/notebook/js/main.js +++ b/notebook/static/notebook/js/main.js @@ -50,6 +50,12 @@ 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(){}); + // END HARDCODED WIDGETS HACK + // compat with old IPython, remove for IPython > 3.0 window.CodeMirror = CodeMirror;