Skip to content

Commit 428e00b

Browse files
echarlesjtpioRRosio
authored
Add show_banner trait to control the banner display (#6808)
Co-authored-by: Jeremy Tuloup <[email protected]> Co-authored-by: Rosio <[email protected]>
1 parent 6fdc8d3 commit 428e00b

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

docs/source/frontend_config.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,11 @@ taking various value depending on the page where the configuration is issued.
8989
``<section>`` can take various values like ``notebook``, ``tree``, and
9090
``editor``. A ``common`` section contains configuration settings shared by all
9191
pages.
92+
93+
Persisting configuration settings
94+
---------------------------------
95+
96+
A banner might be shown to users to inform them about news or updates. This
97+
banner can be hidden launching the server with the show_banner trait.::
98+
99+
jupyter notebook --NotebookApp.show_banner=False

notebook/base/handlers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ def default_url(self):
244244
def ws_url(self):
245245
return self.settings.get('websocket_url', '')
246246

247+
@property
248+
def show_banner(self):
249+
return self.settings.get('show_banner', True)
250+
247251
@property
248252
def contents_js_source(self):
249253
self.log.debug("Using contents: %s", self.settings.get('contents_js_source',
@@ -530,6 +534,7 @@ def template_namespace(self):
530534
xsrf_token=self.xsrf_token.decode('utf8'),
531535
nbjs_translations=json.dumps(combine_translations(
532536
self.request.headers.get('Accept-Language', ''))),
537+
show_banner=self.show_banner,
533538
**self.jinja_template_vars
534539
)
535540

notebook/notebookapp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ def init_settings(self, jupyter_app, kernel_manager, contents_manager,
278278
},
279279
version_hash=version_hash,
280280
ignore_minified_js=jupyter_app.ignore_minified_js,
281+
show_banner=jupyter_app.show_banner,
281282

282283
# rate limits
283284
iopub_msg_rate_limit=jupyter_app.iopub_msg_rate_limit,
@@ -1171,6 +1172,12 @@ def _default_allow_remote(self):
11711172
"""
11721173
)
11731174

1175+
show_banner = Bool(True, config=True,
1176+
help="""Whether the banner is displayed on the page.
1177+
1178+
By default, the banner is displayed.
1179+
""")
1180+
11741181
open_browser = Bool(True, config=True,
11751182
help="""Whether to open in a browser after starting.
11761183
The specific browser used is platform dependent and

notebook/templates/page.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136

137137
<div id="header" role="navigation" aria-label="{% trans %}Top Menu{% endtrans %}">
138138
<div id="newsId" style="display: none">
139+
{% if show_banner %}
139140
<div class="alert alert-info" role="alert">
140141
<div style="display: flex">
141142
<div>
@@ -153,6 +154,7 @@
153154
</div>
154155
</div>
155156
</div>
157+
{% endif %}
156158
</div>
157159
<div id="header-container" class="container">
158160
<div id="ipython_notebook" class="nav navbar-brand"><a href="{{default_url}}

0 commit comments

Comments
 (0)