Add about dialog in Notebook Help Menu.

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
pull/37/head
Matthias Bussonnier 12 years ago
parent 5be470fcaf
commit e7c2c369e0

@ -25,6 +25,7 @@ except ImportError:
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
@ -221,6 +222,7 @@ class IPythonHandler(AuthenticatedHandler):
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):

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

@ -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(
@ -41,6 +42,7 @@ require([
config,
kernelselector,
CodeMirror,
about,
// please keep sure that even if not used, this is loaded last
custom
) {

@ -245,7 +245,7 @@ class="notebook_app"
("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),
@ -266,7 +266,8 @@ class="notebook_app"
<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>
@ -310,6 +311,9 @@ class="notebook_app"
{% block script %}
{{super()}}
<script type="text/javascript">
sys_info = {{sys_info}};
</script>
<script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>

Loading…
Cancel
Save