<!DOCTYPE html>
<html lang="{{ LANG | default(value='en') }}" dir="{{ LANG_DIR | default(value='ltr') }}" data-theme="{{ theme_default_mode | default(value="light") }}" data-theme-name="{{ theme_slug | default(value="") }}" class="theme-{{ theme_slug | default(value="default") }}"{% if user_timezone %} data-user-tz-pref="{{ user_timezone }}"{% endif %}{% if tenant_default_timezone %} data-tenant-default-tz="{{ tenant_default_timezone }}"{% endif %}{% if tenant_slug %} data-tenant-slug="{{ tenant_slug }}"{% endif %}>
<head>
{# Synchronous "no-flash" block: read saved mode preference from
localStorage BEFORE first paint so the dark/light/system pick
lands before the chrome renders. Editors who switch the active
theme via the picker still get an instant repaint, but
per-visitor mode is sticky across page loads. #}
<script>
(function() {
try {
var m = localStorage.getItem('rcms-admin-mode');
if (m === 'light' || m === 'dark') {
document.documentElement.setAttribute('data-theme', m);
} else {
document.documentElement.removeAttribute('data-theme');
}
var scale = localStorage.getItem('rcms-admin-text-scale');
if (scale === 's' || scale === 'l' || scale === 'xl') {
document.documentElement.setAttribute('data-text-scale', scale);
} else {
document.documentElement.removeAttribute('data-text-scale');
}
if (localStorage.getItem('rcms-admin-high-contrast') === '1') {
document.documentElement.setAttribute('data-high-contrast', '');
} else {
document.documentElement.removeAttribute('data-high-contrast');
}
var slug = document.documentElement.getAttribute('data-tenant-slug') || '';
var collapsed = localStorage.getItem('rcms-admin-sidebar-collapsed:' + slug);
if (collapsed === '1') {
document.documentElement.setAttribute('data-sidebar-collapsed', '');
} else {
document.documentElement.removeAttribute('data-sidebar-collapsed');
}
} catch (e) { }
})();
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{{ "CMS Admin" | translate(locale=LANG) }}{% endblock %}</title>
{% include "rcms_admin/_brand_icons.html" %}
{# Fonts — Hanken Grotesk for UI + Literata for editor body
surfaces. The per-tenant `theme_font_url` (loaded second)
overrides via a different family if the theme supplies one. #}
{% if theme_font_url %}<link rel="stylesheet" href="{{ theme_font_url }}">{% endif %}
{# Bundled MD3 design system — single source of truth for all
admin chrome. Host apps override by dropping
static/cms_admin/cms.css in their project root. #}
<link rel="stylesheet" href="/cms-admin/static/fonts.css?v={{ cms_asset_version() }}">
<link rel="stylesheet" href="/cms-admin/static/cms.css?v={{ cms_asset_version() }}">
{# Active admin theme — emitted as a <style> block with CSS
custom properties on :root + [data-theme="dark"]. Generated by
theme::emit_css() against the row flagged is_admin_default.
Loaded AFTER cms.css so tenant overrides cascade over the
bundled defaults.
Defaulted to empty so handlers that don't call
`add_admin_theme` (e.g. media_upload, error renders) don't
crash the template — the MD3 chrome from cms.css is still
fully usable without the per-tenant overlay. #}
{{ theme_css | default(value="") | safe }}
{# #422 — plugin-injected global admin CSS (insert_global_admin_css). #}
{% for css in admin_css_blobs | default(value=[]) %}
<style>{{ css | safe }}</style>
{% endfor %}
{% block extra_head %}{% endblock %}
</head>
<body class="rcms-admin">
<input type="checkbox" id="__nav_toggle" hidden>
<label for="__nav_toggle" class="rcms-nav-backdrop"></label>
<aside class="rcms-sidebar">
<div class="rcms-sidebar-brand has-logo">
{# #199 — per-tenant logo. Falls back to the brand name
text when no logo is uploaded. #}
{% if branding_logo_url %}
<a href="{{ url(name='rcms-admin:dashboard') }}" class="rcms-sidebar-brand-logo" aria-label="{{ brand_name | default(value='Rustango CMS') }}">
{# Explicit height (not just max-height): a block img with
only max-height collapses to 0×0 inside the flex
`.sidebar-brand`. width:auto keeps the aspect ratio;
object-fit:contain avoids distortion if max-width clamps. #}
<img src="{{ branding_logo_url }}" alt="{{ brand_name | default(value='Rustango CMS') }}"
class="rcms-maxw-full rcms-block" style="height: 48px; width: auto; object-fit: contain;">
</a>
{% else %}
{# No tenant logo: the Rustango CMS icon, light or dark with the theme. #}
<a href="{{ url(name='rcms-admin:dashboard') }}" class="rcms-sidebar-brand-mark" aria-hidden="true" tabindex="-1">
<img src="/cms-admin/static/brand/icon-light.png?v={{ cms_asset_version() }}" alt="" class="rcms-brand-for-light" width="36" height="36">
<img src="/cms-admin/static/brand/icon-dark.png?v={{ cms_asset_version() }}" alt="" class="rcms-brand-for-dark" width="36" height="36">
</a>
<h1>{{ brand_name | default(value="Rustango CMS") }}</h1>
{% endif %}
<div class="rcms-tenant">{{ tenant_slug | default(value="") }}</div>
{# #271 — collapse / expand toggle. Sits at the top of
the sidebar (right of the brand); clicking shrinks the
sidebar to an icons-only rail
(`html[data-sidebar-collapsed]` selector) and persists
the pick per tenant in localStorage. The no-flash
<script> in <head> reads the same key before first
paint, so reloads don't flicker. #}
<button type="button"
class="rcms-sidebar-collapse-toggle"
data-sidebar-collapse-toggle
aria-label="{{ "Collapse sidebar to icons" | translate(locale=LANG) }}">
<span class="material-symbols-rounded">chevron_left</span>
</button>
</div>
{# #77 — Global search. Lives in the sidebar rather than the
topbar: search is navigation, and the topbar's three-child
layout gave it no natural home — it stranded mid-row between
the page title and the page actions. Here it also survives
the mobile breakpoint, where the topbar copy was simply
hidden. The `/` shortcut and the autocomplete dropdown are
wired by document-level selectors in cms-ux.js, so the markup
moves without touching the JS. #}
<div class="rcms-sidebar-search rcms-relative" data-search-root>
<form method="get" action="{{ url(name='rcms-admin:search') }}"
class="rcms-search-input rcms-search-input--sidebar"
title="{{ "Search… press /" | translate(locale=LANG) }}">
<span class="material-symbols-rounded sm">search</span>
<input type="search" name="q" placeholder="{{ "Search… press /" | translate(locale=LANG) }}"
data-search-input autocomplete="off">
</form>
{# Anchored inside the sidebar on purpose: `.rcms-sidebar` is
`overflow-y: auto`, so a dropdown escaping its box would be
clipped. It spans the rail width and scrolls itself. #}
<div data-search-dropdown class="rcms-sidebar-search-dropdown" style="display: none;"></div>
</div>
<nav class="rcms-sidebar-nav">
{# Sidebar gating (#33): a link renders when one of the
following is true —
1. `sidebar_gating` is false (anon flows / handlers
that don't call add_user_chrome yet),
2. the user is a superuser,
3. the resource's `<prefix>.view` codename is in the
pre-computed `allowed_resources` set.
When false, the item is omitted from the DOM entirely. #}
<div class="rcms-sidebar-section">{{ "Content" | translate(locale=LANG) }}</div>
{% if not sidebar_gating or user_is_superuser or "cms_page.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:pages:list') }}" class="rcms-sidebar-link{% if active_tab == "pages" %} active{% endif %}">
<span class="material-symbols-rounded">article</span> {{ "Pages" | translate(locale=LANG) }}
</a>
{% endif %}
{# #557 — Taxonomies (categories + custom vocabularies). #}
<a href="{{ url(name='rcms-admin:taxonomies:list') }}" class="rcms-sidebar-link{% if active_tab == "taxonomies" %} active{% endif %}">
<span class="material-symbols-rounded">category</span> {{ "Taxonomies" | translate(locale=LANG) }}
</a>
{% if not sidebar_gating or user_is_superuser or "cms_library.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:library:list') }}" class="rcms-sidebar-link{% if active_tab == "library" %} active{% endif %}">
<span class="material-symbols-rounded">library_books</span> {{ "Library" | translate(locale=LANG) }}
</a>
{# FB-03 (#536) — dedicated Forms area: its own list with per-form
submission counts (forms stay snippet-backed underneath). #}
<a href="/cms-admin/forms" class="rcms-sidebar-link{% if active_tab == "forms" %} active{% endif %}">
<span class="material-symbols-rounded">dynamic_form</span> {{ "Forms" | translate(locale=LANG) }}
</a>
{% endif %}
{% if not sidebar_gating or user_is_superuser or "cms_media.view" in allowed_resources %}
{# #272 — Media group. Wrapping "All media" + "Unused"
under a collapsible parent keeps the icon rail clean
while the variant pages remain discoverable. The
group auto-opens whenever the visitor is on either
of the two media routes. #}
{% set media_active = active_tab == "media" or active_tab == "media-unused" %}
<details class="rcms-sidebar-group{% if media_active %} active{% endif %}"
data-sidebar-group="media"
{% if media_active %}open{% endif %}>
<summary class="rcms-sidebar-link rcms-sidebar-group-summary">
<span class="material-symbols-rounded">image</span>
<span class="rcms-sidebar-group-label">{{ "Media" | translate(locale=LANG) }}</span>
<span class="material-symbols-rounded rcms-sidebar-group-chevron">expand_more</span>
</summary>
<div class="rcms-sidebar-group-items">
<a href="{{ url(name='rcms-admin:media:list') }}" class="rcms-sidebar-link{% if active_tab == "media" %} active{% endif %}">
<span class="material-symbols-rounded">photo_library</span> {{ "All media" | translate(locale=LANG) }}
</a>
<a href="{{ url(name='rcms-admin:media:unused') }}" class="rcms-sidebar-link{% if active_tab == "media-unused" %} active{% endif %}">
<span class="material-symbols-rounded">cleaning_services</span> {{ "Unused" | translate(locale=LANG) }}
</a>
</div>
</details>
{% endif %}
{% if not sidebar_gating or user_is_superuser or "cms_document.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:documents:list') }}" class="rcms-sidebar-link{% if active_tab == "documents" %} active{% endif %}">
<span class="material-symbols-rounded">description</span> {{ "Documents" | translate(locale=LANG) }}
</a>
{% endif %}
<div class="rcms-sidebar-section">{{ "Site" | translate(locale=LANG) }}</div>
{% if not sidebar_gating or user_is_superuser or "cms_redirect.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:redirects:list') }}" class="rcms-sidebar-link{% if active_tab == "redirects" %} active{% endif %}">
<span class="material-symbols-rounded">swap_horiz</span> {{ "Redirects" | translate(locale=LANG) }}
</a>
{% endif %}
{# Gated on the same codename the handler enforces, so the link
never leads somewhere the click is refused. #}
{% if not sidebar_gating or user_is_superuser or "cms_notification.manage" in allowed_resources %}
<a href="/cms-admin/notifications" class="rcms-sidebar-link{% if active_tab == "notifications" %} active{% endif %}">
<span class="material-symbols-rounded">notifications</span> {{ "Notifications" | translate(locale=LANG) }}
</a>
{% endif %}
{# Gated on the same codename the handler enforces, so the link
never leads somewhere the click is refused. #}
{% if not sidebar_gating or user_is_superuser or "cms_site.manage" in allowed_resources %}
<a href="/cms-admin/sites" class="rcms-sidebar-link{% if active_tab == "sites" %} active{% endif %}">
<span class="material-symbols-rounded">language</span> {{ "Sites" | translate(locale=LANG) }}
</a>
{% endif %}
{% if not sidebar_gating or user_is_superuser or "cms_navigation_menu.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:navigation:list') }}" class="rcms-sidebar-link{% if active_tab == "navigation" %} active{% endif %}">
<span class="material-symbols-rounded">menu</span> {{ "Navigation" | translate(locale=LANG) }}
</a>
{% endif %}
{# #272 — Reports group. Native <details> handles the
collapse/expand; the small JS hook in cms-ux.js
mirrors open/closed state into a per-tenant
localStorage key so the pick survives reloads. The
`open` attribute is set server-side whenever any of
the report tabs is the current page, so visitors
land on the report without having to expand the
group. #}
{% if not sidebar_gating or user_is_superuser or "cms_history.view" in allowed_resources %}
{% set reports_active = active_tab is starting_with("reports") or active_tab is starting_with("report:") %}
<details class="rcms-sidebar-group{% if reports_active %} active{% endif %}"
data-sidebar-group="reports"
{% if reports_active %}open{% endif %}>
<summary class="rcms-sidebar-link rcms-sidebar-group-summary">
<span class="material-symbols-rounded">analytics</span>
<span class="rcms-sidebar-group-label">{{ "Reports" | translate(locale=LANG) }}</span>
<span class="material-symbols-rounded rcms-sidebar-group-chevron">expand_more</span>
</summary>
<div class="rcms-sidebar-group-items">
<a href="/cms-admin/analytics" class="rcms-sidebar-link{% if active_tab == "analytics" %} active{% endif %}">
<span class="material-symbols-rounded">monitoring</span> {{ "Analytics" | translate(locale=LANG) }}
</a>
<a href="{{ url(name='rcms-admin:reports:aging') }}" class="rcms-sidebar-link{% if active_tab == "reports" %} active{% endif %}">
<span class="material-symbols-rounded">hourglass_top</span> {{ "Aging pages" | translate(locale=LANG) }}
</a>
<a href="{{ url(name='rcms-admin:reports:locked-pages') }}" class="rcms-sidebar-link{% if active_tab == "reports-locked" %} active{% endif %}">
<span class="material-symbols-rounded">lock_clock</span> {{ "Locked pages" | translate(locale=LANG) }}
</a>
<a href="{{ url(name='rcms-admin:reports:workflows') }}" class="rcms-sidebar-link{% if active_tab == "reports-workflows" %} active{% endif %}">
<span class="material-symbols-rounded">timeline</span> {{ "Workflow report" | translate(locale=LANG) }}
</a>
<a href="{{ url(name='rcms-admin:reports:revisions') }}" class="rcms-sidebar-link{% if active_tab == "reports-revisions" %} active{% endif %}">
<span class="material-symbols-rounded">history</span> {{ "Revision storage" | translate(locale=LANG) }}
</a>
<a href="{{ url(name='rcms-admin:reports:scheduled') }}" class="rcms-sidebar-link{% if active_tab == "reports-scheduled" %} active{% endif %}">
<span class="material-symbols-rounded">schedule</span> {{ "Scheduled pages" | translate(locale=LANG) }}
</a>
<a href="{{ url(name='rcms-admin:reports:search') }}" class="rcms-sidebar-link{% if active_tab == "reports-search" %} active{% endif %}">
<span class="material-symbols-rounded">push_pin</span> {{ "Search promotions" | translate(locale=LANG) }}
</a>
{# #439 — registry-driven reports (register_report!). #}
{% for r in registered_reports | default(value=[]) %}
<a href="/cms-admin/report/{{ r.slug }}" class="rcms-sidebar-link{% if active_tab == "report:" ~ r.slug %} active{% endif %}">
<span class="material-symbols-rounded">{{ r.icon | default(value="summarize") }}</span> {{ r.title | translate(locale=LANG) }}
</a>
{% endfor %}
</div>
</details>
{% endif %}
{# #272 — Utilities group. Collects the editorial-flow
+ content-modeling tools (History, Workflows, Locales,
Page types) that don't live in any one section. Each
child keeps its own permission gate so the visibility
policy is unchanged; the group only changes the
visual grouping. Auto-opens when any child route is
active. #}
{% set utilities_active = active_tab == "history" or active_tab == "workflows" or active_tab == "locales" or active_tab == "page-types" or active_tab == "components" %}
<details class="rcms-sidebar-group{% if utilities_active %} active{% endif %}"
data-sidebar-group="utilities"
{% if utilities_active %}open{% endif %}>
<summary class="rcms-sidebar-link rcms-sidebar-group-summary">
<span class="material-symbols-rounded">build</span>
<span class="rcms-sidebar-group-label">{{ "Utilities" | translate(locale=LANG) }}</span>
<span class="material-symbols-rounded rcms-sidebar-group-chevron">expand_more</span>
</summary>
<div class="rcms-sidebar-group-items">
{% if not sidebar_gating or user_is_superuser or "cms_history.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:history') }}" class="rcms-sidebar-link{% if active_tab == "history" %} active{% endif %}">
<span class="material-symbols-rounded">history</span> {{ "History" | translate(locale=LANG) }}
</a>
{% endif %}
{% if not sidebar_gating or user_is_superuser or "cms_workflow.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:workflows:list') }}" class="rcms-sidebar-link{% if active_tab == "workflows" %} active{% endif %}">
<span class="material-symbols-rounded">approval</span> {{ "Workflows" | translate(locale=LANG) }}
</a>
{% endif %}
{% if not sidebar_gating or user_is_superuser or "cms_locale.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:locales:list') }}" class="rcms-sidebar-link{% if active_tab == "locales" %} active{% endif %}">
<span class="material-symbols-rounded">language</span> {{ "Locales" | translate(locale=LANG) }}
</a>
{% endif %}
{% if not sidebar_gating or user_is_superuser or "cms_page_type.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:page-types') }}" class="rcms-sidebar-link{% if active_tab == "page-types" %} active{% endif %}">
<span class="material-symbols-rounded">category</span> {{ "Page types" | translate(locale=LANG) }}
</a>
{% endif %}
{# #563 — components library, Developer-gated (same codename as the field builder). #}
{% if not sidebar_gating or user_is_superuser or "cms_page_type.build" in allowed_resources %}
<a href="{{ url(name='rcms-admin:components:index') }}" class="rcms-sidebar-link{% if active_tab == "components" %} active{% endif %}">
<span class="material-symbols-rounded">extension</span> {{ "Components" | translate(locale=LANG) }}
</a>
{% endif %}
</div>
</details>
<div class="rcms-sidebar-section">{{ "Settings" | translate(locale=LANG) }}</div>
{# #272 — Management group. Operator-level admin
(Users, Roles, framework Settings) collapsed under
one parent so the day-to-day editor isn't staring at
admin-only entries. Site settings stays at the top
level since it's editor-facing content config (logo,
favicon, brand). #}
{% set management_active = active_tab == "users" or active_tab == "roles" or active_tab == "permissions" or active_tab == "settings" or active_tab == "security-log" %}
<details class="rcms-sidebar-group{% if management_active %} active{% endif %}"
data-sidebar-group="management"
{% if management_active %}open{% endif %}>
<summary class="rcms-sidebar-link rcms-sidebar-group-summary">
<span class="material-symbols-rounded">admin_panel_settings</span>
<span class="rcms-sidebar-group-label">{{ "Management" | translate(locale=LANG) }}</span>
<span class="material-symbols-rounded rcms-sidebar-group-chevron">expand_more</span>
</summary>
<div class="rcms-sidebar-group-items">
{% if not sidebar_gating or user_is_superuser or "rustango_users.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:users') }}" class="rcms-sidebar-link{% if active_tab == "users" %} active{% endif %}">
<span class="material-symbols-rounded">person</span> {{ "Users" | translate(locale=LANG) }}
</a>
{% endif %}
{% if not sidebar_gating or user_is_superuser or "rustango_roles.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:roles') }}" class="rcms-sidebar-link{% if active_tab == "roles" %} active{% endif %}">
<span class="material-symbols-rounded">key</span> {{ "Roles" | translate(locale=LANG) }}
</a>
{# #436 — read-only permission overview matrix. #}
<a href="/cms-admin/permissions" class="rcms-sidebar-link{% if active_tab == "permissions" %} active{% endif %}">
<span class="material-symbols-rounded">grid_on</span> {{ "Permissions" | translate(locale=LANG) }}
</a>
{% endif %}
{% if not sidebar_gating or user_is_superuser %}
<a href="{{ url(name='rcms-admin:security-log') }}" class="rcms-sidebar-link{% if active_tab == "security-log" %} active{% endif %}">
<span class="material-symbols-rounded">shield_person</span> {{ "Security log" | translate(locale=LANG) }}
</a>
{% endif %}
{% if not sidebar_gating or user_is_superuser or "cms_settings.view" in allowed_resources %}
<a href="{{ url(name='rcms-admin:settings') }}" class="rcms-sidebar-link{% if active_tab == "settings" %} active{% endif %}">
<span class="material-symbols-rounded">tune</span> {{ "Settings" | translate(locale=LANG) }}
</a>
<a href="{{ url(name='rcms-admin:sso-providers:list') }}" class="rcms-sidebar-link{% if active_tab == "sso-providers" %} active{% endif %}">
<span class="material-symbols-rounded">login</span> {{ "SSO Providers" | translate(locale=LANG) }}
</a>
{% endif %}
</div>
</details>
{% if not sidebar_gating or user_is_superuser or "cms_settings.view" in allowed_resources %}
{# Gated on `cms_template.edit` — templates are code-adjacent,
see `admin::template_editor`. Same shape as the page-type
builder's entry above. #}
{% if not sidebar_gating or user_is_superuser or "cms_template.edit" in allowed_resources %}
<a href="{{ url(name='rcms-admin:templates:list') }}" class="rcms-sidebar-link{% if active_tab == "templates" %} active{% endif %}">
<span class="material-symbols-rounded">code_blocks</span> {{ "Templates" | translate(locale=LANG) }}
</a>
{% endif %}
<a href="{{ url(name='rcms-admin:site-settings:list') }}" class="rcms-sidebar-link{% if active_tab == "site-settings" %} active{% endif %}">
<span class="material-symbols-rounded">settings_applications</span> {{ "Site settings" | translate(locale=LANG) }}
</a>
{% endif %}
{# Custom admin pages (#23) — third-party crates register
AdminPageHandlers via `register_admin_page!`; they
surface here grouped by their declared section. Each
page lives at /cms-admin/x/<slug>. #}
{% if extra_admin_pages_by_section %}
{% for section, items in extra_admin_pages_by_section %}
{% if items | length > 0 %}
<div class="rcms-sidebar-section">{{ section | translate(locale=LANG) }}</div>
{% for ap in items %}
<a href="{{ url(name='rcms-admin:custom-page', slug=ap.slug) }}" class="rcms-sidebar-link{% if active_tab == "custom:" ~ ap.slug %} active{% endif %}">
<span class="material-symbols-rounded">{{ ap.icon | default(value="extension") }}</span> {{ ap.label | translate(locale=LANG) }}
</a>
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{# #127 — Help section. Built-in entries (Docs + Keyboard
shortcuts) ship from rustango-cms itself; plugins add
more via `register_help_menu_item!`. The keyboard-shortcuts
entry uses a sentinel href that JS intercepts to open
the cheat-sheet modal in-page.
#272 — Help wrapped in a collapsible `<details>` group
so editors can hide rarely-accessed entries (docs,
styleguide, shortcuts). Persistence + collapsed-rail
handling are inherited from `.rcms-sidebar-group`. #}
{% if help_menu_items and help_menu_items | length > 0 %}
<details class="rcms-sidebar-group" data-sidebar-group="help">
<summary class="rcms-sidebar-link rcms-sidebar-group-summary">
<span class="material-symbols-rounded">help</span>
<span class="rcms-sidebar-group-label">{{ "Help" | translate(locale=LANG) }}</span>
<span class="material-symbols-rounded rcms-sidebar-group-chevron">expand_more</span>
</summary>
<div class="rcms-sidebar-group-items">
{% for mi in help_menu_items %}
{% if mi.href == "#kbd-cheatsheet" %}
<a href="#" class="rcms-sidebar-link" data-kbd-modal-open>
<span class="material-symbols-rounded">{{ mi.icon | default(value="help") }}</span> {{ mi.label | translate(locale=LANG) }}
</a>
{% else %}
<a href="{{ mi.href }}" class="rcms-sidebar-link"
{% if mi.href is starting_with("http") %}target="_blank" rel="noopener"{% endif %}>
<span class="material-symbols-rounded">{{ mi.icon | default(value="help") }}</span> {{ mi.label | translate(locale=LANG) }}
</a>
{% endif %}
{% endfor %}
</div>
</details>
{% endif %}
{# #107 — runtime-hook sidebar entries (`register_admin_menu_item!`).
Backs the `register_admin_menu_item` hook. Lighter
than `AdminPageHandler` — just a label + icon + href. #}
{% if plugin_admin_menu_items and plugin_admin_menu_items | length > 0 %}
<div class="rcms-sidebar-section">{{ "Plugins" | translate(locale=LANG) }}</div>
{% for mi in plugin_admin_menu_items %}
<a href="{{ mi.href }}" class="rcms-sidebar-link{% if active_tab == "plugin:" ~ mi.key %} active{% endif %}">
<span class="material-symbols-rounded">{{ mi.icon | default(value="extension") }}</span> {{ mi.label | translate(locale=LANG) }}
</a>
{% endfor %}
{% endif %}
</nav>
<div class="rcms-sidebar-footer">
{# #27 — appearance, text size, and high-contrast toggles
moved out of here into `/cms-admin/me`. The no-flash
script at the top of <head> still reads the same
localStorage keys so existing preferences keep applying. #}
{# #201 — profile pill: avatar (or initial) + display name. #}
{% if user_username %}
<a href="{{ url(name='rcms-admin:account') }}"
class="rcms-sidebar-profile rcms-flex rcms-items-center rcms-gap-2 rcms-py-2 rcms-px-0 rcms-no-underline rcms-text-inherit"
title="{{ "Edit profile" | translate(locale=LANG) }}">
{% if user_avatar_url %}
<img src="{{ user_avatar_url }}" alt=""
class="rcms-rounded-circle rcms-avatar rcms-avatar--sm">
{% else %}
<span class="rcms-rounded-circle rcms-inline-flex rcms-items-center rcms-text-xs rcms-fw-semibold rcms-avatar rcms-avatar--sm rcms-avatar-fallback rcms-justify-center">
{{ user_display_name | default(value=user_username) | truncate(length=1, end="") | upper }}
</span>
{% endif %}
<span class="rcms-text-xs">{{ user_display_name | default(value=user_username) }}</span>
</a>
{% endif %}
<a href="{{ url(name='rcms-admin:account') }}" class="rcms-sidebar-logout" title="{{ "Appearance, text size, accessibility" | translate(locale=LANG) }}">
<span class="material-symbols-rounded">tune</span> {{ "Preferences" | translate(locale=LANG) }}
</a>
{# #525 — the language switcher lives on Preferences, not here.
Its open menu is a stack of full-width labels, which the
collapsed rail has no room for — the options rendered one
glyph per line. Preferences also saves the choice to the
account via POST, where this was a state-changing GET. #}
<form method="post" action="{{ url(name='rcms-admin:logout') }}" class="rcms-m-0">
{{ csrf_token | csrf_input | safe }}
<button type="submit" class="rcms-sidebar-logout" title="{{ "Sign out of the CMS admin" | translate(locale=LANG) }}">
<span class="material-symbols-rounded">logout</span> {{ "Sign out" | translate(locale=LANG) }}
</button>
</form>
<span class="rcms-hint rcms-text-2xs" data-user-tz title="The CMS stores dates in UTC; the chrome localizes them to this timezone in the browser.">
<span class="material-symbols-rounded sm">schedule</span> {{ "Detecting timezone…" | translate(locale=LANG) }}
</span>
</div>
</aside>
<main class="rcms-app-main">
<header class="rcms-app-topbar">
<div class="rcms-app-topbar-left">
<label for="__nav_toggle" class="rcms-nav-toggle-label" aria-label="{{ "Toggle navigation" | translate(locale=LANG) }}"><span class="material-symbols-rounded">menu</span></label>
{# Heading slot — list/index pages use the default page
title; the page-editor overrides it with inline
breadcrumbs + status chips so the bar stays dense. #}
<h1 class="rcms-app-topbar-heading">{% block heading %}{% if heading %}{{ heading }}{% else %}{{ "Dashboard" | translate(locale=LANG) }}{% endif %}{% endblock %}</h1>
</div>
<div class="rcms-app-topbar-actions">
{% block topbar_actions %}{% endblock %}
</div>
</header>
{# Optional secondary bar — page-editor mounts the tab strip +
preview controls here; list pages leave it empty so the row
collapses. Sticky below the topbar via CSS. #}
{% block action_bar %}{% endblock %}
{# Standalone breadcrumbs row — only rendered when a child
template opts in via `{% block breadcrumbs %}`. The page
editor folds breadcrumbs into the topbar instead. #}
{% block breadcrumbs %}{% endblock %}
{# rustango::messages flash region — one-shot success / info /
warning / error banners staged by POST handlers via
`redirect_with_message`. Drained + cleared on every render
through render_with_csrf in handlers.rs. #}
{% if messages and messages | length > 0 %}
<div class="rcms-app-flash" role="status" aria-live="polite">
{% for msg in messages %}
<div class="rcms-flash rcms-flash--{{ msg.level }}{% if msg.tags %} {{ msg.tags }}{% endif %}">
<span class="material-symbols-rounded rcms-flash-icon">
{% if msg.level == "success" %}check_circle
{% elif msg.level == "warning" %}warning
{% elif msg.level == "error" %}error
{% else %}info
{% endif %}
</span>
<span class="rcms-flash-body">{{ msg.body }}</span>
</div>
{% endfor %}
</div>
{% endif %}
<div class="rcms-app-content">
{% block content %}{% endblock %}
</div>
</main>
<script src="/cms-admin/static/cms-ux.js?v={{ cms_asset_version() }}" defer></script>
<script src="/cms-admin/static/stream_editor.js?v={{ cms_asset_version() }}" defer></script>
<script src="/cms-admin/static/block_tree.js?v={{ cms_asset_version() }}" defer></script>
{# #294 — TipTap richtext editor glue (small). It lazy-loads the ~312 KB
engine bundle on demand, only when a RichText field is present on the
page — so admin pages without one never fetch/parse it. #}
<script src="/cms-admin/static/richtext-editor.js?v={{ cms_asset_version() }}" defer></script>
<script>
(function () {
const STORAGE_KEY = "rcms-admin-mode";
const buttons = document.querySelectorAll(".rcms-mode-toggle-btn[data-mode]");
if (buttons.length === 0) return;
const stored = (() => {
try { return localStorage.getItem(STORAGE_KEY); } catch (e) { return null; }
})();
const current = stored === "light" || stored === "dark" ? stored : "system";
const sync = (mode) => {
buttons.forEach((b) => {
const active = b.dataset.mode === mode;
b.setAttribute("aria-checked", active ? "true" : "false");
b.classList.toggle("active", active);
});
};
sync(current);
buttons.forEach((btn) => {
btn.addEventListener("click", () => {
const mode = btn.dataset.mode;
try {
if (mode === "system") localStorage.removeItem(STORAGE_KEY);
else localStorage.setItem(STORAGE_KEY, mode);
} catch (e) { }
if (mode === "light" || mode === "dark") {
document.documentElement.setAttribute("data-theme", mode);
} else {
document.documentElement.removeAttribute("data-theme");
}
sync(mode);
});
});
const SCALE_KEY = "rcms-admin-text-scale";
const scaleButtons = document.querySelectorAll(".rcms-text-scale-btn[data-text-scale]");
if (scaleButtons.length > 0) {
const storedScale = (() => {
try { return localStorage.getItem(SCALE_KEY); } catch (e) { return null; }
})();
const currentScale = ["s", "m", "l", "xl"].includes(storedScale) ? storedScale : "m";
const syncScale = (scale) => {
scaleButtons.forEach((b) => {
const active = b.dataset.textScale === scale;
b.setAttribute("aria-checked", active ? "true" : "false");
b.classList.toggle("active", active);
});
};
syncScale(currentScale);
scaleButtons.forEach((b) => {
b.addEventListener("click", () => {
const scale = b.dataset.textScale;
try {
if (scale === "m") localStorage.removeItem(SCALE_KEY);
else localStorage.setItem(SCALE_KEY, scale);
} catch (e) { }
if (scale === "m") document.documentElement.removeAttribute("data-text-scale");
else document.documentElement.setAttribute("data-text-scale", scale);
syncScale(scale);
});
});
}
const CONTRAST_KEY = "rcms-admin-high-contrast";
const contrastBtn = document.querySelector("[data-high-contrast-toggle]");
if (contrastBtn) {
const isOn = () => document.documentElement.hasAttribute("data-high-contrast");
const syncContrast = () => {
const on = isOn();
contrastBtn.classList.toggle("active", on);
contrastBtn.setAttribute("aria-pressed", on ? "true" : "false");
const label = contrastBtn.querySelector("[data-high-contrast-label]");
if (label) label.textContent = on ? "High contrast on" : "High contrast";
};
syncContrast();
contrastBtn.addEventListener("click", () => {
const next = !isOn();
try {
if (next) localStorage.setItem(CONTRAST_KEY, "1");
else localStorage.removeItem(CONTRAST_KEY);
} catch (e) { }
if (next) document.documentElement.setAttribute("data-high-contrast", "");
else document.documentElement.removeAttribute("data-high-contrast");
syncContrast();
});
}
})();
</script>
<script>
(function () {
const prefAttr = document.documentElement.getAttribute("data-user-tz-pref");
const tenantAttr = document.documentElement.getAttribute("data-tenant-default-tz");
let effectiveTz = "";
try {
effectiveTz = prefAttr || tenantAttr || Intl.DateTimeFormat().resolvedOptions().timeZone;
} catch (e) { }
try {
document
.querySelectorAll("[data-user-tz]")
.forEach((el) => {
el.textContent = "";
const icon = document.createElement("span");
icon.className = "material-symbols-rounded sm";
icon.textContent = "schedule";
el.appendChild(icon);
el.appendChild(
document.createTextNode(" " + (effectiveTz || "—") + (prefAttr ? " (pref)" : ""))
);
});
} catch (e) { }
const pad = (n) => String(n).padStart(2, "0");
const zoneOffset = (ms, tz) => {
const p = {};
new Intl.DateTimeFormat("en-US", {
timeZone: tz, hourCycle: "h23", year: "numeric", month: "2-digit",
day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit",
}).formatToParts(new Date(ms)).forEach((x) => { p[x.type] = x.value; });
return Date.UTC(+p.year, +p.month - 1, +p.day, +p.hour, +p.minute, +p.second) - ms;
};
const utcToWall = (iso) => {
const d = new Date(iso);
if (Number.isNaN(d.getTime())) return "";
const w = new Date(d.getTime() + (effectiveTz ? zoneOffset(d.getTime(), effectiveTz) : -d.getTimezoneOffset() * 60000));
return `${w.getUTCFullYear()}-${pad(w.getUTCMonth() + 1)}-${pad(w.getUTCDate())}T${pad(w.getUTCHours())}:${pad(w.getUTCMinutes())}`;
};
const wallToUtc = (wall) => {
const m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(wall || "");
if (!m) return wall;
const asUtc = Date.UTC(+m[1], +m[2] - 1, +m[3], +m[4], +m[5]);
let ms;
if (effectiveTz) {
ms = asUtc - zoneOffset(asUtc, effectiveTz);
ms = asUtc - zoneOffset(ms, effectiveTz);
} else {
ms = new Date(+m[1], +m[2] - 1, +m[3], +m[4], +m[5]).getTime();
}
return new Date(ms).toISOString().slice(0, 16) + "Z";
};
window.rcmsTimeZone = effectiveTz;
const zoned = document.querySelectorAll('input[type="datetime-local"][data-utc]');
zoned.forEach((input) => {
const iso = input.getAttribute("data-utc");
if (iso) input.value = utcToWall(iso);
});
const zonedForms = new Set([...zoned].map((i) => i.form).filter(Boolean));
zonedForms.forEach((form) => {
form.addEventListener("formdata", (e) => {
form.querySelectorAll('input[type="datetime-local"][data-utc]').forEach((input) => {
if (input.name && e.formData.has(input.name) && input.value) {
e.formData.set(input.name, wallToUtc(input.value));
}
});
});
});
const elements = document.querySelectorAll("time[data-utc]");
if (elements.length === 0) return;
const tzOpt = effectiveTz ? { timeZone: effectiveTz } : {};
const uiLocale = document.documentElement.getAttribute("lang") || undefined;
const fmt = (d, mode) => {
if (mode === "date")
return d.toLocaleDateString(uiLocale, { dateStyle: "medium", ...tzOpt });
if (mode === "time")
return d.toLocaleTimeString(uiLocale, { timeStyle: "short", ...tzOpt });
return d.toLocaleString(uiLocale, {
dateStyle: "medium",
timeStyle: "short",
...tzOpt,
});
};
elements.forEach((el) => {
const iso = el.getAttribute("data-utc");
if (!iso) return;
const d = new Date(iso);
if (Number.isNaN(d.getTime())) return;
const mode = el.dataset.format || "datetime";
if (!el.dataset.localized) {
el.textContent = fmt(d, mode);
el.title = iso + " (UTC)";
el.dataset.localized = "1";
}
});
})();
</script>
{% block scripts %}{% endblock %}
{# #422 — plugin-injected global admin JS (insert_global_admin_js). #}
{% for js in admin_js_blobs | default(value=[]) %}
<script>{{ js | safe }}</script>
{% endfor %}
</body>
</html>