Implement static publishing of HTML notebook.

pull/37/head
Stefan van der Walt 15 years ago
parent 70cf4b80ba
commit 201999642f

@ -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;

@ -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');
};

@ -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>

Loading…
Cancel
Save