diff --git a/framework/h/state.go b/framework/h/state.go deleted file mode 100644 index 6059b7b..0000000 --- a/framework/h/state.go +++ /dev/null @@ -1,35 +0,0 @@ -package h - -import ( - "fmt" - "github.com/gofiber/fiber/v2" - "mhtml/database" -) - -func SessionSet(ctx *fiber.Ctx, key string, value string) error { - sessionId := getSessionId(ctx) - if sessionId == "" { - return nil - } - return database.HSet(fmt.Sprintf("session:%s", sessionId), key, value) -} - -func SessionIncr(ctx *fiber.Ctx, key string) int64 { - sessionId := getSessionId(ctx) - if sessionId == "" { - return 0 - } - return database.HIncr(fmt.Sprintf("session:%s", sessionId), key) -} - -func SessionGet[T any](ctx *fiber.Ctx, key string) *T { - sessionId := getSessionId(ctx) - if sessionId == "" { - return nil - } - return database.HGet[T](fmt.Sprintf("session:%s", sessionId), key) -} - -func getSessionId(ctx *fiber.Ctx) string { - return ctx.Cookies("mhtml-session") -} diff --git a/starter-template/features/patient/patient-service.go b/starter-template/features/patient/patient-service.go index d3737ce..293ff5a 100644 --- a/starter-template/features/patient/patient-service.go +++ b/starter-template/features/patient/patient-service.go @@ -4,7 +4,7 @@ import ( "errors" "github.com/gofiber/fiber/v2" "github.com/google/uuid" - "mhtml/database" + "github.com/maddalax/mhtml/starter-template/database" "time" ) diff --git a/starter-template/news/posts.go b/starter-template/news/posts.go index f44b757..73a1988 100644 --- a/starter-template/news/posts.go +++ b/starter-template/news/posts.go @@ -2,7 +2,7 @@ package news import ( "fmt" - "mhtml/httpjson" + "github.com/maddalax/mhtml/framework/util/httpjson" "sync" ) diff --git a/starter-template/pages/generated.go b/starter-template/pages/generated.go index f7c56d7..ae7d961 100644 --- a/starter-template/pages/generated.go +++ b/starter-template/pages/generated.go @@ -1,8 +1,10 @@ // Package pages THIS FILE IS GENERATED. DO NOT EDIT. package pages -import "github.com/gofiber/fiber/v2" -import "mhtml/h" +import ( + "github.com/gofiber/fiber/v2" + "github.com/maddalax/mhtml/framework/h" +) func RegisterPages(f *fiber.App) { f.Get("/", func(ctx *fiber.Ctx) error { diff --git a/starter-template/pages/index.go b/starter-template/pages/index.go index cbb2ebb..b6e7ccc 100644 --- a/starter-template/pages/index.go +++ b/starter-template/pages/index.go @@ -3,7 +3,7 @@ package pages import ( "fmt" "github.com/gofiber/fiber/v2" - "mhtml/h" + "github.com/maddalax/mhtml/framework/h" "os" "time" ) diff --git a/starter-template/pages/news.$id.go b/starter-template/pages/news.$id.go index 650716c..e9691dc 100644 --- a/starter-template/pages/news.$id.go +++ b/starter-template/pages/news.$id.go @@ -3,7 +3,7 @@ package pages import ( "fmt" "github.com/gofiber/fiber/v2" - "mhtml/h" + "github.com/maddalax/mhtml/framework/h" ) func Test(ctx *fiber.Ctx) *h.Page { diff --git a/starter-template/pages/news.index.go b/starter-template/pages/news.index.go index 740d6d0..b29de59 100644 --- a/starter-template/pages/news.index.go +++ b/starter-template/pages/news.index.go @@ -2,9 +2,9 @@ package pages import ( "github.com/gofiber/fiber/v2" - "mhtml/h" - "mhtml/pages/base" - "mhtml/partials" + "github.com/maddalax/mhtml/framework/h" + "github.com/maddalax/mhtml/starter-template/pages/base" + "github.com/maddalax/mhtml/starter-template/partials" ) func ListPage(ctx *fiber.Ctx) *h.Page { diff --git a/starter-template/partials/button.go b/starter-template/partials/button.go index f0a7512..269d34e 100644 --- a/starter-template/partials/button.go +++ b/starter-template/partials/button.go @@ -1,9 +1,6 @@ package partials -import ( - "mhtml/h" - "mhtml/ui" -) +import "github.com/maddalax/mhtml/framework/h" func OpenSheetButton(open bool, children ...h.Renderable) h.Renderable { if open { diff --git a/starter-template/partials/load/generated.go b/starter-template/partials/load/generated.go index cfdfe1a..aa6c31e 100644 --- a/starter-template/partials/load/generated.go +++ b/starter-template/partials/load/generated.go @@ -1,11 +1,13 @@ // Package partials THIS FILE IS GENERATED. DO NOT EDIT. package load -import "mhtml/h" -import "github.com/gofiber/fiber/v2" -import "mhtml/partials" -import "mhtml/partials/patient" -import "mhtml/partials/sheet" +import ( + "github.com/gofiber/fiber/v2" + "github.com/maddalax/mhtml/framework/h" + "github.com/maddalax/mhtml/starter-template/partials" + "github.com/maddalax/mhtml/starter-template/partials/patient" + "github.com/maddalax/mhtml/starter-template/partials/sheet" +) func GetPartialFromContext(ctx *fiber.Ctx) *h.Partial { path := ctx.Path() diff --git a/starter-template/partials/load/register.go b/starter-template/partials/load/register.go index dbef714..4732011 100644 --- a/starter-template/partials/load/register.go +++ b/starter-template/partials/load/register.go @@ -2,7 +2,7 @@ package load import ( "github.com/gofiber/fiber/v2" - "mhtml/h" + "github.com/maddalax/mhtml/framework/h" ) func RegisterPartials(f *fiber.App) { diff --git a/starter-template/partials/nav.go b/starter-template/partials/nav.go index 2c0fd79..6dffde6 100644 --- a/starter-template/partials/nav.go +++ b/starter-template/partials/nav.go @@ -1,6 +1,6 @@ package partials -import "mhtml/h" +import "github.com/maddalax/mhtml/framework/h" type Link struct { Name string diff --git a/starter-template/partials/news.go b/starter-template/partials/news.go index 2dc5a3b..59af725 100644 --- a/starter-template/partials/news.go +++ b/starter-template/partials/news.go @@ -3,9 +3,8 @@ package partials import ( "fmt" "github.com/gofiber/fiber/v2" - "mhtml/h" - "mhtml/news" - "mhtml/ui" + "github.com/maddalax/mhtml/framework/h" + "github.com/maddalax/mhtml/starter-template/news" ) func NewsSheet(ctx *fiber.Ctx) *h.Partial { diff --git a/starter-template/partials/patient/create.go b/starter-template/partials/patient/create.go index 9a6f4f4..6e89bd7 100644 --- a/starter-template/partials/patient/create.go +++ b/starter-template/partials/patient/create.go @@ -2,9 +2,9 @@ package patient import ( "github.com/gofiber/fiber/v2" - "mhtml/features/patient" - "mhtml/h" - "mhtml/partials/sheet" + "github.com/maddalax/mhtml/framework/h" + "github.com/maddalax/mhtml/starter-template/features/patient" + "github.com/maddalax/mhtml/starter-template/partials/sheet" ) func Create(ctx *fiber.Ctx) *h.Partial { diff --git a/starter-template/partials/patient/patient.go b/starter-template/partials/patient/patient.go index 547fef9..1e858a3 100644 --- a/starter-template/partials/patient/patient.go +++ b/starter-template/partials/patient/patient.go @@ -2,10 +2,9 @@ package patient import ( "github.com/gofiber/fiber/v2" - "mhtml/features/patient" - "mhtml/h" - "mhtml/partials/sheet" - "mhtml/ui" + "github.com/maddalax/mhtml/framework/h" + "github.com/maddalax/mhtml/starter-template/features/patient" + "github.com/maddalax/mhtml/starter-template/partials/sheet" "strings" ) diff --git a/starter-template/partials/sheet/sheet.go b/starter-template/partials/sheet/sheet.go index 2d52bf7..1a27b3e 100644 --- a/starter-template/partials/sheet/sheet.go +++ b/starter-template/partials/sheet/sheet.go @@ -3,7 +3,7 @@ package sheet import ( "fmt" "github.com/gofiber/fiber/v2" - "mhtml/h" + "github.com/maddalax/mhtml/framework/h" ) type Props struct {