vienalatina/apps/board/templates/brand_form.html
Pablo Volenski 81d9fae4a9
Identidad, tipografías, y tres herramientas de administración
The second half of the superadministrator's job: not just who may do things, but
what they get to do that nobody else does.

**Identidad** is everything that used to be frozen in config.yaml — the name and
the one-line tagline in all three languages, the association's accounts
elsewhere, a public email, a city and street, a share picture and the footer
line. It commits data/site.yaml the way Marca commits data/brand.yaml.

Hugo cannot have config.yaml overridden by a data file, so the name and tagline
are read through two new partials that prefer the data file and fall back to the
config; every template showing either calls one, so they cannot drift. A site
with no data/site.yaml builds byte-for-byte what it built before — asserted by
building both ways and diffing with the stylesheet fingerprint normalised.

The contact fields are not decoration: they become ContactPoint and
PostalAddress in the Organization schema, which is what puts an association in a
local result rather than only a web one, and the social links become sameAs,
which is how an engine knows an Instagram account and this site are one body.

**Marca** grows a typeface and a roundness. Four system stacks — nothing
downloaded, which is deliberate and a GDPR matter — or an uploaded .woff2,
sniffed by its wOF2 signature, capped at 400 KB, named ahead of the old stack so
a font that fails to load leaves a readable site. The fold-out warning covers
missing accented glyphs, file size, synthesised bold, and licensing: a font is
software, a desktop licence is not a webfont licence, and that liability follows
the platform to every organisation it is installed for. SIL OFL and Apache-2.0
are named, with seven places to find them.

**Three tools.** Estado del sistema exercises the content token against the
repository rather than checking it is non-empty — "present" was never the
problem, a wrong scope broke publishing for three phases while looking fine —
and reports mail, backups, disk and every documented setting the container does
not have. It changes nothing on purpose. Registro de actividad records the dozen
acts that change who can do what; the actor is cleared and not cascaded on
erasure, and log() never raises, because an administrator who could not be
appointed because the note about it could not be saved is worse than a gap in
the notes. Biblioteca de medios lists every picture with the posts that use it
and, finally, shows the orphans — a picture whose post was deleted has stayed in
the repository, deployed and unreferenced, for the life of this site with no way
to see one.

Two bugs found by looking at the rendered pages rather than at the tests:

**Gestión had disappeared from the superadministrator's own navigation.**
base.html asked `g.member.role in ('owner', 'admin')`, right until a role
appeared above both. 622 tests passed while it was broken, because every one of
them signed in as an admin or below. The templates now call the same
`is_at_least` the handlers do, and test_navigation.py covers the tier above
admin — verified by reintroducing the tuple and watching it fail.

And the status screen counted the tombstone as a suspended member.

Migration 8 is plain ADD COLUMNs; `activity` and `site` are new tables, so
CREATE TABLE IF NOT EXISTS covers them with no step at all. The erase guard
caught both the moment they existed, which is that test doing its job.

627 tests pass. Hugo builds clean with the pipeline's flags, both with and
without the two data files.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
2026-10-06 12:18:04 +00:00

