2023-01-18 15:04:12 +00:00
|
|
|
package theme
|
|
|
|
|
|
|
|
import (
|
2023-02-08 15:49:48 +00:00
|
|
|
"github.com/fthvgb1/wp-go/internal/theme/common"
|
2023-01-18 15:04:12 +00:00
|
|
|
)
|
|
|
|
|
2023-02-08 15:49:48 +00:00
|
|
|
var themeMap = map[string]func(handle common.Handle){}
|
2023-01-18 15:04:12 +00:00
|
|
|
|
2023-02-08 15:49:48 +00:00
|
|
|
func addThemeHookFunc(name string, fn func(handle common.Handle)) {
|
2023-01-18 15:04:12 +00:00
|
|
|
if _, ok := themeMap[name]; ok {
|
|
|
|
panic("exists same name theme")
|
|
|
|
}
|
|
|
|
themeMap[name] = fn
|
|
|
|
}
|
|
|
|
|
2023-02-08 15:49:48 +00:00
|
|
|
func Hook(themeName string, handle common.Handle) {
|
2023-01-18 15:04:12 +00:00
|
|
|
fn, ok := themeMap[themeName]
|
|
|
|
if ok && fn != nil {
|
2023-02-08 15:49:48 +00:00
|
|
|
fn(handle)
|
2023-01-18 15:04:12 +00:00
|
|
|
return
|
|
|
|
}
|
2023-02-08 15:49:48 +00:00
|
|
|
/*if _, ok := plugins.IndexSceneMap[scene]; ok {
|
2023-01-18 15:04:12 +00:00
|
|
|
p, ok := h["pagination"]
|
|
|
|
if ok {
|
|
|
|
pp, ok := p.(pagination.ParsePagination)
|
|
|
|
if ok {
|
|
|
|
h["pagination"] = pagination.Paginate(plugins.TwentyFifteenPagination(), pp)
|
|
|
|
}
|
|
|
|
}
|
2023-01-21 13:13:33 +00:00
|
|
|
c.HTML(code, "twentyfifteen/posts/index.gohtml", h)
|
2023-01-18 15:04:12 +00:00
|
|
|
return
|
2023-01-21 13:13:33 +00:00
|
|
|
} else if scene == plugins.Detail {
|
2023-01-26 16:07:42 +00:00
|
|
|
h["comments"] = plugins.FormatComments(c, plugins.CommentRender(), h["comments"].([]models.Comments), h["maxDep"].(int))
|
2023-01-21 13:13:33 +00:00
|
|
|
c.HTML(code, "twentyfifteen/posts/detail.gohtml", h)
|
2023-01-18 15:04:12 +00:00
|
|
|
return
|
|
|
|
}
|
2023-02-08 15:49:48 +00:00
|
|
|
logs.ErrPrintln(errors.New("what happening"), " how reached here", themeName, code, h, scene, status)*/
|
2023-01-18 15:04:12 +00:00
|
|
|
}
|