aggiunto e testato quasar apps

This commit is contained in:
fabio
2026-03-01 20:42:27 +01:00
parent cdcacadb5f
commit 66a3cc7cdb
73 changed files with 1559 additions and 389 deletions

View File

@@ -1,49 +1,27 @@
package controllers
import (
"bytes"
"html/template"
"path/filepath"
"github.com/gofiber/fiber/v2"
)
type AdminController struct{}
type AdminController struct {
spaDir string
}
func NewAdminController() *AdminController {
return &AdminController{}
func NewAdminController(spaDir string) *AdminController {
return &AdminController{spaDir: spaDir}
}
func (ac *AdminController) Dashboard(c *fiber.Ctx) error {
return renderAdminPage(c, "Admin")
return c.SendFile(filepath.Join(ac.spaDir, "index.html"))
}
func renderAdminPage(c *fiber.Ctx, title string) error {
viewData := map[string]any{
"Title": title,
"NavSection": "admin",
}
for k, v := range localsTemplateData(c) {
viewData[k] = v
}
files := []string{
"web/templates/layout.html",
"web/templates/public/_navbar.html",
"web/templates/partials/language_dropdown.html",
"web/templates/public/_flash.html",
"web/templates/admin/admin.html",
}
tmpl, err := template.ParseFiles(files...)
if err != nil {
return err
}
var out bytes.Buffer
if err := tmpl.ExecuteTemplate(&out, "layout.html", viewData); err != nil {
return err
}
c.Type("html", "utf-8")
return c.Send(out.Bytes())
func (ac *AdminController) Fallback(c *fiber.Ctx) error {
return c.SendFile(filepath.Join(ac.spaDir, "index.html"))
}
func (ac *AdminController) Favicon(c *fiber.Ctx) error {
return c.SendFile(filepath.Join(ac.spaDir, "favicon.ico"))
}