Skip to content

Commit 74615ad

Browse files
committed
Apply an ugly patch for require config, needed for notebook 5.1
it got broken by jupyter/notebook#2140
1 parent d722470 commit 74615ad

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/jupyter_nbextensions_configurator/templates/nbextensions_configurator.html

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,34 @@
2828
{% block script %}
2929

3030
{{super()}}
31-
3231
<script type="text/javascript">
3332
sys_info = {{sys_info|safe}};
3433
</script>
3534

3635
<script type="text/javascript" charset="utf-8">
36+
// some ugly hacks to fix notebook 5.1.0's broken require config, as
37+
// introduced by https://github.com/jupyter/notebook/pull/2140
38+
(function () {
39+
var nb_v_arr = sys_info.notebook_version.split('.');
40+
if (Number(nb_v_arr[0]) == 5 && Number(nb_v_arr[1]) > 0) {
41+
console.log(
42+
'[nbextensions_configurator] patching requirejs config for notebook',
43+
sys_info.notebook_version);
44+
require.config({paths: {
45+
jed: 'components/jed/jed',
46+
json: 'components/requirejs-plugins/src/json',
47+
text: 'components/requirejs-text/text',
48+
moment: 'components/moment/min/moment-with-locales'
49+
}});
50+
if (!require.defined('json!base/../../i18n/nbjs.json')) {
51+
define('json!base/../../i18n/nbjs.json', function() { return {
52+
"domain": "nbjs",
53+
"supported_languages": [],
54+
"locale_data": {"nbjs": {"": {"domain": "nbjs"}}}
55+
}; });
56+
}
57+
}
58+
})(); // end ugly nb 5.1 hacks IIFE
3759
require(['jquery'], function (jq) {
3860
// hack to fix notebook 4.2.1
3961
// see https://github.com/jupyter/notebook/pull/1399

0 commit comments

Comments
 (0)