Skip to content
This repository
Browse code

Implement static publishing of HTML notebook.

  • Loading branch information...
commit 567f1c3bde4b331b312f91322b881c89464c5049 1 parent 18ad520
Stefan van der Walt stefanv authored
17 IPython/frontend/html/notebook/static/js/notebook.js
@@ -762,6 +762,23 @@ var IPython = (function (IPython) {
762 762 };
763 763 };
764 764
  765 + Notebook.prototype.publish_notebook = function () {
  766 + var w = window.open('', '_blank', 'scrollbars=1,menubar=1');
  767 + var html = '<html><head>' +
  768 + $('head').clone().html() +
  769 + '<style type="text/css">' +
  770 + '@media print { body { overflow: visible !important; } }' +
  771 + '</style>' +
  772 + '</head><body style="overflow: auto;">' +
  773 + $('#notebook').clone().html() +
  774 + '</body></html>';
  775 +
  776 + w.document.open();
  777 + w.document.write(html);
  778 + w.document.close();
  779 +
  780 + return false;
  781 + };
765 782
766 783 Notebook.prototype.notebook_saved = function (data, status, xhr) {
767 784 this.dirty = false;
24 IPython/frontend/html/notebook/static/js/savewidget.js
@@ -21,6 +21,7 @@ var IPython = (function (IPython) {
21 21 SaveWidget.prototype.style = function () {
22 22 this.element.find('input#notebook_name').addClass('ui-widget ui-widget-content');
23 23 this.element.find('button#save_notebook').button();
  24 + this.element.find('button#publish_notebook').button();
24 25 var left_panel_width = $('div#left_panel').outerWidth();
25 26 var left_panel_splitter_width = $('div#left_panel_splitter').outerWidth();
26 27 $('span#save_widget').css({marginLeft:left_panel_width+left_panel_splitter_width});
@@ -33,6 +34,10 @@ var IPython = (function (IPython) {
33 34 IPython.notebook.save_notebook();
34 35 that.set_document_title();
35 36 });
  37 +
  38 + this.element.find('button#publish_notebook').click(function () {
  39 + IPython.notebook.publish_notebook();
  40 + });
36 41 };
37 42
38 43
@@ -84,20 +89,23 @@ var IPython = (function (IPython) {
84 89
85 90
86 91 SaveWidget.prototype.status_save = function () {
87   - this.element.find('span.ui-button-text').text('Save');
88   - this.element.find('button#save_notebook').button('enable');
89   - };
  92 + $('button#save_notebook').button('option', 'label', 'Save');
  93 + $('button#save_notebook').button('enable');
  94 + $('button#publish_notebook').button('enable');
  95 + };
90 96
91 97
92 98 SaveWidget.prototype.status_saving = function () {
93   - this.element.find('span.ui-button-text').text('Saving');
94   - this.element.find('button#save_notebook').button('disable');
95   - };
  99 + $('button#save_notebook').button('option', 'label', 'Saving');
  100 + $('button#save_notebook').button('disable');
  101 + $('button#publish_notebook').button('disable');
  102 + };
96 103
97 104
98 105 SaveWidget.prototype.status_loading = function () {
99   - this.element.find('span.ui-button-text').text('Loading');
100   - this.element.find('button#save_notebook').button('disable');
  106 + $('button#save_notebook').button('option', 'label', 'Loading');
  107 + $('button#save_notebook').button('disable');
  108 + $('button#publish_notebook').button('disable');
101 109 };
102 110
103 111
1  IPython/frontend/html/notebook/templates/notebook.html
@@ -41,6 +41,7 @@
41 41 <input type="text" id="notebook_name" size="20"></textarea>
42 42 <span id="notebook_id" style="display:none">{{notebook_id}}</span>
43 43 <button id="save_notebook">Save</button>
  44 + <button id="publish_notebook">Publish</button>
44 45 </span>
45 46 <span id="kernel_status">Idle</span>
46 47 </div>

0 comments on commit 567f1c3

Please sign in to comment.
Something went wrong with that request. Please try again.