diff --git a/app/theme/twentyfifteen/twentyfifteen.go b/app/theme/twentyfifteen/twentyfifteen.go index 7fc240b..a10bf56 100644 --- a/app/theme/twentyfifteen/twentyfifteen.go +++ b/app/theme/twentyfifteen/twentyfifteen.go @@ -23,7 +23,11 @@ func configs(h *wp.Handle) { }) wp.InitPipe(h) h.PushHandler(constraints.PipeMiddleware, constraints.Home, - wp.NewHandleFn(widget.CheckCategory, 100, "widget.CheckCategory")) + wp.NewHandleFn(widget.CheckCategory, 100, "widget.CheckCategory"), + ) + h.PushHandler(constraints.PipeMiddleware, constraints.Detail, + wp.NewHandleFn(wp.ShowPreComment, 100, "wp.ShowPreComment"), + ) h.Index.SetPageEle(plugins.TwentyFifteenPagination()) h.PushCacheGroupHeadScript(constraints.AllScene, "CalCustomBackGround", 10.005, CalCustomBackGround) diff --git a/app/theme/twentyseventeen/twentyseventeen.go b/app/theme/twentyseventeen/twentyseventeen.go index 249285b..f37d6e8 100644 --- a/app/theme/twentyseventeen/twentyseventeen.go +++ b/app/theme/twentyseventeen/twentyseventeen.go @@ -38,6 +38,9 @@ func configs(h *wp.Handle) { wp.InitPipe(h) h.PushHandler(constraints.PipeMiddleware, constraints.Home, wp.NewHandleFn(widget.CheckCategory, 100.006, "widget.CheckCategory")) + h.PushHandler(constraints.PipeMiddleware, constraints.Detail, + wp.NewHandleFn(wp.ShowPreComment, 100, "wp.ShowPreComment"), + ) h.AddActionFilter("bodyClass", calClass) h.PushCacheGroupHeadScript(constraints.AllScene, "colorScheme-customHeader", 10, colorScheme, customHeader) components.WidgetArea(h) diff --git a/app/theme/wp/detail.go b/app/theme/wp/detail.go index 35356f4..693a8dc 100644 --- a/app/theme/wp/detail.go +++ b/app/theme/wp/detail.go @@ -11,6 +11,7 @@ import ( "github.com/fthvgb1/wp-go/app/plugins/wpposts" "github.com/fthvgb1/wp-go/app/wpconfig" str "github.com/fthvgb1/wp-go/helper/strings" + "net/http" ) type DetailHandle struct { @@ -35,6 +36,16 @@ func (d *DetailHandle) BuildDetailData() (err error) { return } +func ShowPreComment(h *Handle) { + v, ok := cache.NewCommentCache().Get(h.C, h.C.Request.URL.RawQuery) + if ok { + h.C.Writer.Header().Set("Content-Type", "text/html; charset=utf-8") + h.C.Writer.WriteHeader(http.StatusOK) + _, _ = h.C.Writer.Write([]byte(v)) + h.Abort() + } +} + func (d *DetailHandle) CheckAndGetPost() (err error) { id := str.ToInteger[uint64](d.C.Param("id"), 0) maxId, err := cache.GetMaxPostId(d.C)