From 9af2a04a97851aa4d436b8cb433ef506cb3d0f1e Mon Sep 17 00:00:00 2001 From: xing Date: Wed, 1 Mar 2023 13:17:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/actions/themehook.go | 8 ++-- internal/theme/fs.go | 2 +- internal/theme/hook.go | 8 ++-- .../theme/twentyfifteen/colorschemecss.go | 12 +++--- .../theme/twentyfifteen/custombackground.go | 4 +- internal/theme/twentyfifteen/customheader.go | 6 +-- internal/theme/twentyfifteen/twentyfifteen.go | 18 ++++----- internal/theme/twentyseventeen/colorscheme.go | 4 +- .../theme/twentyseventeen/customheader.go | 4 +- .../theme/twentyseventeen/twentyseventeen.go | 32 ++++++++-------- internal/theme/{common => wp}/bodyclass.go | 2 +- internal/theme/{common => wp}/customcss.go | 2 +- internal/theme/{common => wp}/customheader.go | 2 +- internal/theme/{common => wp}/customlogo.go | 2 +- internal/theme/{common => wp}/detail.go | 2 +- internal/theme/{common => wp}/index.go | 2 +- internal/theme/{common => wp}/indexparams.go | 2 +- .../theme/{common => wp}/listpostplugins.go | 2 +- internal/theme/{common => wp}/siteicon.go | 2 +- internal/theme/{common => wp}/template.gohtml | 0 .../theme/{common => wp}/widgetareadata.go | 2 +- internal/theme/{common/common.go => wp/wp.go} | 38 +++++++++++-------- 22 files changed, 82 insertions(+), 74 deletions(-) rename internal/theme/{common => wp}/bodyclass.go (99%) rename internal/theme/{common => wp}/customcss.go (96%) rename internal/theme/{common => wp}/customheader.go (97%) rename internal/theme/{common => wp}/customlogo.go (98%) rename internal/theme/{common => wp}/detail.go (99%) rename internal/theme/{common => wp}/index.go (99%) rename internal/theme/{common => wp}/indexparams.go (99%) rename internal/theme/{common => wp}/listpostplugins.go (99%) rename internal/theme/{common => wp}/siteicon.go (98%) rename internal/theme/{common => wp}/template.gohtml (100%) rename internal/theme/{common => wp}/widgetareadata.go (96%) rename internal/theme/{common/common.go => wp/wp.go} (91%) diff --git a/internal/actions/themehook.go b/internal/actions/themehook.go index cbcbcd5..fcf2bb6 100644 --- a/internal/actions/themehook.go +++ b/internal/actions/themehook.go @@ -2,16 +2,16 @@ package actions import ( "github.com/fthvgb1/wp-go/internal/theme" - "github.com/fthvgb1/wp-go/internal/theme/common" + "github.com/fthvgb1/wp-go/internal/theme/wp" "github.com/gin-gonic/gin" ) func ThemeHook(scene int) func(*gin.Context) { return func(ctx *gin.Context) { t := theme.GetTemplateName() - h := common.NewHandle(ctx, scene, t) - h.Index = common.NewIndexHandle(h) - h.Detail = common.NewDetailHandle(h) + h := wp.NewHandle(ctx, scene, t) + h.Index = wp.NewIndexHandle(h) + h.Detail = wp.NewDetailHandle(h) theme.Hook(t, h) } } diff --git a/internal/theme/fs.go b/internal/theme/fs.go index 55ba6bb..5eaa264 100644 --- a/internal/theme/fs.go +++ b/internal/theme/fs.go @@ -33,7 +33,7 @@ func commonTemplate(t *multipTemplate.MultipleFsTemplate) { for _, main := range m { file := filepath.Base(main) dir := strings.Split(main, "/")[0] - templ := template.Must(template.New(file).Funcs(t.FuncMap).ParseFS(t.Fs, main, filepath.Join(dir, "layout/*.gohtml"), "common/template.gohtml")) + templ := template.Must(template.New(file).Funcs(t.FuncMap).ParseFS(t.Fs, main, filepath.Join(dir, "layout/*.gohtml"), "wp/template.gohtml")) t.SetTemplate(main, templ) } } diff --git a/internal/theme/hook.go b/internal/theme/hook.go index 4819f7e..72d86b3 100644 --- a/internal/theme/hook.go +++ b/internal/theme/hook.go @@ -1,20 +1,20 @@ package theme import ( - "github.com/fthvgb1/wp-go/internal/theme/common" "github.com/fthvgb1/wp-go/internal/theme/twentyfifteen" + "github.com/fthvgb1/wp-go/internal/theme/wp" ) -var themeMap = map[string]func(*common.Handle){} +var themeMap = map[string]func(*wp.Handle){} -func addThemeHookFunc(name string, fn func(handle *common.Handle)) { +func addThemeHookFunc(name string, fn func(handle *wp.Handle)) { if _, ok := themeMap[name]; ok { panic("exists same name theme") } themeMap[name] = fn } -func Hook(themeName string, handle *common.Handle) { +func Hook(themeName string, handle *wp.Handle) { fn, ok := themeMap[themeName] if ok && fn != nil { fn(handle) diff --git a/internal/theme/twentyfifteen/colorschemecss.go b/internal/theme/twentyfifteen/colorschemecss.go index 6fc7c95..f3bc12f 100644 --- a/internal/theme/twentyfifteen/colorschemecss.go +++ b/internal/theme/twentyfifteen/colorschemecss.go @@ -3,12 +3,12 @@ package twentyfifteen import ( "fmt" "github.com/fthvgb1/wp-go/helper/slice" - "github.com/fthvgb1/wp-go/internal/theme/common" + "github.com/fthvgb1/wp-go/internal/theme/wp" "strconv" "strings" ) -func colorSchemeCss(h *common.Handle) string { +func colorSchemeCss(h *wp.Handle) string { s := slice.Filter([]string{calColorSchemeCss(h), calSidebarTextColorCss(h), calHeaderBackgroundColorCss(h)}, func(s string) bool { return s != "" }) @@ -17,7 +17,7 @@ func colorSchemeCss(h *common.Handle) string { } return fmt.Sprintf(``, "twentyfifteen-style", "", strings.Join(s, "\n")) } -func calColorSchemeCss(h *common.Handle) (r string) { +func calColorSchemeCss(h *wp.Handle) (r string) { color := getColorScheme(h) if "default" == h.CommonThemeMods().ColorScheme || len(color) < 1 { return @@ -46,7 +46,7 @@ func calColorSchemeCss(h *common.Handle) (r string) { return } -func calSidebarTextColorCss(h *common.Handle) (r string) { +func calSidebarTextColorCss(h *wp.Handle) (r string) { colors := getColorScheme(h) themeMods := h.CommonThemeMods() if themeMods.SidebarTextcolor == "" || themeMods.SidebarTextcolor == colors[4] { @@ -61,7 +61,7 @@ func calSidebarTextColorCss(h *common.Handle) (r string) { return } -func calHeaderBackgroundColorCss(h *common.Handle) (r string) { +func calHeaderBackgroundColorCss(h *wp.Handle) (r string) { colors := getColorScheme(h) themeMods := h.CommonThemeMods() if themeMods.HeaderBackgroundColor == "" || themeMods.HeaderBackgroundColor == colors[1] { @@ -71,7 +71,7 @@ func calHeaderBackgroundColorCss(h *common.Handle) (r string) { return } -func getColorScheme(h *common.Handle) (r []string) { +func getColorScheme(h *wp.Handle) (r []string) { x, ok := colorscheme[h.CommonThemeMods().ColorScheme] if ok { r = x.Colors diff --git a/internal/theme/twentyfifteen/custombackground.go b/internal/theme/twentyfifteen/custombackground.go index fdba529..463c987 100644 --- a/internal/theme/twentyfifteen/custombackground.go +++ b/internal/theme/twentyfifteen/custombackground.go @@ -5,7 +5,7 @@ import ( "github.com/fthvgb1/wp-go/helper" "github.com/fthvgb1/wp-go/helper/maps" str "github.com/fthvgb1/wp-go/helper/strings" - "github.com/fthvgb1/wp-go/internal/theme/common" + "github.com/fthvgb1/wp-go/internal/theme/wp" ) var postx = map[string]string{ @@ -30,7 +30,7 @@ var repeat = map[string]string{ "no-repeat": "no-repeat", } -func CalCustomBackGround(h *common.Handle) (r string) { +func CalCustomBackGround(h *wp.Handle) (r string) { themeMods := h.CommonThemeMods() if themeMods.BackgroundImage == "" && themeMods.BackgroundColor == themesupport.CustomBackground.DefaultColor { return diff --git a/internal/theme/twentyfifteen/customheader.go b/internal/theme/twentyfifteen/customheader.go index c238df9..338cd50 100644 --- a/internal/theme/twentyfifteen/customheader.go +++ b/internal/theme/twentyfifteen/customheader.go @@ -4,7 +4,7 @@ import ( str "github.com/fthvgb1/wp-go/helper/strings" "github.com/fthvgb1/wp-go/internal/cmd/reload" "github.com/fthvgb1/wp-go/internal/pkg/constraints" - "github.com/fthvgb1/wp-go/internal/theme/common" + "github.com/fthvgb1/wp-go/internal/theme/wp" ) var style = `