mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-09 03:50:45 +08:00
Cli --retro-logo to enable the retro inline logo
This commit is contained in:
parent
bd983920ee
commit
7e0244162b
@ -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<void> = {
|
||||
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',
|
||||
|
@ -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
|
||||
});
|
||||
|
39
packages/ui-components/style/icons/retrolabInline.svg
Normal file
39
packages/ui-components/style/icons/retrolabInline.svg
Normal file
@ -0,0 +1,39 @@
|
||||
<svg width="4240.5" height="879.73" version="1.1" viewBox="0 0 1122 232.76" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<linearGradient id="linearGradient11104-2" x1="-276.78" x2="-276.78" y1="181.02" y2="208.49" gradientTransform="matrix(2.3947 0 0 2.3947 444.54 -117.45)" gradientUnits="userSpaceOnUse" xlink:href="#linearGradient4992"/>
|
||||
<linearGradient id="linearGradient4992">
|
||||
<stop stop-color="#faf327" offset="0"/>
|
||||
<stop stop-color="#fa2c8d" offset="1"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="linearGradient22598" x1="-143.43" x2="-143.43" y1="645.46" y2="751.2" gradientTransform="matrix(8.122 0 0 8.122 2145 -4828.8)" gradientUnits="userSpaceOnUse" xlink:href="#linearGradient4992"/>
|
||||
<linearGradient id="linearGradient22600" x1="-33.991" x2="-25.952" y1="344.73" y2="362.6" gradientTransform="translate(18.881 -401.29)" gradientUnits="userSpaceOnUse" xlink:href="#linearGradient19205"/>
|
||||
<linearGradient id="linearGradient19205">
|
||||
<stop stop-color="#f95" offset="0"/>
|
||||
<stop stop-color="#fff" stop-opacity="0" offset="1"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="linearGradient22602" x1="-33.991" x2="-25.952" y1="344.73" y2="362.6" gradientTransform="matrix(.49643 0 0 .49643 -126.98 -208.56)" gradientUnits="userSpaceOnUse" xlink:href="#linearGradient19205"/>
|
||||
<linearGradient id="linearGradient22604" x1="-33.991" x2="-25.952" y1="344.73" y2="362.6" gradientTransform="matrix(.64523 0 0 .64523 -113.31 -194.34)" gradientUnits="userSpaceOnUse" xlink:href="#linearGradient19205"/>
|
||||
</defs>
|
||||
<g transform="translate(838.25 -264.07)">
|
||||
<g transform="translate(0 44.183)">
|
||||
<g transform="matrix(2.1489 0 0 2.1489 -512.88 360.65)" stroke-width=".73932">
|
||||
<path transform="matrix(.12312 0 0 .12312 -205.52 -110.84)" d="m995.89 373.2a434.86 434.86 0 0 0-434.86 434.86 434.86 434.86 0 0 0 0.48047 20.422h868.77a434.86 434.86 0 0 0 0.4805-20.422 434.86 434.86 0 0 0-434.86-434.86zm-426.51 519.71a434.86 434.86 0 0 0 8.8066 36.123h835.4a434.86 434.86 0 0 0 8.8066-36.123zm33.141 100.54a434.86 434.86 0 0 0 17.799 33.828h751.13a434.86 434.86 0 0 0 17.801-33.828zm45.984 76.205a434.86 434.86 0 0 0 26.217 31.594h642.33a434.86 434.86 0 0 0 26.219-31.594zm69.4 72.82a434.86 434.86 0 0 0 34.543 25.926h486.88a434.86 434.86 0 0 0 34.545-25.926zm124.95 72.633a434.86 434.86 0 0 0 153.04 27.82 434.86 434.86 0 0 0 153.04-27.82z" fill="url(#linearGradient22598)" style="mix-blend-mode:normal"/>
|
||||
<g>
|
||||
<circle cx="-17.476" cy="-50.398" r="11.615" fill="url(#linearGradient22600)" style="mix-blend-mode:normal"/>
|
||||
<circle cx="-145.03" cy="-34.367" r="5.7663" fill="url(#linearGradient22602)" style="mix-blend-mode:normal"/>
|
||||
<circle cx="-136.77" cy="32.057" r="7.4946" fill="url(#linearGradient22604)" style="mix-blend-mode:normal"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(1.5533 0 0 1.5533 132.2 -206.08)" fill="url(#linearGradient11104-2)" stroke-width=".2858" aria-label="RETROLAB">
|
||||
<path d="m-397.29 345.41q5.7466 0 8.6857-2.6759 2.983-2.6759 2.983-7.8522 0-3.2462-2.0618-4.7376-2.0179-1.5354-6.4046-1.5354h-6.9749l-3.3339 16.801zm-9.3437 11.669-4.8692 24.785h-16.889l12.765-65.494h24.96q10.791 0 16.362 4.0358 5.5711 4.0358 5.5711 11.888 0 7.9399-4.3867 13.072-4.3867 5.1324-11.888 5.8782 3.4216 0.70187 5.7027 3.5094 2.2811 2.7636 3.9919 8.5102l5.5711 18.6h-16.801l-4.9131-16.275q-1.4915-4.8692-3.641-6.6678-2.1056-1.8424-6.1414-1.8424z"/>
|
||||
<path d="m-346.45 316.37h45.534l-2.5004 12.765h-28.645l-2.3688 12.195h26.978l-2.5443 12.765h-26.934l-2.8952 15.003h29.566l-2.4127 12.765h-46.543z"/>
|
||||
<path d="m-292.89 316.37h60.361l-2.5004 12.765h-21.758l-10.265 52.728h-16.889l10.265-52.728h-21.758z"/>
|
||||
<path d="m-205.46 345.41q5.7466 0 8.6857-2.6759 2.983-2.6759 2.983-7.8522 0-3.2462-2.0618-4.7376-2.0179-1.5354-6.4046-1.5354h-6.9749l-3.3339 16.801zm-9.3437 11.669-4.8692 24.785h-16.889l12.765-65.494h24.96q10.791 0 16.362 4.0358 5.5711 4.0358 5.5711 11.888 0 7.9399-4.3867 13.072-4.3867 5.1324-11.888 5.8782 3.4216 0.70187 5.7027 3.5094 2.2811 2.7636 3.9919 8.5102l5.5711 18.6h-16.801l-4.9131-16.275q-1.4915-4.8692-3.641-6.6678-2.1056-1.8424-6.1414-1.8424z"/>
|
||||
<path d="m-114 343.22q0-7.7206-3.5094-11.756-3.4655-4.0358-10.089-4.0358-8.7734 0-14.739 7.8961-5.9221 7.8522-5.9221 19.696 0 7.5451 3.4655 11.713t9.6508 4.1674q5.0447 0 8.9489-2.1056 3.948-2.1495 6.7117-6.3169 2.632-3.9919 4.0358-8.9928 1.4476-5.0008 1.4476-10.265zm-11.142-28.031q13.072 0 21.012 7.2819 7.9838 7.2381 7.9838 18.951 0 7.9838-2.4566 15.09-2.4127 7.1065-7.0626 12.765-5.7027 6.9749-13.511 10.44-7.7645 3.4216-17.942 3.4216-13.029 0-20.968-7.2381-7.9399-7.2381-7.9399-18.994 0-8.0277 2.4127-15.134t7.1065-12.809q5.615-6.931 13.379-10.353 7.8083-3.4216 17.986-3.4216z"/>
|
||||
<path d="m-78.244 316.37h16.889l-10.265 52.728h29.566l-2.4127 12.765h-46.543z"/>
|
||||
<path d="m8.4808 369.93h-26.145l-6.4923 11.932h-17.328l37.024-65.494h19.302l11.581 65.494h-16.055zm-19.784-11.888h17.591l-3.948-25.224z"/>
|
||||
<path d="m69.807 341.73q4.5183 0 7.0626-2.2811t2.5443-6.273q0-2.5882-1.7986-3.948-1.7547-1.3599-5.0886-1.3599h-9.4314l-2.7198 13.862zm-5.0008 28.645q5.7905 0 8.905-2.7636 3.1146-2.7636 3.1146-7.9399 0-3.29-2.1495-4.8692-2.1495-1.5792-6.5801-1.5792h-9.9578l-3.3339 17.152zm20.003-23.557q4.299 1.2283 6.6239 4.5183 2.3688 3.2462 2.3688 8.0716 0 10.572-7.8961 16.538-7.8522 5.9221-22.109 5.9221h-28.031l12.765-65.494h25.311q11.669 0 17.24 3.4216 5.615 3.4216 5.615 10.572 0 6.0098-3.29 10.572-3.29 4.5183-8.5979 5.8782z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 5.4 KiB |
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user