Merge pull request #7327 from minrk/kernel-links

move Python-specific help links to kernel_info
pull/37/head
Matthias Bussonnier 12 years ago
commit 214195ce5f

@ -76,7 +76,7 @@ define([
notebook_path
) + "?download=" + download.toString();
var w = window.open()
var w = window.open();
if (this.notebook.dirty) {
this.notebook.save_notebook().then(function() {
w.location = url;
@ -332,6 +332,7 @@ define([
this.events.on('kernel_ready.Kernel', function(event, data) {
var langinfo = data.kernel.info_reply.language_info || {};
that.update_nbconvert_script(langinfo);
that.add_kernel_help_links(data.kernel.info_reply.help_links || []);
});
};
@ -374,11 +375,49 @@ define([
var that = this;
// Set menu entry text to e.g. "Python (.py)"
var langname = (langinfo.name || 'Script')
langname = langname.charAt(0).toUpperCase()+langname.substr(1) // Capitalise
var langname = (langinfo.name || 'Script');
langname = langname.charAt(0).toUpperCase()+langname.substr(1); // Capitalise
el.find('a').text(langname + ' ('+(langinfo.file_extension || 'txt')+')');
};
MenuBar.prototype.add_kernel_help_links = function(help_links) {
/** add links from kernel_info to the help menu */
var divider = $("#kernel-help-links");
if (divider.length === 0) {
// insert kernel help section above about link
var about = $("#notebook_about").parent();
divider = $("<li>")
.attr('id', "kernel-help-links")
.addClass('divider');
about.prev().before(divider);
}
// remove previous entries
while (!divider.next().hasClass('divider')) {
divider.next().remove();
}
if (help_links.length === 0) {
// no help links, remove the divider
divider.remove();
return;
}
var cursor = divider;
help_links.map(function (link) {
cursor.after($("<li>")
.append($("<a>")
.attr('target', '_blank')
.attr('title', 'Opens in a new window')
.attr('href', link.url)
.text(link.text)
.append($("<i>")
.addClass("fa fa-external-link menu-icon pull-right")
)
)
);
cursor = cursor.next();
});
};
// Backwards compatability.
IPython.MenuBar = MenuBar;

@ -246,17 +246,9 @@ class="notebook_app"
{% set
sections = (
(
("http://ipython.org/documentation.html","IPython Help",True),
("http://nbviewer.ipython.org/github/ipython/ipython/tree/2.x/examples/Index.ipynb", "Notebook Help", True),
),(
("http://docs.python.org","Python",True),
("http://nbviewer.ipython.org/github/ipython/ipython/blob/2.x/examples/Index.ipynb", "Notebook Help", True),
("http://help.github.com/articles/github-flavored-markdown","Markdown",True),
("http://docs.scipy.org/doc/numpy/reference/","NumPy",True),
("http://docs.scipy.org/doc/scipy/reference/","SciPy",True),
("http://matplotlib.org/contents.html","Matplotlib",True),
("http://docs.sympy.org/latest/index.html","SymPy",True),
("http://pandas.pydata.org/pandas-docs/stable/","pandas", True)
)
),
)
%}

Loading…
Cancel
Save