mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Merge pull request #4043 from reece/4029-header-and-footer
closes #4029: implement optional markdown header and footer files
This commit is contained in:
commit
9fa644bbe4
4
docs/source/examples/Notebook/header.md
Normal file
4
docs/source/examples/Notebook/header.md
Normal file
@ -0,0 +1,4 @@
|
||||
# Notebook Examples
|
||||
|
||||
The pages in this section are all converted notebook files. You can also
|
||||
[view these notebooks on nbviewer](http://nbviewer.jupyter.org/github/jupyter/notebook/blob/master/)
|
@ -10,8 +10,9 @@ define([
|
||||
'base/js/events',
|
||||
'base/js/keyboard',
|
||||
'moment',
|
||||
'bidi/bidi'
|
||||
], function($, IPython, utils, i18n, dialog, events, keyboard, moment, bidi) {
|
||||
'bidi/bidi',
|
||||
'components/marked/lib/marked'
|
||||
], function($, IPython, utils, i18n, dialog, events, keyboard, moment, bidi, marked) {
|
||||
"use strict";
|
||||
|
||||
var extension = function(path){
|
||||
@ -509,6 +510,7 @@ define([
|
||||
console.log('Error adding link: ' + err);
|
||||
}
|
||||
}
|
||||
this.add_header_footer(list)
|
||||
// Trigger an event when we've finished drawing the notebook list.
|
||||
events.trigger('draw_notebook_list.NotebookList');
|
||||
|
||||
@ -528,6 +530,35 @@ define([
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Adds header and/or footer
|
||||
* @param {Array} list - list of folder contents
|
||||
*/
|
||||
NotebookList.prototype.add_header_footer = function (list) {
|
||||
var that = this;
|
||||
function create_markdown_row(index, list_item) {
|
||||
var item = that.new_item(index);
|
||||
var span12 = item.children().first();
|
||||
span12.empty();
|
||||
that.contents.get(list_item.path, {"content": true}).then(
|
||||
function (data) {
|
||||
span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').innerHTML = marked(data.content));
|
||||
},
|
||||
function(error) {
|
||||
span12.append(i18n.msg._("Server error: ") + error.message);
|
||||
});
|
||||
};
|
||||
var f = list.content.find(function (el) {return el.name == "header.md"})
|
||||
if (f !== undefined) {
|
||||
create_markdown_row(0, f)
|
||||
}
|
||||
var f = list.content.find(function (el) {return el.name == "footer.md"})
|
||||
if (f !== undefined) {
|
||||
create_markdown_row(-1, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new item.
|
||||
* @param {integer} index
|
||||
|
Loading…
Reference in New Issue
Block a user