Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add show_banner trait to control the banner display #243

Merged
merged 2 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ dependencies:
- sphinxcontrib_github_alt
- ipython_genutils
- jupyter_server>=1.8
- notebook_shim>=0.1.0
- notebook_shim>=0.2.3
9 changes: 9 additions & 0 deletions docs/source/frontend_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,12 @@ taking various value depending on the page where the configuration is issued.
``<section>`` can take various values like ``notebook``, ``tree``, and
``editor``. A ``common`` section contains configuration settings shared by all
pages.


Persisting configuration settings
---------------------------------

A banner might be shown to users to inform them about news or updates. This
banner can be hidden launching the server with the show_banner trait.::

jupyter notebook --NotebookApp.show_banner=False
8 changes: 8 additions & 0 deletions nbclassic/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ class NotebookApp(

default_url = Unicode("%s/tree" % nbclassic_path()).tag(config=True)

show_banner = Bool(
True,
help="""Whether the banner is displayed on the page.
By default, the banner is displayed.
"""
).tag(config=True)

# Override the default open_Browser trait in ExtensionApp,
# setting it to True.
open_browser = Bool(
Expand Down Expand Up @@ -184,6 +191,7 @@ def _prepare_templates(self):
base_dir, 'nbclassic/i18n'), fallback=True)
self.jinja2_env.install_gettext_translations(nbui, newstyle=False)
self.jinja2_env.globals.update(nbclassic_path=nbclassic_path)
self.jinja2_env.globals.update(show_banner=self.show_banner)

def _link_jupyter_server_extension(self, serverapp):
# Monkey-patch Jupyter Server's and nbclassic's static path list to include
Expand Down
2 changes: 1 addition & 1 deletion nbclassic/static/base/js/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ define(function(){
// tree
jglobal('SessionList','tree/js/sessionlist');

Jupyter.version = "0.5.5";
Jupyter.version = "0.6.0.dev0";
Jupyter._target = '_blank';

return Jupyter;
Expand Down
2 changes: 2 additions & 0 deletions nbclassic/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@

<div id="header" role="navigation" aria-label="{% trans %}Top Menu{% endtrans %}">
<div id="newsId" style="display: none">
{% if show_banner %}
<div class="alert alert-info" role="alert">
<div style="display: flex">
<div>
Expand All @@ -155,6 +156,7 @@
</div>
</div>
</div>
{% endif %}
</div>
<div id="header-container" class="container">
<div id="ipython_notebook" class="nav navbar-brand"><a href="
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ install_requires =
ipython_genutils
jupyter_server>=1.8
nbformat
notebook_shim>=0.1.0
notebook_shim>=0.2.3
nbconvert>=5
nest-asyncio>=1.5
ipykernel # bless IPython kernel for now
Expand Down