diff --git a/internal/pkg/constraints/const.go b/internal/pkg/constraints/const.go index b293b07..f8c9dd9 100644 --- a/internal/pkg/constraints/const.go +++ b/internal/pkg/constraints/const.go @@ -16,8 +16,9 @@ const ( AllStats = "AllStats" AllScene = "AllScene" - PipeData = "PipeData" - PipeRender = "PipeRender" + PipeData = "PipeData" + PipeMiddleware = "PipeMiddleware" + PipeRender = "PipeRender" Defaults = "default" diff --git a/internal/plugins/wphandle/handle.go b/internal/plugins/wphandle/handle.go index 2833f07..89249d5 100644 --- a/internal/plugins/wphandle/handle.go +++ b/internal/plugins/wphandle/handle.go @@ -4,12 +4,14 @@ import ( "github.com/fthvgb1/wp-go/internal/pkg/config" "github.com/fthvgb1/wp-go/internal/plugins/wphandle/enlightjs" "github.com/fthvgb1/wp-go/internal/plugins/wphandle/hiddenlogin" + "github.com/fthvgb1/wp-go/internal/plugins/wphandle/tests" "github.com/fthvgb1/wp-go/internal/theme/wp" ) var plugins = wp.HandlePlugins{ "enlightjs": enlightjs.EnlighterJS, "hiddenLogin": hiddenlogin.HiddenLogin, + "test": tests.Tt, } func RegisterPlugins(m wp.HandlePlugins) { diff --git a/internal/plugins/wphandle/tests/tt.go b/internal/plugins/wphandle/tests/tt.go new file mode 100644 index 0000000..5dad265 --- /dev/null +++ b/internal/plugins/wphandle/tests/tt.go @@ -0,0 +1,22 @@ +package tests + +import ( + "fmt" + "github.com/fthvgb1/wp-go/internal/pkg/constraints" + "github.com/fthvgb1/wp-go/internal/theme/wp" +) + +func Tt(h *wp.Handle) { + h.HookHandle(constraints.PipeMiddleware, func(call wp.HandleCall) (wp.HandleCall, bool) { + return call, false + }) + /*h.PushPipeHook(constraints.Home, func(pipe wp.Pipe) (wp.Pipe, bool) { + return wp.Pipe{}, false + })*/ + //h.DeletePipe(constraints.Home, constraints.PipeMiddleware) + h.ReplacePipe(constraints.Home, constraints.PipeMiddleware, wp.NewPipe("log", 500, func(next wp.HandleFn[*wp.Handle], h *wp.Handle) { + fmt.Println("ffff") + next(h) + fmt.Println("iiiii") + })) +} diff --git a/internal/theme/twentyfifteen/twentyfifteen.go b/internal/theme/twentyfifteen/twentyfifteen.go index e096f0f..ddfc86c 100644 --- a/internal/theme/twentyfifteen/twentyfifteen.go +++ b/internal/theme/twentyfifteen/twentyfifteen.go @@ -41,28 +41,21 @@ func Init(fs embed.FS) { } } -var pipe = wp.HandlePipe(wp.NothingToDo, widget.MiddleWare(ready, - wp.PipeHandle(constraints.PipeData, wp.PipeKey, wp.PipeDataHandle), - wp.PipeHandle(constraints.PipeRender, wp.PipeKey, wp.PipeRender), -)...) - func Hook(h *wp.Handle) { - pipe(h) -} - -func ready(next wp.HandleFn[*wp.Handle], h *wp.Handle) { - wp.InitThemeArgAndConfig(configs, h) - h.GetPassword() - next(h) + wp.Run(h, configs) } func configs(h *wp.Handle) { + wphandle.UsePlugins(h) 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"`) }) + wp.InitPipe(h) + h.PushHandler(constraints.PipeMiddleware, constraints.Home, + wp.NewHandleFn(widget.IsCategory, 100, "widget.IsCategory")) + h.Index.SetPageEle(plugins.TwentyFifteenPagination()) - wphandle.UsePlugins(h) h.PushCacheGroupHeadScript(constraints.AllScene, "CalCustomBackGround", 10, CalCustomBackGround) h.PushCacheGroupHeadScript(constraints.AllScene, "colorSchemeCss", 10, colorSchemeCss) h.CommonComponents() diff --git a/internal/theme/twentyseventeen/twentyseventeen.go b/internal/theme/twentyseventeen/twentyseventeen.go index 5c163ea..33cfcd7 100644 --- a/internal/theme/twentyseventeen/twentyseventeen.go +++ b/internal/theme/twentyseventeen/twentyseventeen.go @@ -42,18 +42,16 @@ var paginate = func() plugins.PageEle { return p }() -var pipe = wp.HandlePipe(wp.NothingToDo, widget.MiddleWare(ready, - wp.PipeHandle(constraints.PipeData, wp.PipeKey, wp.PipeDataHandle), - wp.PipeHandle(constraints.PipeRender, wp.PipeKey, wp.PipeRender), -)...) - func Hook(h *wp.Handle) { - pipe(h) + wp.Run(h, configs) } func configs(h *wp.Handle) { conf := config.GetConfig() wphandle.UsePlugins(h) + wp.InitPipe(h) + h.PushHandler(constraints.PipeMiddleware, constraints.Home, + wp.NewHandleFn(widget.IsCategory, 100, "widget.IsCategory")) h.PushComponentFilterFn("bodyClass", calClass) h.PushCacheGroupHeadScript(constraints.AllScene, "colorScheme-customHeader", 10, colorScheme, customHeader) components.WidgetArea(h) @@ -79,11 +77,6 @@ func configs(h *wp.Handle) { h.PushDataHandler(constraints.AllScene, wp.NewHandleFn(index, 100, "index")) h.PushDataHandler(constraints.AllScene, wp.NewHandleFn(wp.PreCodeAndStats, 90, "wp.PreCodeAndStats")) } -func ready(next wp.HandleFn[*wp.Handle], h *wp.Handle) { - wp.InitThemeArgAndConfig(configs, h) - h.GetPassword() - next(h) -} var searchForm = `