##// END OF EJS Templates
partial refactor, can't quite get environments working
Aron Ahmadia -
Show More
@@ -1,83 +1,230 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2012 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // MathJax initialization
9 // MathJax utility functions
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 IPython.namespace('IPython.mathjaxutils');
13
13
14 var init_mathjax = function () {
14 IPython.mathjaxutils = (function (IPython) {
15
16 var init = function () {
15 if (window.MathJax) {
17 if (window.MathJax) {
16 // MathJax loaded
18 // MathJax loaded
17 MathJax.Hub.Config({
19 MathJax.Hub.Config({
20 TeX: { equationNumbers: { autoNumber: "AMS", useLabelIds: true },
21 extensions: ["autoload-all.js"] },
18 tex2jax: {
22 tex2jax: {
19 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
23 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
20 displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
24 displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
25 processEnvironments: true
21 },
26 },
22 displayAlign: 'left', // Change this to 'center' to center equations.
27 displayAlign: 'left', // Change this to 'center' to center equations.
23 "HTML-CSS": {
28 "HTML-CSS": {
24 styles: {'.MathJax_Display': {"margin": 0}}
29 styles: {'.MathJax_Display': {"margin": 0}}
25 }
30 }
26 });
31 });
27 } else if (window.mathjax_url != "") {
32 } else if (window.mathjax_url != "") {
28 // Don't have MathJax, but should. Show dialog.
33 // Don't have MathJax, but should. Show dialog.
29 var dialog = $('<div></div>')
34 var dialog = $('<div></div>')
30 .append(
35 .append(
31 $("<p></p>").addClass('dialog').html(
36 $("<p></p>").addClass('dialog').html(
32 "Math/LaTeX rendering will be disabled."
37 "Math/LaTeX rendering will be disabled."
33 )
38 )
34 ).append(
39 ).append(
35 $("<p></p>").addClass('dialog').html(
40 $("<p></p>").addClass('dialog').html(
36 "If you have administrative access to the notebook server and" +
41 "If you have administrative access to the notebook server and" +
37 " a working internet connection, you can install a local copy" +
42 " a working internet connection, you can install a local copy" +
38 " of MathJax for offline use with the following command on the server" +
43 " of MathJax for offline use with the following command on the server" +
39 " at a Python or IPython prompt:"
44 " at a Python or IPython prompt:"
40 )
45 )
41 ).append(
46 ).append(
42 $("<pre></pre>").addClass('dialog').html(
47 $("<pre></pre>").addClass('dialog').html(
43 ">>> from IPython.external import mathjax; mathjax.install_mathjax()"
48 ">>> from IPython.external import mathjax; mathjax.install_mathjax()"
44 )
49 )
45 ).append(
50 ).append(
46 $("<p></p>").addClass('dialog').html(
51 $("<p></p>").addClass('dialog').html(
47 "This will try to install MathJax into the IPython source directory."
52 "This will try to install MathJax into the IPython source directory."
48 )
53 )
49 ).append(
54 ).append(
50 $("<p></p>").addClass('dialog').html(
55 $("<p></p>").addClass('dialog').html(
51 "If IPython is installed to a location that requires" +
56 "If IPython is installed to a location that requires" +
52 " administrative privileges to write, you will need to make this call as" +
57 " administrative privileges to write, you will need to make this call as" +
53 " an administrator, via 'sudo'."
58 " an administrator, via 'sudo'."
54 )
59 )
55 ).append(
60 ).append(
56 $("<p></p>").addClass('dialog').html(
61 $("<p></p>").addClass('dialog').html(
57 "When you start the notebook server, you can instruct it to disable MathJax support altogether:"
62 "When you start the notebook server, you can instruct it to disable MathJax support altogether:"
58 )
63 )
59 ).append(
64 ).append(
60 $("<pre></pre>").addClass('dialog').html(
65 $("<pre></pre>").addClass('dialog').html(
61 "$ ipython notebook --no-mathjax"
66 "$ ipython notebook --no-mathjax"
62 )
67 )
63 ).append(
68 ).append(
64 $("<p></p>").addClass('dialog').html(
69 $("<p></p>").addClass('dialog').html(
65 "which will prevent this dialog from appearing."
70 "which will prevent this dialog from appearing."
66 )
71 )
67 ).dialog({
72 ).dialog({
68 title: "Failed to retrieve MathJax from '" + window.mathjax_url + "'",
73 title: "Failed to retrieve MathJax from '" + window.mathjax_url + "'",
69 width: "70%",
74 width: "70%",
70 modal: true,
75 modal: true,
71 })
76 })
72 } else {
77 } else {
73 // No MathJax, but none expected. No dialog.
78 // No MathJax, but none expected. No dialog.
74 };
79 };
75 };
80 };
76
81
82 // Some magic for deferring mathematical expressions to MathJaX
83 // Some of the code here is adapted with permission from Stack Exchange Inc.
84
85 var inline = "$"; // the inline math delimiter
86 var blocks, start, end, last, braces; // used in searching for math
87 var math; // stores math until pagedown (Markdown parser) is done
88 var HUB = MathJax.Hub;
89
90 // MATHSPLIT contains the pattern for math delimiters and special symbols
91 // needed for searching for math in the text input.
92 var MATHSPLIT = /(\$\$?|\\(?:begin|end)\{[a-z]*\*?\}|\\[\\{}$]|[{}]|(?:\n\s*)+|@@\d+@@)/i;
93
94 // The math is in blocks i through j, so
95 // collect it into one block and clear the others.
96 // Replace &, <, and > by named entities.
97 // For IE, put <br> at the ends of comments since IE removes \n.
98 // Clear the current math positions and store the index of the
99 // math, then push the math string onto the storage array.
100 // The preProcess function is called on all blocks if it has been passed in
101 function processMath(i, j, preProcess) {
102 var block = blocks.slice(i, j + 1).join("").replace(/&/g, "&amp;") // use HTML entity for &
103 .replace(/</g, "&lt;") // use HTML entity for <
104 .replace(/>/g, "&gt;") // use HTML entity for >
105 ;
106 if (HUB.Browser.isMSIE) {
107 block = block.replace(/(%[^\n]*)\n/g, "$1<br/>\n")
108 }
109 while (j > i) {
110 blocks[j] = "";
111 j--;
112 }
113 blocks[i] = "@@" + math.length + "@@"; // replace the current block text with a unique tag to find later
114 if (preProcess)
115 block = preProcess(block);
116 math.push(block);
117 start = end = last = null;
118 }
119
120 // Break up the text into its component parts and search
121 // through them for math delimiters, braces, linebreaks, etc.
122 // Math delimiters must match and braces must balance.
123 // Don't allow math to pass through a double linebreak
124 // (which will be a paragraph).
125 //
126 function removeMath(text) {
127 start = end = last = null; // for tracking math delimiters
128 math = []; // stores math strings for later
129
130 // Except for extreme edge cases, this should catch precisely those pieces of the markdown
131 // source that will later be turned into code spans. While MathJax will not TeXify code spans,
132 // we still have to consider them at this point; the following issue has happened several times:
133 //
134 // `$foo` and `$bar` are varibales. --> <code>$foo ` and `$bar</code> are variables.
135
136 var hasCodeSpans = /`/.test(text),
137 deTilde;
138 if (hasCodeSpans) {
139 text = text.replace(/~/g, "~T").replace(/(^|[^\\])(`+)([^\n]*?[^`\n])\2(?!`)/gm, function (wholematch) {
140 return wholematch.replace(/\$/g, "~D");
141 });
142 deTilde = function (text) { return text.replace(/~([TD])/g, function (wholematch, character) { return { T: "~", D: "$" }[character]; }) };
143 } else {
144 deTilde = function (text) { return text; };
145 }
146
147 blocks = IPython.utils.regex_split(text.replace(/\r\n?/g, "\n"),MATHSPLIT);
148
149 for (var i = 1, m = blocks.length; i < m; i += 2) {
150 var block = blocks[i];
151 if (block.charAt(0) === "@") {
152 //
153 // Things that look like our math markers will get
154 // stored and then retrieved along with the math.
155 //
156 blocks[i] = "@@" + math.length + "@@";
157 math.push(block);
158 }
159 else if (start) {
160 //
161 // If we are in math, look for the end delimiter,
162 // but don't go past double line breaks, and
163 // and balance braces within the math.
164 //
165 if (block === end) {
166 if (braces) {
167 last = i
168 }
169 else {
170 processMath(start, i, deTilde)
171 }
172 }
173 else if (block.match(/\n.*\n/)) {
174 if (last) {
175 i = last;
176 processMath(start, i, deTilde)
177 }
178 start = end = last = null;
179 braces = 0;
180 }
181 else if (block === "{") {
182 braces++
183 }
184 else if (block === "}" && braces) {
185 braces--
186 }
187 }
188 else {
189 //
190 // Look for math start delimiters and when
191 // found, set up the end delimiter.
192 //
193 if (block === inline || block === "$$") {
194 start = i;
195 end = block;
196 braces = 0;
197 }
198 else if (block.substr(1, 5) === "begin") {
199 start = i;
200 end = "\\end" + block.substr(6);
201 braces = 0;
202 }
203 }
204 }
205 if (last) {
206 processMath(start, last, deTilde)
207 }
208 return deTilde(blocks.join(""));
209 }
77
210
78 // Set module variables
211 //
79 IPython.init_mathjax = init_mathjax;
212 // Put back the math strings that were saved,
213 // and clear the math array (no need to keep it around).
214 //
215 function replaceMath(text) {
216 text = text.replace(/@@(\d+)@@/g, function (match, n) {
217 return math[n]
218 });
219 math = null;
220 return text;
221 }
80
222
81 return IPython;
223 return {
224 init : init,
225 processMath : processMath,
226 removeMath : removeMath,
227 replaceMath : replaceMath,
228 };
82
229
83 }(IPython)); No newline at end of file
230 }(IPython));
@@ -1,87 +1,87 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2011 The IPython Development Team
2 // Copyright (C) 2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // On document ready
9 // On document ready
10 //============================================================================
10 //============================================================================
11
11
12
12
13 $(document).ready(function () {
13 $(document).ready(function () {
14
14
15 // monkey patch CM to be able to syntax highlight cell magics
15 // monkey patch CM to be able to syntax highlight cell magics
16 // bug reported upstream,
16 // bug reported upstream,
17 // see https://github.com/marijnh/CodeMirror2/issues/670
17 // see https://github.com/marijnh/CodeMirror2/issues/670
18 if(CodeMirror.getMode(1,'text/plain').indent == undefined ){
18 if(CodeMirror.getMode(1,'text/plain').indent == undefined ){
19 console.log('patching CM for undefined indent');
19 console.log('patching CM for undefined indent');
20 CodeMirror.modes.null = function() { return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0}}}
20 CodeMirror.modes.null = function() { return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0}}}
21 }
21 }
22
22
23 CodeMirror.patchedGetMode = function(config, mode){
23 CodeMirror.patchedGetMode = function(config, mode){
24 var cmmode = CodeMirror.getMode(config, mode);
24 var cmmode = CodeMirror.getMode(config, mode);
25 if(cmmode.indent == null)
25 if(cmmode.indent == null)
26 {
26 {
27 console.log('patch mode "' , mode, '" on the fly');
27 console.log('patch mode "' , mode, '" on the fly');
28 cmmode.indent = function(){return 0};
28 cmmode.indent = function(){return 0};
29 }
29 }
30 return cmmode;
30 return cmmode;
31 }
31 }
32 // end monkey patching CodeMirror
32 // end monkey patching CodeMirror
33
33
34 IPython.init_mathjax();
34 IPython.mathjaxutils.init();
35
35
36 IPython.read_only = $('body').data('readOnly') === 'True';
36 IPython.read_only = $('body').data('readOnly') === 'True';
37 $('div#main_app').addClass('border-box-sizing ui-widget');
37 $('div#main_app').addClass('border-box-sizing ui-widget');
38 $('div#notebook_panel').addClass('border-box-sizing ui-widget');
38 $('div#notebook_panel').addClass('border-box-sizing ui-widget');
39 // The header's bottom border is provided by the menu bar so we remove it.
39 // The header's bottom border is provided by the menu bar so we remove it.
40 $('div#header').css('border-bottom-style','none');
40 $('div#header').css('border-bottom-style','none');
41
41
42 IPython.page = new IPython.Page();
42 IPython.page = new IPython.Page();
43 IPython.markdown_converter = new Markdown.Converter();
43 IPython.markdown_converter = new Markdown.Converter();
44 IPython.layout_manager = new IPython.LayoutManager();
44 IPython.layout_manager = new IPython.LayoutManager();
45 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
45 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
46 IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
46 IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
47 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
47 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
48 IPython.notebook = new IPython.Notebook('div#notebook');
48 IPython.notebook = new IPython.Notebook('div#notebook');
49 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
49 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
50 IPython.menubar = new IPython.MenuBar('#menubar')
50 IPython.menubar = new IPython.MenuBar('#menubar')
51 IPython.toolbar = new IPython.MainToolBar('#maintoolbar')
51 IPython.toolbar = new IPython.MainToolBar('#maintoolbar')
52 IPython.tooltip = new IPython.Tooltip()
52 IPython.tooltip = new IPython.Tooltip()
53 IPython.notification_area = new IPython.NotificationArea('#notification_area')
53 IPython.notification_area = new IPython.NotificationArea('#notification_area')
54 IPython.notification_area.init_notification_widgets();
54 IPython.notification_area.init_notification_widgets();
55
55
56 IPython.layout_manager.do_resize();
56 IPython.layout_manager.do_resize();
57
57
58 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
58 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
59 '<span id="test2" style="font-weight: bold;">x</span>'+
59 '<span id="test2" style="font-weight: bold;">x</span>'+
60 '<span id="test3" style="font-style: italic;">x</span></pre></div>')
60 '<span id="test3" style="font-style: italic;">x</span></pre></div>')
61 var nh = $('#test1').innerHeight();
61 var nh = $('#test1').innerHeight();
62 var bh = $('#test2').innerHeight();
62 var bh = $('#test2').innerHeight();
63 var ih = $('#test3').innerHeight();
63 var ih = $('#test3').innerHeight();
64 if(nh != bh || nh != ih) {
64 if(nh != bh || nh != ih) {
65 $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>');
65 $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>');
66 }
66 }
67 $('#fonttest').remove();
67 $('#fonttest').remove();
68
68
69 if(IPython.read_only){
69 if(IPython.read_only){
70 // hide various elements from read-only view
70 // hide various elements from read-only view
71 $('div#pager').remove();
71 $('div#pager').remove();
72 $('div#pager_splitter').remove();
72 $('div#pager_splitter').remove();
73
73
74 // set the notebook name field as not modifiable
74 // set the notebook name field as not modifiable
75 $('#notebook_name').attr('disabled','disabled')
75 $('#notebook_name').attr('disabled','disabled')
76 }
76 }
77
77
78 IPython.page.show();
78 IPython.page.show();
79
79
80 IPython.layout_manager.do_resize();
80 IPython.layout_manager.do_resize();
81 $([IPython.events]).on('notebook_loaded.Notebook', function () {
81 $([IPython.events]).on('notebook_loaded.Notebook', function () {
82 IPython.layout_manager.do_resize();
82 IPython.layout_manager.do_resize();
83 })
83 })
84 IPython.notebook.load_notebook($('body').data('notebookId'));
84 IPython.notebook.load_notebook($('body').data('notebookId'));
85
85
86 });
86 });
87
87
@@ -1,30 +1,30 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // On document ready
9 // On document ready
10 //============================================================================
10 //============================================================================
11
11
12
12
13 $(document).ready(function () {
13 $(document).ready(function () {
14
14
15 IPython.init_mathjax();
15 IPython.mathjaxutils.init();
16
16
17 IPython.read_only = $('body').data('readOnly') === 'True';
17 IPython.read_only = $('body').data('readOnly') === 'True';
18 $('div#main_app').addClass('border-box-sizing ui-widget');
18 $('div#main_app').addClass('border-box-sizing ui-widget');
19 $('div#notebook_panel').addClass('border-box-sizing ui-widget');
19 $('div#notebook_panel').addClass('border-box-sizing ui-widget');
20
20
21 IPython.page = new IPython.Page();
21 IPython.page = new IPython.Page();
22 IPython.markdown_converter = new Markdown.Converter();
22 IPython.markdown_converter = new Markdown.Converter();
23 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
23 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
24 IPython.notebook = new IPython.Notebook('div#notebook');
24 IPython.notebook = new IPython.Notebook('div#notebook');
25 IPython.page.show_site();
25 IPython.page.show_site();
26
26
27 IPython.notebook.load_notebook($('body').data('notebookId'));
27 IPython.notebook.load_notebook($('body').data('notebookId'));
28
28
29 });
29 });
30
30
@@ -1,415 +1,419 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2012 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // TextCell
9 // TextCell
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13
13
14 // TextCell base class
14 // TextCell base class
15 var key = IPython.utils.keycodes;
15 var key = IPython.utils.keycodes;
16
16
17 var TextCell = function () {
17 var TextCell = function () {
18 this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed';
18 this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed';
19 IPython.Cell.apply(this, arguments);
19 IPython.Cell.apply(this, arguments);
20 this.rendered = false;
20 this.rendered = false;
21 this.cell_type = this.cell_type || 'text';
21 this.cell_type = this.cell_type || 'text';
22 };
22 };
23
23
24
24
25 TextCell.prototype = new IPython.Cell();
25 TextCell.prototype = new IPython.Cell();
26
26
27
27
28 TextCell.prototype.create_element = function () {
28 TextCell.prototype.create_element = function () {
29 var cell = $("<div>").addClass('cell text_cell border-box-sizing');
29 var cell = $("<div>").addClass('cell text_cell border-box-sizing');
30 cell.attr('tabindex','2');
30 cell.attr('tabindex','2');
31 var input_area = $('<div/>').addClass('text_cell_input border-box-sizing');
31 var input_area = $('<div/>').addClass('text_cell_input border-box-sizing');
32 this.code_mirror = CodeMirror(input_area.get(0), {
32 this.code_mirror = CodeMirror(input_area.get(0), {
33 indentUnit : 4,
33 indentUnit : 4,
34 mode: this.code_mirror_mode,
34 mode: this.code_mirror_mode,
35 theme: 'default',
35 theme: 'default',
36 value: this.placeholder,
36 value: this.placeholder,
37 readOnly: this.read_only,
37 readOnly: this.read_only,
38 lineWrapping : true,
38 lineWrapping : true,
39 extraKeys: {"Tab": "indentMore","Shift-Tab" : "indentLess"},
39 extraKeys: {"Tab": "indentMore","Shift-Tab" : "indentLess"},
40 onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
40 onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
41 });
41 });
42 // The tabindex=-1 makes this div focusable.
42 // The tabindex=-1 makes this div focusable.
43 var render_area = $('<div/>').addClass('text_cell_render border-box-sizing').
43 var render_area = $('<div/>').addClass('text_cell_render border-box-sizing').
44 addClass('rendered_html').attr('tabindex','-1');
44 addClass('rendered_html').attr('tabindex','-1');
45 cell.append(input_area).append(render_area);
45 cell.append(input_area).append(render_area);
46 this.element = cell;
46 this.element = cell;
47 };
47 };
48
48
49
49
50 TextCell.prototype.bind_events = function () {
50 TextCell.prototype.bind_events = function () {
51 IPython.Cell.prototype.bind_events.apply(this);
51 IPython.Cell.prototype.bind_events.apply(this);
52 var that = this;
52 var that = this;
53 this.element.keydown(function (event) {
53 this.element.keydown(function (event) {
54 if (event.which === 13 && !event.shiftKey) {
54 if (event.which === 13 && !event.shiftKey) {
55 if (that.rendered) {
55 if (that.rendered) {
56 that.edit();
56 that.edit();
57 return false;
57 return false;
58 };
58 };
59 };
59 };
60 });
60 });
61 this.element.dblclick(function () {
61 this.element.dblclick(function () {
62 that.edit();
62 that.edit();
63 });
63 });
64 };
64 };
65
65
66
66
67 TextCell.prototype.handle_codemirror_keyevent = function (editor, event) {
67 TextCell.prototype.handle_codemirror_keyevent = function (editor, event) {
68 // This method gets called in CodeMirror's onKeyDown/onKeyPress
68 // This method gets called in CodeMirror's onKeyDown/onKeyPress
69 // handlers and is used to provide custom key handling. Its return
69 // handlers and is used to provide custom key handling. Its return
70 // value is used to determine if CodeMirror should ignore the event:
70 // value is used to determine if CodeMirror should ignore the event:
71 // true = ignore, false = don't ignore.
71 // true = ignore, false = don't ignore.
72
72
73 if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
73 if (event.keyCode === 13 && (event.shiftKey || event.ctrlKey)) {
74 // Always ignore shift-enter in CodeMirror as we handle it.
74 // Always ignore shift-enter in CodeMirror as we handle it.
75 return true;
75 return true;
76 }
76 }
77 return false;
77 return false;
78 };
78 };
79
79
80
80
81 TextCell.prototype.select = function () {
81 TextCell.prototype.select = function () {
82 IPython.Cell.prototype.select.apply(this);
82 IPython.Cell.prototype.select.apply(this);
83 var output = this.element.find("div.text_cell_render");
83 var output = this.element.find("div.text_cell_render");
84 output.trigger('focus');
84 output.trigger('focus');
85 };
85 };
86
86
87
87
88 TextCell.prototype.unselect = function() {
88 TextCell.prototype.unselect = function() {
89 // render on selection of another cell
89 // render on selection of another cell
90 this.render();
90 this.render();
91 IPython.Cell.prototype.unselect.apply(this);
91 IPython.Cell.prototype.unselect.apply(this);
92 };
92 };
93
93
94
94
95 TextCell.prototype.edit = function () {
95 TextCell.prototype.edit = function () {
96 if ( this.read_only ) return;
96 if ( this.read_only ) return;
97 if (this.rendered === true) {
97 if (this.rendered === true) {
98 var text_cell = this.element;
98 var text_cell = this.element;
99 var output = text_cell.find("div.text_cell_render");
99 var output = text_cell.find("div.text_cell_render");
100 output.hide();
100 output.hide();
101 text_cell.find('div.text_cell_input').show();
101 text_cell.find('div.text_cell_input').show();
102 this.code_mirror.refresh();
102 this.code_mirror.refresh();
103 this.code_mirror.focus();
103 this.code_mirror.focus();
104 // We used to need an additional refresh() after the focus, but
104 // We used to need an additional refresh() after the focus, but
105 // it appears that this has been fixed in CM. This bug would show
105 // it appears that this has been fixed in CM. This bug would show
106 // up on FF when a newly loaded markdown cell was edited.
106 // up on FF when a newly loaded markdown cell was edited.
107 this.rendered = false;
107 this.rendered = false;
108 if (this.get_text() === this.placeholder) {
108 if (this.get_text() === this.placeholder) {
109 this.set_text('');
109 this.set_text('');
110 this.refresh();
110 this.refresh();
111 }
111 }
112 }
112 }
113 };
113 };
114
114
115
115
116 // Subclasses must define render.
116 // Subclasses must define render.
117 TextCell.prototype.render = function () {};
117 TextCell.prototype.render = function () {};
118
118
119
119
120 TextCell.prototype.get_text = function() {
120 TextCell.prototype.get_text = function() {
121 return this.code_mirror.getValue();
121 return this.code_mirror.getValue();
122 };
122 };
123
123
124
124
125 TextCell.prototype.set_text = function(text) {
125 TextCell.prototype.set_text = function(text) {
126 this.code_mirror.setValue(text);
126 this.code_mirror.setValue(text);
127 this.code_mirror.refresh();
127 this.code_mirror.refresh();
128 };
128 };
129
129
130
130
131 TextCell.prototype.get_rendered = function() {
131 TextCell.prototype.get_rendered = function() {
132 return this.element.find('div.text_cell_render').html();
132 return this.element.find('div.text_cell_render').html();
133 };
133 };
134
134
135
135
136 TextCell.prototype.set_rendered = function(text) {
136 TextCell.prototype.set_rendered = function(text) {
137 this.element.find('div.text_cell_render').html(text);
137 this.element.find('div.text_cell_render').html(text);
138 };
138 };
139
139
140
140
141 TextCell.prototype.at_top = function () {
141 TextCell.prototype.at_top = function () {
142 if (this.rendered) {
142 if (this.rendered) {
143 return true;
143 return true;
144 } else {
144 } else {
145 return false;
145 return false;
146 }
146 }
147 };
147 };
148
148
149
149
150 TextCell.prototype.at_bottom = function () {
150 TextCell.prototype.at_bottom = function () {
151 if (this.rendered) {
151 if (this.rendered) {
152 return true;
152 return true;
153 } else {
153 } else {
154 return false;
154 return false;
155 }
155 }
156 };
156 };
157
157
158
158
159 TextCell.prototype.fromJSON = function (data) {
159 TextCell.prototype.fromJSON = function (data) {
160 IPython.Cell.prototype.fromJSON.apply(this, arguments);
160 IPython.Cell.prototype.fromJSON.apply(this, arguments);
161 if (data.cell_type === this.cell_type) {
161 if (data.cell_type === this.cell_type) {
162 if (data.source !== undefined) {
162 if (data.source !== undefined) {
163 this.set_text(data.source);
163 this.set_text(data.source);
164 // make this value the starting point, so that we can only undo
164 // make this value the starting point, so that we can only undo
165 // to this state, instead of a blank cell
165 // to this state, instead of a blank cell
166 this.code_mirror.clearHistory();
166 this.code_mirror.clearHistory();
167 this.set_rendered(data.rendered || '');
167 this.set_rendered(data.rendered || '');
168 this.rendered = false;
168 this.rendered = false;
169 this.render();
169 this.render();
170 }
170 }
171 }
171 }
172 };
172 };
173
173
174
174
175 TextCell.prototype.toJSON = function () {
175 TextCell.prototype.toJSON = function () {
176 var data = IPython.Cell.prototype.toJSON.apply(this);
176 var data = IPython.Cell.prototype.toJSON.apply(this);
177 data.cell_type = this.cell_type;
177 data.cell_type = this.cell_type;
178 data.source = this.get_text();
178 data.source = this.get_text();
179 return data;
179 return data;
180 };
180 };
181
181
182
182
183 // HTMLCell
183 // HTMLCell
184
184
185 var HTMLCell = function () {
185 var HTMLCell = function () {
186 this.placeholder = "Type <strong>HTML</strong> and LaTeX: $\\alpha^2$";
186 this.placeholder = "Type <strong>HTML</strong> and LaTeX: $\\alpha^2$";
187 IPython.TextCell.apply(this, arguments);
187 IPython.TextCell.apply(this, arguments);
188 this.cell_type = 'html';
188 this.cell_type = 'html';
189 };
189 };
190
190
191
191
192 HTMLCell.prototype = new TextCell();
192 HTMLCell.prototype = new TextCell();
193
193
194
194
195 HTMLCell.prototype.render = function () {
195 HTMLCell.prototype.render = function () {
196 if (this.rendered === false) {
196 if (this.rendered === false) {
197 var text = this.get_text();
197 var text = this.get_text();
198 if (text === "") { text = this.placeholder; }
198 if (text === "") { text = this.placeholder; }
199 this.set_rendered(text);
199 this.set_rendered(text);
200 this.typeset();
200 this.typeset();
201 this.element.find('div.text_cell_input').hide();
201 this.element.find('div.text_cell_input').hide();
202 this.element.find("div.text_cell_render").show();
202 this.element.find("div.text_cell_render").show();
203 this.rendered = true;
203 this.rendered = true;
204 }
204 }
205 };
205 };
206
206
207
207
208 // MarkdownCell
208 // MarkdownCell
209
209
210 var MarkdownCell = function () {
210 var MarkdownCell = function () {
211 this.placeholder = "Type *Markdown* and LaTeX: $\\alpha^2$";
211 this.placeholder = "Type *Markdown* and LaTeX: $\\alpha^2$";
212 IPython.TextCell.apply(this, arguments);
212 IPython.TextCell.apply(this, arguments);
213 this.cell_type = 'markdown';
213 this.cell_type = 'markdown';
214 };
214 };
215
215
216
216
217 MarkdownCell.prototype = new TextCell();
217 MarkdownCell.prototype = new TextCell();
218
218
219
219
220 MarkdownCell.prototype.render = function () {
220 MarkdownCell.prototype.render = function () {
221 if (this.rendered === false) {
221 if (this.rendered === false) {
222 var text = this.get_text();
222 var text = this.get_text();
223 if (text === "") { text = this.placeholder; }
223 if (text === "") { text = this.placeholder; }
224
225 text = IPython.mathjaxutils.removeMath(text)
224 var html = IPython.markdown_converter.makeHtml(text);
226 var html = IPython.markdown_converter.makeHtml(text);
227 html = IPython.mathjaxutils.replaceMath(html)
228
225 try {
229 try {
226 this.set_rendered(html);
230 this.set_rendered(html);
227 } catch (e) {
231 } catch (e) {
228 console.log("Error running Javascript in Markdown:");
232 console.log("Error running Javascript in Markdown:");
229 console.log(e);
233 console.log(e);
230 this.set_rendered($("<div/>").addClass("js-error").html(
234 this.set_rendered($("<div/>").addClass("js-error").html(
231 "Error rendering Markdown!<br/>" + e.toString())
235 "Error rendering Markdown!<br/>" + e.toString())
232 );
236 );
233 }
237 }
234 this.typeset()
238 this.typeset()
235 this.element.find('div.text_cell_input').hide();
239 this.element.find('div.text_cell_input').hide();
236 this.element.find("div.text_cell_render").show();
240 this.element.find("div.text_cell_render").show();
237 var code_snippets = this.element.find("pre > code");
241 var code_snippets = this.element.find("pre > code");
238 code_snippets.replaceWith(function () {
242 code_snippets.replaceWith(function () {
239 var code = $(this).html();
243 var code = $(this).html();
240 /* Substitute br for newlines and &nbsp; for spaces
244 /* Substitute br for newlines and &nbsp; for spaces
241 before highlighting, since prettify doesn't
245 before highlighting, since prettify doesn't
242 preserve those on all browsers */
246 preserve those on all browsers */
243 code = code.replace(/(\r\n|\n|\r)/gm, "<br/>");
247 code = code.replace(/(\r\n|\n|\r)/gm, "<br/>");
244 code = code.replace(/ /gm, '&nbsp;');
248 code = code.replace(/ /gm, '&nbsp;');
245 code = prettyPrintOne(code);
249 code = prettyPrintOne(code);
246
250
247 return '<code class="prettyprint">' + code + '</code>';
251 return '<code class="prettyprint">' + code + '</code>';
248 });
252 });
249 this.rendered = true;
253 this.rendered = true;
250 }
254 }
251 };
255 };
252
256
253
257
254 // RawCell
258 // RawCell
255
259
256 var RawCell = function () {
260 var RawCell = function () {
257 this.placeholder = "Type plain text and LaTeX: $\\alpha^2$";
261 this.placeholder = "Type plain text and LaTeX: $\\alpha^2$";
258 this.code_mirror_mode = 'rst';
262 this.code_mirror_mode = 'rst';
259 IPython.TextCell.apply(this, arguments);
263 IPython.TextCell.apply(this, arguments);
260 this.cell_type = 'raw';
264 this.cell_type = 'raw';
261 var that = this
265 var that = this
262
266
263 this.element.focusout(
267 this.element.focusout(
264 function() { that.auto_highlight(); }
268 function() { that.auto_highlight(); }
265 );
269 );
266 };
270 };
267
271
268
272
269 RawCell.prototype = new TextCell();
273 RawCell.prototype = new TextCell();
270
274
271 RawCell.prototype.auto_highlight = function () {
275 RawCell.prototype.auto_highlight = function () {
272 this._auto_highlight(IPython.config.raw_cell_highlight);
276 this._auto_highlight(IPython.config.raw_cell_highlight);
273 };
277 };
274
278
275 RawCell.prototype.render = function () {
279 RawCell.prototype.render = function () {
276 this.rendered = true;
280 this.rendered = true;
277 this.edit();
281 this.edit();
278 };
282 };
279
283
280
284
281 RawCell.prototype.handle_codemirror_keyevent = function (editor, event) {
285 RawCell.prototype.handle_codemirror_keyevent = function (editor, event) {
282 // This method gets called in CodeMirror's onKeyDown/onKeyPress
286 // This method gets called in CodeMirror's onKeyDown/onKeyPress
283 // handlers and is used to provide custom key handling. Its return
287 // handlers and is used to provide custom key handling. Its return
284 // value is used to determine if CodeMirror should ignore the event:
288 // value is used to determine if CodeMirror should ignore the event:
285 // true = ignore, false = don't ignore.
289 // true = ignore, false = don't ignore.
286
290
287 var that = this;
291 var that = this;
288 if (event.which === key.UPARROW && event.type === 'keydown') {
292 if (event.which === key.UPARROW && event.type === 'keydown') {
289 // If we are not at the top, let CM handle the up arrow and
293 // If we are not at the top, let CM handle the up arrow and
290 // prevent the global keydown handler from handling it.
294 // prevent the global keydown handler from handling it.
291 if (!that.at_top()) {
295 if (!that.at_top()) {
292 event.stop();
296 event.stop();
293 return false;
297 return false;
294 } else {
298 } else {
295 return true;
299 return true;
296 };
300 };
297 } else if (event.which === key.DOWNARROW && event.type === 'keydown') {
301 } else if (event.which === key.DOWNARROW && event.type === 'keydown') {
298 // If we are not at the bottom, let CM handle the down arrow and
302 // If we are not at the bottom, let CM handle the down arrow and
299 // prevent the global keydown handler from handling it.
303 // prevent the global keydown handler from handling it.
300 if (!that.at_bottom()) {
304 if (!that.at_bottom()) {
301 event.stop();
305 event.stop();
302 return false;
306 return false;
303 } else {
307 } else {
304 return true;
308 return true;
305 };
309 };
306 };
310 };
307 return false;
311 return false;
308 };
312 };
309
313
310
314
311 RawCell.prototype.select = function () {
315 RawCell.prototype.select = function () {
312 IPython.Cell.prototype.select.apply(this);
316 IPython.Cell.prototype.select.apply(this);
313 this.code_mirror.refresh();
317 this.code_mirror.refresh();
314 this.code_mirror.focus();
318 this.code_mirror.focus();
315 };
319 };
316
320
317
321
318 RawCell.prototype.at_top = function () {
322 RawCell.prototype.at_top = function () {
319 var cursor = this.code_mirror.getCursor();
323 var cursor = this.code_mirror.getCursor();
320 if (cursor.line === 0 && cursor.ch === 0) {
324 if (cursor.line === 0 && cursor.ch === 0) {
321 return true;
325 return true;
322 } else {
326 } else {
323 return false;
327 return false;
324 }
328 }
325 };
329 };
326
330
327
331
328 RawCell.prototype.at_bottom = function () {
332 RawCell.prototype.at_bottom = function () {
329 var cursor = this.code_mirror.getCursor();
333 var cursor = this.code_mirror.getCursor();
330 if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
334 if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
331 return true;
335 return true;
332 } else {
336 } else {
333 return false;
337 return false;
334 }
338 }
335 };
339 };
336
340
337
341
338 // HTMLCell
342 // HTMLCell
339
343
340 var HeadingCell = function () {
344 var HeadingCell = function () {
341 this.placeholder = "Type Heading Here";
345 this.placeholder = "Type Heading Here";
342 IPython.TextCell.apply(this, arguments);
346 IPython.TextCell.apply(this, arguments);
343 this.cell_type = 'heading';
347 this.cell_type = 'heading';
344 this.level = 1;
348 this.level = 1;
345 };
349 };
346
350
347
351
348 HeadingCell.prototype = new TextCell();
352 HeadingCell.prototype = new TextCell();
349
353
350
354
351 HeadingCell.prototype.fromJSON = function (data) {
355 HeadingCell.prototype.fromJSON = function (data) {
352 if (data.level != undefined){
356 if (data.level != undefined){
353 this.level = data.level;
357 this.level = data.level;
354 }
358 }
355 IPython.TextCell.prototype.fromJSON.apply(this, arguments);
359 IPython.TextCell.prototype.fromJSON.apply(this, arguments);
356 };
360 };
357
361
358
362
359 HeadingCell.prototype.toJSON = function () {
363 HeadingCell.prototype.toJSON = function () {
360 var data = IPython.TextCell.prototype.toJSON.apply(this);
364 var data = IPython.TextCell.prototype.toJSON.apply(this);
361 data.level = this.get_level();
365 data.level = this.get_level();
362 return data;
366 return data;
363 };
367 };
364
368
365
369
366 HeadingCell.prototype.set_level = function (level) {
370 HeadingCell.prototype.set_level = function (level) {
367 this.level = level;
371 this.level = level;
368 if (this.rendered) {
372 if (this.rendered) {
369 this.rendered = false;
373 this.rendered = false;
370 this.render();
374 this.render();
371 };
375 };
372 };
376 };
373
377
374
378
375 HeadingCell.prototype.get_level = function () {
379 HeadingCell.prototype.get_level = function () {
376 return this.level;
380 return this.level;
377 };
381 };
378
382
379
383
380 HeadingCell.prototype.set_rendered = function (text) {
384 HeadingCell.prototype.set_rendered = function (text) {
381 var r = this.element.find("div.text_cell_render");
385 var r = this.element.find("div.text_cell_render");
382 r.empty();
386 r.empty();
383 r.append($('<h'+this.level+'/>').html(text));
387 r.append($('<h'+this.level+'/>').html(text));
384 };
388 };
385
389
386
390
387 HeadingCell.prototype.get_rendered = function () {
391 HeadingCell.prototype.get_rendered = function () {
388 var r = this.element.find("div.text_cell_render");
392 var r = this.element.find("div.text_cell_render");
389 return r.children().first().html();
393 return r.children().first().html();
390 };
394 };
391
395
392
396
393 HeadingCell.prototype.render = function () {
397 HeadingCell.prototype.render = function () {
394 if (this.rendered === false) {
398 if (this.rendered === false) {
395 var text = this.get_text();
399 var text = this.get_text();
396 if (text === "") { text = this.placeholder; }
400 if (text === "") { text = this.placeholder; }
397 this.set_rendered(text);
401 this.set_rendered(text);
398 this.typeset();
402 this.typeset();
399 this.element.find('div.text_cell_input').hide();
403 this.element.find('div.text_cell_input').hide();
400 this.element.find("div.text_cell_render").show();
404 this.element.find("div.text_cell_render").show();
401 this.rendered = true;
405 this.rendered = true;
402 };
406 };
403 };
407 };
404
408
405 IPython.TextCell = TextCell;
409 IPython.TextCell = TextCell;
406 IPython.HTMLCell = HTMLCell;
410 IPython.HTMLCell = HTMLCell;
407 IPython.MarkdownCell = MarkdownCell;
411 IPython.MarkdownCell = MarkdownCell;
408 IPython.RawCell = RawCell;
412 IPython.RawCell = RawCell;
409 IPython.HeadingCell = HeadingCell;
413 IPython.HeadingCell = HeadingCell;
410
414
411
415
412 return IPython;
416 return IPython;
413
417
414 }(IPython));
418 }(IPython));
415
419
@@ -1,149 +1,267 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2012 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // Utilities
9 // Utilities
10 //============================================================================
10 //============================================================================
11
11
12 IPython.namespace('IPython.utils');
12 IPython.namespace('IPython.utils');
13
13
14 IPython.utils = (function (IPython) {
14 IPython.utils = (function (IPython) {
15
15
16 //============================================================================
17 // Cross-browser RegEx Split
18 //============================================================================
19
20 // This code has been MODIFIED from the code licensed below to not replace the
21 // default browser split. The license is reproduced here.
22
23 // see http://blog.stevenlevithan.com/archives/cross-browser-split for more info:
24 /*!
25 * Cross-Browser Split 1.1.1
26 * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
27 * Available under the MIT License
28 * ECMAScript compliant, uniform cross-browser split method
29 */
30
31 /**
32 * Splits a string into an array of strings using a regex or string
33 * separator. Matches of the separator are not included in the result array.
34 * However, if `separator` is a regex that contains capturing groups,
35 * backreferences are spliced into the result each time `separator` is
36 * matched. Fixes browser bugs compared to the native
37 * `String.prototype.split` and can be used reliably cross-browser.
38 * @param {String} str String to split.
39 * @param {RegExp|String} separator Regex or string to use for separating
40 * the string.
41 * @param {Number} [limit] Maximum number of items to include in the result
42 * array.
43 * @returns {Array} Array of substrings.
44 * @example
45 *
46 * // Basic use
47 * regex_split('a b c d', ' ');
48 * // -> ['a', 'b', 'c', 'd']
49 *
50 * // With limit
51 * regex_split('a b c d', ' ', 2);
52 * // -> ['a', 'b']
53 *
54 * // Backreferences in result array
55 * regex_split('..word1 word2..', /([a-z]+)(\d+)/i);
56 * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
57 */
58 var regex_split = function (str, separator, limit) {
59 // If `separator` is not a regex, use `split`
60 if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
61 return split.call(str, separator, limit);
62 }
63 var output = [],
64 flags = (separator.ignoreCase ? "i" : "") +
65 (separator.multiline ? "m" : "") +
66 (separator.extended ? "x" : "") + // Proposed for ES6
67 (separator.sticky ? "y" : ""), // Firefox 3+
68 lastLastIndex = 0,
69 // Make `global` and avoid `lastIndex` issues by working with a copy
70 separator = new RegExp(separator.source, flags + "g"),
71 separator2, match, lastIndex, lastLength;
72 str += ""; // Type-convert
73
74 compliantExecNpcg = typeof(/()??/.exec("")[1]) === "undefined"
75 if (!compliantExecNpcg) {
76 // Doesn't need flags gy, but they don't hurt
77 separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
78 }
79 /* Values for `limit`, per the spec:
80 * If undefined: 4294967295 // Math.pow(2, 32) - 1
81 * If 0, Infinity, or NaN: 0
82 * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
83 * If negative number: 4294967296 - Math.floor(Math.abs(limit))
84 * If other: Type-convert, then use the above rules
85 */
86 limit = typeof(limit) === "undefined" ?
87 -1 >>> 0 : // Math.pow(2, 32) - 1
88 limit >>> 0; // ToUint32(limit)
89 while (match = separator.exec(str)) {
90 // `separator.lastIndex` is not reliable cross-browser
91 lastIndex = match.index + match[0].length;
92 if (lastIndex > lastLastIndex) {
93 output.push(str.slice(lastLastIndex, match.index));
94 // Fix browsers whose `exec` methods don't consistently return `undefined` for
95 // nonparticipating capturing groups
96 if (!compliantExecNpcg && match.length > 1) {
97 match[0].replace(separator2, function () {
98 for (var i = 1; i < arguments.length - 2; i++) {
99 if (typeof(arguments[i]) === "undefined") {
100 match[i] = undefined;
101 }
102 }
103 });
104 }
105 if (match.length > 1 && match.index < str.length) {
106 Array.prototype.push.apply(output, match.slice(1));
107 }
108 lastLength = match[0].length;
109 lastLastIndex = lastIndex;
110 if (output.length >= limit) {
111 break;
112 }
113 }
114 if (separator.lastIndex === match.index) {
115 separator.lastIndex++; // Avoid an infinite loop
116 }
117 }
118 if (lastLastIndex === str.length) {
119 if (lastLength || !separator.test("")) {
120 output.push("");
121 }
122 } else {
123 output.push(str.slice(lastLastIndex));
124 }
125 return output.length > limit ? output.slice(0, limit) : output;
126 };
127
128 //============================================================================
129 // End contributed Cross-browser RegEx Split
130 //============================================================================
131
132
16 var uuid = function () {
133 var uuid = function () {
17 // http://www.ietf.org/rfc/rfc4122.txt
134 // http://www.ietf.org/rfc/rfc4122.txt
18 var s = [];
135 var s = [];
19 var hexDigits = "0123456789ABCDEF";
136 var hexDigits = "0123456789ABCDEF";
20 for (var i = 0; i < 32; i++) {
137 for (var i = 0; i < 32; i++) {
21 s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
138 s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
22 }
139 }
23 s[12] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
140 s[12] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
24 s[16] = hexDigits.substr((s[16] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
141 s[16] = hexDigits.substr((s[16] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
25
142
26 var uuid = s.join("");
143 var uuid = s.join("");
27 return uuid;
144 return uuid;
28 };
145 };
29
146
30
147
31 //Fix raw text to parse correctly in crazy XML
148 //Fix raw text to parse correctly in crazy XML
32 function xmlencode(string) {
149 function xmlencode(string) {
33 return string.replace(/\&/g,'&'+'amp;')
150 return string.replace(/\&/g,'&'+'amp;')
34 .replace(/</g,'&'+'lt;')
151 .replace(/</g,'&'+'lt;')
35 .replace(/>/g,'&'+'gt;')
152 .replace(/>/g,'&'+'gt;')
36 .replace(/\'/g,'&'+'apos;')
153 .replace(/\'/g,'&'+'apos;')
37 .replace(/\"/g,'&'+'quot;')
154 .replace(/\"/g,'&'+'quot;')
38 .replace(/`/g,'&'+'#96;');
155 .replace(/`/g,'&'+'#96;');
39 }
156 }
40
157
41
158
42 //Map from terminal commands to CSS classes
159 //Map from terminal commands to CSS classes
43 ansi_colormap = {
160 ansi_colormap = {
44 "30":"ansiblack", "31":"ansired",
161 "30":"ansiblack", "31":"ansired",
45 "32":"ansigreen", "33":"ansiyellow",
162 "32":"ansigreen", "33":"ansiyellow",
46 "34":"ansiblue", "35":"ansipurple","36":"ansicyan",
163 "34":"ansiblue", "35":"ansipurple","36":"ansicyan",
47 "37":"ansigrey", "01":"ansibold"
164 "37":"ansigrey", "01":"ansibold"
48 };
165 };
49
166
50 // Transform ANSI color escape codes into HTML <span> tags with css
167 // Transform ANSI color escape codes into HTML <span> tags with css
51 // classes listed in the above ansi_colormap object. The actual color used
168 // classes listed in the above ansi_colormap object. The actual color used
52 // are set in the css file.
169 // are set in the css file.
53 function fixConsole(txt) {
170 function fixConsole(txt) {
54 txt = xmlencode(txt);
171 txt = xmlencode(txt);
55 var re = /\033\[([\dA-Fa-f;]*?)m/;
172 var re = /\033\[([\dA-Fa-f;]*?)m/;
56 var opened = false;
173 var opened = false;
57 var cmds = [];
174 var cmds = [];
58 var opener = "";
175 var opener = "";
59 var closer = "";
176 var closer = "";
60 while (re.test(txt)) {
177 while (re.test(txt)) {
61 var cmds = txt.match(re)[1].split(";");
178 var cmds = txt.match(re)[1].split(";");
62 closer = opened?"</span>":"";
179 closer = opened?"</span>":"";
63 opened = cmds.length > 1 || cmds[0] != 0;
180 opened = cmds.length > 1 || cmds[0] != 0;
64 var rep = [];
181 var rep = [];
65 for (var i in cmds)
182 for (var i in cmds)
66 if (typeof(ansi_colormap[cmds[i]]) != "undefined")
183 if (typeof(ansi_colormap[cmds[i]]) != "undefined")
67 rep.push(ansi_colormap[cmds[i]]);
184 rep.push(ansi_colormap[cmds[i]]);
68 opener = rep.length > 0?"<span class=\""+rep.join(" ")+"\">":"";
185 opener = rep.length > 0?"<span class=\""+rep.join(" ")+"\">":"";
69 txt = txt.replace(re, closer + opener);
186 txt = txt.replace(re, closer + opener);
70 }
187 }
71 if (opened) txt += "</span>";
188 if (opened) txt += "</span>";
72 return txt;
189 return txt;
73 }
190 }
74
191
75 // Remove chunks that should be overridden by the effect of
192 // Remove chunks that should be overridden by the effect of
76 // carriage return characters
193 // carriage return characters
77 function fixCarriageReturn(txt) {
194 function fixCarriageReturn(txt) {
78 tmp = txt;
195 tmp = txt;
79 do {
196 do {
80 txt = tmp;
197 txt = tmp;
81 tmp = txt.replace(/^.*\r(?!\n)/gm, '');
198 tmp = txt.replace(/^.*\r(?!\n)/gm, '');
82 } while (tmp.length < txt.length);
199 } while (tmp.length < txt.length);
83 return txt;
200 return txt;
84 }
201 }
85
202
86 grow = function(element) {
203 grow = function(element) {
87 // Grow the cell by hand. This is used upon reloading from JSON, when the
204 // Grow the cell by hand. This is used upon reloading from JSON, when the
88 // autogrow handler is not called.
205 // autogrow handler is not called.
89 var dom = element.get(0);
206 var dom = element.get(0);
90 var lines_count = 0;
207 var lines_count = 0;
91 // modified split rule from
208 // modified split rule from
92 // http://stackoverflow.com/questions/2035910/how-to-get-the-number-of-lines-in-a-textarea/2036424#2036424
209 // http://stackoverflow.com/questions/2035910/how-to-get-the-number-of-lines-in-a-textarea/2036424#2036424
93 var lines = dom.value.split(/\r|\r\n|\n/);
210 var lines = dom.value.split(/\r|\r\n|\n/);
94 lines_count = lines.length;
211 lines_count = lines.length;
95 if (lines_count >= 1) {
212 if (lines_count >= 1) {
96 dom.rows = lines_count;
213 dom.rows = lines_count;
97 } else {
214 } else {
98 dom.rows = 1;
215 dom.rows = 1;
99 }
216 }
100 };
217 };
101
218
102 // some keycodes that seem to be platform/browser independant
219 // some keycodes that seem to be platform/browser independant
103 var keycodes ={
220 var keycodes ={
104 BACKSPACE: 8,
221 BACKSPACE: 8,
105 TAB : 9,
222 TAB : 9,
106 ENTER : 13,
223 ENTER : 13,
107 SHIFT : 16,
224 SHIFT : 16,
108 CTRL : 17,
225 CTRL : 17,
109 CONTROL : 17,
226 CONTROL : 17,
110 ALT : 18,
227 ALT : 18,
111 ESC : 27,
228 ESC : 27,
112 SPACE : 32,
229 SPACE : 32,
113 PGUP : 33,
230 PGUP : 33,
114 PGDOWN : 34,
231 PGDOWN : 34,
115 LEFT_ARROW: 37,
232 LEFT_ARROW: 37,
116 LEFTARROW: 37,
233 LEFTARROW: 37,
117 LEFT : 37,
234 LEFT : 37,
118 UP_ARROW : 38,
235 UP_ARROW : 38,
119 UPARROW : 38,
236 UPARROW : 38,
120 UP : 38,
237 UP : 38,
121 RIGHT_ARROW:39,
238 RIGHT_ARROW:39,
122 RIGHTARROW:39,
239 RIGHTARROW:39,
123 RIGHT : 39,
240 RIGHT : 39,
124 DOWN_ARROW: 40,
241 DOWN_ARROW: 40,
125 DOWNARROW: 40,
242 DOWNARROW: 40,
126 DOWN : 40,
243 DOWN : 40,
127 };
244 };
128
245
129
246
130 points_to_pixels = function (points) {
247 points_to_pixels = function (points) {
131 // A reasonably good way of converting between points and pixels.
248 // A reasonably good way of converting between points and pixels.
132 var test = $('<div style="display: none; width: 10000pt; padding:0; border:0;"></div>');
249 var test = $('<div style="display: none; width: 10000pt; padding:0; border:0;"></div>');
133 $(body).append(test);
250 $(body).append(test);
134 var pixel_per_point = test.width()/10000;
251 var pixel_per_point = test.width()/10000;
135 test.remove();
252 test.remove();
136 return Math.floor(points*pixel_per_point);
253 return Math.floor(points*pixel_per_point);
137 }
254 }
138
255
139
256
140 return {
257 return {
258 regex_split : regex_split,
141 uuid : uuid,
259 uuid : uuid,
142 fixConsole : fixConsole,
260 fixConsole : fixConsole,
143 keycodes : keycodes,
261 keycodes : keycodes,
144 grow : grow,
262 grow : grow,
145 fixCarriageReturn : fixCarriageReturn,
263 fixCarriageReturn : fixCarriageReturn,
146 points_to_pixels : points_to_pixels
264 points_to_pixels : points_to_pixels
147 };
265 };
148
266
149 }(IPython));
267 }(IPython));
@@ -1,224 +1,224 b''
1 {% extends page.html %}
1 {% extends page.html %}
2 {% block stylesheet %}
2 {% block stylesheet %}
3
3
4 {% if mathjax_url %}
4 {% if mathjax_url %}
5 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script>
5 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script>
6 {% end %}
6 {% end %}
7 <script type="text/javascript">
7 <script type="text/javascript">
8 // MathJax disabled, set as null to distingish from *missing* MathJax,
8 // MathJax disabled, set as null to distingish from *missing* MathJax,
9 // where it will be undefined, and should prompt a dialog later.
9 // where it will be undefined, and should prompt a dialog later.
10 window.mathjax_url = "{{mathjax_url}}";
10 window.mathjax_url = "{{mathjax_url}}";
11 </script>
11 </script>
12
12
13 <link rel="stylesheet" href="{{ static_url("codemirror/lib/codemirror.css") }}">
13 <link rel="stylesheet" href="{{ static_url("codemirror/lib/codemirror.css") }}">
14 <link rel="stylesheet" href="{{ static_url("codemirror/theme/ipython.css") }}">
14 <link rel="stylesheet" href="{{ static_url("codemirror/theme/ipython.css") }}">
15
15
16 <link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
16 <link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
17
17
18 <link rel="stylesheet" href="{{ static_url("css/notebook.css") }}" type="text/css" />
18 <link rel="stylesheet" href="{{ static_url("css/notebook.css") }}" type="text/css" />
19 <link rel="stylesheet" href="{{ static_url("css/tooltip.css") }}" type="text/css" />
19 <link rel="stylesheet" href="{{ static_url("css/tooltip.css") }}" type="text/css" />
20 <link rel="stylesheet" href="{{ static_url("css/renderedhtml.css") }}" type="text/css" />
20 <link rel="stylesheet" href="{{ static_url("css/renderedhtml.css") }}" type="text/css" />
21
21
22 <link rel="stylesheet" href="{{ static_url("css/printnotebook.css") }}" type="text/css" media="print"/>
22 <link rel="stylesheet" href="{{ static_url("css/printnotebook.css") }}" type="text/css" media="print"/>
23
23
24 {% end %}
24 {% end %}
25
25
26
26
27 {% block params %}
27 {% block params %}
28
28
29 data-project={{project}}
29 data-project={{project}}
30 data-base-project-url={{base_project_url}}
30 data-base-project-url={{base_project_url}}
31 data-base-kernel-url={{base_kernel_url}}
31 data-base-kernel-url={{base_kernel_url}}
32 data-read-only={{read_only and not logged_in}}
32 data-read-only={{read_only and not logged_in}}
33 data-notebook-id={{notebook_id}}
33 data-notebook-id={{notebook_id}}
34
34
35 {% end %}
35 {% end %}
36
36
37
37
38 {% block header %}
38 {% block header %}
39
39
40 <span id="save_widget">
40 <span id="save_widget">
41 <span id="notebook_name"></span>
41 <span id="notebook_name"></span>
42 <span id="save_status"></span>
42 <span id="save_status"></span>
43 </span>
43 </span>
44
44
45 {% end %}
45 {% end %}
46
46
47
47
48 {% block site %}
48 {% block site %}
49
49
50 <div id="menubar_container">
50 <div id="menubar_container">
51 <div id="menubar">
51 <div id="menubar">
52 <ul id="menus">
52 <ul id="menus">
53 <li><a href="#">File</a>
53 <li><a href="#">File</a>
54 <ul>
54 <ul>
55 <li id="new_notebook"><a href="#">New</a></li>
55 <li id="new_notebook"><a href="#">New</a></li>
56 <li id="open_notebook"><a href="#">Open...</a></li>
56 <li id="open_notebook"><a href="#">Open...</a></li>
57 <hr/>
57 <hr/>
58 <li id="copy_notebook"><a href="#">Make a Copy...</a></li>
58 <li id="copy_notebook"><a href="#">Make a Copy...</a></li>
59 <li id="rename_notebook"><a href="#">Rename...</a></li>
59 <li id="rename_notebook"><a href="#">Rename...</a></li>
60 <li id="save_notebook"><a href="#">Save</a></li>
60 <li id="save_notebook"><a href="#">Save</a></li>
61 <hr/>
61 <hr/>
62 <li><a href="#">Download as</a>
62 <li><a href="#">Download as</a>
63 <ul>
63 <ul>
64 <li id="download_ipynb"><a href="#">IPython (.ipynb)</a></li>
64 <li id="download_ipynb"><a href="#">IPython (.ipynb)</a></li>
65 <li id="download_py"><a href="#">Python (.py)</a></li>
65 <li id="download_py"><a href="#">Python (.py)</a></li>
66 </ul>
66 </ul>
67 </li>
67 </li>
68 <hr/>
68 <hr/>
69 <li id="print_notebook"><a href="/{{notebook_id}}/print" target="_blank">Print View</a></li>
69 <li id="print_notebook"><a href="/{{notebook_id}}/print" target="_blank">Print View</a></li>
70 <hr/>
70 <hr/>
71 <li id="kill_and_exit"><a href="#" >Close and halt</a></li>
71 <li id="kill_and_exit"><a href="#" >Close and halt</a></li>
72 </ul>
72 </ul>
73 </li>
73 </li>
74 <li><a href="#">Edit</a>
74 <li><a href="#">Edit</a>
75 <ul>
75 <ul>
76 <li id="cut_cell"><a href="#">Cut Cell</a></li>
76 <li id="cut_cell"><a href="#">Cut Cell</a></li>
77 <li id="copy_cell"><a href="#">Copy Cell</a></li>
77 <li id="copy_cell"><a href="#">Copy Cell</a></li>
78 <li id="paste_cell" class="ui-state-disabled"><a href="#">Paste Cell</a></li>
78 <li id="paste_cell" class="ui-state-disabled"><a href="#">Paste Cell</a></li>
79 <li id="paste_cell_above" class="ui-state-disabled"><a href="#">Paste Cell Above</a></li>
79 <li id="paste_cell_above" class="ui-state-disabled"><a href="#">Paste Cell Above</a></li>
80 <li id="paste_cell_below" class="ui-state-disabled"><a href="#">Paste Cell Below</a></li>
80 <li id="paste_cell_below" class="ui-state-disabled"><a href="#">Paste Cell Below</a></li>
81 <li id="delete_cell"><a href="#">Delete</a></li>
81 <li id="delete_cell"><a href="#">Delete</a></li>
82 <hr/>
82 <hr/>
83 <li id="split_cell"><a href="#">Split Cell</a></li>
83 <li id="split_cell"><a href="#">Split Cell</a></li>
84 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
84 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
85 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
85 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
86 <hr/>
86 <hr/>
87 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
87 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
88 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
88 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
89 <hr/>
89 <hr/>
90 <li id="select_previous"><a href="#">Select Previous Cell</a></li>
90 <li id="select_previous"><a href="#">Select Previous Cell</a></li>
91 <li id="select_next"><a href="#">Select Next Cell</a></li>
91 <li id="select_next"><a href="#">Select Next Cell</a></li>
92 </ul>
92 </ul>
93 </li>
93 </li>
94 <li><a href="#">View</a>
94 <li><a href="#">View</a>
95 <ul>
95 <ul>
96 <li id="toggle_header"><a href="#">Toggle Header</a></li>
96 <li id="toggle_header"><a href="#">Toggle Header</a></li>
97 <li id="toggle_toolbar"><a href="#">Toggle Toolbar</a></li>
97 <li id="toggle_toolbar"><a href="#">Toggle Toolbar</a></li>
98 </ul>
98 </ul>
99 </li>
99 </li>
100 <li><a href="#">Insert</a>
100 <li><a href="#">Insert</a>
101 <ul>
101 <ul>
102 <li id="insert_cell_above"><a href="#">Insert Cell Above</a></li>
102 <li id="insert_cell_above"><a href="#">Insert Cell Above</a></li>
103 <li id="insert_cell_below"><a href="#">Insert Cell Below</a></li>
103 <li id="insert_cell_below"><a href="#">Insert Cell Below</a></li>
104 </ul>
104 </ul>
105 </li>
105 </li>
106 <li><a href="#">Cell</a>
106 <li><a href="#">Cell</a>
107 <ul>
107 <ul>
108 <li id="run_cell"><a href="#">Run</a></li>
108 <li id="run_cell"><a href="#">Run</a></li>
109 <li id="run_cell_in_place"><a href="#">Run in Place</a></li>
109 <li id="run_cell_in_place"><a href="#">Run in Place</a></li>
110 <li id="run_all_cells"><a href="#">Run All</a></li>
110 <li id="run_all_cells"><a href="#">Run All</a></li>
111 <hr/>
111 <hr/>
112 <li id="to_code"><a href="#">Code</a></li>
112 <li id="to_code"><a href="#">Code</a></li>
113 <li id="to_markdown"><a href="#">Markdown </a></li>
113 <li id="to_markdown"><a href="#">Markdown </a></li>
114 <li id="to_raw"><a href="#">Raw Text</a></li>
114 <li id="to_raw"><a href="#">Raw Text</a></li>
115 <li id="to_heading1"><a href="#">Heading 1</a></li>
115 <li id="to_heading1"><a href="#">Heading 1</a></li>
116 <li id="to_heading2"><a href="#">Heading 2</a></li>
116 <li id="to_heading2"><a href="#">Heading 2</a></li>
117 <li id="to_heading3"><a href="#">Heading 3</a></li>
117 <li id="to_heading3"><a href="#">Heading 3</a></li>
118 <li id="to_heading4"><a href="#">Heading 4</a></li>
118 <li id="to_heading4"><a href="#">Heading 4</a></li>
119 <li id="to_heading5"><a href="#">Heading 5</a></li>
119 <li id="to_heading5"><a href="#">Heading 5</a></li>
120 <li id="to_heading6"><a href="#">Heading 6</a></li>
120 <li id="to_heading6"><a href="#">Heading 6</a></li>
121 <hr/>
121 <hr/>
122 <li id="toggle_output"><a href="#">Toggle Current Output</a></li>
122 <li id="toggle_output"><a href="#">Toggle Current Output</a></li>
123 <li id="all_outputs"><a href="#">All Output</a>
123 <li id="all_outputs"><a href="#">All Output</a>
124 <ul>
124 <ul>
125 <li id="expand_all_output"><a href="#">Expand</a></li>
125 <li id="expand_all_output"><a href="#">Expand</a></li>
126 <li id="scroll_all_output"><a href="#">Scroll Long</a></li>
126 <li id="scroll_all_output"><a href="#">Scroll Long</a></li>
127 <li id="collapse_all_output"><a href="#">Collapse</a></li>
127 <li id="collapse_all_output"><a href="#">Collapse</a></li>
128 <li id="clear_all_output"><a href="#">Clear</a></li>
128 <li id="clear_all_output"><a href="#">Clear</a></li>
129 </ul>
129 </ul>
130 </li>
130 </li>
131 </ul>
131 </ul>
132 </li>
132 </li>
133 <li><a href="#">Kernel</a>
133 <li><a href="#">Kernel</a>
134 <ul>
134 <ul>
135 <li id="int_kernel"><a href="#">Interrupt</a></li>
135 <li id="int_kernel"><a href="#">Interrupt</a></li>
136 <li id="restart_kernel"><a href="#">Restart</a></li>
136 <li id="restart_kernel"><a href="#">Restart</a></li>
137 </ul>
137 </ul>
138 </li>
138 </li>
139 <li><a href="#">Help</a>
139 <li><a href="#">Help</a>
140 <ul>
140 <ul>
141 <li><a href="http://ipython.org/documentation.html" target="_blank">IPython Help</a></li>
141 <li><a href="http://ipython.org/documentation.html" target="_blank">IPython Help</a></li>
142 <li><a href="http://ipython.org/ipython-doc/stable/interactive/htmlnotebook.html" target="_blank">Notebook Help</a></li>
142 <li><a href="http://ipython.org/ipython-doc/stable/interactive/htmlnotebook.html" target="_blank">Notebook Help</a></li>
143 <li id="keyboard_shortcuts"><a href="#">Keyboard Shortcuts</a></li>
143 <li id="keyboard_shortcuts"><a href="#">Keyboard Shortcuts</a></li>
144 <hr/>
144 <hr/>
145 <li><a href="http://docs.python.org" target="_blank">Python</a></li>
145 <li><a href="http://docs.python.org" target="_blank">Python</a></li>
146 <li><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></li>
146 <li><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></li>
147 <li><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></li>
147 <li><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></li>
148 <li><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></li>
148 <li><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></li>
149 <li><a href="http://matplotlib.sourceforge.net/" target="_blank">Matplotlib</a></li>
149 <li><a href="http://matplotlib.sourceforge.net/" target="_blank">Matplotlib</a></li>
150 </ul>
150 </ul>
151 </li>
151 </li>
152 </ul>
152 </ul>
153
153
154 </div>
154 </div>
155 <div id="notification_area">
155 <div id="notification_area">
156 </div>
156 </div>
157 </div>
157 </div>
158
158
159
159
160 <div id="maintoolbar"></div>
160 <div id="maintoolbar"></div>
161
161
162 <div id="main_app">
162 <div id="main_app">
163
163
164 <div id="notebook_panel">
164 <div id="notebook_panel">
165 <div id="notebook"></div>
165 <div id="notebook"></div>
166 <div id="pager_splitter"></div>
166 <div id="pager_splitter"></div>
167 <div id="pager_container">
167 <div id="pager_container">
168 <div id='pager_button_area'>
168 <div id='pager_button_area'>
169 </div>
169 </div>
170 <div id="pager"></div>
170 <div id="pager"></div>
171 </div>
171 </div>
172 </div>
172 </div>
173
173
174 </div>
174 </div>
175 <div id='tooltip' class='ipython_tooltip ui-corner-all' style='display:none'></div>
175 <div id='tooltip' class='ipython_tooltip ui-corner-all' style='display:none'></div>
176
176
177
177
178 {% end %}
178 {% end %}
179
179
180
180
181 {% block script %}
181 {% block script %}
182
182
183 <script src="{{ static_url("codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
183 <script src="{{ static_url("codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
184 <script src="{{ static_url("codemirror/lib/util/loadmode.js") }}" charset="utf-8"></script>
184 <script src="{{ static_url("codemirror/lib/util/loadmode.js") }}" charset="utf-8"></script>
185 <script src="{{ static_url("codemirror/lib/util/multiplex.js") }}" charset="utf-8"></script>
185 <script src="{{ static_url("codemirror/lib/util/multiplex.js") }}" charset="utf-8"></script>
186 <script src="{{ static_url("codemirror/mode/python/python.js") }}" charset="utf-8"></script>
186 <script src="{{ static_url("codemirror/mode/python/python.js") }}" charset="utf-8"></script>
187 <script src="{{ static_url("codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
187 <script src="{{ static_url("codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
188 <script src="{{ static_url("codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
188 <script src="{{ static_url("codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
189 <script src="{{ static_url("codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
189 <script src="{{ static_url("codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
190 <script src="{{ static_url("codemirror/mode/css/css.js") }}" charset="utf-8"></script>
190 <script src="{{ static_url("codemirror/mode/css/css.js") }}" charset="utf-8"></script>
191 <script src="{{ static_url("codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
191 <script src="{{ static_url("codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
192 <script src="{{ static_url("codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
192 <script src="{{ static_url("codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
193
193
194 <script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
194 <script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
195
195
196 <script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
196 <script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
197 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
197 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
198
198
199 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
199 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
200 <script src="{{ static_url("js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
200 <script src="{{ static_url("js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
201 <script src="{{ static_url("js/layoutmanager.js") }}" type="text/javascript" charset="utf-8"></script>
201 <script src="{{ static_url("js/layoutmanager.js") }}" type="text/javascript" charset="utf-8"></script>
202 <script src="{{ static_url("js/initmathjax.js") }}" type="text/javascript" charset="utf-8"></script>
202 <script src="{{ static_url("js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
203 <script src="{{ static_url("js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
203 <script src="{{ static_url("js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
204 <script src="{{ static_url("js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
204 <script src="{{ static_url("js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
205 <script src="{{ static_url("js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
205 <script src="{{ static_url("js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
206 <script src="{{ static_url("js/completer.js") }}" type="text/javascript" charset="utf-8"></script>
206 <script src="{{ static_url("js/completer.js") }}" type="text/javascript" charset="utf-8"></script>
207 <script src="{{ static_url("js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
207 <script src="{{ static_url("js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
208 <script src="{{ static_url("js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
208 <script src="{{ static_url("js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
209 <script src="{{ static_url("js/savewidget.js") }}" type="text/javascript" charset="utf-8"></script>
209 <script src="{{ static_url("js/savewidget.js") }}" type="text/javascript" charset="utf-8"></script>
210 <script src="{{ static_url("js/quickhelp.js") }}" type="text/javascript" charset="utf-8"></script>
210 <script src="{{ static_url("js/quickhelp.js") }}" type="text/javascript" charset="utf-8"></script>
211 <script src="{{ static_url("js/pager.js") }}" type="text/javascript" charset="utf-8"></script>
211 <script src="{{ static_url("js/pager.js") }}" type="text/javascript" charset="utf-8"></script>
212 <script src="{{ static_url("js/menubar.js") }}" type="text/javascript" charset="utf-8"></script>
212 <script src="{{ static_url("js/menubar.js") }}" type="text/javascript" charset="utf-8"></script>
213 <script src="{{ static_url("js/toolbar.js") }}" type="text/javascript" charset="utf-8"></script>
213 <script src="{{ static_url("js/toolbar.js") }}" type="text/javascript" charset="utf-8"></script>
214 <script src="{{ static_url("js/maintoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
214 <script src="{{ static_url("js/maintoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
215 <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
215 <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
216 <script src="{{ static_url("js/notificationwidget.js") }}" type="text/javascript" charset="utf-8"></script>
216 <script src="{{ static_url("js/notificationwidget.js") }}" type="text/javascript" charset="utf-8"></script>
217 <script src="{{ static_url("js/notificationarea.js") }}" type="text/javascript" charset="utf-8"></script>
217 <script src="{{ static_url("js/notificationarea.js") }}" type="text/javascript" charset="utf-8"></script>
218 <script src="{{ static_url("js/tooltip.js") }}" type="text/javascript" charset="utf-8"></script>
218 <script src="{{ static_url("js/tooltip.js") }}" type="text/javascript" charset="utf-8"></script>
219 <script src="{{ static_url("js/config.js") }}" type="text/javascript" charset="utf-8"></script>
219 <script src="{{ static_url("js/config.js") }}" type="text/javascript" charset="utf-8"></script>
220 <script src="{{ static_url("js/notebookmain.js") }}" type="text/javascript" charset="utf-8"></script>
220 <script src="{{ static_url("js/notebookmain.js") }}" type="text/javascript" charset="utf-8"></script>
221
221
222 <script src="{{ static_url("js/contexthint.js") }}" charset="utf-8"></script>
222 <script src="{{ static_url("js/contexthint.js") }}" charset="utf-8"></script>
223
223
224 {% end %}
224 {% end %}
@@ -1,81 +1,81 b''
1 {% extends page.html %}
1 {% extends page.html %}
2
2
3 {% block stylesheet %}
3 {% block stylesheet %}
4
4
5 {% if mathjax_url %}
5 {% if mathjax_url %}
6 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script>
6 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML" charset="utf-8"></script>
7 {% end %}
7 {% end %}
8 <script type="text/javascript">
8 <script type="text/javascript">
9 // MathJax disabled, set as null to distingish from *missing* MathJax,
9 // MathJax disabled, set as null to distingish from *missing* MathJax,
10 // where it will be undefined, and should prompt a dialog later.
10 // where it will be undefined, and should prompt a dialog later.
11 window.mathjax_url = "{{mathjax_url}}";
11 window.mathjax_url = "{{mathjax_url}}";
12 </script>
12 </script>
13
13
14 <link rel="stylesheet" href="{{ static_url("codemirror/lib/codemirror.css") }}">
14 <link rel="stylesheet" href="{{ static_url("codemirror/lib/codemirror.css") }}">
15 <link rel="stylesheet" href="{{ static_url("codemirror/theme/ipython.css") }}">
15 <link rel="stylesheet" href="{{ static_url("codemirror/theme/ipython.css") }}">
16
16
17 <link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
17 <link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
18
18
19 <link rel="stylesheet" href="{{ static_url("css/notebook.css") }}" type="text/css" />
19 <link rel="stylesheet" href="{{ static_url("css/notebook.css") }}" type="text/css" />
20 <link rel="stylesheet" href="{{ static_url("css/printnotebook.css") }}" type="text/css" />
20 <link rel="stylesheet" href="{{ static_url("css/printnotebook.css") }}" type="text/css" />
21 <link rel="stylesheet" href="{{ static_url("css/renderedhtml.css") }}" type="text/css" />
21 <link rel="stylesheet" href="{{ static_url("css/renderedhtml.css") }}" type="text/css" />
22
22
23 {% end %}
23 {% end %}
24
24
25
25
26 {% block params %}
26 {% block params %}
27
27
28 data-project={{project}}
28 data-project={{project}}
29 data-base-project-url={{base_project_url}}
29 data-base-project-url={{base_project_url}}
30 data-base-kernel-url={{base_kernel_url}}
30 data-base-kernel-url={{base_kernel_url}}
31 data-read-only={{read_only and not logged_in}}
31 data-read-only={{read_only and not logged_in}}
32 data-notebook-id={{notebook_id}}
32 data-notebook-id={{notebook_id}}
33
33
34 {% end %}
34 {% end %}
35
35
36
36
37 {% block header %}
37 {% block header %}
38 {% end %}
38 {% end %}
39
39
40
40
41 {% block site %}
41 {% block site %}
42
42
43 <div id="main_app">
43 <div id="main_app">
44
44
45 <div id="notebook_panel">
45 <div id="notebook_panel">
46 <div id="notebook"></div>
46 <div id="notebook"></div>
47 </div>
47 </div>
48
48
49 </div>
49 </div>
50
50
51 {% end %}
51 {% end %}
52
52
53
53
54 {% block script %}
54 {% block script %}
55
55
56 <script src="{{ static_url("codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
56 <script src="{{ static_url("codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
57 <script src="{{ static_url("codemirror/mode/python/python.js") }}" charset="utf-8"></script>
57 <script src="{{ static_url("codemirror/mode/python/python.js") }}" charset="utf-8"></script>
58 <script src="{{ static_url("codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
58 <script src="{{ static_url("codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
59 <script src="{{ static_url("codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
59 <script src="{{ static_url("codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
60 <script src="{{ static_url("codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
60 <script src="{{ static_url("codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
61 <script src="{{ static_url("codemirror/mode/css/css.js") }}" charset="utf-8"></script>
61 <script src="{{ static_url("codemirror/mode/css/css.js") }}" charset="utf-8"></script>
62 <script src="{{ static_url("codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
62 <script src="{{ static_url("codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
63 <script src="{{ static_url("codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
63 <script src="{{ static_url("codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
64
64
65 <script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
65 <script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
66
66
67 <script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
67 <script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
68 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
68 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
69
69
70 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
70 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
71 <script src="{{ static_url("js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
71 <script src="{{ static_url("js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
72 <script src="{{ static_url("js/initmathjax.js") }}" type="text/javascript" charset="utf-8"></script>
72 <script src="{{ static_url("js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
73 <script src="{{ static_url("js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
73 <script src="{{ static_url("js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
74 <script src="{{ static_url("js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
74 <script src="{{ static_url("js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
75 <script src="{{ static_url("js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
75 <script src="{{ static_url("js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
76 <script src="{{ static_url("js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
76 <script src="{{ static_url("js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
77 <script src="{{ static_url("js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
77 <script src="{{ static_url("js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
78 <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
78 <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
79 <script src="{{ static_url("js/printnotebookmain.js") }}" type="text/javascript" charset="utf-8"></script>
79 <script src="{{ static_url("js/printnotebookmain.js") }}" type="text/javascript" charset="utf-8"></script>
80
80
81 {% end %}
81 {% end %}
General Comments 0
You need to be logged in to leave comments. Login now