New /prompts section extends the existing database (new Prompt model,
same SQLite file) and mirrors the Links experience: add a prompt, get
it auto-categorized and tagged by AI, filter by category, full-text
search, sort, edit, or have the AI re-categorize it. A header nav
switch ("Links" / "Prompts") toggles between the two collections; the
shared topbar/menu markup was factored into _topbar.html and
_topbar_actions.html so both pages (and settings) stay in sync.
Each prompt card has a dedicated copy-to-clipboard icon next to
edit/delete, so a stored prompt can be reused immediately. Copying
uses the raw markdown source (not the rendered HTML) so structure
survives when pasted into another AI tool. The copy handler tries the
async Clipboard API first and falls back to a hidden-textarea +
execCommand('copy') for plain-http/non-secure contexts, with clear
success/failure icon feedback either way.
Prompt content supports Markdown and is rendered server-side
(app/mdrender.py) for the card preview. Since this is user-supplied
HTML-adjacent content, rendering goes through two defenses: the raw
text is escaped (only '<' and '&', not '>', so blockquotes keep
working) before conversion so no raw tag can survive, and the
resulting HTML is passed through bleach with a tag/attribute/protocol
allowlist so Markdown-generated links can't carry a javascript: URL.
Verified against raw <script>, <img onerror>, and javascript: link
payloads. The edit form always shows the raw Markdown source, never
the rendered HTML.
Also bumps the default APP_VERSION (shown in the footer) from 1.0.0
to 2.0.0 to mark this feature addition.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
56 lines
2.3 KiB
HTML
56 lines
2.3 KiB
HTML
{% import "_icons.html" as icons %}
|
|
<div class="panel link-card" id="prompt-{{ prompt.id }}">
|
|
<form hx-put="/prompts/{{ prompt.id }}" hx-target="#prompt-{{ prompt.id }}" hx-swap="outerHTML"
|
|
hx-disabled-elt="button">
|
|
<div class="muted" style="font-size:.75rem; margin:0 0 10px;">
|
|
{{ icons.clock(size=13) }} hinzugefügt am {{ prompt.created_at | datum }}
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label>Titel</label>
|
|
<input type="text" name="title" value="{{ prompt.title }}">
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label>Prompt-Text</label>
|
|
<textarea name="content" rows="6" style="width:100%; background:var(--panel2); border:1px solid var(--border); color:var(--text); border-radius:8px; padding:10px 12px; font-size:.95rem; font-family:inherit;">{{ prompt.content }}</textarea>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label>Kategorie</label>
|
|
<input type="text" name="category" value="{{ prompt.category }}"
|
|
list="prompt-cats-{{ prompt.id }}" placeholder="wählen oder neu eingeben"
|
|
autocomplete="off">
|
|
<datalist id="prompt-cats-{{ prompt.id }}">
|
|
{% for name in all_categories %}<option value="{{ name }}"></option>{% endfor %}
|
|
</datalist>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label>Tags (mit Komma getrennt)</label>
|
|
<input type="text" name="tags" value="{{ prompt.tag_list | join(', ') }}">
|
|
</div>
|
|
|
|
<div style="display:flex; justify-content:space-between; gap:8px; margin-top:4px; flex-wrap:wrap;">
|
|
<div style="display:flex; gap:8px;">
|
|
<button type="submit">Speichern</button>
|
|
<button type="button" class="ghost"
|
|
hx-get="/prompts/{{ prompt.id }}/view"
|
|
hx-target="#prompt-{{ prompt.id }}"
|
|
hx-swap="outerHTML">Abbrechen</button>
|
|
</div>
|
|
{% if ai_enabled %}
|
|
<button type="button" class="ghost"
|
|
hx-post="/prompts/{{ prompt.id }}/reanalyze"
|
|
hx-target="#prompt-{{ prompt.id }}"
|
|
hx-swap="outerHTML"
|
|
hx-disabled-elt="this"
|
|
hx-confirm="Prompt erneut von der KI kategorisieren lassen? Bestehende Angaben werden dabei ersetzt.">
|
|
<span class="htmx-indicator icon-spin">{{ icons.spinner(size=14) }}</span>
|
|
{{ icons.sparkles(size=14) }} KI neu kategorisieren lassen
|
|
</button>
|
|
{% endif %}
|
|
</div>
|
|
</form>
|
|
</div>
|