add template management #14
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_slides#14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
put this in admin section
let users change the prompts
do in markdown editor (like we already have)
Implementation Spec for Issue #14: Add Template Management
Objective
Add a "Templates" section to the Admin tab listing all AI prompt templates, and a new Templates top-level tab with a markdown editor for editing them — following the same editor pattern already used for slides, themes, and instructions.
Requirements
prompts/directory convention)template.list,template.get,template.save,template.resetDefaultlist_templates(),save_template(),reset_template()Files to Modify
crates/hero_slides_lib/src/prompts.rslist_templates(),save_template(),reset_template()functionscrates/hero_slides_lib/src/lib.rscrates/hero_slides_server/src/rpc.rstemplate.list,template.get,template.save,template.resetDefaultRPC handlerscrates/hero_slides_ui/templates/index.htmlcrates/hero_slides_ui/static/js/dashboard.jsImplementation Plan
Step 1: Add template management functions to
hero_slides_libFiles:
prompts.rs,lib.rslist_templates()→ returns list of all template names and default contentsave_template(prompts_dir, name, content)→ writes template to disk (validates name against ALL_TEMPLATES)reset_template(prompts_dir, name)→ restores embedded defaultlib.rsDependencies: none
Step 2: Add RPC handlers for template operations
Files:
rpc.rstemplate.list→ lists all templates with content and default statustemplate.get→ returns template content and default contenttemplate.save→ saves template (validates name)template.resetDefault→ restores default, returns contentDependencies: Step 1
Step 3: Add template UI (Admin section + Templates tab + editor)
Files:
index.html,dashboard.jsDependencies: Step 2
Acceptance Criteria
prompts/directorysave_templatevalidates name against known templates (security)cargo buildsucceeds with no warningsNotes
save_templatevalidates name againstALL_TEMPLATESto prevent arbitrary file writestemplate.listcallsseed_prompts_dirbefore listing to ensure directory existsTest Results
✅ All tests pass. Build compiles with no new warnings.
Implementation Summary
Changes Made
Library (
crates/hero_slides_lib/)src/error.rs— AddedInvalidInput(String)variant toHeroSlidesErrorsrc/prompts.rs— Added 3 new public functions:list_templates(),save_template(),reset_template()src/lib.rs— Re-exported the new functionsServer (
crates/hero_slides_server/)src/rpc.rs— Added 4 RPC handlers:template.list,template.get,template.save,template.resetDefaultUI (
crates/hero_slides_ui/)templates/base.html— Added "Templates" nav tab buttontemplates/index.html— Added AI Prompt Templates section in Admin tab + new Templates tab with split-pane markdown editorstatic/js/dashboard.js— Added template management JS (list, editor, save, reset, live preview, Ctrl+S shortcut)Test Results
Implementation committed:
f859477Browse:
f859477