跳转到主要内容

Nebari JupyterHub 主题

项目描述

Nebari logo mark - text will be black in light color mode and white in dark color mode.

信息 链接
项目 License Nebari documentation PyPI package version
社区 GH discussions Open an issue Nebari documentation - Community guidelines

自定义Nebari JupyterHub模板

此存储库包含一个自定义的Nebari JupyterHub模板。此模板覆盖了https://github.com/jupyterhub/jupyterhub/tree/main/share/jupyterhub/templates中的默认JupyterHub模板。

有关JupyterHub模板及其使用方式的更多详细信息,请参阅官方JupyterHub文档

开发 👩🏻‍💻

先决条件

  • Python >= 3.8

  • 我们使用 Hatch 来开发和发布 Nebari JupyterHub 主题。

    建议您通过 pipx 安装 hatch,因为它会修改安装此环境的 Python 环境(更多详情,请参阅 Hatch 文档)。

    pipx install hatch
    
  • hatch-conda 插件。要安装

    pipx install hatch-conda
    

设置您的开发环境

  1. 在你的个人 GitHub 账户上创建 Nebari JupyterHub 主题仓库的分支

  2. 将此仓库克隆到您的本地计算机

    git clone https://github.com/<your-username>/nebari-jupyterhub-theme.git
    
  3. 从项目根目录,使用 hatch 创建一个新的开发环境

    hatch env create
    

    这将创建一个新的开发环境,其中包含所有开发所需的依赖项。它还将以开发模式安装 nebari_jupyterhub_theme。您可以通过运行以下命令来验证您的开发环境是否正确设置:

    $ hatch env show
                           Standalone
    ┏━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
    ┃ Name     Type     Dependencies             Scripts ┃
    ┡━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
    │ default  virtual                                   │
    ├─────────┼─────────┼─────────────────────────┼─────────┤
    │ dev      virtual  configurable-http-proxy  render  │
    │                   jupyterhub                       │
    │                   jupyterlab                       │
    │                   nodejs                           │
    └─────────┴─────────┴─────────────────────────┴─────────┘
    
  4. 在开发环境中初始化一个新的 shell

    hatch --env dev shell
    

    要离开环境,您可以在终端中输入 exit

  5. 为开发初始化 JupyterHub 实例

    hatch run dev:render
    

    此命令将启动 JupyterHub,其中 --config 选项指向 test_jupyterhub_config.py。您应该能够通过您的网页浏览器访问 http://127.0.0.1:8081 并看到正在运行的 JupyterHub 实例。

    Login page of a local JupyterHub instance with the Nebari JupyterHub theme - the main text reads "welcome to Nebari your open source data science platform". The subheading reads "Running in dev mode". In the middle of the page there is the JupyterHub authentication form with a "username" and "password" fields.

    注意 从这里您可以使用任何用户名和在 test_jupyterhub_config.py 中的 c.DummyAuthenticator.password 配置选项中设置的密码登录。请注意,并非所有扩展和集成都在此 dev 模式下可用。

  6. 现在您可以修改模板和 style.css 文件,而无需重新启动服务器即可看到 JupyterHub 实例中的更改。

注意c.JupyterHub.template_vars 中指定的值将覆盖在 nebari_jupyterhub_theme/templates 中设置的默认值。

此软件包的发布过程在 RELEASE.md 中进行了记录。

在您的JupyterHub实例上使用nebari_jupyterhub_theme 📦

  1. 安装 nebari_jupyterhub_theme

    pip install nebari_jupyterhub_theme
    

    注意 如果您已经有一个 JupyterHub 配置文件,您可以跳到下一步。否则,请按照 JupyterHub 文档 中的说明首先生成一个配置文件。

  2. 将以下内容添加到您的 JupyterHub 配置文件中,以获取新的 jinja2 模板目录和静态文件

    from nebari_jupyterhub_theme import theme_extra_handlers, theme_template_paths
    
    c.JupyterHub.extra_handlers = theme_extra_handlers
    
    c.JupyterHub.template_paths = theme_template_paths
    
  3. 可选 - 如果您需要进一步自定义 UI,您可以修改您的 JupyterHub 配置文件中的 template_vars,通过添加以下行到其中

    # minimal configuration example overwriting the default values in the nebari_jupyterhub_theme
    c.JupyterHub.template_vars = {
     "hub_title": "Welcome to Nebari",
     "logo": "/hub/custom/images/Nebari-logo-square.svg",
     "primary_color": "#cb39ed",
     "secondary_color": "#2bd1c5",
    

可用的配置变量有

  • hub_title:JupyterHub 实例的标题。它将在登录页面的页眉中显示。(H1 标题,默认:欢迎来到 Nebari)
  • hub_subtitle:在主实例标题下显示的副标题。(H2 标题,默认:"")
  • welcome:登录页面上的欢迎信息(默认:欢迎来到 Nebari。有关 Nebari 的更多信息,请访问 <a href="https://nebari.dev/">https://nebari.dev</a>)
  • logo:在导航栏中显示的标志(默认:Nebari 标志)
  • primary_color:主颜色(默认:#9e17b7)
  • secondary_color:辅助颜色(默认:#2bd1c5)
  • accent_color:强调颜色(默认:#eda61d)
  • text_color:文本颜色(默认:#1c1d26)
  • h1_color:H1 颜色,登录页面中的主要标题(默认:#0f1015)
  • h2_color:H2 颜色,登录页面中的副标题(默认:#0f1015)
  • navbar_text_color:导航栏链接和文本颜色(默认:#1c1d26)
  • navbar_hover_color: 导航栏链接的悬停颜色(默认:#00a3b0
  • display_version: 在页脚显示 JupyterHub 版本(默认:False)
  • keycloak_realm_name: Keycloak 域名(默认:"nebari")

注意 默认的颜色、字体和标志是基于 Nebari 品牌选择的。更多关于此信息,请参阅 Nebari 设计仓库

:computer: 您可以在 test_jupyterhub_config.py 中看到这些变量和配置的示例。

Nebari 内部选项

  • cdsdashboards_enabled: 这需要 JupyterHub 环境中存在 cdsdashboards(默认:False)
  • cdsdashboards_restricted: 这需要 JupyterHub 环境中存在 cdsdashboards(默认:False)
  • nebari_theme_extra_js_urls

架构 🏗

该仓库结构如下

nebari-nebari_jupyterhub_theme做出贡献👩‍💻

想要贡献?请查看我们的 贡献指南 以开始。

行为准则 📖

为了确保社区友好和欢迎,我们要求所有社区成员遵守我们的 行为准则

许可 📄

nebari-nebari_jupyterhub_theme 依据 BSD-3 OSI 许可证 许可。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源代码分发

nebari_jupyterhub_theme-2024.7.1.tar.gz (212.7 kB 查看散列)

源代码

构建分发

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面