Skip to content
Browse files

Implement static publishing of HTML notebook.

  • Loading branch information...
1 parent 18ad520 commit 567f1c3bde4b331b312f91322b881c89464c5049 @stefanv stefanv committed Aug 16, 2011
View
17 IPython/frontend/html/notebook/static/js/notebook.js
@@ -762,6 +762,23 @@ var IPython = (function (IPython) {
};
};
+ Notebook.prototype.publish_notebook = function () {
+ var w = window.open('', '_blank', 'scrollbars=1,menubar=1');
+ var html = '<html><head>' +
+ $('head').clone().html() +
+ '<style type="text/css">' +
+ '@media print { body { overflow: visible !important; } }' +
+ '</style>' +
+ '</head><body style="overflow: auto;">' +
+ $('#notebook').clone().html() +
+ '</body></html>';
+
+ w.document.open();
+ w.document.write(html);
+ w.document.close();
+
+ return false;
+ };
Notebook.prototype.notebook_saved = function (data, status, xhr) {
this.dirty = false;
View
24 IPython/frontend/html/notebook/static/js/savewidget.js
@@ -21,6 +21,7 @@ var IPython = (function (IPython) {
SaveWidget.prototype.style = function () {
this.element.find('input#notebook_name').addClass('ui-widget ui-widget-content');
this.element.find('button#save_notebook').button();
+ this.element.find('button#publish_notebook').button();
var left_panel_width = $('div#left_panel').outerWidth();
var left_panel_splitter_width = $('div#left_panel_splitter').outerWidth();
$('span#save_widget').css({marginLeft:left_panel_width+left_panel_splitter_width});
@@ -33,6 +34,10 @@ var IPython = (function (IPython) {
IPython.notebook.save_notebook();
that.set_document_title();
});
+
+ this.element.find('button#publish_notebook').click(function () {
+ IPython.notebook.publish_notebook();
+ });
};
@@ -84,20 +89,23 @@ var IPython = (function (IPython) {
SaveWidget.prototype.status_save = function () {
- this.element.find('span.ui-button-text').text('Save');
- this.element.find('button#save_notebook').button('enable');
- };
+ $('button#save_notebook').button('option', 'label', 'Save');
+ $('button#save_notebook').button('enable');
+ $('button#publish_notebook').button('enable');
+ };
SaveWidget.prototype.status_saving = function () {
- this.element.find('span.ui-button-text').text('Saving');
- this.element.find('button#save_notebook').button('disable');
- };
+ $('button#save_notebook').button('option', 'label', 'Saving');
+ $('button#save_notebook').button('disable');
+ $('button#publish_notebook').button('disable');
+ };
SaveWidget.prototype.status_loading = function () {
- this.element.find('span.ui-button-text').text('Loading');
- this.element.find('button#save_notebook').button('disable');
+ $('button#save_notebook').button('option', 'label', 'Loading');
+ $('button#save_notebook').button('disable');
+ $('button#publish_notebook').button('disable');
};
View
1 IPython/frontend/html/notebook/templates/notebook.html
@@ -41,6 +41,7 @@
<input type="text" id="notebook_name" size="20"></textarea>
<span id="notebook_id" style="display:none">{{notebook_id}}</span>
<button id="save_notebook">Save</button>
+ <button id="publish_notebook">Publish</button>
</span>
<span id="kernel_status">Idle</span>
</div>

0 comments on commit 567f1c3

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