From 0cd153d625253f8c31ae973fc1535243098f5e6f 2013-05-26 19:38:25 From: Matthias BUSSONNIER Date: 2013-05-26 19:38:25 Subject: [PATCH] Inject requirejs in notebook and start using it. --- diff --git a/IPython/frontend/html/notebook/static/components b/IPython/frontend/html/notebook/static/components index 5548cce..723c966 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 432fb2b..56e3656 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 ae21231..2ecb151 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 f5339bd..e171aff 100644 --- a/IPython/frontend/html/notebook/templates/notebook.html +++ b/IPython/frontend/html/notebook/templates/notebook.html @@ -205,7 +205,6 @@ class="notebook_app" - @@ -231,7 +230,6 @@ class="notebook_app" - diff --git a/IPython/frontend/html/notebook/templates/page.html b/IPython/frontend/html/notebook/templates/page.html index e9354dd..27857dc 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 %}