diff --git a/docs/source/examples/Notebook/header.md b/docs/source/examples/Notebook/header.md new file mode 100644 index 0000000000..532919d1fe --- /dev/null +++ b/docs/source/examples/Notebook/header.md @@ -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/) diff --git a/notebook/static/tree/js/notebooklist.js b/notebook/static/tree/js/notebooklist.js index 010a95a569..eefc9992ef 100644 --- a/notebook/static/tree/js/notebooklist.js +++ b/notebook/static/tree/js/notebooklist.js @@ -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($('
').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