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>
52 lines
1.7 KiB
HTML
52 lines
1.7 KiB
HTML
{% import "_icons.html" as icons %}
|
|
<div class="panel link-card" id="prompt-{{ prompt.id }}">
|
|
<div class="card-head">
|
|
<span class="card-avatar" style="--h: {{ prompt.category | texthue }};">
|
|
{{ (prompt.category[:1] | upper) or '?' }}
|
|
</span>
|
|
|
|
<div class="card-badges">
|
|
{% if prompt.category %}
|
|
<span class="badge badge-cat">{{ prompt.category }}</span>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="card-actions">
|
|
<button type="button" class="ghost icon-btn"
|
|
title="In die Zwischenablage kopieren"
|
|
onclick="copyPromptContent(this)" data-content="{{ prompt.content }}">{{ icons.copy() }}</button>
|
|
<button class="ghost icon-btn"
|
|
title="Bearbeiten"
|
|
hx-get="/prompts/{{ prompt.id }}/edit"
|
|
hx-target="#prompt-{{ prompt.id }}"
|
|
hx-swap="outerHTML">{{ icons.edit() }}</button>
|
|
<button class="danger icon-btn"
|
|
title="Löschen"
|
|
hx-delete="/prompts/{{ prompt.id }}"
|
|
hx-target="#prompt-{{ prompt.id }}"
|
|
hx-swap="outerHTML"
|
|
hx-confirm="Diesen Prompt wirklich löschen?">{{ icons.trash() }}</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-title">{{ prompt.title or "Prompt" }}</div>
|
|
|
|
<div class="card-summary md-preview">{{ prompt.content | markdown }}</div>
|
|
|
|
<div class="card-spacer"></div>
|
|
|
|
{% if prompt.tag_list %}
|
|
<div class="card-tags">
|
|
{% for tag in prompt.tag_list %}
|
|
<span class="badge badge-tag">#{{ tag }}</span>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="card-foot" style="justify-content:flex-end;">
|
|
<span title="hinzugefügt am {{ prompt.created_at | datum }}">
|
|
{{ icons.clock(size=13) }} {{ prompt.created_at | datum }}
|
|
</span>
|
|
</div>
|
|
</div>
|