vienalatina/apps/board/templates/content_form.html
Claude c84a996eef
The bar, the share card, the writing box and subpages
**A signed-in member sees the members area from anywhere.** A slim bar above the
public header, with the same five sections /comunidad/ has. Those pages are
files on disk and get cached, so it is drawn in the browser: memberbar.js asks
/comunidad/sesion.json who is reading, and that endpoint is the only thing that
decides — a visitor is told `{"signed_in": false}` and the answer is never
cached. Sign-in also sets vl_sesion=1, a cookie holding one digit that scripts
can read, and without it the script makes no request at all: a stranger reading
one article costs the app nothing. It is a hint, never a credential — the
session cookie stays HttpOnly and signed, and a forged hint earns a reply saying
you are not signed in. Comunidad is now in the public menu in all three
languages, signed in or not.

**The public menu is built from the pages.** It was three names per language in
config.yaml, so a page published through Contenido never appeared on the site at
all and the German and Portuguese menus had to be kept in step by hand. Pages
carry `parent` (another page's basename — the one translate.py already uses to
pair siblings, so it holds in all three languages) and `weight`, both chosen in
the editor, and header.html builds two levels from them. URLs do not change: a
subpage is still /page/<slug>/, only the menu nests, so nothing in the Caddyfile
or the pipeline learns about folders. The dropdown is the theme's own, ported
from WordPress — hover, focus-within, inline on a phone, no script. A parent that
has been deleted is kept and labelled rather than silently dropped on the next
save.

**Sharing and the rest of SEO/GEO.** The groundwork was already here — hreflang,
Open Graph, Twitter card, BlogPosting, llms.txt, robots.txt naming the AI
crawlers — so this closes the gaps. Static pages had *none* of it and shared as
bare links; they now carry WebPage schema and the full set of tags. Both branches
gain og:image with an alt and a twitter:image, falling back to params.defaultImage
(empty until there is a logo, which is the one line to fill in then). The home
page gains Organization with areaServed Wien and a sameAs list; posts and pages
gain BreadcrumbList, and an article's structured data now carries the author's
profile URL. An optional FAQ — `pregunta|respuesta` per line — renders at the
foot of the page and as FAQPage schema, because current guidance for generative
engines puts exactly that shape at the top of what gets quoted, and schema
describing something invisible is what search engines penalise. translate.py
carries both new fields: image_alt joins the translated keys, and faq is
translated half by half so the separator survives.

**The writing boxes.** A markdown toolbar and a Vista previa on every box where
somebody writes prose, opted in with data-markdown. The preview POSTs to
/comunidad/previsualizar and renders with render.to_html — the same function the
board and the site use, so it cannot promise something publishing will not
deliver; a markdown parser in the browser would be a second opinion about what
somebody's text means. Choosing a picture now shows a thumbnail with its name and
size before anything is uploaded, which is the only reason `blob:` joins img-src:
a handle to bytes already in the page, reaching no network.

All of it ours, no dependency added, under a policy that loads scripts from this
origin only. Verified by building the site with Hugo 0.135, the version the
pipeline runs: the nested menu, the page's share tags, the FAQ schema matching
the rendered section, and llms.txt listing the pages.

463 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
2026-10-02 15:21:35 +00:00

131 lines
5.3 KiB
HTML

