From 7e0244162bf6fcd4cf8f5e3d35946742560eddac Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Wed, 26 May 2021 11:07:37 +0200 Subject: [PATCH] Cli --retro-logo to enable the retro inline logo --- packages/application-extension/src/index.ts | 7 +++- .../ui-components/src/icon/iconimports.ts | 7 ++++ .../style/icons/retrolabInline.svg | 39 +++++++++++++++++++ retrolab/app.py | 24 +++++++++--- 4 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 packages/ui-components/style/icons/retrolabInline.svg diff --git a/packages/application-extension/src/index.ts b/packages/application-extension/src/index.ts index 55a9cbb20..2f52b1fe4 100644 --- a/packages/application-extension/src/index.ts +++ b/packages/application-extension/src/index.ts @@ -27,7 +27,7 @@ import { ITranslator, TranslationManager } from '@jupyterlab/translation'; import { RetroApp, RetroShell, IRetroShell } from '@retrolab/application'; -import { jupyterIcon } from '@retrolab/ui-components'; +import { jupyterIcon, retroInlineIcon } from '@retrolab/ui-components'; import { Widget } from '@lumino/widgets'; @@ -84,7 +84,10 @@ const logo: JupyterFrontEndPlugin = { node.target = '_blank'; node.rel = 'noopener noreferrer'; const logo = new Widget({ node }); - jupyterIcon.element({ + + const retroLogo = PageConfig.getOption('retroLogo') === 'true'; + const icon = retroLogo ? retroInlineIcon : jupyterIcon; + icon.element({ container: node, elementPosition: 'center', padding: '2px 2px 2px 8px', diff --git a/packages/ui-components/src/icon/iconimports.ts b/packages/ui-components/src/icon/iconimports.ts index 259a03910..9c6b84540 100644 --- a/packages/ui-components/src/icon/iconimports.ts +++ b/packages/ui-components/src/icon/iconimports.ts @@ -9,6 +9,8 @@ import jupyterSvgstr from '../../style/icons/jupyter.svg'; import retroSvgstr from '../../style/icons/retrolab.svg'; +import retroInlineSvgstr from '../../style/icons/retrolabInline.svg'; + export const jupyterIcon = new LabIcon({ name: 'retro-ui-components:jupyter', svgstr: jupyterSvgstr @@ -18,3 +20,8 @@ export const retroIcon = new LabIcon({ name: 'retro-ui-components:retrolab', svgstr: retroSvgstr }); + +export const retroInlineIcon = new LabIcon({ + name: 'retro-ui-components:retrolabInline', + svgstr: retroInlineSvgstr +}); diff --git a/packages/ui-components/style/icons/retrolabInline.svg b/packages/ui-components/style/icons/retrolabInline.svg new file mode 100644 index 000000000..77b793ec6 --- /dev/null +++ b/packages/ui-components/style/icons/retrolabInline.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/retrolab/app.py b/retrolab/app.py index 154bfd4a7..f17601bc5 100644 --- a/retrolab/app.py +++ b/retrolab/app.py @@ -1,7 +1,8 @@ import os from os.path import join as pjoin -from jupyter_core.application import base_aliases, base_flags +from jupyter_core.application import base_aliases +from jupyter_server.serverapp import flags from jupyter_server.base.handlers import JupyterHandler from jupyter_server.extension.handler import ( ExtensionHandlerMixin, @@ -33,11 +34,12 @@ class RetroHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHan page_config = { "appVersion": version, "baseUrl": self.base_url, - "terminalsAvailable": self.settings.get('terminals_available', False), + "terminalsAvailable": self.settings.get("terminals_available", False), "token": self.settings["token"], "fullStaticUrl": ujoin(self.base_url, "static", self.name), "frontendUrl": ujoin(self.base_url, "retro/"), "collaborative": app.collaborative, + "retroLogo": app.retro_logo, } mathjax_config = self.settings.get("mathjax_config", "TeX-AMS_HTML-full,Safe") @@ -103,6 +105,12 @@ class RetroNotebookHandler(RetroHandler): return self.write(tpl) +aliases = dict(base_aliases) +aliases.update({ + "retro-logo": "RetroApp.retro_logo" +}) + + class RetroApp(NBClassicConfigShimMixin, LabServerApp): name = "retro" app_name = "RetroLab" @@ -122,20 +130,26 @@ class RetroApp(NBClassicConfigShimMixin, LabServerApp): collaborative = Bool( False, config=True, help="Whether to enable collaborative mode." ) + retro_logo = Bool( + False, config=True, help="Whether to use the RetroLab inline logo." + ) - aliases = dict(base_aliases) - flags = dict(base_flags) + flags = flags flags["collaborative"] = ( {"RetroApp": {"collaborative": True}}, "Whether to enable collaborative mode.", ) + flags["retro-logo"] = ( + {"RetroApp": {"retro_logo": True}}, + "Whether to use the RetroLab inline logo", + ) def initialize_handlers(self): self.handlers.append( ( rf"/{self.file_url_prefix}/((?!.*\.ipynb($|\?)).*)", web.RedirectHandler, - {"url": "/retro/edit/{0}"} + {"url": "/retro/edit/{0}"}, ) ) self.handlers.append(("/retro/tree(.*)", RetroTreeHandler))