elighterjs做成插件
This commit is contained in:
parent
d3be997b8f
commit
2ea52f1752
@ -93,5 +93,7 @@ postOrder: "desc"
|
|||||||
uploadDir: ""
|
uploadDir: ""
|
||||||
# pprof route path 为空表示不开启pprof,否则为pprof的路由
|
# pprof route path 为空表示不开启pprof,否则为pprof的路由
|
||||||
pprof: "/debug/pprof"
|
pprof: "/debug/pprof"
|
||||||
|
# 程序插件
|
||||||
|
plugins: ["enlightjs"]
|
||||||
# 列表页面post使用的插件
|
# 列表页面post使用的插件
|
||||||
listPagePlugins: ["passwordProject","digest","twentyseventeen_postThumbnail"]
|
listPagePlugins: ["passwordProject","digest","twentyseventeen_postThumbnail"]
|
14
internal/pkg/cache/feed.go
vendored
14
internal/pkg/cache/feed.go
vendored
@ -7,7 +7,7 @@ import (
|
|||||||
str "github.com/fthvgb1/wp-go/helper/strings"
|
str "github.com/fthvgb1/wp-go/helper/strings"
|
||||||
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
||||||
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
||||||
"github.com/fthvgb1/wp-go/internal/plugins"
|
"github.com/fthvgb1/wp-go/internal/plugins/wpposts"
|
||||||
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
||||||
"github.com/fthvgb1/wp-go/plugin/digest"
|
"github.com/fthvgb1/wp-go/plugin/digest"
|
||||||
"github.com/fthvgb1/wp-go/rss2"
|
"github.com/fthvgb1/wp-go/rss2"
|
||||||
@ -60,8 +60,8 @@ func feed(arg ...any) (xml []string, err error) {
|
|||||||
rs.Items = slice.Map(posts, func(t models.Posts) rss2.Item {
|
rs.Items = slice.Map(posts, func(t models.Posts) rss2.Item {
|
||||||
desc := "无法提供摘要。这是一篇受保护的文章。"
|
desc := "无法提供摘要。这是一篇受保护的文章。"
|
||||||
if t.PostPassword != "" {
|
if t.PostPassword != "" {
|
||||||
plugins.PasswordProjectTitle(&t)
|
wpposts.PasswordProjectTitle(&t)
|
||||||
plugins.PasswdProjectContent(&t)
|
wpposts.PasswdProjectContent(&t)
|
||||||
} else {
|
} else {
|
||||||
desc = digest.Raw(t.PostContent, 55, fmt.Sprintf("/p/%d", t.Id))
|
desc = digest.Raw(t.PostContent, 55, fmt.Sprintf("/p/%d", t.Id))
|
||||||
}
|
}
|
||||||
@ -116,8 +116,8 @@ func postFeed(arg ...any) (x string, err error) {
|
|||||||
rs.Link = fmt.Sprintf("%s/p/%d", site, post.Id)
|
rs.Link = fmt.Sprintf("%s/p/%d", site, post.Id)
|
||||||
rs.LastBuildDate = time.Now().Format(timeFormat)
|
rs.LastBuildDate = time.Now().Format(timeFormat)
|
||||||
if post.PostPassword != "" {
|
if post.PostPassword != "" {
|
||||||
plugins.PasswordProjectTitle(&post)
|
wpposts.PasswordProjectTitle(&post)
|
||||||
plugins.PasswdProjectContent(&post)
|
wpposts.PasswdProjectContent(&post)
|
||||||
if len(comments) > 0 {
|
if len(comments) > 0 {
|
||||||
t := comments[len(comments)-1]
|
t := comments[len(comments)-1]
|
||||||
rs.Items = []rss2.Item{
|
rs.Items = []rss2.Item{
|
||||||
@ -168,8 +168,8 @@ func commentsFeed(args ...any) (r []string, err error) {
|
|||||||
desc := "评论受保护:要查看请输入密码。"
|
desc := "评论受保护:要查看请输入密码。"
|
||||||
content := t.CommentContent
|
content := t.CommentContent
|
||||||
if post.PostPassword != "" {
|
if post.PostPassword != "" {
|
||||||
plugins.PasswordProjectTitle(&post)
|
wpposts.PasswordProjectTitle(&post)
|
||||||
plugins.PasswdProjectContent(&post)
|
wpposts.PasswdProjectContent(&post)
|
||||||
content = post.PostContent
|
content = post.PostContent
|
||||||
} else {
|
} else {
|
||||||
desc = digest.ClearHtml(t.CommentContent)
|
desc = digest.ClearHtml(t.CommentContent)
|
||||||
|
@ -34,6 +34,7 @@ type Config struct {
|
|||||||
ListPagePlugins []string `yaml:"listPagePlugins"`
|
ListPagePlugins []string `yaml:"listPagePlugins"`
|
||||||
PaginationStep int `yaml:"paginationStep"`
|
PaginationStep int `yaml:"paginationStep"`
|
||||||
ShowQuerySql bool `yaml:"showQuerySql"`
|
ShowQuerySql bool `yaml:"showQuerySql"`
|
||||||
|
Plugins []string `yaml:"plugins"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CacheTime struct {
|
type CacheTime struct {
|
||||||
|
20
internal/plugins/wphandle/enlightjs/enlighterjs.go
Normal file
20
internal/plugins/wphandle/enlightjs/enlighterjs.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package enlightjs
|
||||||
|
|
||||||
|
import (
|
||||||
|
str "github.com/fthvgb1/wp-go/helper/strings"
|
||||||
|
"github.com/fthvgb1/wp-go/internal/theme/wp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func EnlighterJS(h *wp.Handle) {
|
||||||
|
h.PushGroupHeadScript(20, func(h *wp.Handle) string {
|
||||||
|
return `<link rel='stylesheet' id='enlighterjs-css' href='/wp-content/plugins/enlighter/cache/enlighterjs.min.css' media='all' />`
|
||||||
|
})
|
||||||
|
|
||||||
|
h.PushGroupFooterScript(20, func(h *wp.Handle) string {
|
||||||
|
return str.Join(`<script src='/wp-content/plugins/enlighter/cache/enlighterjs.min.js?ver=0A0B0C' id='enlighterjs-js'></script>`, "\n", enlighterjs)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var enlighterjs = `<script id='enlighterjs-js-after'>
|
||||||
|
!function(e,n){if("undefined"!=typeof EnlighterJS){var o={"selectors":{"block":"pre.EnlighterJSRAW","inline":"code.EnlighterJSRAW"},"options":{"indent":4,"ampersandCleanup":true,"linehover":true,"rawcodeDbclick":false,"textOverflow":"break","linenumbers":true,"theme":"enlighter","language":"generic","retainCssClasses":false,"collapse":false,"toolbarOuter":"","toolbarTop":"{BTN_RAW}{BTN_COPY}{BTN_WINDOW}{BTN_WEBSITE}","toolbarBottom":""}};(e.EnlighterJSINIT=function(){EnlighterJS.init(o.selectors.block,o.selectors.inline,o.options)})()}else{(n&&(n.error||n.log)||function(){})("Error: EnlighterJS resources not loaded yet!")}}(window,console);
|
||||||
|
</script>`
|
23
internal/plugins/wphandle/handle.go
Normal file
23
internal/plugins/wphandle/handle.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package wphandle
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/fthvgb1/wp-go/helper/maps"
|
||||||
|
"github.com/fthvgb1/wp-go/internal/plugins/wphandle/enlightjs"
|
||||||
|
"github.com/fthvgb1/wp-go/internal/theme/wp"
|
||||||
|
)
|
||||||
|
|
||||||
|
var plugins = wp.HandlePlugins{
|
||||||
|
"enlightjs": enlightjs.EnlighterJS,
|
||||||
|
}
|
||||||
|
|
||||||
|
func Plugins() wp.HandlePlugins {
|
||||||
|
return maps.Copy(plugins)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterPlugins(h *wp.Handle, calls ...string) {
|
||||||
|
for _, call := range calls {
|
||||||
|
if fn, ok := plugins[call]; ok {
|
||||||
|
fn(h)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package plugins
|
package wpposts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -8,10 +8,7 @@
|
|||||||
var screenReaderText = {"expand":"<span class=\"screen-reader-text\">\u5c55\u5f00\u5b50\u83dc\u5355<\/span>","collapse":"<span class=\"screen-reader-text\">\u6298\u53e0\u5b50\u83dc\u5355<\/span>"};
|
var screenReaderText = {"expand":"<span class=\"screen-reader-text\">\u5c55\u5f00\u5b50\u83dc\u5355<\/span>","collapse":"<span class=\"screen-reader-text\">\u6298\u53e0\u5b50\u83dc\u5355<\/span>"};
|
||||||
</script>
|
</script>
|
||||||
<script src='/wp-content/themes/twentyfifteen/js/functions.js?ver=20220524' id='twentyfifteen-script-js'></script>
|
<script src='/wp-content/themes/twentyfifteen/js/functions.js?ver=20220524' id='twentyfifteen-script-js'></script>
|
||||||
<script src='/wp-content/plugins/enlighter/cache/enlighterjs.min.js?ver=0A0B0C' id='enlighterjs-js'></script>
|
|
||||||
<script id='enlighterjs-js-after'>
|
|
||||||
!function(e,n){if("undefined"!=typeof EnlighterJS){var o={"selectors":{"block":"pre.EnlighterJSRAW","inline":"code.EnlighterJSRAW"},"options":{"indent":4,"ampersandCleanup":true,"linehover":true,"rawcodeDbclick":false,"textOverflow":"break","linenumbers":true,"theme":"enlighter","language":"generic","retainCssClasses":false,"collapse":false,"toolbarOuter":"","toolbarTop":"{BTN_RAW}{BTN_COPY}{BTN_WINDOW}{BTN_WEBSITE}","toolbarBottom":""}};(e.EnlighterJSINIT=function(){EnlighterJS.init(o.selectors.block,o.selectors.inline,o.options)})()}else{(n&&(n.error||n.log)||function(){})("Error: EnlighterJS resources not loaded yet!")}}(window,console);
|
|
||||||
</script>
|
|
||||||
{{template "common/footer" .}}
|
{{template "common/footer" .}}
|
||||||
{{ block "footer" .}}
|
{{ block "footer" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
<link href='https://fonts.gstatic.com' crossorigin rel='preconnect' />
|
<link href='https://fonts.gstatic.com' crossorigin rel='preconnect' />
|
||||||
<link rel="alternate" type="application/rss+xml" title="{{ .title }} » Feed" href="/feed" />
|
<link rel="alternate" type="application/rss+xml" title="{{ .title }} » Feed" href="/feed" />
|
||||||
<link rel="alternate" type="application/rss+xml" title="{{ .title }} » 评论Feed" href="/comments/feed" />
|
<link rel="alternate" type="application/rss+xml" title="{{ .title }} » 评论Feed" href="/comments/feed" />
|
||||||
<link rel='stylesheet' id='enlighterjs-css' href='/wp-content/plugins/enlighter/cache/enlighterjs.min.css?ver=0A0B0C' media='all' />
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/svg\/","svgExt":".svg","source":{"concatemoji":"\/wp-includes\/js\/wp-emoji-release.min.js?ver=6.0.2"}};
|
window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/svg\/","svgExt":".svg","source":{"concatemoji":"\/wp-includes\/js\/wp-emoji-release.min.js?ver=6.0.2"}};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{{template "layout/base" .}}
|
{{template "layout/base" .}}
|
||||||
|
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
{{ if and .post gt .post.Id 0}}
|
{{ if and (.post) (gt .post.Id 0)}}
|
||||||
<div id="primary" class="content-area">
|
<div id="primary" class="content-area">
|
||||||
<main id="main" class="site-main">
|
<main id="main" class="site-main">
|
||||||
<article id="post-{{.post.Id}}"
|
<article id="post-{{.post.Id}}"
|
||||||
|
@ -3,8 +3,10 @@ package twentyfifteen
|
|||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/fthvgb1/wp-go/internal/pkg/config"
|
||||||
"github.com/fthvgb1/wp-go/internal/pkg/constraints"
|
"github.com/fthvgb1/wp-go/internal/pkg/constraints"
|
||||||
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
||||||
|
"github.com/fthvgb1/wp-go/internal/plugins/wphandle"
|
||||||
"github.com/fthvgb1/wp-go/internal/theme/wp"
|
"github.com/fthvgb1/wp-go/internal/theme/wp"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,6 +39,8 @@ func Hook(h *wp.Handle) {
|
|||||||
func dispatch(next wp.HandleFn[*wp.Handle], h *wp.Handle) {
|
func dispatch(next wp.HandleFn[*wp.Handle], h *wp.Handle) {
|
||||||
h.WidgetAreaData()
|
h.WidgetAreaData()
|
||||||
h.GetPassword()
|
h.GetPassword()
|
||||||
|
wphandle.RegisterPlugins(h, config.GetConfig().Plugins...)
|
||||||
|
|
||||||
h.PushGroupHeadScript(10, CalCustomBackGround, colorSchemeCss)
|
h.PushGroupHeadScript(10, CalCustomBackGround, colorSchemeCss)
|
||||||
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(customHeader, 10))
|
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(customHeader, 10))
|
||||||
switch h.Scene() {
|
switch h.Scene() {
|
||||||
|
@ -6,11 +6,6 @@
|
|||||||
<script src="/wp-content/themes/twentyseventeen/assets/js/skip-link-focus-fix.js?ver=20161114" id="twentyseventeen-skip-link-focus-fix-js"></script>
|
<script src="/wp-content/themes/twentyseventeen/assets/js/skip-link-focus-fix.js?ver=20161114" id="twentyseventeen-skip-link-focus-fix-js"></script>
|
||||||
<script src="/wp-content/themes/twentyseventeen/assets/js/global.js?ver=20211130" id="twentyseventeen-global-js"></script>
|
<script src="/wp-content/themes/twentyseventeen/assets/js/global.js?ver=20211130" id="twentyseventeen-global-js"></script>
|
||||||
<script src="/wp-content/themes/twentyseventeen/assets/js/jquery.scrollTo.js?ver=2.1.3" id="jquery-scrollto-js"></script>
|
<script src="/wp-content/themes/twentyseventeen/assets/js/jquery.scrollTo.js?ver=2.1.3" id="jquery-scrollto-js"></script>
|
||||||
|
|
||||||
<script src='/wp-content/plugins/enlighter/cache/enlighterjs.min.js?ver=0A0B0C' id='enlighterjs-js'></script>
|
|
||||||
<script id='enlighterjs-js-after'>
|
|
||||||
!function(e,n){if("undefined"!=typeof EnlighterJS){var o={"selectors":{"block":"pre.EnlighterJSRAW","inline":"code.EnlighterJSRAW"},"options":{"indent":4,"ampersandCleanup":true,"linehover":true,"rawcodeDbclick":false,"textOverflow":"break","linenumbers":true,"theme":"enlighter","language":"generic","retainCssClasses":false,"collapse":false,"toolbarOuter":"","toolbarTop":"{BTN_RAW}{BTN_COPY}{BTN_WINDOW}{BTN_WEBSITE}","toolbarBottom":""}};(e.EnlighterJSINIT=function(){EnlighterJS.init(o.selectors.block,o.selectors.inline,o.options)})()}else{(n&&(n.error||n.log)||function(){})("Error: EnlighterJS resources not loaded yet!")}}(window,console);
|
|
||||||
</script>
|
|
||||||
{{template "common/footer" .}}
|
{{template "common/footer" .}}
|
||||||
{{ block "footer" .}}
|
{{ block "footer" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -53,7 +53,6 @@
|
|||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<link rel='stylesheet' id='twentyseventeen-ie8-css' href='/wp-content/themes/twentyseventeen/assets/css/ie8.css?ver=20161202' media='all' />
|
<link rel='stylesheet' id='twentyseventeen-ie8-css' href='/wp-content/themes/twentyseventeen/assets/css/ie8.css?ver=20161202' media='all' />
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<link rel='stylesheet' id='enlighterjs-css' href='/wp-content/plugins/enlighter/cache/enlighterjs.min.css?ver=0A0B0C' media='all' />
|
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src='/wp-content/themes/twentyseventeen/assets/js/html5.js?ver=20161020' id='html5-js'></script>
|
<script src='/wp-content/themes/twentyseventeen/assets/js/html5.js?ver=20161020' id='html5-js'></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{{template "layout/base" .}}
|
{{template "layout/base" .}}
|
||||||
|
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
{{ if gt .post.Id 0}}
|
{{ if and (.post) (gt .post.Id 0) }}
|
||||||
{{if .post.Thumbnail.Path}}
|
{{if .post.Thumbnail.Path}}
|
||||||
<div class="single-featured-image-header">
|
<div class="single-featured-image-header">
|
||||||
<img width="{{.post.Thumbnail.OriginAttachmentData.Width}}" height="{{.post.Thumbnail.OriginAttachmentData.Height}}" src="{{.post.Thumbnail.Path}}" class="attachment-twentyseventeen-featured-image size-twentyseventeen-featured-image wp-post-image" alt="{{.post.PostTitle}}" decoding="async" loading="lazy" srcset="{{.post.Thumbnail.Srcset}}" sizes="{{.post.Thumbnail.Sizes}}">
|
<img width="{{.post.Thumbnail.OriginAttachmentData.Width}}" height="{{.post.Thumbnail.OriginAttachmentData.Height}}" src="{{.post.Thumbnail.Path}}" class="attachment-twentyseventeen-featured-image size-twentyseventeen-featured-image wp-post-image" alt="{{.post.PostTitle}}" decoding="async" loading="lazy" srcset="{{.post.Thumbnail.Srcset}}" sizes="{{.post.Thumbnail.Sizes}}">
|
||||||
|
@ -8,10 +8,12 @@ import (
|
|||||||
"github.com/fthvgb1/wp-go/helper/maps"
|
"github.com/fthvgb1/wp-go/helper/maps"
|
||||||
str "github.com/fthvgb1/wp-go/helper/strings"
|
str "github.com/fthvgb1/wp-go/helper/strings"
|
||||||
"github.com/fthvgb1/wp-go/internal/cmd/reload"
|
"github.com/fthvgb1/wp-go/internal/cmd/reload"
|
||||||
|
"github.com/fthvgb1/wp-go/internal/pkg/config"
|
||||||
"github.com/fthvgb1/wp-go/internal/pkg/constraints"
|
"github.com/fthvgb1/wp-go/internal/pkg/constraints"
|
||||||
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
||||||
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
||||||
"github.com/fthvgb1/wp-go/internal/plugins"
|
"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"
|
||||||
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -47,6 +49,7 @@ func Hook(h *wp.Handle) {
|
|||||||
func ready(next wp.HandleFn[*wp.Handle], h *wp.Handle) {
|
func ready(next wp.HandleFn[*wp.Handle], h *wp.Handle) {
|
||||||
h.WidgetAreaData()
|
h.WidgetAreaData()
|
||||||
h.GetPassword()
|
h.GetPassword()
|
||||||
|
wphandle.RegisterPlugins(h, config.GetConfig().Plugins...)
|
||||||
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(calClass, 20))
|
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(calClass, 20))
|
||||||
errHandle := wp.NewHandleFn(errorsHandle, 100)
|
errHandle := wp.NewHandleFn(errorsHandle, 100)
|
||||||
h.PushHandleFn(constraints.Error404, errHandle)
|
h.PushHandleFn(constraints.Error404, errHandle)
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
||||||
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
||||||
"github.com/fthvgb1/wp-go/internal/plugins"
|
"github.com/fthvgb1/wp-go/internal/plugins"
|
||||||
|
"github.com/fthvgb1/wp-go/internal/plugins/wpposts"
|
||||||
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,9 +62,9 @@ func (d *DetailHandle) CheckAndGetPost() (err error) {
|
|||||||
|
|
||||||
func (d *DetailHandle) PasswordProject() {
|
func (d *DetailHandle) PasswordProject() {
|
||||||
if d.Post.PostPassword != "" {
|
if d.Post.PostPassword != "" {
|
||||||
plugins.PasswordProjectTitle(&d.Post)
|
wpposts.PasswordProjectTitle(&d.Post)
|
||||||
if d.password != d.Post.PostPassword {
|
if d.password != d.Post.PostPassword {
|
||||||
plugins.PasswdProjectContent(&d.Post)
|
wpposts.PasswdProjectContent(&d.Post)
|
||||||
}
|
}
|
||||||
d.ginH["post"] = d.Post
|
d.ginH["post"] = d.Post
|
||||||
}
|
}
|
||||||
|
@ -145,8 +145,8 @@ func (i *IndexHandle) Render() {
|
|||||||
i.PushHandleFn(constraints.Ok, NewHandleFn(func(h *Handle) {
|
i.PushHandleFn(constraints.Ok, NewHandleFn(func(h *Handle) {
|
||||||
i.ExecPostsPlugin()
|
i.ExecPostsPlugin()
|
||||||
i.Pagination()
|
i.Pagination()
|
||||||
|
i.ginH["posts"] = i.Posts
|
||||||
}, 10))
|
}, 10))
|
||||||
i.ginH["posts"] = i.Posts
|
|
||||||
i.Handle.Render()
|
i.Handle.Render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
||||||
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
||||||
"github.com/fthvgb1/wp-go/internal/plugins"
|
"github.com/fthvgb1/wp-go/internal/plugins"
|
||||||
|
"github.com/fthvgb1/wp-go/internal/plugins/wpposts"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Fn[T any] func(T) T
|
type Fn[T any] func(T) T
|
||||||
@ -32,9 +33,9 @@ var pluginFns = map[string]Plugin[models.Posts, *Handle]{
|
|||||||
func PasswordProject(next Fn[models.Posts], h *Handle, post models.Posts) (r models.Posts) {
|
func PasswordProject(next Fn[models.Posts], h *Handle, post models.Posts) (r models.Posts) {
|
||||||
r = post
|
r = post
|
||||||
if post.PostPassword != "" {
|
if post.PostPassword != "" {
|
||||||
plugins.PasswordProjectTitle(&r)
|
wpposts.PasswordProjectTitle(&r)
|
||||||
if h.password != post.PostPassword {
|
if h.password != post.PostPassword {
|
||||||
plugins.PasswdProjectContent(&r)
|
wpposts.PasswdProjectContent(&r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +59,7 @@ func ListPostPlugins() map[string]Plugin[models.Posts, *Handle] {
|
|||||||
|
|
||||||
func ProjectTitle(t models.Posts) models.Posts {
|
func ProjectTitle(t models.Posts) models.Posts {
|
||||||
if t.PostPassword != "" {
|
if t.PostPassword != "" {
|
||||||
plugins.PasswordProjectTitle(&t)
|
wpposts.PasswordProjectTitle(&t)
|
||||||
}
|
}
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,7 @@ type Handle struct {
|
|||||||
abort bool
|
abort bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) Abort() {
|
type HandlePlugins map[string]HandleFn[*Handle]
|
||||||
h.abort = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Handle) CommonThemeMods() wpconfig.ThemeMods {
|
|
||||||
return h.themeMods
|
|
||||||
}
|
|
||||||
|
|
||||||
// Components Order 为执行顺序,降序执行
|
// Components Order 为执行顺序,降序执行
|
||||||
type Components struct {
|
type Components struct {
|
||||||
@ -57,6 +51,14 @@ type HandleCall struct {
|
|||||||
Order int
|
Order int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Handle) Abort() {
|
||||||
|
h.abort = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) CommonThemeMods() wpconfig.ThemeMods {
|
||||||
|
return h.themeMods
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Handle) Err() error {
|
func (h *Handle) Err() error {
|
||||||
return h.err
|
return h.err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user