"""HTML views for the prompt library (#428)."""
from __future__ import annotations
import html
from webui.layout import render_page
from webui.prompt_library import PromptEntry, load_prompt_library
def _escape(text: str) -> str:
return html.escape(text, quote=True)
def _render_prompt_card(entry: PromptEntry) -> str:
hash_short = (
f"{_escape(entry.workflow_hash[:12])}"
if entry.workflow_hash
else "n/a"
)
task_mode = (
f"{_escape(entry.task_mode)}"
if entry.task_mode
else "n/a"
)
note = (
f'
{_escape(entry.prompt_text)}'
f'"
f"{note}"
"Short copy/paste task prompts derived from canonical workflows. " "Full policy remains in the cited workflow files — not duplicated here.
" f"{cards}" "" f"{PROMPT_PAGE_SCRIPT}" ) return render_page(title="Prompts", body_html=body) def render_prompt_detail(entry: PromptEntry) -> str: body = ( f"" f"{_render_prompt_card(entry)}" f"{PROMPT_PAGE_SCRIPT}" ) return render_page(title=entry.label, body_html=body)