Skip to content

Commit 463a08c

Browse files
committed
mention change in favicon location
1 parent 9d4354d commit 463a08c

File tree

1 file changed

+67
-2
lines changed

1 file changed

+67
-2
lines changed

docs/source/developers/extensions.rst

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,14 @@ Migrating an extension to use Jupyter Server
408408

409409
If you're a developer of a `classic Notebook Server`_ extension, your extension should be able to work with *both* the classic notebook server and ``jupyter_server``.
410410

411-
There are two key steps to make this happen:
411+
There are a few key steps to make this happen:
412412

413413
1. Point Jupyter Server to the ``load_jupyter_server_extension`` function with a new reference name.
414414
The ``load_jupyter_server_extension`` function was the key to loading a server extension in the classic Notebook Server. Jupyter Server expects the name of this function to be prefixed with an underscore—i.e. ``_load_jupyter_server_extension``. You can easily achieve this by adding a reference to the old function name with the new name in the same module.
415415

416416
.. code-block:: python
417417
418-
def load_jupyter_server_extension(nbapp):
418+
def load_jupyter_server_extension(nb_server_app):
419419
...
420420
421421
# Reference the old function name with the new function name.
@@ -475,7 +475,72 @@ There are two key steps to make this happen:
475475
476476
)
477477
478+
3. (Optional) Point extension at the new favicon location.
479+
The favicons in the Jupyter Notebook have been moved to a new location in Jupyter Server. If your extension is using one of these icons, you'll want to add a set of redirect handlers this. (In ``ExtensionApp``, this is handled automatically).
478480

481+
This usually means adding a chunk to your ``load_jupyter_server_extension`` function similar to this:
482+
483+
.. code-block:: python
484+
485+
def load_jupyter_server_extension(nb_server_app):
486+
487+
web_app = nb_server_app.web_app
488+
host_pattern = '.*$'
489+
base_url = web_app.settings['base_url']
490+
491+
# Add custom extensions handler.
492+
custom_handlers = [
493+
...
494+
]
495+
496+
# Favicon redirects.
497+
favicon_redirects = [
498+
(
499+
url_path_join(base_url, "/static/favicons/favicon.ico"),
500+
RedirectHandler,
501+
{"url": url_path_join(serverapp.base_url, "static/base/images/favicon.ico")
502+
),
503+
(
504+
url_path_join(base_url, "/static/favicons/favicon-busy-1.ico"),
505+
RedirectHandler,
506+
{"url": url_path_join(serverapp.base_url, "static/base/images/favicon-busy-1.ico")}
507+
),
508+
(
509+
url_path_join(base_url, "/static/favicons/favicon-busy-2.ico"),
510+
RedirectHandler,
511+
{"url": url_path_join(serverapp.base_url, "static/base/images/favicon-busy-2.ico")}
512+
),
513+
(
514+
url_path_join(base_url, "/static/favicons/favicon-busy-3.ico"),
515+
RedirectHandler,
516+
{"url": url_path_join(serverapp.base_url, "static/base/images/favicon-busy-3.ico")}
517+
),
518+
(
519+
url_path_join(base_url, "/static/favicons/favicon-file.ico"),
520+
RedirectHandler,
521+
{"url": url_path_join(serverapp.base_url, "static/base/images/favicon-file.ico")}
522+
),
523+
(
524+
url_path_join(base_url, "/static/favicons/favicon-notebook.ico"),
525+
RedirectHandler,
526+
{"url": url_path_join(serverapp.base_url, "static/base/images/favicon-notebook.ico")}
527+
),
528+
(
529+
url_path_join(base_url, "/static/favicons/favicon-terminal.ico"),
530+
RedirectHandler,
531+
{"url": url_path_join(serverapp.base_url, "static/base/images/favicon-terminal.ico")}
532+
),
533+
(
534+
url_path_join(base_url, "/static/logo/logo.png"),
535+
RedirectHandler,
536+
{"url": url_path_join(serverapp.base_url, "static/base/images/logo.png")}
537+
),
538+
]
539+
540+
web_app.add_handlers(
541+
host_pattern,
542+
custom_handlers + favicon_redirects
543+
)
479544
480545
481546
.. _`classic Notebook Server`: https://jupyter-notebook.readthedocs.io/en/stable/extending/handlers.html

0 commit comments

Comments
 (0)