feat: Sprint 2 — snippets + keychain CRUD, standalone templates, clipboard/utils JS

This commit is contained in:
swanadiva
2026-07-07 13:26:56 +07:00
parent 8cfdec3980
commit c4b0d7d8c0
17 changed files with 691 additions and 112 deletions
+40
View File
@@ -0,0 +1,40 @@
package handler
import (
"github.com/gofiber/fiber/v2"
"git.tukangketik.id/swanadiva/hostkeeper/v2/internal/model"
)
var snippetStore = model.NewSnippetStore()
func Snippets(c *fiber.Ctx) error {
snippets := snippetStore.All()
return c.Render("snippets", fiber.Map{
"View": "snippets",
"Title": "Snippets",
"Snippets": snippets,
"NavItems": navItems,
})
}
func SnippetGrid(c *fiber.Ctx) error {
q := c.Query("q", "")
snippets := snippetStore.Search(q)
return c.Render("snippet_grid", fiber.Map{"Snippets": snippets})
}
func CreateSnippet(c *fiber.Ctx) error {
name := c.FormValue("name")
content := c.FormValue("content")
language := c.FormValue("language")
snippetStore.Add(name, content, language, nil)
snippets := snippetStore.All()
return c.Render("snippet_grid", fiber.Map{"Snippets": snippets})
}
func DeleteSnippet(c *fiber.Ctx) error {
id := c.Params("id")
snippetStore.Delete(id)
snippets := snippetStore.All()
return c.Render("snippet_grid", fiber.Map{"Snippets": snippets})
}