From 0cd153d625253f8c31ae973fc1535243098f5e6f Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Sun, 26 May 2013 21:38:25 +0200 Subject: [PATCH 1/4] Inject requirejs in notebook and start using it. --- .../frontend/html/notebook/static/components | 2 +- .../notebook/static/notebook/js/config.js | 14 +++++----- .../html/notebook/static/notebook/js/main.js | 26 ++++++++++++++----- .../html/notebook/templates/notebook.html | 2 -- .../html/notebook/templates/page.html | 7 ++++- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/IPython/frontend/html/notebook/static/components b/IPython/frontend/html/notebook/static/components index 5548cce21d4..723c9669981 160000 --- a/IPython/frontend/html/notebook/static/components +++ b/IPython/frontend/html/notebook/static/components @@ -1 +1 @@ -Subproject commit 5548cce21d47d044438874e68a210884ba6a1549 +Subproject commit 723c96699818e54ea31a5efe1b88042a5ac95151 diff --git a/IPython/frontend/html/notebook/static/notebook/js/config.js b/IPython/frontend/html/notebook/static/notebook/js/config.js index 432fb2b7f0f..56e3656a90f 100644 --- a/IPython/frontend/html/notebook/static/notebook/js/config.js +++ b/IPython/frontend/html/notebook/static/notebook/js/config.js @@ -8,15 +8,16 @@ //============================================================================ // Notebook //============================================================================ +"use strict"; /** * @module IPython * @namespace IPython **/ -var IPython = (function (IPython) { +define(function () { /** - * A place where some stuff can be confugured. + * A place where some stuff can be configured. * * @class config * @static @@ -69,10 +70,9 @@ var IPython = (function (IPython) { }; // use the same method to merge user configuration - IPython.config = {}; - $.extend(IPython.config, default_config); + var config = {}; + $.extend(config, default_config); - return IPython; - -}(IPython)); + return config; +}); diff --git a/IPython/frontend/html/notebook/static/notebook/js/main.js b/IPython/frontend/html/notebook/static/notebook/js/main.js index ae212314271..2ecb1510794 100644 --- a/IPython/frontend/html/notebook/static/notebook/js/main.js +++ b/IPython/frontend/html/notebook/static/notebook/js/main.js @@ -8,17 +8,30 @@ //============================================================================ // On document ready //============================================================================ +"use strict"; +// for the time beeing, we have to pass marked as a parameter here, +// as injecting require.js make marked not to put itself in the globals, +// which make both this file fail at setting marked configuration, and textcell.js +// which search marked into global. +require(['static/components/marked/lib/marked.js', + 'static/notebook/js/config.js'], -$(document).ready(function () { +function (marked, config) { + IPython.config = config; + console.log('config is',config); + + window.marked = marked // monkey patch CM to be able to syntax highlight cell magics // bug reported upstream, // see https://github.com/marijnh/CodeMirror2/issues/670 if(CodeMirror.getMode(1,'text/plain').indent == undefined ){ console.log('patching CM for undefined indent'); - CodeMirror.modes.null = function() { return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0}}} + CodeMirror.modes.null = function() { + return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0}} } + } CodeMirror.patchedGetMode = function(config, mode){ var cmmode = CodeMirror.getMode(config, mode); @@ -90,10 +103,11 @@ $(document).ready(function () { // only do this once $([IPython.events]).off('notebook_loaded.Notebook', first_load); }; - + $([IPython.events]).on('notebook_loaded.Notebook', first_load); IPython.notebook.load_notebook($('body').data('notebookId')); - + + var marked; if (marked) { marked.setOptions({ gfm : true, @@ -110,6 +124,6 @@ $(document).ready(function () { } }) } +} -}); - +); diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html index f5339bd5884..e171aff16cb 100644 --- a/IPython/frontend/html/notebook/templates/notebook.html +++ b/IPython/frontend/html/notebook/templates/notebook.html @@ -205,7 +205,6 @@ - @@ -231,7 +230,6 @@ - diff --git a/IPython/frontend/html/notebook/templates/page.html b/IPython/frontend/html/notebook/templates/page.html index e9354dd6e7b..27857dcd5b9 100644 --- a/IPython/frontend/html/notebook/templates/page.html +++ b/IPython/frontend/html/notebook/templates/page.html @@ -24,7 +24,12 @@ {% endblock %} {% endblock %} - + + {% block meta %} {% endblock %} From 374ffe74e6ee7da716f19472e33a0ce69b193694 Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Tue, 4 Jun 2013 10:09:18 +0200 Subject: [PATCH 2/4] de-require-config --- .../html/notebook/static/notebook/js/config.js | 14 +++++++------- .../html/notebook/static/notebook/js/main.js | 10 +++------- .../frontend/html/notebook/templates/notebook.html | 1 + 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/IPython/frontend/html/notebook/static/notebook/js/config.js b/IPython/frontend/html/notebook/static/notebook/js/config.js index 56e3656a90f..432fb2b7f0f 100644 --- a/IPython/frontend/html/notebook/static/notebook/js/config.js +++ b/IPython/frontend/html/notebook/static/notebook/js/config.js @@ -8,16 +8,15 @@ //============================================================================ // Notebook //============================================================================ -"use strict"; /** * @module IPython * @namespace IPython **/ -define(function () { +var IPython = (function (IPython) { /** - * A place where some stuff can be configured. + * A place where some stuff can be confugured. * * @class config * @static @@ -70,9 +69,10 @@ define(function () { }; // use the same method to merge user configuration - var config = {}; - $.extend(config, default_config); + IPython.config = {}; + $.extend(IPython.config, default_config); - return config; -}); + return IPython; + +}(IPython)); diff --git a/IPython/frontend/html/notebook/static/notebook/js/main.js b/IPython/frontend/html/notebook/static/notebook/js/main.js index 2ecb1510794..8c21b3a1160 100644 --- a/IPython/frontend/html/notebook/static/notebook/js/main.js +++ b/IPython/frontend/html/notebook/static/notebook/js/main.js @@ -14,15 +14,12 @@ // as injecting require.js make marked not to put itself in the globals, // which make both this file fail at setting marked configuration, and textcell.js // which search marked into global. -require(['static/components/marked/lib/marked.js', - 'static/notebook/js/config.js'], +require(['static/components/marked/lib/marked.js'], -function (marked, config) { - - IPython.config = config; - console.log('config is',config); +function (marked) { window.marked = marked + // monkey patch CM to be able to syntax highlight cell magics // bug reported upstream, // see https://github.com/marijnh/CodeMirror2/issues/670 @@ -107,7 +104,6 @@ function (marked, config) { $([IPython.events]).on('notebook_loaded.Notebook', first_load); IPython.notebook.load_notebook($('body').data('notebookId')); - var marked; if (marked) { marked.setOptions({ gfm : true, diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html index e171aff16cb..80b53a6f6e1 100644 --- a/IPython/frontend/html/notebook/templates/notebook.html +++ b/IPython/frontend/html/notebook/templates/notebook.html @@ -230,6 +230,7 @@ + From 1ffd3653e12085c81d71e815a1399e473048fbce Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Tue, 4 Jun 2013 20:47:38 +0200 Subject: [PATCH 3/4] Use {{static_url}} as require search root --- IPython/frontend/html/notebook/static/notebook/js/main.js | 2 +- IPython/frontend/html/notebook/templates/page.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/IPython/frontend/html/notebook/static/notebook/js/main.js b/IPython/frontend/html/notebook/static/notebook/js/main.js index 8c21b3a1160..0024d6ce18e 100644 --- a/IPython/frontend/html/notebook/static/notebook/js/main.js +++ b/IPython/frontend/html/notebook/static/notebook/js/main.js @@ -14,7 +14,7 @@ // as injecting require.js make marked not to put itself in the globals, // which make both this file fail at setting marked configuration, and textcell.js // which search marked into global. -require(['static/components/marked/lib/marked.js'], +require(['components/marked/lib/marked'], function (marked) { diff --git a/IPython/frontend/html/notebook/templates/page.html b/IPython/frontend/html/notebook/templates/page.html index 27857dcd5b9..b92027b5f9d 100644 --- a/IPython/frontend/html/notebook/templates/page.html +++ b/IPython/frontend/html/notebook/templates/page.html @@ -27,7 +27,7 @@ From f2b674a673ea0a113eef853a0d5421f6b73ab6b7 Mon Sep 17 00:00:00 2001 From: Matthias BUSSONNIER Date: Wed, 5 Jun 2013 09:27:37 +0200 Subject: [PATCH 4/4] update componenet to latest (bootstrap) --- IPython/frontend/html/notebook/static/components | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IPython/frontend/html/notebook/static/components b/IPython/frontend/html/notebook/static/components index 723c9669981..2a98f498092 160000 --- a/IPython/frontend/html/notebook/static/components +++ b/IPython/frontend/html/notebook/static/components @@ -1 +1 @@ -Subproject commit 723c96699818e54ea31a5efe1b88042a5ac95151 +Subproject commit 2a98f498092682f11affe9b0b86bd7e642cf7b13