aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-03-07 17:15:38 +0530
committerBobby <[email protected]>2026-03-07 17:15:38 +0530
commit57df54999e778887e66775481dab46191b46d0b6 (patch)
tree2009abf151fd34923c7a3ae760d08c3c6bbe72e0 /utils
parent6dd57549df7b6679a1aa9888f4d59edaaec5b3f9 (diff)
downloaddove-57df54999e778887e66775481dab46191b46d0b6.tar.xz
dove-57df54999e778887e66775481dab46191b46d0b6.zip
Refactor dashboard templates and enhance URL handling
- Added `variableName` to `urlNode` struct for improved variable handling in URL tags. - Updated `url` function to support variable assignment using the `as` keyword. - Removed deprecated `dashboard.django` template and replaced it with a new layout structure. - Introduced partial templates for header and sidebar to streamline dashboard layout. - Created new HTMX templates for mailboxes, mailbox, overview, and users to enhance dynamic content loading. - Implemented navigation JavaScript to manage active link states in the sidebar. - Refactored render functions to resolve template paths based on HTMX requests. - Updated constants for request key naming consistency.
Diffstat (limited to 'utils')
-rw-r--r--utils/meta/constants.go2
-rw-r--r--utils/shortcuts/functions.go13
-rw-r--r--utils/shortcuts/render.go2
3 files changed, 15 insertions, 2 deletions
diff --git a/utils/meta/constants.go b/utils/meta/constants.go
index 3f2ce68..0138884 100644
--- a/utils/meta/constants.go
+++ b/utils/meta/constants.go
@@ -2,5 +2,5 @@ package meta
const (
LOG_PREFIX = "Meta"
- REQUEST_KEY = "__request"
+ REQUEST_KEY = "Request"
)
diff --git a/utils/shortcuts/functions.go b/utils/shortcuts/functions.go
index df00dcf..3e76a9a 100644
--- a/utils/shortcuts/functions.go
+++ b/utils/shortcuts/functions.go
@@ -1,7 +1,9 @@
package shortcuts
import (
+ "fmt"
"maps"
+ "path"
"reflect"
"strings"
@@ -11,6 +13,17 @@ import (
"github.com/gofiber/fiber/v2"
)
+func resolveTemplate(context *fiber.Ctx, templateName string) string {
+ switch {
+ case context.Get("HX-Request") == "true" && context.Get("HX-Boosted") != "true":
+ directory := path.Dir(templateName)
+ filename := path.Base(templateName)
+ return fmt.Sprintf("%s/htmx/%s.htmx", directory, filename)
+ default:
+ return templateName
+ }
+}
+
func mergeContextValues(context *fiber.Ctx, targetMap fiber.Map) {
context.Context().VisitUserValues(func(key []byte, value any) {
targetMap[string(key)] = value
diff --git a/utils/shortcuts/render.go b/utils/shortcuts/render.go
index 29c7a8f..e91ccfa 100644
--- a/utils/shortcuts/render.go
+++ b/utils/shortcuts/render.go
@@ -13,7 +13,7 @@ func Render(context *fiber.Ctx, templateName string, data any) error {
}
}
- return context.Render(templateName, templateData)
+ return context.Render(resolveTemplate(context, templateName), templateData)
}
func RenderWithStatus(context *fiber.Ctx, templateName string, data any, statusCode int) error {