fix: UI overhaul — align all HTMX views with Lumina Design System (46 fixes)
- All 7 pages rewritten: Dashboard, Terminal, Snippets, Keychain, SFTP, Settings, Brief - Apply consistent Lumina glassmorphic theme (rounded-2xl, shadows, borders, tracking) - Fix SVG icons not rendering — return template.HTML instead of string - Fix Alpine x-data scoping: terminal tabs, SFTP modals, snippet tag buttons - Fix dashboard search sending literal ?q=... - Rebuild CSS with all new Tailwind classes (62KB) - Add .air.toml with hot-reload config, docs/PERBAIKANUI.md checklist - Remove unused backup partials
This commit is contained in:
@@ -1,40 +1,88 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"git.tukangketik.id/swanadiva/hostkeeper/v2/internal/model"
|
||||
"git.tukangketik.id/swanadiva/hostkeeper/v2/internal/store"
|
||||
)
|
||||
|
||||
func jsonOrEmpty(v interface{}) string {
|
||||
b, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return "[]"
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func allTags(snippets []model.Snippet) []string {
|
||||
seen := map[string]bool{}
|
||||
var out []string
|
||||
for _, sn := range snippets {
|
||||
for _, t := range sn.Tags {
|
||||
if !seen[t] {
|
||||
seen[t] = true
|
||||
out = append(out, t)
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
var snippetStore = store.NewSnippetStore()
|
||||
|
||||
func Snippets(c *fiber.Ctx) error {
|
||||
if c.Get("HX-Request") != "" {
|
||||
return SnippetGrid(c)
|
||||
}
|
||||
snippets := snippetStore.All()
|
||||
return c.Render("snippets", fiber.Map{
|
||||
"View": "snippets",
|
||||
"Title": "Snippets",
|
||||
"Snippets": snippets,
|
||||
"NavItems": navItems,
|
||||
"View": "snippets",
|
||||
"Title": "Snippets",
|
||||
"Snippets": snippets,
|
||||
"SnippetsJSON": jsonOrEmpty(snippets),
|
||||
"AllTags": allTags(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})
|
||||
collection := c.Query("collection", "")
|
||||
tag := c.Query("tag", "")
|
||||
snippets := snippetStore.Search(q, collection, tag)
|
||||
return c.Render("snippet_grid", fiber.Map{
|
||||
"Snippets": snippets,
|
||||
"SnippetsJSON": jsonOrEmpty(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)
|
||||
description := c.FormValue("description")
|
||||
collection := c.FormValue("collection")
|
||||
tagStr := c.FormValue("tags")
|
||||
var tags []string
|
||||
if tagStr != "" {
|
||||
tags = []string{tagStr}
|
||||
}
|
||||
snippetStore.Add(name, content, language, tags, description, collection)
|
||||
snippets := snippetStore.All()
|
||||
return c.Render("snippet_grid", fiber.Map{"Snippets": snippets})
|
||||
return c.Render("snippet_grid", fiber.Map{
|
||||
"Snippets": snippets,
|
||||
"SnippetsJSON": jsonOrEmpty(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})
|
||||
return c.Render("snippet_grid", fiber.Map{
|
||||
"Snippets": snippets,
|
||||
"SnippetsJSON": jsonOrEmpty(snippets),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user