{% extends "base.html" %}
{% block title %}{{ 'Editar' if item else 'Nuevo' }} {{ meta.singular|lower }}{% endblock %}
{% set f = fields or {} %}
{% block main %}
{% if preview_html %}
<article class="card">
<div class="card__meta"><span class="tag tag--quiet">Vista previa</span></div>
<h1 class="card__title">{{ f.title }}</h1>
<div class="prose">{{ preview_html }}</div>
</article>
{% endif %}
<form class="card" method="post" enctype="multipart/form-data"
action="{{ url_for('content.edit', collection=collection, name=item.name) if item
else url_for('content.new', collection=collection) }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
{% if item %}
<input type="hidden" name="sha" value="{{ item.sha }}">
<input type="hidden" name="name" value="{{ item.name }}">
{% endif %}
{# The byline travels with the document, like the date and the image path.
An edit keeps whoever wrote it; only publishing sets it. #}
{% if f and f.author %}
<input type="hidden" name="author" value="{{ f.author }}">
<input type="hidden" name="author_url" value="{{ f.author_url or '' }}">
{% endif %}
<h1>{{ ('Editar ' ~ meta.singular|lower) if item else meta.new_label }}</h1>
<label for="title">Título</label>
<input id="title" name="title" maxlength="140" required value="{{ f.title or '' }}">
{% if meta.dated %}
<label for="date">Fecha</label>
<input id="date" name="date" type="date" required value="{{ f.date or today }}">
{% endif %}
{% if collection == 'page' %}
{# Where this page sits in the public menu. The menu is built from the pages
themselves, so a page published here appears on the site by itself —
choosing a parent puts it in the submenu under that page instead of on the
top row. The choice is made once and holds in the three languages. #}
<label for="parent">En el menú</label>
{% set names = parents | map(attribute='base') | list %}
<select id="parent" name="parent">
<option value="">En la barra principal</option>
{% if f.parent and f.parent not in names %}
{# The page it hung under has been deleted, or the git server could not be
reached to list them. Either way the relationship is kept and said out
loud, rather than dropped silently by the next save. #}
<option value="{{ f.parent }}" selected>Dentro de «{{ f.parent }}» (no encontrada)</option>
{% endif %}
{% for other in parents %}
<option value="{{ other.base }}" {{ 'selected' if f.parent == other.base }}>
Dentro de «{{ other.title }}»
</option>
{% endfor %}
</select>
<label for="weight">Orden</label>
<input id="weight" name="weight" type="number" min="0" max="999"
value="{{ f.weight or 50 }}">
<p class="muted small">Menor número, más a la izquierda. 50 si da igual.</p>
{% endif %}
{% if collection == 'post' %}
<fieldset class="fieldset">
<legend>Categorías</legend>
{% for category in categories %}
<label class="check">
<input type="checkbox" name="categories" value="{{ category }}"
{{ 'checked' if category in (f.categories or []) }}>
{{ category }}
</label>
{% endfor %}
</fieldset>
<label for="description">Resumen</label>
<textarea id="description" name="description" rows="2">{{ f.description or '' }}</textarea>
<p class="muted small">
Una o dos frases que se entiendan solas: es lo que aparece en los
listados, en WhatsApp al compartir el enlace y lo que citan los
buscadores. Mejor concreta («El sábado 12 en Ottakring») que general.
</p>
<label for="picture">Imagen destacada</label>
{% if f.image %}
<p class="muted small">Actual: <span class="mono">{{ f.image }}</span> — sube otra para reemplazarla.</p>
<input type="hidden" name="image" value="{{ f.image }}">
{% endif %}
<input id="picture" name="picture" type="file" accept="image/*">
<label for="image_alt">Texto alternativo de la imagen</label>
<input id="image_alt" name="image_alt" maxlength="200" value="{{ f.image_alt or '' }}">
<p class="muted small">
Qué se ve en la foto, en una frase. Lo lee quien no puede ver la imagen y
lo leen también los buscadores.
</p>
{% endif %}
<label for="body">Cuerpo</label>
<textarea id="body" data-markdown name="body" rows="18" required
placeholder="Markdown: **negrita**, ## títulos, listas, [enlaces](https://…).">{{ body }}</textarea>
<label for="faq">Preguntas frecuentes <span class="muted small">(opcional)</span></label>
<textarea id="faq" name="faq" rows="5"
placeholder="¿Dónde es?|En la plaza de Ottakring, junto al mercado.">{{ f.faq or '' }}</textarea>
<p class="muted small">
Una por línea, con el formato <span class="mono">pregunta|respuesta</span>.
Se muestran al final de la página y son lo que mejor citan los buscadores
y los asistentes de IA: pregunta concreta, respuesta corta y verificable.
</p>
<label class="check">
<input type="checkbox" name="manual_translation" {{ 'checked' if f.manual_translation }}>
Traducción manual — no generar alemán ni portugués para esto
</label>
<div class="actions">
<button class="btn" type="submit">{{ 'Guardar' if item else 'Publicar' }}</button>
<button class="linkish" type="submit"
formaction="{{ url_for('content.preview', collection=collection) }}">
Vista previa
</button>
<a class="linkish" href="{{ url_for('content.index', collection=collection) }}">Cancelar</a>
</div>
</form>
{% endblock %}