From 224e1d41c2f588f0db3f8d8f8eab2d5e2ef6b450 Mon Sep 17 00:00:00 2001 From: xing Date: Fri, 4 Nov 2022 10:54:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=96=87=E4=BB=B6=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- actions/detail.go | 2 +- actions/index.go | 2 +- templates/feed/feed.gohtml | 46 ------------------- templates/templatefs.go | 6 +-- .../{ => twentyfifteen}/layout/base.gohtml | 0 .../{ => twentyfifteen}/layout/empty.gohtml | 0 .../{ => twentyfifteen}/layout/footer.gohtml | 0 .../{ => twentyfifteen}/layout/head.gohtml | 0 .../{ => twentyfifteen}/layout/message.gohtml | 0 .../layout/pagination.gohtml | 0 .../{ => twentyfifteen}/layout/sidebar.gohtml | 0 .../{ => twentyfifteen}/layout/svg.gohtml | 0 .../{ => twentyfifteen}/posts/detail.gohtml | 0 .../{ => twentyfifteen}/posts/index.gohtml | 0 15 files changed, 6 insertions(+), 52 deletions(-) delete mode 100644 templates/feed/feed.gohtml rename templates/{ => twentyfifteen}/layout/base.gohtml (100%) rename templates/{ => twentyfifteen}/layout/empty.gohtml (100%) rename templates/{ => twentyfifteen}/layout/footer.gohtml (100%) rename templates/{ => twentyfifteen}/layout/head.gohtml (100%) rename templates/{ => twentyfifteen}/layout/message.gohtml (100%) rename templates/{ => twentyfifteen}/layout/pagination.gohtml (100%) rename templates/{ => twentyfifteen}/layout/sidebar.gohtml (100%) rename templates/{ => twentyfifteen}/layout/svg.gohtml (100%) rename templates/{ => twentyfifteen}/posts/detail.gohtml (100%) rename templates/{ => twentyfifteen}/posts/index.gohtml (100%) diff --git a/README.md b/README.md index cc70ef5..8e3fa9f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ ## wp-go a simple front of wordpress build with golang. -一个go写的wordress的前端,功能比较简单,只有列表页和详情页,rss2,主题只有一个twentyfifeen主题,插件的话只有一个简单的列表页的摘要生成和enlighter代码高亮。本身只用于展示文章,添加评论走的转发请求到php的wordpress。 \ No newline at end of file +一个go写的wordress的前端,功能比较简单,只有列表页和详情页,rss2,主题只有一个twentyfifteen主题,插件的话只有一个简单的列表页的摘要生成和enlighter代码高亮。本身只用于展示文章,添加评论走的转发请求到php的wordpress。 \ No newline at end of file diff --git a/actions/detail.go b/actions/detail.go index c4175c7..b09dd9f 100644 --- a/actions/detail.go +++ b/actions/detail.go @@ -45,7 +45,7 @@ func Detail(c *gin.Context) { status = http.StatusInternalServerError c.Error(err) } - c.HTML(status, "posts/detail.gohtml", h) + c.HTML(status, "twentyfifteen/posts/detail.gohtml", h) }() id := c.Param("id") Id := 0 diff --git a/actions/index.go b/actions/index.go index 3aaef7f..128eee5 100644 --- a/actions/index.go +++ b/actions/index.go @@ -195,7 +195,7 @@ func Index(c *gin.Context) { c.Error(err) stat = http.StatusInternalServerError } - c.HTML(stat, "posts/index.gohtml", ginH) + c.HTML(stat, "twentyfifteen/posts/index.gohtml", ginH) }() if err != nil { return diff --git a/templates/feed/feed.gohtml b/templates/feed/feed.gohtml deleted file mode 100644 index 22d962d..0000000 --- a/templates/feed/feed.gohtml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - {{ .options.blogname }} - - {{.options.siteurl}}/ - {{.options.blogdescription}} - {{.now}} - zh-CN - - hourly - - - 1 - - https://wordpress.org/?v=6.0.2 - {{range $k,$v := .posts}} - - {{$v.PostTitle}} - {{$v.Link}} - {{if $v.CommentLink}} - {{ $v.CommentLink}} - {{end}} - - {{$v.Date}} - - {{$v.Guid}} - - - {{if gt $v.CommentCount 0 }} - {{$v.CommentLink}} - {{$v.CommentCount}} - {{end}} - - - {{end}} - - diff --git a/templates/templatefs.go b/templates/templatefs.go index 910d0bf..e607ee2 100644 --- a/templates/templatefs.go +++ b/templates/templatefs.go @@ -8,7 +8,7 @@ import ( "path/filepath" ) -//go:embed posts layout feed +//go:embed twentyfifteen var TemplateFs embed.FS type FsTemplate struct { @@ -21,13 +21,13 @@ func NewFsTemplate(funcMap template.FuncMap) *FsTemplate { } func (t *FsTemplate) SetTemplate() *FsTemplate { - mainTemplates, err := fs.Glob(TemplateFs, "*[^layout]/*.gohtml") + mainTemplates, err := fs.Glob(TemplateFs, `twentyfifteen/*[^layout]/*.gohtml`) if err != nil { panic(err) } for _, include := range mainTemplates { name := filepath.Base(include) - t.Templates[include] = template.Must(template.New(name).Funcs(t.FuncMap).ParseFS(TemplateFs, include, "layout/*.gohtml")) + t.Templates[include] = template.Must(template.New(name).Funcs(t.FuncMap).ParseFS(TemplateFs, include, "twentyfifteen/layout/*.gohtml")) } return t } diff --git a/templates/layout/base.gohtml b/templates/twentyfifteen/layout/base.gohtml similarity index 100% rename from templates/layout/base.gohtml rename to templates/twentyfifteen/layout/base.gohtml diff --git a/templates/layout/empty.gohtml b/templates/twentyfifteen/layout/empty.gohtml similarity index 100% rename from templates/layout/empty.gohtml rename to templates/twentyfifteen/layout/empty.gohtml diff --git a/templates/layout/footer.gohtml b/templates/twentyfifteen/layout/footer.gohtml similarity index 100% rename from templates/layout/footer.gohtml rename to templates/twentyfifteen/layout/footer.gohtml diff --git a/templates/layout/head.gohtml b/templates/twentyfifteen/layout/head.gohtml similarity index 100% rename from templates/layout/head.gohtml rename to templates/twentyfifteen/layout/head.gohtml diff --git a/templates/layout/message.gohtml b/templates/twentyfifteen/layout/message.gohtml similarity index 100% rename from templates/layout/message.gohtml rename to templates/twentyfifteen/layout/message.gohtml diff --git a/templates/layout/pagination.gohtml b/templates/twentyfifteen/layout/pagination.gohtml similarity index 100% rename from templates/layout/pagination.gohtml rename to templates/twentyfifteen/layout/pagination.gohtml diff --git a/templates/layout/sidebar.gohtml b/templates/twentyfifteen/layout/sidebar.gohtml similarity index 100% rename from templates/layout/sidebar.gohtml rename to templates/twentyfifteen/layout/sidebar.gohtml diff --git a/templates/layout/svg.gohtml b/templates/twentyfifteen/layout/svg.gohtml similarity index 100% rename from templates/layout/svg.gohtml rename to templates/twentyfifteen/layout/svg.gohtml diff --git a/templates/posts/detail.gohtml b/templates/twentyfifteen/posts/detail.gohtml similarity index 100% rename from templates/posts/detail.gohtml rename to templates/twentyfifteen/posts/detail.gohtml diff --git a/templates/posts/index.gohtml b/templates/twentyfifteen/posts/index.gohtml similarity index 100% rename from templates/posts/index.gohtml rename to templates/twentyfifteen/posts/index.gohtml