模板文件目录调整

This commit is contained in:
xing 2022-11-04 10:54:07 +08:00
parent faaafa2349
commit 224e1d41c2
15 changed files with 6 additions and 52 deletions

View File

@ -1,4 +1,4 @@
## wp-go ## wp-go
a simple front of wordpress build with golang. a simple front of wordpress build with golang.
一个go写的wordress的前端功能比较简单只有列表页和详情页,rss2主题只有一个twentyfifeen主题插件的话只有一个简单的列表页的摘要生成和enlighter代码高亮。本身只用于展示文章添加评论走的转发请求到php的wordpress。 一个go写的wordress的前端功能比较简单只有列表页和详情页,rss2主题只有一个twentyfifteen主题插件的话只有一个简单的列表页的摘要生成和enlighter代码高亮。本身只用于展示文章添加评论走的转发请求到php的wordpress。

View File

@ -45,7 +45,7 @@ func Detail(c *gin.Context) {
status = http.StatusInternalServerError status = http.StatusInternalServerError
c.Error(err) c.Error(err)
} }
c.HTML(status, "posts/detail.gohtml", h) c.HTML(status, "twentyfifteen/posts/detail.gohtml", h)
}() }()
id := c.Param("id") id := c.Param("id")
Id := 0 Id := 0

View File

@ -195,7 +195,7 @@ func Index(c *gin.Context) {
c.Error(err) c.Error(err)
stat = http.StatusInternalServerError stat = http.StatusInternalServerError
} }
c.HTML(stat, "posts/index.gohtml", ginH) c.HTML(stat, "twentyfifteen/posts/index.gohtml", ginH)
}() }()
if err != nil { if err != nil {
return return

View File

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>
<channel>
<title>{{ .options.blogname }}</title>
<atom:link href="{{.options.home}}/feed" rel="self" type="application/rss+xml"/>
<link>{{.options.siteurl}}/</link>
<description>{{.options.blogdescription}}</description>
<lastBuildDate>{{.now}}</lastBuildDate>
<language>zh-CN</language>
<sy:updatePeriod>
hourly
</sy:updatePeriod>
<sy:updateFrequency>
1
</sy:updateFrequency>
<generator>https://wordpress.org/?v=6.0.2</generator>
{{range $k,$v := .posts}}
<item>
<title>{{$v.PostTitle}}</title>
<link>{{$v.Link}}</link>
{{if $v.CommentLink}}
<comments>{{ $v.CommentLink}}</comments>
{{end}}
<dc:creator><![CDATA[{{$v.Username}}]]></dc:creator>
<pubDate>{{$v.Date}}</pubDate>
<category><![CDATA[{{$v.Cates}}]]></category>
<guid isPermaLink="false">{{$v.Guid}}</guid>
<description><![CDATA[{{$v.Description}}]]></description>
<content:encoded><![CDATA[{{$v.PostContent}}]]></content:encoded>
{{if gt $v.CommentCount 0 }}
<wfw:commentRss>{{$v.CommentLink}}</wfw:commentRss>
<slash:comments>{{$v.CommentCount}}</slash:comments>
{{end}}
</item>
{{end}}
</channel>
</rss>

View File

@ -8,7 +8,7 @@ import (
"path/filepath" "path/filepath"
) )
//go:embed posts layout feed //go:embed twentyfifteen
var TemplateFs embed.FS var TemplateFs embed.FS
type FsTemplate struct { type FsTemplate struct {
@ -21,13 +21,13 @@ func NewFsTemplate(funcMap template.FuncMap) *FsTemplate {
} }
func (t *FsTemplate) SetTemplate() *FsTemplate { func (t *FsTemplate) SetTemplate() *FsTemplate {
mainTemplates, err := fs.Glob(TemplateFs, "*[^layout]/*.gohtml") mainTemplates, err := fs.Glob(TemplateFs, `twentyfifteen/*[^layout]/*.gohtml`)
if err != nil { if err != nil {
panic(err) panic(err)
} }
for _, include := range mainTemplates { for _, include := range mainTemplates {
name := filepath.Base(include) 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 return t
} }