2023-02-09 12:49:33 +00:00
|
|
|
package twentyfifteen
|
|
|
|
|
|
|
|
import (
|
2023-02-18 15:35:39 +00:00
|
|
|
"embed"
|
|
|
|
"encoding/json"
|
2023-02-10 13:23:30 +00:00
|
|
|
"github.com/fthvgb1/wp-go/internal/pkg/constraints"
|
2023-02-18 15:35:39 +00:00
|
|
|
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
2023-02-09 12:49:33 +00:00
|
|
|
"github.com/fthvgb1/wp-go/internal/theme/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
const ThemeName = "twentyfifteen"
|
|
|
|
|
2023-02-18 15:35:39 +00:00
|
|
|
func Init(fs embed.FS) {
|
|
|
|
b, err := fs.ReadFile("twentyfifteen/themesupport.json")
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err = json.Unmarshal(b, &themesupport)
|
|
|
|
logs.ErrPrintln(err, "解析themesupport失败")
|
|
|
|
bytes, err := fs.ReadFile("twentyfifteen/colorscheme.json")
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err = json.Unmarshal(bytes, &colorscheme)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
logs.ErrPrintln(err, "解析colorscheme失败")
|
|
|
|
}
|
|
|
|
|
2023-02-24 11:43:12 +00:00
|
|
|
var pipe = common.HandlePipe(common.Render, dispatch)
|
2023-02-10 16:32:46 +00:00
|
|
|
|
2023-02-11 15:51:07 +00:00
|
|
|
func Hook(h *common.Handle) {
|
2023-02-24 11:43:12 +00:00
|
|
|
pipe(h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func dispatch(next common.HandleFn[*common.Handle], h *common.Handle) {
|
2023-02-11 15:51:07 +00:00
|
|
|
h.WidgetAreaData()
|
|
|
|
h.GetPassword()
|
2023-02-24 16:56:52 +00:00
|
|
|
h.PushHeadScript(constraints.HeadScript, CalCustomBackGround, colorSchemeCss)
|
2023-02-23 15:42:51 +00:00
|
|
|
h.PushHandleFn(customHeader)
|
|
|
|
switch h.Scene {
|
|
|
|
case constraints.Detail:
|
2023-02-24 11:43:12 +00:00
|
|
|
detail(next, h.Detail)
|
2023-02-23 15:42:51 +00:00
|
|
|
default:
|
2023-02-24 11:43:12 +00:00
|
|
|
index(next, h.Index)
|
2023-02-09 12:49:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-24 11:43:12 +00:00
|
|
|
func index(next common.HandleFn[*common.Handle], i *common.IndexHandle) {
|
2023-02-23 15:42:51 +00:00
|
|
|
i.Indexs()
|
2023-02-09 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
2023-02-24 11:43:12 +00:00
|
|
|
func detail(fn common.HandleFn[*common.Handle], d *common.DetailHandle) {
|
2023-02-23 15:42:51 +00:00
|
|
|
d.Details()
|
2023-02-09 12:49:33 +00:00
|
|
|
}
|