254 lines
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{# Gestión → Marca: the colours, the logo and the favicon.
**This page deliberately does not load the generated stylesheet.** Every
other page in the members area does, and the free CSS box below can contain
anything — including `* { display: none }`. If that CSS applied here, the one
screen that can undo it would be the one screen you could not read. So the
block is overridden with nothing and this page is always in the factory
colours. The live preview below is where the admin sees their own.
The consequence is worth stating because it looks like an oversight: the
colours an admin picks do not show on the page where they pick them. #}
{% extends "base.html" %}
{% block title %}Marca{% endblock %}
{% block brand_css %}{% endblock %}
{% block main %}
<div class="feed-head">
<h1>Marca</h1>
<a class="linkish" href="{{ url_for('home.gestion') }}">Volver a Gestión</a>
</div>
<p class="muted">
Los colores, el logotipo y el icono de la pestaña, para las dos mitades del
sitio. El área privada cambia al guardar; vienalatina.com se reconstruye en
un par de minutos.
</p>
{% if state.updated_at and not state.published_at %}
<section class="panel panel--attention">
<div class="panel__head">
<h2>Pendiente de publicar</h2>
</div>
<p class="panel__row">
Lo de aquí está guardado, pero no ha llegado al sitio público: no se pudo
contactar con el servidor de git la última vez.
</p>
<form method="post" action="{{ url_for('brand.publish') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button class="btn" type="submit">Reintentar publicar en el sitio</button>
</form>
</section>
{% endif %}
{% for note in notes %}
<p class="flash flash--error">{{ note }}</p>
{% endfor %}
<form class="card" method="post" enctype="multipart/form-data"
action="{{ url_for('brand.edit') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<h2 class="section-title">Colores</h2>
<p class="muted small">
Seis colores. Los demás —los tonos claros y oscuros del principal— se
calculan a partir de él, para que no haya que acertar con cinco rojos
parecidos. Están en «Avanzado» si los quieres a mano.
</p>
{# A real colour picker, which every current browser draws natively: no
dependency, no script, and it works with a keyboard. The text beside each
one says where that colour shows up, because "--surface-soft" is not a
question an admin can answer. #}
<div class="swatches" data-brand-preview>
{% for name, label, where in simple %}
<div class="swatch">
<label for="token-{{ name }}">{{ label }}</label>
<input id="token-{{ name }}" name="token-{{ name }}" type="color"
data-token="{{ name }}" value="{{ state.tokens[name] }}">
<p class="muted small">{{ where }}</p>
</div>
{% endfor %}
</div>
{# Restyled by the pickers above, through board.js setting the custom
properties on this element. The DOM write is not an inline style
attribute in the HTML, which is why it works under the CSP. #}
<div class="brand-preview" data-brand-preview-target>
<div class="brand-preview__bar">Viena Latina</div>
<div class="brand-preview__card">
<p class="brand-preview__meta">Ana Pérez · hace dos horas</p>
<p>Así se verá una tarjeta del muro con estos colores.</p>
<span class="brand-preview__btn">Un botón</span>
</div>
</div>
<h2 class="section-title">Logotipo</h2>
<p class="muted small">
PNG, JPG o WebP. Aparece en la cabecera de las dos mitades del sitio y es
la imagen que sale al compartir un enlace que no tiene foto propia.
{% if state.logo_name %}Ahora hay uno puesto; si eliges otro, lo reemplaza.{% endif %}
</p>
{% if state.logo_name %}
<p><img class="brand-current"
src="{{ url_for('brand.picture', stored_name=state.logo_name) }}?v={{ state.stamp }}"
alt="El logotipo actual"></p>
{% endif %}
<input id="logo" name="logo" type="file" accept="image/png,image/jpeg,image/webp">
<h2 class="section-title">Icono de la pestaña</h2>
<p class="muted small">
PNG, y cuadrado: 32×32 o 180×180 van bien. Se sube aparte y no se saca del
logotipo — recortar un logotipo ancho a un cuadrado da un trozo de letra.
</p>
{% if state.favicon_name %}
<p><img class="brand-current brand-current--small"
src="{{ url_for('brand.picture', stored_name=state.favicon_name) }}?v={{ state.stamp }}"
alt="El icono actual"></p>
{% endif %}
<input id="favicon" name="favicon" type="file" accept="image/png">
<h2 class="section-title">Tipografía</h2>
<p class="muted small">
Las cuatro primeras ya están en el ordenador de quien lee: no se descarga
nada de ningún sitio. Eso es a propósito — una hoja de estilos que pide una
fuente a Google le cuenta a Google la dirección IP de todo el que entra, y
eso no se puede consentir en nombre de quien visita la página.
</p>
<div class="choices">
{% for key, (label, stack) in typefaces.items() %}
<label class="choice">
<input type="radio" name="typeface" value="{{ key }}"
{{ 'checked' if state.typeface == key }}>
{# The class, not a style attribute: `default-src 'self'` covers
style-src, so an inline style on this label would be dropped and
every option would look identical. The four classes are in
board.css beside the form rules. #}
<span class="face face--{{ key }}">{{ label }}</span>
</label>
{% endfor %}
<label class="choice">
<input type="radio" name="typeface" value="propia"
{{ 'checked' if state.typeface == 'propia' }}>
Propia (subida aquí)
</label>
</div>
{% if state.font_name %}
<p class="muted small">Ya hay una tipografía subida. Si eliges otra, la sustituye.</p>
{% endif %}
<label for="font">Archivo .woff2 <span class="muted small">(sólo para «Propia»)</span></label>
<input id="font" name="font" type="file" accept=".woff2,font/woff2">
{# Closed by default and one line tall, as asked. Everything in it is a way
this goes wrong in practice rather than in theory. #}
<details class="brand-warning">
<summary>Antes de subir una tipografía, lee esto</summary>
<p><strong>Lo que hace una fuente mala.</strong> Una tipografía sin
<span class="mono">ñ á ü ç ã</span> dibuja esas letras con otra distinta, así
que el español y el portugués salen visiblemente remendados — y nadie te
avisa. Un archivo de 2 MB retrasa cada página en un móvil. Una fuente de
titulares puesta a 16px no se lee.</p>
<p><strong>Cómo hacerlo bien.</strong> Sube un solo archivo, el peso normal:
la negrita y la cursiva las fabrica el navegador a partir de él, lo cual
está bien para un sitio con logotipo y mal para textos largos. Subconjunta
la fuente a latín y latín extendido-A. Que no pase de unos 100 KB. Sólo
<span class="mono">.woff2</span>: es el formato de la web, lo entienden
todos los navegadores y es el que este formulario comprueba por su firma,
no por el nombre del archivo. Antes de guardar, mira cómo quedan
<span class="mono">ñ á ü ç ã</span> en la vista previa de arriba.</p>
<p><strong>La licencia, que es lo único de aquí que cuesta dinero.</strong>
Una tipografía es software, y una licencia de escritorio no es una licencia
web: servir desde tu propio servidor una fuente que compraste para el
ordenador suele incumplirla, y esa responsabilidad viaja con la plataforma
a cada organización donde la instales. Busca
<strong>SIL OFL</strong> o <strong>Apache 2.0</strong>: las dos permiten
alojarla uno mismo y redistribuirla.</p>
<p><strong>Dónde buscarlas sin riesgo.</strong>
<a href="https://fonts.google.com/" rel="nofollow noopener">Google Fonts</a>
(descargándolas, no enlazándolas, por lo del párrafo primero),
<a href="https://fontsource.org/" rel="nofollow noopener">Fontsource</a>
(las mismas familias ya empaquetadas en <span class="mono">.woff2</span>),
<a href="https://www.fontsquirrel.com/" rel="nofollow noopener">Font Squirrel</a>,
<a href="https://www.theleagueofmoveabletype.com/" rel="nofollow noopener">The League of Moveable Type</a>,
<a href="https://velvetyne.fr/" rel="nofollow noopener">Velvetyne</a>,
<a href="https://open-foundry.com/" rel="nofollow noopener">Open Foundry</a> y
<a href="https://usemodify.com/" rel="nofollow noopener">Use &amp; Modify</a>.
Comprueba la licencia del archivo que te has descargado, no la de la página
desde la que llegaste a él.</p>
</details>
<h2 class="section-title">Esquinas</h2>
<p class="muted small">
Lo redondeadas que son las tarjetas, los botones y las fotos. Un solo ajuste
para todo: un sitio con tarjetas redondas y botones cuadrados parece dos
sitios.
</p>
<div class="choices">
{% for key, (label, values) in roundness.items() %}
<label class="choice">
<input type="radio" name="roundness" value="{{ key }}"
{{ 'checked' if state.roundness == key }}>
{{ label }}
</label>
{% endfor %}
</div>
<details class="brand-advanced">
<summary>Avanzado</summary>
<p class="muted small">
Para quien sepa CSS. Todo lo de aquí se aplica después de lo de arriba,
así que gana. Si algo sale mal, «Restaurar lo de fábrica» está al final
de esta página y esta página nunca carga este CSS, justamente para que
se pueda llegar a ese botón.
</p>
<h3 class="section-title">Los demás colores</h3>
<p class="muted small">
Déjalos en blanco para que se calculen desde el color principal
({{ derived|join(', ') }}) o queden como están de fábrica.
</p>
<div class="swatches">
{% for name in advanced %}
<div class="swatch">
<label for="token-{{ name }}"><span class="mono">--{{ name }}</span></label>
<input id="token-{{ name }}" name="token-{{ name }}" type="text"
value="{{ state.stored.get(name, '') }}"
placeholder="{{ state.tokens[name] }}"
pattern="^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$">
</div>
{% endfor %}
</div>
<h3 class="section-title">CSS propio</h3>
<p class="muted small">
Se añade al final de la hoja de estilos, en las dos mitades del sitio.
No puede contener «&lt;» ni «&gt;».
</p>
<textarea id="custom_css" name="custom_css" rows="10" class="mono"
placeholder=".site-bar__logo { max-height: 48px; }">{{ state.custom_css }}</textarea>
</details>
<button class="btn" type="submit">Guardar</button>
</form>
{% if state.customised %}
<form class="card" method="post" action="{{ url_for('brand.restore') }}"
data-confirm="Se vuelve a los colores originales y se borran el logotipo y el icono. ¿Seguro?">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<h2 class="section-title">Restaurar lo de fábrica</h2>
<p class="muted small">
Deja los colores como estaban al principio y quita el logotipo y el icono.
Esto funciona siempre, incluso si el CSS propio ha roto el resto del sitio.
</p>
<button class="btn btn--danger" type="submit">Restaurar lo de fábrica</button>
</form>
{% endif %}
{% endblock %}