Skip to content

Commit

Permalink
Add about dialog in Notebook Help Menu.
Browse files Browse the repository at this point in the history
This allow to get info on version of IPython when running remotely.
The about dialog also send a kernel info request and display the banner
which is useful for non-python kernel that don't match IPython version
  • Loading branch information
Carreau committed Oct 16, 2014
1 parent 5be470f commit e7c2c36
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
2 changes: 2 additions & 0 deletions IPython/html/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
app_log = logging.getLogger()

import IPython
from IPython.utils.sysinfo import get_sys_info

from IPython.config import Application
from IPython.utils.path import filefind
Expand Down Expand Up @@ -221,6 +222,7 @@ def template_namespace(self):
logged_in=self.logged_in,
login_available=self.login_available,
static_url=self.static_url,
sys_info=json.dumps(get_sys_info())
)

def get_json_body(self):
Expand Down
38 changes: 38 additions & 0 deletions IPython/html/static/notebook/js/about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
require([
'jquery',
'base/js/dialog',
'underscore',
'base/js/namespace'
], function ($, dialog, _, IPython) {
'use strict';
$('#notebook_about').click(function () {
// use underscore template to auto html escape
var text = 'You are using IPython notebook.<br/><br/>';
text = text + 'The version of the notebook server is ';
text = text + _.template('<b><%- version %></b>')({ version: sys_info.ipython_version });
if (sys_info.commit_hash) {
text = text + _.template('-<%- hash %>')({ hash: sys_info.commit_hash });
}
text = text + _.template(' and is running on:<br/><pre>Python <%- pyver %></pre>')({ pyver: sys_info.sys_version });
var kinfo = $('<div/>').attr('id', '#about-kinfo').text('Waiting for kernel to be available...');
var body = $('<div/>');
body.append($('<h4/>').text('Server Information:'));
body.append($('<p/>').html(text));
body.append($('<h4/>').text('Current Kernel Information:'));
body.append(kinfo);
dialog.modal({
title: 'About IPython Notebook',
body: body,
buttons: { 'OK': {} }
});
try {
IPython.notebook.session.kernel.kernel_info(function (data) {
kinfo.html($('<pre/>').text(data.content.banner));
});
} catch (e) {
kinfo.html($('<p/>').text('unable to contact kernel'));
}
});
});
2 changes: 2 additions & 0 deletions IPython/html/static/notebook/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require([
'notebook/js/config',
'notebook/js/kernelselector',
'codemirror/lib/codemirror',
'notebook/js/about',
// only loaded, not used, please keep sure this is loaded last
'custom/custom'
], function(
Expand All @@ -41,6 +42,7 @@ require([
config,
kernelselector,
CodeMirror,
about,
// please keep sure that even if not used, this is loaded last
custom
) {
Expand Down
8 changes: 6 additions & 2 deletions IPython/html/templates/notebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
("http://nbviewer.ipython.org/github/ipython/ipython/tree/2.x/examples/Index.ipynb", "Notebook Help", True),
),(
("http://docs.python.org","Python",True),
("http://help.github.com/articles/github-flavored-markdown","Markdown",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),
Expand All @@ -266,7 +266,8 @@
<li class="divider"></li>
{% endif %}
{% endfor %}
</li>
<li class="divider"></li>
<li title="About IPython Notebook"><a id="notebook_about" href="#">About</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -310,6 +311,9 @@

{% block script %}
{{super()}}
<script type="text/javascript">
sys_info = {{sys_info}};
</script>


<script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>
Expand Down

0 comments on commit e7c2c36

Please sign in to comment.