An instance that can be somebody else's
A name, a tagline, a logo, a favicon and the launcher icons derived from it; the Middle-earth strings as data; themes as token sets; and a stylesheet for what none of that reaches. All four are on one page, in one settings group. The snapshot is a Jinja global over a process-level cache, because render() has no session and four render paths never reach it at all -- the sign-in page, the error pages, the offline page and the SSE fragments. A context value would have had to be threaded through every one and would still have missed those. It being a global is also what lets mark() branch on an uploaded logo without any of its six call sites learning about branding; the macro that renders the sidebar link is called brandlink now, because a macro imported as `brand` shadows the global for the whole template and took out every page at once. Defaults in code and overrides in the database, as the prompt fragments do, with one difference stated in the module: an empty fragment means off, an empty flavour string means the shipped wording. And blanked rather than dropped -- settings_store.update merges, so an omitted key leaves what was stored last time and "I typed the default back in" would store something different from "I changed nothing". A custom theme sets a handful of tokens and inherits the rest, and the inheritance is a CSS fact: tokens.css matches [data-base="shire"] as well as [data-theme="shire"], so a custom light theme lands on parchment rather than four light colours on near-black. Values are validated on read rather than on save, because a theme written straight into the settings table still has to produce a stylesheet that parses -- a `}` in a value ends the rule and silently breaks every rule after it. The soft variants are derived from the accent, or a changed accent leaves focus rings in the old hue and reads as half-working. /branding.css is a route, not an inline block: an external stylesheet has no HTML context to escape from. The link carries a content hash, so a save is not left to the browser's cache, and it is deliberately outside the service worker's precache list, which is versioned by the release. The instance name moved off /admin/general rather than being duplicated there. An upgrade keeps it: the general row is read as a seed exactly while the branding row has never mentioned the name, which is `key in row` and not `row[key] is truthy` -- the two read alike would resurrect the old name underneath a cleared one. The theme list stops being a hard-coded pair in five places. Every failure mode in that area is silent, so it is driven under a DOM stub as well as tested. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
46066150d9
commit
78e5717f77
@@ -238,7 +238,17 @@
|
||||
reads as clinical rather than as paper.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
:root[data-theme="shire"] {
|
||||
/*
|
||||
`[data-base="shire"]` as well as `[data-theme="shire"]`, and that second
|
||||
selector is what makes a custom theme possible. A custom theme is a handful of
|
||||
token overrides served from /branding.css; everything it does not set has to
|
||||
come from somewhere, and Moria's block above matches bare `:root` so it always
|
||||
applies. Without this a custom *light* theme would be four light colours on
|
||||
near-black surfaces. `<html>` carries both attributes -- see base.html and
|
||||
app.js:applyTheme.
|
||||
*/
|
||||
:root[data-theme="shire"],
|
||||
:root[data-base="shire"] {
|
||||
color-scheme: light;
|
||||
|
||||
--bg: #F6F1E4;
|
||||
|
||||
@@ -9,19 +9,44 @@
|
||||
"use strict";
|
||||
|
||||
var THEME_KEY = "lembas-theme";
|
||||
var THEMES = ["moria", "shire"];
|
||||
|
||||
/* --- Theme -------------------------------------------------------------
|
||||
Stored locally so the choice applies instantly and survives being signed
|
||||
out, and mirrored to the server so it follows the user to another device.
|
||||
The server call is best-effort: a failure must not undo the local switch. */
|
||||
The server call is best-effort: a failure must not undo the local switch.
|
||||
|
||||
The list used to be a literal pair here, and in four other places. It comes
|
||||
from `data-themes` on <html> now -- "id:base" pairs, space separated --
|
||||
because an administrator can define one, and a hard-coded pair would refuse
|
||||
it silently: applyTheme would return, the button would do nothing, and
|
||||
nothing anywhere would say why. */
|
||||
function themes() {
|
||||
var raw = document.documentElement.dataset.themes || "moria:moria shire:shire";
|
||||
var map = {};
|
||||
raw.split(/\s+/).forEach(function (entry) {
|
||||
var parts = entry.split(":");
|
||||
if (parts[0]) map[parts[0]] = parts[1] || "moria";
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
||||
function themeNames() {
|
||||
return Object.keys(themes());
|
||||
}
|
||||
|
||||
function currentTheme() {
|
||||
return document.documentElement.dataset.theme || THEMES[0];
|
||||
return document.documentElement.dataset.theme || themeNames()[0];
|
||||
}
|
||||
|
||||
function applyTheme(name) {
|
||||
if (THEMES.indexOf(name) === -1) return;
|
||||
var known = themes();
|
||||
if (!Object.prototype.hasOwnProperty.call(known, name)) return;
|
||||
document.documentElement.dataset.theme = name;
|
||||
/* Both attributes, always. `data-base` is what makes a custom theme inherit
|
||||
its built-in palette -- tokens.css matches it as well as `data-theme` --
|
||||
so setting only the first leaves a custom light theme's four colours on
|
||||
Moria's near-black surfaces. */
|
||||
document.documentElement.dataset.base = known[name];
|
||||
try {
|
||||
localStorage.setItem(THEME_KEY, name);
|
||||
} catch (e) { /* private mode */ }
|
||||
@@ -36,9 +61,13 @@
|
||||
if (bg) meta.setAttribute("content", bg);
|
||||
}
|
||||
|
||||
/* The toggle names where it is going, not where it is. With more than two
|
||||
themes "the next one" is the honest description, because naming it would
|
||||
mean carrying every label into the browser for a label nobody reads
|
||||
twice. */
|
||||
document.querySelectorAll("[data-theme-toggle]").forEach(function (el) {
|
||||
el.setAttribute("aria-label", name === "moria" ? "Switch to Shire (light)"
|
||||
: "Switch to Moria (dark)");
|
||||
el.setAttribute("aria-label", known[name] === "moria" ? "Switch to the light theme"
|
||||
: "Switch to the dark theme");
|
||||
});
|
||||
|
||||
/* For anything holding colours as values rather than reading them from a
|
||||
@@ -56,8 +85,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Round the list rather than between two names. With only the built-in pair
|
||||
this is exactly what it always did; with a third defined it reaches it,
|
||||
which a hard-coded flip never could. */
|
||||
function toggleTheme() {
|
||||
applyTheme(currentTheme() === "moria" ? "shire" : "moria");
|
||||
var names = themeNames();
|
||||
var at = names.indexOf(currentTheme());
|
||||
applyTheme(names[(at + 1) % names.length] || names[0]);
|
||||
}
|
||||
|
||||
/* --- Textarea autosize -------------------------------------------------
|
||||
|
||||
@@ -161,10 +161,18 @@
|
||||
{
|
||||
name: "theme",
|
||||
summary: "Switch theme",
|
||||
argument: "moria | shire",
|
||||
/* Read from the document rather than written here, for the reason
|
||||
app.js's own list is: an administrator can define a theme, and a
|
||||
literal pair would leave `/theme dusk` silently toggling instead. */
|
||||
argument: function () {
|
||||
return (document.documentElement.dataset.themes || "moria:moria shire:shire")
|
||||
.split(/\s+/).map(function (entry) { return entry.split(":")[0]; }).join(" | ");
|
||||
},
|
||||
run: function (rest) {
|
||||
var wanted = (rest || "").trim().toLowerCase();
|
||||
if (wanted === "moria" || wanted === "shire") window.lembas.applyTheme(wanted);
|
||||
var known = (document.documentElement.dataset.themes || "").split(/\s+/)
|
||||
.map(function (entry) { return entry.split(":")[0]; });
|
||||
if (wanted && known.indexOf(wanted) !== -1) window.lembas.applyTheme(wanted);
|
||||
else window.lembas.toggleTheme();
|
||||
}
|
||||
},
|
||||
@@ -411,7 +419,8 @@
|
||||
body.className = "picker__option-body";
|
||||
var name = document.createElement("span");
|
||||
name.className = "picker__option-name";
|
||||
name.textContent = "/" + command.name + (command.argument ? " " + command.argument : "");
|
||||
var hint = argumentOf(command);
|
||||
name.textContent = "/" + command.name + (hint ? " " + hint : "");
|
||||
var summary = document.createElement("span");
|
||||
summary.className = "picker__option-note";
|
||||
summary.textContent = command.summary;
|
||||
@@ -482,11 +491,20 @@
|
||||
dialog.showModal();
|
||||
}
|
||||
|
||||
/* A command's argument hint, which is usually a literal and is sometimes
|
||||
worked out from the page -- `/theme` lists the themes that exist, and those
|
||||
are an administrator's to define. Resolved in the two places that render
|
||||
it, so a command may be either without either caring. */
|
||||
function argumentOf(command) {
|
||||
var value = command.argument;
|
||||
return typeof value === "function" ? value() : (value || "");
|
||||
}
|
||||
|
||||
function helpSheet() {
|
||||
var rows = available().map(function (command) {
|
||||
return (
|
||||
"<tr><td class='mono'>/" + command.name +
|
||||
(command.argument ? " " + escapeText(command.argument) : "") +
|
||||
(argumentOf(command) ? " " + escapeText(argumentOf(command)) : "") +
|
||||
"</td><td>" + escapeText(command.summary) + "</td></tr>"
|
||||
);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Shared template macros.
|
||||
|
||||
Import at the top of any template that needs them:
|
||||
{% from "_macros.html" import icon, brand, mark %}
|
||||
{% from "_macros.html" import icon, brandlink, mark %}
|
||||
#}
|
||||
|
||||
{# An icon from the inlined sprite. `name` omits the "i-" prefix. #}
|
||||
@@ -16,8 +16,21 @@
|
||||
because ids are document-global: two marks on one page with the same ids
|
||||
means the second silently reuses the first one's gradients.
|
||||
#}
|
||||
{#
|
||||
An uploaded logo replaces it, the same way `model_avatar` branches. The branch
|
||||
is inside the macro rather than at each of the six call sites, so a logo
|
||||
reaches the sidebar, the sign-in page, the offline page and every empty state
|
||||
at once -- and so the one place that has to know the fallback exists is here.
|
||||
|
||||
`brand` is a Jinja global, so it is available inside a macro with nothing
|
||||
passed in. That is the whole reason it is a global: a macro has no context.
|
||||
#}
|
||||
{% macro mark(cls="brand-mark", uid="a") -%}
|
||||
<svg class="{{ cls }}" viewBox="0 0 64 64" role="img" aria-label="LLeMbas">
|
||||
{% if brand.logo_path %}
|
||||
<img class="{{ cls }}" src="/branding/{{ brand.logo_path }}" alt="{{ brand.name }}"
|
||||
width="64" height="64">
|
||||
{% else %}
|
||||
<svg class="{{ cls }}" viewBox="0 0 64 64" role="img" aria-label="{{ brand.name }}">
|
||||
<defs>
|
||||
<linearGradient id="mk-{{ uid }}-w" x1="0" y1="0" x2="0.3" y2="1">
|
||||
<stop offset="0" stop-color="#7FB758"/>
|
||||
@@ -50,15 +63,25 @@
|
||||
<path d="M21 46 Q30.5 34.5 46 18" fill="none" stroke="#57734F"
|
||||
stroke-opacity="0.5" stroke-width="1.5" stroke-linecap="round"/>
|
||||
</svg>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{#
|
||||
The wordmark as live text rather than the outlined SVG: it stays selectable,
|
||||
searchable and readable to a screen reader, and scales with the user's font
|
||||
size. The capitals spelling LLM take the leaf accent.
|
||||
size.
|
||||
|
||||
The accent on the capitals spelling LLM is only meaningful for the shipped
|
||||
name, so it is applied only when the name *is* the shipped one. Guessing which
|
||||
letters of somebody else's name to highlight would produce "InTernal AI" —
|
||||
worse than plain text, and worse in a way nobody would think to look for.
|
||||
#}
|
||||
{% macro wordmark() -%}
|
||||
{% if brand.name == "LLeMbas" %}
|
||||
<span class="brand-llm">LL</span>e<span class="brand-llm">M</span>bas
|
||||
{%- else -%}
|
||||
{{ brand.name }}
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{#
|
||||
@@ -80,7 +103,13 @@
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro brand(href="/", uid="a") -%}
|
||||
{#
|
||||
The brand link in a sidebar. Named `brandlink` and not `brand`, because
|
||||
`brand` is the Jinja global holding this instance's identity -- and a macro
|
||||
imported under that name shadows it for the whole template, which took out
|
||||
every page that imports this one at once.
|
||||
#}
|
||||
{% macro brandlink(href="/", uid="a") -%}
|
||||
<a class="sidebar__brand" href="{{ href }}">
|
||||
{{ mark(uid=uid) }}
|
||||
<span>{{ wordmark() }}</span>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "_macros.html" import icon, brand %}
|
||||
{% from "_macros.html" import icon, brandlink %}
|
||||
{#
|
||||
Shared chrome for the admin area: its own narrow nav rather than the chat
|
||||
sidebar, so administration is visibly a different place from chatting.
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="shell">
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar__header">
|
||||
{{ brand(uid="admin") }}
|
||||
{{ brandlink(uid="admin") }}
|
||||
</div>
|
||||
|
||||
<nav class="sidebar__scroll" aria-label="Administration">
|
||||
@@ -26,6 +26,11 @@
|
||||
{{ icon("gear", "icon--sm") }}
|
||||
<span class="nav-item__label">General</span>
|
||||
</a>
|
||||
<a class="nav-item {{ 'is-active' if section == 'customization' }}"
|
||||
href="/admin/customization">
|
||||
{{ icon("sun", "icon--sm") }}
|
||||
<span class="nav-item__label">Customization</span>
|
||||
</a>
|
||||
<a class="nav-item {{ 'is-active' if section == 'connections' }}"
|
||||
href="/admin/connections">
|
||||
{{ icon("server", "icon--sm") }}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "agents" %}
|
||||
|
||||
{% block title %}Agents - LLeMbas{% endblock %}
|
||||
{% block title %}Agents - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Agents{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
@@ -18,7 +18,7 @@
|
||||
<span>
|
||||
There is no sandbox to configure, and that is deliberate: containment is
|
||||
whatever host somebody points a connection at. A container built for the
|
||||
job is a very different thing from a key to a live server, and LLeMbas
|
||||
job is a very different thing from a key to a live server, and {{ brand.name }}
|
||||
cannot tell them apart. What a model reads — a web page, a file, the output
|
||||
of the last command — is untrusted, and in <strong>Auto</strong> mode
|
||||
nothing stands between that and a command running.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "audio" %}
|
||||
|
||||
{% block title %}Audio - LLeMbas{% endblock %}
|
||||
{% block title %}Audio - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Audio{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "connections" %}
|
||||
|
||||
{% block title %}Connections - LLeMbas{% endblock %}
|
||||
{% block title %}Connections - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Connections{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
<p class="admin-lede">
|
||||
Any endpoint that speaks the OpenAI HTTP API: OpenAI itself, or a local
|
||||
runner such as LM Studio, vLLM, llama.cpp or Ollama. LLeMbas asks each one
|
||||
runner such as LM Studio, vLLM, llama.cpp or Ollama. {{ brand.name }} asks each one
|
||||
for its model list and offers those models in the chat picker.
|
||||
</p>
|
||||
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
{% extends "admin/_layout.html" %}
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "customization" %}
|
||||
|
||||
{% block title %}Customization - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Customization{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
<p class="admin-lede">
|
||||
What this installation is called and what it looks like. Every box below ships
|
||||
with a default; leaving one alone means it is <em>not</em> stored, so a later
|
||||
release can still improve the wording. Clearing a box gives you the shipped
|
||||
version back rather than nothing.
|
||||
</p>
|
||||
|
||||
{% if error %}
|
||||
<div class="alert alert--error">{{ icon("warning", "icon--sm") }} <span>{{ error }}</span></div>
|
||||
{% endif %}
|
||||
{% if saved %}
|
||||
<div class="alert alert--success">{{ icon("check", "icon--sm") }} <span>{{ saved }}</span></div>
|
||||
{% endif %}
|
||||
|
||||
{# --- Identity ------------------------------------------------------------- #}
|
||||
<form method="post" action="/admin/customization/identity" enctype="multipart/form-data"
|
||||
class="form-grid">
|
||||
<section class="card">
|
||||
<h2 class="card__title">Identity</h2>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="instance-name">Name</label>
|
||||
<input class="input" id="instance-name" name="instance_name"
|
||||
value="{{ values.instance_name }}" maxlength="120" placeholder="LLeMbas">
|
||||
<p class="field__hint">
|
||||
Shown in the sidebar, in every page title, in the launcher when this is
|
||||
installed as an app, and to the model — it is told which installation it
|
||||
is answering in. Empty means <strong>LLeMbas</strong>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="tagline">Tagline</label>
|
||||
<input class="input" id="tagline" name="tagline"
|
||||
value="{{ values.tagline }}" maxlength="200">
|
||||
<p class="field__hint">
|
||||
One line, used in the page description. The sign-in page has a line of
|
||||
its own under <strong>Wording</strong> below.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="logo">Logo</label>
|
||||
{% if current.logo_path %}
|
||||
<p class="field__hint" style="margin-bottom: var(--sp-2)">
|
||||
<img src="/branding/{{ current.logo_path }}" alt="" width="48" height="48"
|
||||
style="vertical-align: middle; border-radius: var(--radius)">
|
||||
<label class="checkbox" style="display: inline-flex; margin-left: var(--sp-3)">
|
||||
<input type="checkbox" name="remove_logo" value="true">
|
||||
<span>Remove it</span>
|
||||
</label>
|
||||
</p>
|
||||
{% endif %}
|
||||
<input class="input" id="logo" name="logo" type="file"
|
||||
accept="image/png,image/jpeg,image/webp,image/gif">
|
||||
<p class="field__hint">
|
||||
Replaces the leaf mark everywhere it appears. PNG, JPEG, WEBP or GIF,
|
||||
under 2 MB, square. <strong>SVG is deliberately not accepted</strong>:
|
||||
these files are served to people who are not signed in, and an SVG can
|
||||
carry a script. The launcher icons are made from this automatically.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="favicon">Favicon</label>
|
||||
{% if current.favicon_path %}
|
||||
<p class="field__hint" style="margin-bottom: var(--sp-2)">
|
||||
<img src="/branding/{{ current.favicon_path }}" alt="" width="16" height="16"
|
||||
style="vertical-align: middle">
|
||||
<label class="checkbox" style="display: inline-flex; margin-left: var(--sp-3)">
|
||||
<input type="checkbox" name="remove_favicon" value="true">
|
||||
<span>Remove it</span>
|
||||
</label>
|
||||
</p>
|
||||
{% endif %}
|
||||
<input class="input" id="favicon" name="favicon" type="file"
|
||||
accept="image/png,image/jpeg,image/webp,image/gif">
|
||||
<p class="field__hint">
|
||||
Optional. Without one, a logo you upload is used at 32px, and without
|
||||
that the shipped leaf.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="btn-row">
|
||||
<button class="btn btn--primary" type="submit">Save identity</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{# --- Wording -------------------------------------------------------------- #}
|
||||
<form method="post" action="/admin/customization/flavour" class="form-grid">
|
||||
<section class="card">
|
||||
<h2 class="card__title">Wording</h2>
|
||||
<p class="field__hint">
|
||||
The lines with a bit of character in them. They live in the empty states,
|
||||
the error pages and the sign-in screen — never in the functional interface,
|
||||
where a button says what it does. Replace them with your own, or leave them.
|
||||
</p>
|
||||
|
||||
{% for entry in flavour %}
|
||||
<div class="field">
|
||||
<label class="field__label" for="text-{{ entry.key }}">{{ entry.label }}</label>
|
||||
<input class="input" id="text-{{ entry.key }}" name="text_{{ entry.key }}"
|
||||
value="{{ entry.value }}" maxlength="400"
|
||||
placeholder="{{ entry.default }}">
|
||||
<p class="field__hint">{{ entry.hint }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</section>
|
||||
|
||||
<div class="btn-row">
|
||||
<button class="btn btn--primary" type="submit">Save wording</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{# --- Themes --------------------------------------------------------------- #}
|
||||
{#
|
||||
Three blocks, always rendered, so adding a theme needs no JavaScript: an empty
|
||||
id means that block is not a theme. Saving replaces the whole list, which is
|
||||
what makes removing one a matter of clearing its id.
|
||||
#}
|
||||
<form method="post" action="/admin/customization/themes" class="form-grid">
|
||||
<section class="card">
|
||||
<h2 class="card__title">Themes</h2>
|
||||
<p class="field__hint">
|
||||
A theme is a set of colours, not a stylesheet — nothing in this interface
|
||||
hard-codes one, so a third palette composes with everything. Pick which
|
||||
built-in it starts from and change only what you want; everything left
|
||||
empty is inherited. The soft variants behind focus rings and selected rows
|
||||
are worked out from the accent, so you do not have to.
|
||||
</p>
|
||||
|
||||
{% for index in range(3) %}
|
||||
{% set existing = custom_themes[index] if index < custom_themes | length else none %}
|
||||
<div class="card" style="margin-top: var(--sp-4)">
|
||||
<h3 class="section-title">
|
||||
{{ existing.label if existing else "A theme of your own" }}
|
||||
</h3>
|
||||
|
||||
<div class="field-row">
|
||||
<div class="field">
|
||||
<label class="field__label" for="theme-{{ index }}-id">Id</label>
|
||||
<input class="input" id="theme-{{ index }}-id" name="theme_{{ index }}_id"
|
||||
value="{{ existing.id if existing else '' }}" maxlength="24"
|
||||
pattern="[a-z][a-z0-9-]*" placeholder="dusk">
|
||||
<p class="field__hint">
|
||||
Lowercase letters, digits and hyphens. Clear it to remove the theme.
|
||||
</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="theme-{{ index }}-label">Name</label>
|
||||
<input class="input" id="theme-{{ index }}-label" name="theme_{{ index }}_label"
|
||||
value="{{ existing.label if existing else '' }}" maxlength="60"
|
||||
placeholder="Dusk">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="theme-{{ index }}-base">Starts from</label>
|
||||
<select class="input" id="theme-{{ index }}-base" name="theme_{{ index }}_base">
|
||||
{% for base in bases %}
|
||||
<option value="{{ base }}"
|
||||
{{ 'selected' if existing and existing.base == base }}>{{ base }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field-row">
|
||||
{% for name, description in tokens %}
|
||||
<div class="field">
|
||||
<label class="field__label" for="theme-{{ index }}-{{ name }}">
|
||||
{{ description }}
|
||||
</label>
|
||||
<input class="input" id="theme-{{ index }}-{{ name }}"
|
||||
name="theme_{{ index }}_{{ name }}" type="text"
|
||||
value="{{ existing.tokens.get(name, '') if existing else '' }}"
|
||||
maxlength="40" placeholder="inherited"
|
||||
spellcheck="false">
|
||||
<p class="field__hint"><code>--{{ name }}</code></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</section>
|
||||
|
||||
<div class="btn-row">
|
||||
<button class="btn btn--primary" type="submit">Save themes</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{# --- Stylesheet ----------------------------------------------------------- #}
|
||||
<form method="post" action="/admin/customization/css" class="form-grid">
|
||||
<section class="card">
|
||||
<h2 class="card__title">Stylesheet</h2>
|
||||
<p class="field__hint">
|
||||
Served as <code>/branding.css</code> after everything else, so these rules
|
||||
win. It is a file rather than a block inside the page on purpose: a
|
||||
stylesheet has no markup around it to escape from. Reach for the themes
|
||||
above first — a colour set there follows both palettes, and a rule here
|
||||
follows neither.
|
||||
</p>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="custom-css">CSS</label>
|
||||
<textarea class="input textarea" id="custom-css" name="custom_css" rows="10"
|
||||
spellcheck="false"
|
||||
placeholder=".sidebar__brand { letter-spacing: 0.02em; }"
|
||||
>{{ values.custom_css }}</textarea>
|
||||
<p class="field__hint">
|
||||
Up to 40,000 characters. Nothing here is validated: a rule that does not
|
||||
parse is dropped by the browser, quietly, as it would be in any
|
||||
stylesheet.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="btn-row">
|
||||
<button class="btn btn--primary" type="submit">Save stylesheet</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "general" %}
|
||||
|
||||
{% block title %}General - LLeMbas{% endblock %}
|
||||
{% block title %}General - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}General{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
@@ -15,16 +15,18 @@
|
||||
<div class="alert alert--success">{{ icon("check", "icon--sm") }} <span>Settings saved.</span></div>
|
||||
{% endif %}
|
||||
|
||||
{#
|
||||
The instance name used to be here. It lives on Customization now, with the
|
||||
logo, the wording and the themes -- one field, one page. Left as a link rather
|
||||
than duplicated: two controls writing one value is how each becomes the answer
|
||||
to "why did my change not stick?".
|
||||
#}
|
||||
<p class="admin-lede">
|
||||
The name, the logo, the wording and the themes are on
|
||||
<a href="/admin/customization">Customization</a>.
|
||||
</p>
|
||||
|
||||
<form method="post" action="/admin/general">
|
||||
<section class="card">
|
||||
<h2 class="card__title">Identity</h2>
|
||||
<div class="field">
|
||||
<label class="field__label" for="instance-name">Instance name</label>
|
||||
<input class="input" id="instance-name" name="instance_name"
|
||||
value="{{ values.instance_name }}" maxlength="120">
|
||||
<p class="field__hint">Shown in the browser tab and on the sign-in page.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Default system prompt</h2>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon, model_avatar %}
|
||||
{% set section = "groups" %}
|
||||
|
||||
{% block title %}Groups & permissions - LLeMbas{% endblock %}
|
||||
{% block title %}Groups & permissions - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Groups & permissions{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "images" %}
|
||||
|
||||
{% block title %}Image generation - LLeMbas{% endblock %}
|
||||
{% block title %}Image generation - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Image generation{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "mcp" %}
|
||||
|
||||
{% block title %}MCP servers - LLeMbas{% endblock %}
|
||||
{% block title %}MCP servers - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}MCP servers{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "mcp" %}
|
||||
|
||||
{% block title %}{{ "New server" if is_new else server.name }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ "New server" if is_new else server.name }} - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ "New MCP server" if is_new else server.name }}{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
@@ -186,7 +186,7 @@
|
||||
</div>
|
||||
<p class="field__hint">
|
||||
Tick the second only for a server on your own network. It is what stops
|
||||
this being aimed at LLeMbas itself, a router, or a metadata endpoint.
|
||||
this being aimed at {{ brand.name }} itself, a router, or a metadata endpoint.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon, model_avatar %}
|
||||
{% set section = "models" %}
|
||||
|
||||
{% block title %}{{ model.label }} - Models - LLeMbas{% endblock %}
|
||||
{% block title %}{{ model.label }} - Models - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ model.label }}{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon, model_avatar %}
|
||||
{% set section = "models" %}
|
||||
|
||||
{% block title %}Models - LLeMbas{% endblock %}
|
||||
{% block title %}Models - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Models{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "prompts" %}
|
||||
|
||||
{% block title %}Prompts - LLeMbas{% endblock %}
|
||||
{% block title %}Prompts - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Prompts{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
<p class="admin-lede">
|
||||
Everything LLeMbas puts in front of a model on its own: what day it is, how to
|
||||
Everything {{ brand.name }} puts in front of a model on its own: what day it is, how to
|
||||
use each tool, what it has been asked to remember. These sit above whichever
|
||||
system prompt was authored for the instance, the model or the chat — that
|
||||
prompt still wins where the two disagree. Clear a box to leave that piece out
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "schedules" %}
|
||||
|
||||
{% block title %}Scheduling - LLeMbas{% endblock %}
|
||||
{% block title %}Scheduling - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Scheduling{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "search" %}
|
||||
|
||||
{% block title %}Web search - LLeMbas{% endblock %}
|
||||
{% block title %}Web search - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Web search{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
@@ -112,7 +112,7 @@
|
||||
<h2 class="card__title">Saving links</h2>
|
||||
<p class="card__lede">
|
||||
Applies to the composer's <strong>Link</strong> option and to anything the
|
||||
model fetches: LLeMbas retrieves the page and keeps its text.
|
||||
model fetches: {{ brand.name }} retrieves the page and keeps its text.
|
||||
</p>
|
||||
<div class="field">
|
||||
<label class="checkbox">
|
||||
@@ -136,7 +136,7 @@
|
||||
</label>
|
||||
<p class="field__hint">
|
||||
Off by default, and worth leaving off. This server can reach your
|
||||
router, your other services and LLeMbas itself; the address to fetch can
|
||||
router, your other services and {{ brand.name }} itself; the address to fetch can
|
||||
come from a model, which can be talked into things by a web page it just
|
||||
read. Turn this on only if you actually want to archive pages from your
|
||||
own network.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "suggestions" %}
|
||||
|
||||
{% block title %}Suggestions - LLeMbas{% endblock %}
|
||||
{% block title %}Suggestions - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Suggestions{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "tools" %}
|
||||
|
||||
{% block title %}{{ "New tool" if is_new else tool.name }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ "New tool" if is_new else tool.name }} - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ "New tool" if is_new else tool.name }}{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "tools" %}
|
||||
|
||||
{% block title %}Tools - LLeMbas{% endblock %}
|
||||
{% block title %}Tools - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Tools{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "users" %}
|
||||
|
||||
{% block title %}Users - LLeMbas{% endblock %}
|
||||
{% block title %}Users - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Users{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "images" %}
|
||||
|
||||
{% block title %}{{ workflow.name or "New workflow" }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ workflow.name or "New workflow" }} - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ workflow.name or "New workflow" }}{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Connections, kept by the person who owns them.
|
||||
|
||||
Shares the chat sidebar with the library for the same reason: this is part of
|
||||
using LLeMbas, not administering it. You come here to add a machine and go
|
||||
using {{ brand.name }}, not administering it. You come here to add a machine and go
|
||||
straight back to a conversation.
|
||||
#}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "agents/_layout.html" %}
|
||||
{% from "_macros.html" import icon %}
|
||||
|
||||
{% block title %}{{ "New connection" if is_new else profile.name }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ "New connection" if is_new else profile.name }} - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ "New connection" if is_new else profile.name }}{% endblock %}
|
||||
|
||||
{% block agents_content %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "agents/_layout.html" %}
|
||||
{% from "_macros.html" import icon %}
|
||||
|
||||
{% block title %}Connections - LLeMbas{% endblock %}
|
||||
{% block title %}Connections - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Connections{% endblock %}
|
||||
{% block actions %}
|
||||
<a class="btn btn--primary btn--sm" href="/agents/new">
|
||||
@@ -21,7 +21,7 @@
|
||||
<span>
|
||||
Whatever this connection can reach, a model in an agent chat can reach. A
|
||||
container built for the job, with one project mounted into it, is a very
|
||||
different thing from a key to a machine you care about — and LLeMbas cannot
|
||||
different thing from a key to a machine you care about — and {{ brand.name }} cannot
|
||||
tell them apart.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "_macros.html" import icon, mark, wordmark %}
|
||||
|
||||
{% block title %}Sign in - LLeMbas{% endblock %}
|
||||
{% block title %}Sign in - {{ brand.name }}{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<main class="auth">
|
||||
@@ -9,7 +9,7 @@
|
||||
<div class="auth__brand">
|
||||
{{ mark(cls="brand-mark", uid="auth") }}
|
||||
<h1 class="auth__title">{{ wordmark() }}</h1>
|
||||
<p class="auth__subtitle">Waybread for the long road of thought.</p>
|
||||
<p class="auth__subtitle">{{ brand.text.login_tagline }}</p>
|
||||
</div>
|
||||
|
||||
{% if error %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "_macros.html" import icon, mark, wordmark %}
|
||||
|
||||
{% block title %}{% if first_run %}Set up LLeMbas{% else %}Create an account{% endif %}{% endblock %}
|
||||
{% block title %}{% if first_run %}Set up {{ brand.name }}{% else %}Create an account{% endif %}{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<main class="auth">
|
||||
|
||||
@@ -1,13 +1,33 @@
|
||||
<!doctype html>
|
||||
<html lang="en" data-theme="{{ theme }}"{% if layout %} style="{{ layout }}"{% endif %}>
|
||||
{#
|
||||
`data-base` is what makes a custom theme inherit: tokens.css matches
|
||||
`[data-base="shire"]` as well as `[data-theme="shire"]`, so a custom light
|
||||
theme gets the whole parchment palette underneath its own handful of colours.
|
||||
Without it, four light colours would sit on Moria's near-black surfaces.
|
||||
|
||||
`data-themes` is the list of `id:base` pairs, which is what the browser needs
|
||||
in order to set both attributes when somebody switches -- one attribute to
|
||||
split rather than a JSON island to parse.
|
||||
#}
|
||||
<html lang="en" data-theme="{{ theme }}" data-base="{{ brand.theme(theme).base }}"
|
||||
data-themes="{{ brand.theme_list }}"{% if layout %} style="{{ layout }}"{% endif %}>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}LLeMbas{% endblock %}</title>
|
||||
<meta name="description" content="LLeMbas - a web UI for your language models.">
|
||||
<title>{% block title %}{{ brand.name }}{% endblock %}</title>
|
||||
<meta name="description" content="{{ brand.tagline or brand.name ~ ' — a web UI for your language models.' }}">
|
||||
<meta name="color-scheme" content="dark light">
|
||||
|
||||
{# An uploaded favicon wins; then the icon derived from an uploaded logo; then
|
||||
the shipped leaf. Three rungs rather than two because somebody who uploads a
|
||||
logo and no favicon still expects the tab to change. #}
|
||||
{% if brand.favicon_path %}
|
||||
<link rel="icon" href="/branding/{{ brand.favicon_path }}">
|
||||
{% elif brand.icon_paths.favicon %}
|
||||
<link rel="icon" href="/branding/{{ brand.icon_paths.favicon }}">
|
||||
{% else %}
|
||||
<link rel="icon" href="{{ url_for('static', path='img/favicon.svg') }}" type="image/svg+xml">
|
||||
{% endif %}
|
||||
|
||||
{#
|
||||
Installing as an app. The manifest is a route, not a file, because it carries
|
||||
@@ -17,14 +37,27 @@
|
||||
#}
|
||||
<link rel="manifest" href="/manifest.webmanifest">
|
||||
<meta name="theme-color" content="#101317">
|
||||
{% if brand.icon_paths['apple-touch'] %}
|
||||
<link rel="apple-touch-icon" href="/branding/{{ brand.icon_paths['apple-touch'] }}">
|
||||
{% else %}
|
||||
<link rel="apple-touch-icon" href="{{ url_for('static', path='img/apple-touch-icon-180.png') }}">
|
||||
{% endif %}
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-title" content="LLeMbas">
|
||||
<meta name="apple-mobile-web-app-title" content="{{ brand.name }}">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for('static', path='css/tokens.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', path='css/app.css') }}">
|
||||
{#
|
||||
Last, so an administrator's rules win, and before {% block head %} so a page's
|
||||
own stylesheet still comes after it. The query string is a hash of everything
|
||||
the route builds, so the URL changes exactly when the stylesheet does -- with a
|
||||
fixed URL the browser's cache would be what decided when a rebrand took effect.
|
||||
Deliberately NOT in the service worker's precache list for the same reason:
|
||||
that cache is versioned by the release, and branding changes between releases.
|
||||
#}
|
||||
<link rel="stylesheet" href="/branding.css?v={{ brand.revision }}">
|
||||
{% block head %}{% endblock %}
|
||||
|
||||
{#
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
itself all came from a model that may have been reading somebody else's file
|
||||
a moment ago.
|
||||
|
||||
Deliberately attributed to the model rather than styled as if LLeMbas were
|
||||
Deliberately attributed to the model rather than styled as if {{ brand.name }} were
|
||||
asking. A question that looks like it came from the application is a question
|
||||
people answer with things they would not tell a chatbot.
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<header class="msg__meta">
|
||||
<span class="msg__author">
|
||||
{% if message.role == "assistant" %}
|
||||
{{ speaking_model.label if speaking_model else "LLeMbas" }}
|
||||
{{ speaking_model.label if speaking_model else brand.name }}
|
||||
{% elif machine %}
|
||||
Background job
|
||||
{% else %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "_macros.html" import icon, mark, model_avatar %}
|
||||
|
||||
{% block title %}{{ chat.title if chat else "New chat" }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ chat.title if chat else "New chat" }} - {{ brand.name }}{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', path='css/chat.css') }}">
|
||||
@@ -286,7 +286,7 @@
|
||||
<h2 class="empty__title">No models available</h2>
|
||||
<p class="empty__text">
|
||||
{% if user.is_admin %}
|
||||
Add an OpenAI-compatible connection and LLeMbas will load its models.
|
||||
Add an OpenAI-compatible connection and {{ brand.name }} will load its models.
|
||||
{% else %}
|
||||
No model connections have been set up yet. Ask an administrator.
|
||||
{% endif %}
|
||||
@@ -305,7 +305,7 @@
|
||||
<div class="thread__intro">
|
||||
{{ mark(cls="empty__mark", uid="intro") }}
|
||||
<h2 class="empty__title">What would you ask?</h2>
|
||||
<p class="empty__text">Speak, friend, and enter.</p>
|
||||
<p class="empty__text">{{ brand.text.chat_empty }}</p>
|
||||
|
||||
{# Only on a chat that does not exist yet. An empty chat someone
|
||||
opened on purpose already has a model and a prompt chosen. #}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "_macros.html" import mark %}
|
||||
|
||||
{% block title %}{{ status_code }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ status_code }} - {{ brand.name }}{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<main class="auth">
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
an absent one are the same request.
|
||||
#}
|
||||
|
||||
{% block title %}{{ folder.name }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ folder.name }} - {{ brand.name }}{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', path='css/chat.css') }}">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "knowledge" %}
|
||||
|
||||
{% block title %}{{ base.name }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ base.name }} - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ base.name }}{% endblock %}
|
||||
|
||||
{% block library_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "knowledge" %}
|
||||
|
||||
{% block title %}Knowledge - LLeMbas{% endblock %}
|
||||
{% block title %}Knowledge - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Knowledge{% endblock %}
|
||||
|
||||
{% block library_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "knowledge" %}
|
||||
|
||||
{% block title %}{{ document.title }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ document.title }} - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ document.title }}{% endblock %}
|
||||
|
||||
{% block library_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "notes" %}
|
||||
|
||||
{% block title %}{{ note.title if note else "New note" }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ note.title if note else "New note" }} - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ note.title if note else "New note" }}{% endblock %}
|
||||
|
||||
{% block library_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "notes" %}
|
||||
|
||||
{% block title %}Notes - LLeMbas{% endblock %}
|
||||
{% block title %}Notes - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Notes{% endblock %}
|
||||
{% block actions %}
|
||||
<a class="btn btn--primary btn--sm" href="/library/notes/new">{{ icon("plus", "icon--sm") }} New note</a>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "skills" %}
|
||||
|
||||
{% block title %}{{ skill.name if skill else "New skill" }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ skill.name if skill else "New skill" }} - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ skill.name if skill else "New skill" }}{% endblock %}
|
||||
|
||||
{% block library_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "skills" %}
|
||||
|
||||
{% block title %}Skills - LLeMbas{% endblock %}
|
||||
{% block title %}Skills - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Skills{% endblock %}
|
||||
{% block actions %}
|
||||
<a class="btn btn--primary btn--sm" href="/library/skills/new">{{ icon("plus", "icon--sm") }} New skill</a>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
is the whole reason this is a `Chat` with a different `kind`.
|
||||
#}
|
||||
|
||||
{% block title %}Messages - LLeMbas{% endblock %}
|
||||
{% block title %}Messages - {{ brand.name }}{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', path='css/chat.css') }}">
|
||||
|
||||
@@ -8,18 +8,18 @@
|
||||
flavour belongs -- see the flavour rule in CLAUDE.md.
|
||||
#}
|
||||
|
||||
{% block title %}Offline - LLeMbas{% endblock %}
|
||||
{% block title %}Offline - {{ brand.name }}{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<main class="auth">
|
||||
<div class="auth__card" style="text-align: center">
|
||||
{{ mark(cls="empty__mark", uid="offline") }}
|
||||
<h1 class="auth__title" style="margin-top: var(--sp-4)">No road from here</h1>
|
||||
<h1 class="auth__title" style="margin-top: var(--sp-4)">{{ brand.text.offline_title }}</h1>
|
||||
<p class="empty__text" style="margin: var(--sp-3) auto var(--sp-5)">
|
||||
The Road goes ever on and on — but not without a connection.
|
||||
{{ brand.text.offline_line }}
|
||||
</p>
|
||||
<p class="text-sm muted" style="margin-bottom: var(--sp-5)">
|
||||
LLeMbas answers from your server, so there is nothing to read until it can
|
||||
{{ brand.name }} answers from your server, so there is nothing to read until it can
|
||||
be reached again.
|
||||
</p>
|
||||
<button class="btn btn--primary" type="button" onclick="window.location.reload()">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% from "_macros.html" import icon, brand, model_avatar %}
|
||||
{% from "_macros.html" import icon, brandlink, model_avatar %}
|
||||
{#
|
||||
Sidebar: brand, new chat, pinned models, the folder tree, then unfiled chats.
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#}
|
||||
<aside class="sidebar" id="sidebar">
|
||||
<div class="sidebar__header">
|
||||
{{ brand(uid="side") }}
|
||||
{{ brandlink(uid="side") }}
|
||||
</div>
|
||||
|
||||
{% include "partials/_sidebar_actions.html" %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "reports" %}
|
||||
|
||||
{% block title %}{{ report.title }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ report.title }} - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ report.title }}{% endblock %}
|
||||
{% block actions %}
|
||||
<a class="btn btn--sm" href="/reports">{{ icon("chevron-left", "icon--sm") }} All reports</a>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "reports" %}
|
||||
|
||||
{% block title %}Reports - LLeMbas{% endblock %}
|
||||
{% block title %}Reports - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Reports{% endblock %}
|
||||
|
||||
{% block reports_content %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "scheduled" %}
|
||||
|
||||
{% block title %}{{ schedule.title }} - LLeMbas{% endblock %}
|
||||
{% block title %}{{ schedule.title }} - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}{{ schedule.title }}{% endblock %}
|
||||
{% block actions %}
|
||||
<a class="btn btn--sm" href="/chat/{{ schedule.chat_id }}">Open its chat</a>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "scheduled" %}
|
||||
|
||||
{% block title %}Scheduled - LLeMbas{% endblock %}
|
||||
{% block title %}Scheduled - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}Scheduled{% endblock %}
|
||||
{% block actions %}
|
||||
<a class="btn btn--primary btn--sm" href="/scheduled/new">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "scheduled" %}
|
||||
|
||||
{% block title %}New scheduled task - LLeMbas{% endblock %}
|
||||
{% block title %}New scheduled task - {{ brand.name }}{% endblock %}
|
||||
{% block heading %}What do you want to schedule?{% endblock %}
|
||||
{% block actions %}
|
||||
<a class="btn btn--sm" href="/scheduled">Cancel</a>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "_macros.html" import icon, model_avatar %}
|
||||
|
||||
{% block title %}Your settings - LLeMbas{% endblock %}
|
||||
{% block title %}Your settings - {{ brand.name }}{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', path='css/chat.css') }}">
|
||||
@@ -167,13 +167,20 @@
|
||||
<p class="card__lede">
|
||||
Saved to this browser and to your account, so it follows you.
|
||||
</p>
|
||||
{#
|
||||
A loop rather than two buttons, because an administrator can
|
||||
define more. The names come from the branding snapshot, so a
|
||||
theme renamed on Customization is renamed here without this
|
||||
template knowing there was ever a fixed pair.
|
||||
#}
|
||||
<div class="btn-row">
|
||||
<button class="btn" type="button" onclick="window.lembas.applyTheme('moria')">
|
||||
{{ icon("moon", "icon--sm") }} Moria — dark
|
||||
</button>
|
||||
<button class="btn" type="button" onclick="window.lembas.applyTheme('shire')">
|
||||
{{ icon("sun", "icon--sm") }} Shire — light
|
||||
{% for entry in brand.themes %}
|
||||
<button class="btn" type="button"
|
||||
onclick="window.lembas.applyTheme('{{ entry.id }}')">
|
||||
{{ icon("moon" if entry.scheme == "dark" else "sun", "icon--sm") }}
|
||||
{{ entry.label }} — {{ entry.scheme }}
|
||||
</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -68,16 +68,47 @@ templates.env.globals["tool_icon"] = tool_labels.icon_for
|
||||
templates.env.globals["message_steps"] = steps_service.for_message
|
||||
|
||||
|
||||
class _Brand:
|
||||
"""Whose instance this is, as a Jinja global.
|
||||
|
||||
A **global** and not a context value, because `render()` has no database
|
||||
session and four render paths never reach it at all -- the login page, the
|
||||
error pages, the offline page and the SSE fragments. Threading it through
|
||||
every one of those would still leave the ones that bypass `render()`.
|
||||
|
||||
A proxy rather than the snapshot itself, because a global is bound once at
|
||||
import and the snapshot changes when an administrator saves. Every attribute
|
||||
goes through `branding.snapshot()`, which is a process-level cache: one
|
||||
query per process, and one after each save.
|
||||
"""
|
||||
|
||||
def __getattr__(self, name: str):
|
||||
from lembas.services import branding
|
||||
|
||||
return getattr(branding.snapshot(), name)
|
||||
|
||||
|
||||
templates.env.globals["brand"] = _Brand()
|
||||
|
||||
|
||||
def resolve_theme(user: User | None) -> str:
|
||||
"""Theme to render with on the server.
|
||||
|
||||
Only ever a first guess: the inline script in base.html corrects it from
|
||||
localStorage before first paint. Getting it close server-side is what stops
|
||||
a signed-in user seeing a flash of the wrong theme on every navigation.
|
||||
|
||||
Validated against the themes that actually exist rather than against a
|
||||
hard-coded pair, or a custom theme would be stored on the account, refused
|
||||
here, and rendered as Moria on every page load until localStorage corrected
|
||||
it -- a flash on every navigation, which is what this function exists to
|
||||
prevent.
|
||||
"""
|
||||
from lembas.services import branding
|
||||
|
||||
if user is not None:
|
||||
chosen = (user.settings_json or {}).get("theme")
|
||||
if chosen in ("moria", "shire"):
|
||||
if chosen in branding.snapshot().theme_ids:
|
||||
return chosen
|
||||
return settings.default_theme
|
||||
|
||||
|
||||
Reference in New Issue
Block a user