模板文件目录调整
This commit is contained in:
parent
faaafa2349
commit
224e1d41c2
|
@ -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。
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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>
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user