Add a Prompts library alongside Links, bump to v2.0.0

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>
This commit is contained in:
Erik Thiele
2026-07-30 14:45:30 +02:00
parent 7262aee63d
commit 78c95b522d
18 changed files with 785 additions and 77 deletions

View File

@@ -45,7 +45,15 @@
}
header.topbar .brand { font-weight: 700; font-size: 1.2rem; }
header.topbar .brand span { color: var(--accent-hover); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-info { color: var(--muted); font-size: .9rem; display: flex; gap: 12px; align-items: center; }
.mode-switch { display: flex; gap: 2px; background: var(--panel2); border-radius: 8px; padding: 2px; }
.mode-tab {
display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
border-radius: 6px; font-size: .85rem; color: var(--muted); text-decoration: none;
}
.mode-tab:hover { color: var(--text); text-decoration: none; }
.mode-tab.active { background: var(--accent); color: #fff; }
button, input[type=submit] {
background: var(--accent); color: white; border: none; border-radius: 8px;
padding: 9px 16px; font-size: .95rem; cursor: pointer; font-weight: 500;
@@ -82,9 +90,9 @@
/* Linkliste: bis zu drei Karten pro Zeile, je nach Fensterbreite.
Karten einer Zeile sind gleich hoch; die Zusammenfassung wird
dafür auf drei Zeilen gekürzt. */
#links { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
#links > .panel { margin-bottom: 0; }
#links > #empty-state { grid-column: 1 / -1; }
#links, #prompts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
#links > .panel, #prompts > .panel { margin-bottom: 0; }
#links > #empty-state, #prompts > #empty-state { grid-column: 1 / -1; }
.link-card { display: flex; flex-direction: column; }
.link-card.needs-review { border-color: #ca8a04; }
@@ -121,6 +129,38 @@
display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
overflow: hidden; height: calc(3 * 1.5 * .875rem); flex: none;
}
/* Markdown-Vorschau (Prompts): line-clamp funktioniert nicht zuverlässig
über mehrere Block-Elemente (Überschriften, Listen, Codeblöcke)
hinweg, daher stattdessen feste Höhe + Fade-Ausblendung. */
.card-summary.md-preview {
display: block; -webkit-line-clamp: unset; position: relative;
height: calc(4 * 1.5 * .875rem);
}
.md-preview::after {
content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.6em;
background: linear-gradient(to bottom, transparent, var(--panel));
}
.md-preview > :first-child { margin-top: 0; }
.md-preview > :last-child { margin-bottom: 0; }
.md-preview h1, .md-preview h2, .md-preview h3,
.md-preview h4, .md-preview h5, .md-preview h6 {
font-size: .95rem; margin: 0 0 4px; color: var(--text);
}
.md-preview p { margin: 0 0 6px; }
.md-preview ul, .md-preview ol { margin: 0 0 6px; padding-left: 1.2em; }
.md-preview li { margin-bottom: 2px; }
.md-preview code {
background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: .85em;
}
.md-preview pre {
background: var(--panel2); padding: 8px 10px; border-radius: 8px;
overflow-x: auto; margin: 0 0 6px;
}
.md-preview pre code { background: none; padding: 0; }
.md-preview blockquote {
border-left: 3px solid var(--border); margin: 0 0 6px; padding-left: 10px;
}
.md-preview a { text-decoration: underline; }
.card-spacer { flex: 1 1 auto; }
/* Tags: nur eine Zeile, Rest wird abgeschnitten hält die Karten gleich hoch. */
.card-tags {
@@ -134,8 +174,8 @@
}
.card-domain { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot > span:last-child { flex-shrink: 0; }
@media (min-width: 1000px) { #links { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1500px) { #links { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1000px) { #links, #prompts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1500px) { #links, #prompts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* Auf schmalen Geräten die Seitenleiste über den Inhalt stellen. */
@media (max-width: 800px) {
@@ -169,6 +209,7 @@
.theme-icon-dark, .theme-icon-light { display: inline-flex; }
.icon-warn { color: #eab308; }
.icon-bookmark-active { color: #eab308; }
.icon-copied { color: #22c55e; border-color: #16a34a; }
.input-icon { position: relative; }
.input-icon > .icon {
@@ -255,5 +296,49 @@
}
})();
</script>
<script>
var COPY_ICON_CHECK =
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" ' +
'fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" ' +
'stroke-linejoin="round" class="icon"><polyline points="20 6 9 17 4 12"/></svg>';
function copyPromptContent(btn) {
var text = btn.getAttribute('data-content') || '';
if (!btn.dataset.originalIcon) btn.dataset.originalIcon = btn.innerHTML;
var showResult = function (ok) {
btn.innerHTML = ok ? COPY_ICON_CHECK : btn.dataset.originalIcon;
btn.title = ok ? 'In die Zwischenablage kopiert' : 'Kopieren fehlgeschlagen';
btn.classList.toggle('icon-copied', ok);
setTimeout(function () {
btn.innerHTML = btn.dataset.originalIcon;
btn.title = 'In die Zwischenablage kopieren';
btn.classList.remove('icon-copied');
}, 1500);
};
// Fallback für http (kein sicherer Kontext) oder ältere Browser, in
// denen die asynchrone Clipboard-API nicht verfügbar ist/abgelehnt wird.
var legacyCopy = function () {
var ta = document.createElement('textarea');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
document.body.appendChild(ta);
ta.focus();
ta.select();
var ok = false;
try { ok = document.execCommand('copy'); } catch (e) { ok = false; }
document.body.removeChild(ta);
showResult(ok);
};
if (window.isSecureContext && navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(function () { showResult(true); }, legacyCopy);
} else {
legacyCopy();
}
}
</script>
</body>
</html>