From 1b31a374974b87e3721b00886bbd28f85730ae09 Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Tue, 4 Oct 2022 13:31:45 +0200 Subject: [PATCH] fix: display the correct about box if jupyter notebook command is used to start the server --- nbclassic/static/base/js/namespace.js | 2 +- nbclassic/static/notebook/js/about.js | 48 +++++++++++++++++++-------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/nbclassic/static/base/js/namespace.js b/nbclassic/static/base/js/namespace.js index 5ebc0b889..7ee899278 100644 --- a/nbclassic/static/base/js/namespace.js +++ b/nbclassic/static/base/js/namespace.js @@ -73,7 +73,7 @@ define(function(){ // tree jglobal('SessionList','tree/js/sessionlist'); - Jupyter.version = "0.4.4"; + Jupyter.version = "0.5.0.dev0"; Jupyter._target = '_blank'; return Jupyter; diff --git a/nbclassic/static/notebook/js/about.js b/nbclassic/static/notebook/js/about.js index 88936e9b2..acbabbe0c 100644 --- a/nbclassic/static/notebook/js/about.js +++ b/nbclassic/static/notebook/js/about.js @@ -9,17 +9,31 @@ requirejs([ ], function ($, dialog, i18n, _, IPython) { 'use strict'; $('#notebook_about').click(function () { + // The baseUrlPrefix is only injected in the document by nbclassic. + const is_nbclassic = document.baseUrlPrefix !== undefined; // use underscore template to auto html escape if (sys_info) { - var text = i18n.msg._('You are using Jupyter NbClassic.'); - text = text + '

'; - text = text + i18n.msg._('The version of the Jupyter server is: '); - text = text + _.template('<%- version %>')({ version: sys_info.jupyter_server_version }); - if (sys_info.commit_hash) { - text = text + _.template('-<%- hash %>')({ hash: sys_info.commit_hash }); + var text = ''; + if (is_nbclassic) { + text = text + i18n.msg._('You are using Jupyter NbClassic.'); + text = text + '

'; + text = text + i18n.msg._('The version of the Jupyter server is: '); + text = text + _.template('<%- version %>')({ version: sys_info.jupyter_server_version }); + if (sys_info.commit_hash) { + text = text + _.template('-<%- hash %>')({ hash: sys_info.commit_hash }); + } + text = text + '
'; + text = text + 'To get the version of nbclassic, run in a terminal: jupyter nbclassic --version'; + } + else { + text = text + i18n.msg._('You are using Jupyter Notebook.'); + text = text + '

'; + text = text + i18n.msg._('The version of the notebook server is: '); + text = text + _.template('<%- version %>')({ version: sys_info.notebook_version }); + if (sys_info.commit_hash) { + text = text + _.template('-<%- hash %>')({ hash: sys_info.commit_hash }); + } } - text = text + '
'; - text = text + 'To get the version of nbclassic, run in a terminal: jupyter nbclassic --version'; text = text + '
'; text = text + i18n.msg._('The server is running on this version of Python:'); text = text + _.template('
Python <%- pyver %>
')({ @@ -36,11 +50,19 @@ requirejs([ body.append($('

').text(i18n.msg._('Cannot find sys_info!'))); body.append($('

').html(text)); } - dialog.modal({ - title: i18n.msg._('About Jupyter NbClassic'), - body: body, - buttons: { 'OK': {} } - }); + if (is_nbclassic) { + dialog.modal({ + title: i18n.msg._('About Jupyter NbClassic'), + body: body, + buttons: { 'OK': {} } + }); + } else { + dialog.modal({ + title: i18n.msg._('About Jupyter Notebook'), + body: body, + buttons: { 'OK': {} } + }); + } try { IPython.notebook.session.kernel.kernel_info(function (data) { kinfo.html($('

').text(data.content.banner));