{% extends "admin/base.html" %} {% from "admin/_image_picker_field.html" import image_picker_field %} {% set is_edit = post is not none %} {# In working-copy mode `post` is a PostWorkingCopy, so `post.id` is the WC's id, NOT a live post id. `working_copy_post_id` is the live post id; use it for every live-post route (form action, backlinks, etc.). #} {% set is_wc = is_working_copy | default(false) %} {% block title %}{{ 'Edit' if is_edit else 'New' }} post · bragi admin{% endblock %} {% block content %}

{{ 'Edit post' if is_edit else 'New post' }}

{% if is_edit and not is_wc %}

Backlinks »

{% endif %} {% if is_wc %} {% endif %}
{% include "admin/_tiptap_editor.html" %}
{# A working copy carries no status: the live row keeps its PUBLISHED status through promote. Hide the control entirely in WC mode so the save can't accidentally carry a status field. #} {% if not is_wc %}
{% endif %} {# Show the pin controls on a published live post, AND always in WC mode: a working copy is forked from a published post, so its pin state is meaningful and must stay editable (otherwise a WC save with the controls hidden would silently submit no pin field and blank the forked pin). #} {% if is_wc or form.get('status') == 'published' %}
Naive UTC. Leave blank for an open-ended pin.
{% endif %}
Comma-separated. New tags are created on save; existing tags are re-used by slug.
{{ image_picker_field( name="featured_image_id", value=form.get("featured_image_id"), attachment=featured_image, thumb_storage_key=featured_image_thumb_key, label="Featured image", picker_url=url_for("attachment_admin.picker"), site_slug=request.view_args["site_slug"], helper="Optional. Used as og:image / twitter:image, the landing-page card thumbnail, and the post-detail hero. Falls back to the site's default featured image when unset." ) }} {# skip_redirect is meaningless for a working copy: a WC save fires no hooks and inserts no 301 (nothing is live). Restricted to live edit. #} {% if is_edit and not is_wc %}
{% endif %} {# On a PUBLISHED post, the live Save is relabelled so the operator sees that it publishes immediately; the staging affordance is a second submit button on the SAME form (HTML forbids nested forms). Drafts edit live as today, so the label stays the plain "Save". #} {% set is_published_live = is_edit and not is_wc and post.status == 'published' %}
{# On a published post, stage the CURRENT form content (the operator's unsaved edits) into a working copy. A second submit button on the SAME form with its own `formaction` carries the typed body/title/ tags/etc. to stage_post; a separate form (illegal to nest) would submit none of it. #} {% if is_published_live %} {% endif %} Cancel
{% if not is_edit %} {% endif %} {% endblock %}