diff --git a/.gitignore b/.gitignore index 0603031..b7bebf4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea wp-go.iml -config.yaml \ No newline at end of file +config.yaml +err.log diff --git a/internal/pkg/logs/log.go b/internal/pkg/logs/log.go index 515da40..6899613 100644 --- a/internal/pkg/logs/log.go +++ b/internal/pkg/logs/log.go @@ -12,8 +12,10 @@ import ( ) var logs = safety.NewVar[*log.Logger](nil) +var logFile = safety.NewVar[*os.File](nil) func InitLogger() error { + preFD := logFile.Load() l := &log.Logger{} c := config.GetConfig() if c.LogOutput == "" { @@ -31,6 +33,10 @@ func InitLogger() error { return err } out = file + logFile.Store(file) + } + if preFD != nil { + _ = preFD.Close() } logs.Store(l) l.SetFlags(log.Ldate | log.Ltime) diff --git a/internal/theme/twentyfifteen/twentyfifteen.go b/internal/theme/twentyfifteen/twentyfifteen.go index d4df9c9..c0a0ffa 100644 --- a/internal/theme/twentyfifteen/twentyfifteen.go +++ b/internal/theme/twentyfifteen/twentyfifteen.go @@ -7,6 +7,7 @@ import ( "github.com/fthvgb1/wp-go/internal/pkg/constraints" "github.com/fthvgb1/wp-go/internal/pkg/constraints/widgets" "github.com/fthvgb1/wp-go/internal/pkg/logs" + "github.com/fthvgb1/wp-go/internal/plugins" "github.com/fthvgb1/wp-go/internal/plugins/wphandle" "github.com/fthvgb1/wp-go/internal/theme/wp" "github.com/fthvgb1/wp-go/internal/theme/wp/components" @@ -62,12 +63,15 @@ func data(next wp.HandleFn[*wp.Handle], h *wp.Handle) { } func configs(h *wp.Handle) { + conf := config.GetConfig() h.PushComponentFilterFn(widgets.Search, func(h *wp.Handle, s string, args ...any) string { return strings.ReplaceAll(s, `class="search-submit"`, `class="search-submit screen-reader-text"`) }) - wphandle.RegisterPlugins(h, config.GetConfig().Plugins...) + h.Index.SetPageEle(plugins.TwentyFifteenPagination()) + wphandle.RegisterPlugins(h, conf.Plugins...) h.PushCacheGroupHeadScript("CalCustomBackGround", 10, CalCustomBackGround, colorSchemeCss) h.CommonComponents() + h.Index.SetListPlugin(wp.PostsPlugins(wp.PostPlugin(), wp.GetListPostPlugins(conf.ListPagePlugins, wp.ListPostPlugins())...)) h.PushHandleFn(constraints.Ok, wp.NewHandleFn(components.WidgetArea, 20)) h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(customHeader, 10)) h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(wp.IndexRender, 50)) diff --git a/internal/theme/twentyseventeen/twentyseventeen.go b/internal/theme/twentyseventeen/twentyseventeen.go index 1908a09..fb91281 100644 --- a/internal/theme/twentyseventeen/twentyseventeen.go +++ b/internal/theme/twentyseventeen/twentyseventeen.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "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/cmd/reload" "github.com/fthvgb1/wp-go/internal/pkg/config" @@ -50,7 +49,8 @@ func Hook(h *wp.Handle) { } func configs(h *wp.Handle) { - wphandle.RegisterPlugins(h, config.GetConfig().Plugins...) + conf := config.GetConfig() + wphandle.RegisterPlugins(h, conf.Plugins...) h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(calClass, 20)) h.PushCacheGroupHeadScript("colorScheme-customHeader", 10, colorScheme, customHeader) components.WidgetArea(h) @@ -64,6 +64,8 @@ func configs(h *wp.Handle) { }) h.PushGroupHandleFn(constraints.AllStats, 90, wp.PreTemplate, errorsHandle) h.CommonComponents() + h.Index.SetPageEle(paginate) + h.Index.SetListPlugin(wp.PostsPlugins(wp.PostPlugin(postThumbnail), wp.GetListPostPlugins(conf.ListPagePlugins, wp.ListPostPlugins())...)) wp.SetComponentsArgsForMap(h, widgets.Search, "{$form}", searchForm) h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(wp.IndexRender, 10)) h.PushHandleFn(constraints.Detail, wp.NewHandleFn(wp.DetailRender, 10)) @@ -85,12 +87,6 @@ var searchForm = `