Show More
@@ -129,10 +129,6 b' define([' | |||||
129 | that._nbconvert('html', false); |
|
129 | that._nbconvert('html', false); | |
130 | }); |
|
130 | }); | |
131 |
|
131 | |||
132 | this.element.find('#download_py').click(function () { |
|
|||
133 | that._nbconvert('python', true); |
|
|||
134 | }); |
|
|||
135 |
|
||||
136 | this.element.find('#download_html').click(function () { |
|
132 | this.element.find('#download_html').click(function () { | |
137 | that._nbconvert('html', true); |
|
133 | that._nbconvert('html', true); | |
138 | }); |
|
134 | }); | |
@@ -308,6 +304,16 b' define([' | |||||
308 | this.events.on('checkpoint_created.Notebook', function (event, data) { |
|
304 | this.events.on('checkpoint_created.Notebook', function (event, data) { | |
309 | that.update_restore_checkpoint(that.notebook.checkpoints); |
|
305 | that.update_restore_checkpoint(that.notebook.checkpoints); | |
310 | }); |
|
306 | }); | |
|
307 | ||||
|
308 | this.events.on('notebook_loaded.Notebook', function() { | |||
|
309 | var langinfo = that.notebook.metadata.language_info || {}; | |||
|
310 | that.update_nbconvert_script(langinfo); | |||
|
311 | }); | |||
|
312 | ||||
|
313 | this.events.on('kernel_ready.Kernel', function(event, data) { | |||
|
314 | var langinfo = data.kernel.info_reply.language_info || {}; | |||
|
315 | that.update_nbconvert_script(langinfo); | |||
|
316 | }); | |||
311 | }; |
|
317 | }; | |
312 |
|
318 | |||
313 | MenuBar.prototype.update_restore_checkpoint = function(checkpoints) { |
|
319 | MenuBar.prototype.update_restore_checkpoint = function(checkpoints) { | |
@@ -340,6 +346,31 b' define([' | |||||
340 | ); |
|
346 | ); | |
341 | }); |
|
347 | }); | |
342 | }; |
|
348 | }; | |
|
349 | ||||
|
350 | MenuBar.prototype.update_nbconvert_script = function(langinfo) { | |||
|
351 | // Set the 'Download as foo' menu option for the relevant language. | |||
|
352 | var el = this.element.find('#download_script'); | |||
|
353 | var that = this; | |||
|
354 | ||||
|
355 | // Set menu entry text to e.g. "Python (.py)" | |||
|
356 | var langname = (langinfo.name || 'Script') | |||
|
357 | langname = langname.charAt(0).toUpperCase()+langname.substr(1) // Capitalise | |||
|
358 | el.find('a').text(langname + ' (.'+(langinfo.file_extension || 'txt')+')'); | |||
|
359 | ||||
|
360 | // Unregister any previously registered handlers | |||
|
361 | el.off('click'); | |||
|
362 | if (langinfo.nbconvert_exporter) { | |||
|
363 | // Metadata specifies a specific exporter, e.g. 'python' | |||
|
364 | el.click(function() { | |||
|
365 | that._nbconvert(langinfo.nbconvert_exporter, true); | |||
|
366 | }); | |||
|
367 | } else { | |||
|
368 | // Use generic 'script' exporter | |||
|
369 | el.click(function() { | |||
|
370 | that._nbconvert('script', true); | |||
|
371 | }); | |||
|
372 | } | |||
|
373 | }; | |||
343 |
|
374 | |||
344 | // Backwards compatability. |
|
375 | // Backwards compatability. | |
345 | IPython.MenuBar = MenuBar; |
|
376 | IPython.MenuBar = MenuBar; |
@@ -105,7 +105,7 b' class="notebook_app"' | |||||
105 | <li class="dropdown-submenu"><a href="#">Download as</a> |
|
105 | <li class="dropdown-submenu"><a href="#">Download as</a> | |
106 | <ul class="dropdown-menu"> |
|
106 | <ul class="dropdown-menu"> | |
107 | <li id="download_ipynb"><a href="#">IPython Notebook (.ipynb)</a></li> |
|
107 | <li id="download_ipynb"><a href="#">IPython Notebook (.ipynb)</a></li> | |
108 |
<li id="download_ |
|
108 | <li id="download_script"><a href="#">Script</a></li> | |
109 | <li id="download_html"><a href="#">HTML (.html)</a></li> |
|
109 | <li id="download_html"><a href="#">HTML (.html)</a></li> | |
110 | <li id="download_rst"><a href="#">reST (.rst)</a></li> |
|
110 | <li id="download_rst"><a href="#">reST (.rst)</a></li> | |
111 | <li id="download_pdf"><a href="#">PDF (.pdf)</a></li> |
|
111 | <li id="download_pdf"><a href="#">PDF (.pdf)</a></li> |
@@ -75,6 +75,8 b' class IPythonKernel(KernelBase):' | |||||
75 | 'codemirror_mode': {'name': 'ipython', |
|
75 | 'codemirror_mode': {'name': 'ipython', | |
76 | 'version': sys.version_info[0]}, |
|
76 | 'version': sys.version_info[0]}, | |
77 | 'pygments_lexer': 'ipython%d' % (3 if PY3 else 2), |
|
77 | 'pygments_lexer': 'ipython%d' % (3 if PY3 else 2), | |
|
78 | 'nbconvert_exporter': 'python', | |||
|
79 | 'file_extension': 'py' | |||
78 | } |
|
80 | } | |
79 | @property |
|
81 | @property | |
80 | def banner(self): |
|
82 | def banner(self): |
General Comments 0
You need to be logged in to leave comments.
Login now