2023-02-11 15:51:07 +00:00
|
|
|
package actions
|
|
|
|
|
|
|
|
import (
|
2023-05-04 12:36:17 +00:00
|
|
|
"github.com/fthvgb1/wp-go/app/pkg/constraints"
|
|
|
|
"github.com/fthvgb1/wp-go/app/theme"
|
|
|
|
"github.com/fthvgb1/wp-go/app/theme/wp"
|
2023-02-11 15:51:07 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
2023-04-24 13:51:43 +00:00
|
|
|
func ThemeHook(scene string) func(*gin.Context) {
|
2023-03-17 10:26:08 +00:00
|
|
|
return func(c *gin.Context) {
|
|
|
|
s := scene
|
|
|
|
if scene == constraints.Home {
|
|
|
|
if _, ok := c.GetQuery("s"); ok {
|
|
|
|
s = constraints.Search
|
|
|
|
}
|
|
|
|
}
|
2023-03-09 14:36:41 +00:00
|
|
|
t := theme.GetCurrentTemplateName()
|
2023-03-17 10:26:08 +00:00
|
|
|
h := wp.NewHandle(c, s, t)
|
2023-03-01 05:17:12 +00:00
|
|
|
h.Index = wp.NewIndexHandle(h)
|
|
|
|
h.Detail = wp.NewDetailHandle(h)
|
2023-04-24 13:51:43 +00:00
|
|
|
templ, _ := theme.GetTemplate(t)
|
|
|
|
h.SetTemplate(templ)
|
2023-02-24 11:34:19 +00:00
|
|
|
theme.Hook(t, h)
|
2023-02-11 15:51:07 +00:00
|
|
|
}
|
|
|
|
}
|