调整目录
This commit is contained in:
parent
1a2c50c7dd
commit
a597a7bdf0
|
@ -8,6 +8,7 @@ import (
|
||||||
"github/fthvgb1/wp-go/actions/common"
|
"github/fthvgb1/wp-go/actions/common"
|
||||||
"github/fthvgb1/wp-go/cache"
|
"github/fthvgb1/wp-go/cache"
|
||||||
"github/fthvgb1/wp-go/config"
|
"github/fthvgb1/wp-go/config"
|
||||||
|
"github/fthvgb1/wp-go/config/wpconfig"
|
||||||
"github/fthvgb1/wp-go/helper"
|
"github/fthvgb1/wp-go/helper"
|
||||||
"github/fthvgb1/wp-go/logs"
|
"github/fthvgb1/wp-go/logs"
|
||||||
"github/fthvgb1/wp-go/mail"
|
"github/fthvgb1/wp-go/mail"
|
||||||
|
@ -51,7 +52,7 @@ func PostComment(c *gin.Context) {
|
||||||
}
|
}
|
||||||
defer req.Body.Close()
|
defer req.Body.Close()
|
||||||
req.Header = c.Request.Header.Clone()
|
req.Header = c.Request.Header.Clone()
|
||||||
home, err := url.Parse(config.Options.Value("siteurl"))
|
home, err := url.Parse(wpconfig.Options.Value("siteurl"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -103,7 +104,7 @@ func PostComment(c *gin.Context) {
|
||||||
logs.ErrPrintln(err, "获取文档", id)
|
logs.ErrPrintln(err, "获取文档", id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
su := fmt.Sprintf("%s: %s[%s]发表了评论对文档[%v]的评论", config.Options.Value("siteurl"), author, m, post.PostTitle)
|
su := fmt.Sprintf("%s: %s[%s]发表了评论对文档[%v]的评论", wpconfig.Options.Value("siteurl"), author, m, post.PostTitle)
|
||||||
err = mail.SendMail([]string{config.Conf.Load().Mail.User}, su, comment)
|
err = mail.SendMail([]string{config.Conf.Load().Mail.User}, su, comment)
|
||||||
logs.ErrPrintln(err, "发送邮件", config.Conf.Load().Mail.User, su, comment)
|
logs.ErrPrintln(err, "发送邮件", config.Conf.Load().Mail.User, su, comment)
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github/fthvgb1/wp-go/cache"
|
"github/fthvgb1/wp-go/cache"
|
||||||
"github/fthvgb1/wp-go/config"
|
"github/fthvgb1/wp-go/config"
|
||||||
|
"github/fthvgb1/wp-go/config/wpconfig"
|
||||||
"github/fthvgb1/wp-go/logs"
|
"github/fthvgb1/wp-go/logs"
|
||||||
"github/fthvgb1/wp-go/models"
|
"github/fthvgb1/wp-go/models"
|
||||||
"github/fthvgb1/wp-go/models/wp"
|
"github/fthvgb1/wp-go/models/wp"
|
||||||
|
@ -147,10 +148,10 @@ func categories(a ...any) (terms []wp.WpTermsMy, err error) {
|
||||||
{"t", "inner join", "wp_term_taxonomy tt", "t.term_id = tt.term_id"},
|
{"t", "inner join", "wp_term_taxonomy tt", "t.term_id = tt.term_id"},
|
||||||
}, nil, 0, in)
|
}, nil, 0, in)
|
||||||
for i := 0; i < len(terms); i++ {
|
for i := 0; i < len(terms); i++ {
|
||||||
if v, ok := config.Terms.Load(terms[i].WpTerms.TermId); ok {
|
if v, ok := wpconfig.Terms.Load(terms[i].WpTerms.TermId); ok {
|
||||||
terms[i].WpTerms = v
|
terms[i].WpTerms = v
|
||||||
}
|
}
|
||||||
if v, ok := config.TermTaxonomies.Load(terms[i].WpTerms.TermId); ok {
|
if v, ok := wpconfig.TermTaxonomies.Load(terms[i].WpTerms.TermId); ok {
|
||||||
terms[i].TermTaxonomy = v
|
terms[i].TermTaxonomy = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github/fthvgb1/wp-go/actions/common"
|
"github/fthvgb1/wp-go/actions/common"
|
||||||
"github/fthvgb1/wp-go/config"
|
"github/fthvgb1/wp-go/config/wpconfig"
|
||||||
"github/fthvgb1/wp-go/helper"
|
"github/fthvgb1/wp-go/helper"
|
||||||
"github/fthvgb1/wp-go/logs"
|
"github/fthvgb1/wp-go/logs"
|
||||||
"github/fthvgb1/wp-go/models/wp"
|
"github/fthvgb1/wp-go/models/wp"
|
||||||
|
@ -33,8 +33,8 @@ func Detail(c *gin.Context) {
|
||||||
categoryItems := common.Categories(c)
|
categoryItems := common.Categories(c)
|
||||||
recentComments := common.RecentComments(c, 5)
|
recentComments := common.RecentComments(c, 5)
|
||||||
var h = gin.H{
|
var h = gin.H{
|
||||||
"title": config.Options.Value("blogname"),
|
"title": wpconfig.Options.Value("blogname"),
|
||||||
"options": config.Options,
|
"options": wpconfig.Options,
|
||||||
"recentPosts": recent,
|
"recentPosts": recent,
|
||||||
"archives": archive,
|
"archives": archive,
|
||||||
"categories": categoryItems,
|
"categories": categoryItems,
|
||||||
|
@ -93,11 +93,11 @@ func Detail(c *gin.Context) {
|
||||||
commentss := treeComments(comments)
|
commentss := treeComments(comments)
|
||||||
prev, next, err := common.GetContextPost(c, post.Id, post.PostDate)
|
prev, next, err := common.GetContextPost(c, post.Id, post.PostDate)
|
||||||
logs.ErrPrintln(err, "get pre and next post", post.Id, post.PostDate)
|
logs.ErrPrintln(err, "get pre and next post", post.Id, post.PostDate)
|
||||||
h["title"] = fmt.Sprintf("%s-%s", post.PostTitle, config.Options.Value("blogname"))
|
h["title"] = fmt.Sprintf("%s-%s", post.PostTitle, wpconfig.Options.Value("blogname"))
|
||||||
h["post"] = post
|
h["post"] = post
|
||||||
h["showComment"] = showComment
|
h["showComment"] = showComment
|
||||||
h["prev"] = prev
|
h["prev"] = prev
|
||||||
depth := config.Options.Value("thread_comments_depth")
|
depth := wpconfig.Options.Value("thread_comments_depth")
|
||||||
d, err := strconv.Atoi(depth)
|
d, err := strconv.Atoi(depth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.ErrPrintln(err, "get comment depth")
|
logs.ErrPrintln(err, "get comment depth")
|
||||||
|
@ -275,7 +275,7 @@ func gravatar(c *gin.Context, email string) (u string) {
|
||||||
q := url.Values{}
|
q := url.Values{}
|
||||||
q.Add("s", "112")
|
q.Add("s", "112")
|
||||||
q.Add("d", "mm")
|
q.Add("d", "mm")
|
||||||
q.Add("r", strings.ToLower(config.Options.Value("avatar_rating")))
|
q.Add("r", strings.ToLower(wpconfig.Options.Value("avatar_rating")))
|
||||||
u = fmt.Sprintf("%s?%s", u, q.Encode())
|
u = fmt.Sprintf("%s?%s", u, q.Encode())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github/fthvgb1/wp-go/actions/common"
|
"github/fthvgb1/wp-go/actions/common"
|
||||||
"github/fthvgb1/wp-go/cache"
|
"github/fthvgb1/wp-go/cache"
|
||||||
"github/fthvgb1/wp-go/config"
|
"github/fthvgb1/wp-go/config/wpconfig"
|
||||||
"github/fthvgb1/wp-go/helper"
|
"github/fthvgb1/wp-go/helper"
|
||||||
"github/fthvgb1/wp-go/logs"
|
"github/fthvgb1/wp-go/logs"
|
||||||
"github/fthvgb1/wp-go/models/wp"
|
"github/fthvgb1/wp-go/models/wp"
|
||||||
|
@ -26,14 +26,14 @@ var commentsFeedCache = cache.NewSliceCache(commentsFeed, time.Hour)
|
||||||
|
|
||||||
func InitFeed() {
|
func InitFeed() {
|
||||||
templateRss = rss2.Rss2{
|
templateRss = rss2.Rss2{
|
||||||
Title: config.Options.Value("blogname"),
|
Title: wpconfig.Options.Value("blogname"),
|
||||||
AtomLink: fmt.Sprintf("%s/feed", config.Options.Value("home")),
|
AtomLink: fmt.Sprintf("%s/feed", wpconfig.Options.Value("home")),
|
||||||
Link: config.Options.Value("siteurl"),
|
Link: wpconfig.Options.Value("siteurl"),
|
||||||
Description: config.Options.Value("blogdescription"),
|
Description: wpconfig.Options.Value("blogdescription"),
|
||||||
Language: "zh-CN",
|
Language: "zh-CN",
|
||||||
UpdatePeriod: "hourly",
|
UpdatePeriod: "hourly",
|
||||||
UpdateFrequency: 1,
|
UpdateFrequency: 1,
|
||||||
Generator: config.Options.Value("home"),
|
Generator: wpconfig.Options.Value("home"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,9 +97,9 @@ func feed(arg ...any) (xml []string, err error) {
|
||||||
}
|
}
|
||||||
l := ""
|
l := ""
|
||||||
if t.CommentStatus == "open" && t.CommentCount > 0 {
|
if t.CommentStatus == "open" && t.CommentCount > 0 {
|
||||||
l = fmt.Sprintf("%s/p/%d#comments", config.Options.Value("siteurl"), t.Id)
|
l = fmt.Sprintf("%s/p/%d#comments", wpconfig.Options.Value("siteurl"), t.Id)
|
||||||
} else if t.CommentStatus == "open" && t.CommentCount == 0 {
|
} else if t.CommentStatus == "open" && t.CommentCount == 0 {
|
||||||
l = fmt.Sprintf("%s/p/%d#respond", config.Options.Value("siteurl"), t.Id)
|
l = fmt.Sprintf("%s/p/%d#respond", wpconfig.Options.Value("siteurl"), t.Id)
|
||||||
}
|
}
|
||||||
user := common.GetUserById(c, t.PostAuthor)
|
user := common.GetUserById(c, t.PostAuthor)
|
||||||
|
|
||||||
|
@ -111,8 +111,8 @@ func feed(arg ...any) (xml []string, err error) {
|
||||||
Content: t.PostContent,
|
Content: t.PostContent,
|
||||||
Category: strings.Join(t.Categories, "、"),
|
Category: strings.Join(t.Categories, "、"),
|
||||||
CommentLink: l,
|
CommentLink: l,
|
||||||
CommentRss: fmt.Sprintf("%s/p/%d/feed", config.Options.Value("siteurl"), t.Id),
|
CommentRss: fmt.Sprintf("%s/p/%d/feed", wpconfig.Options.Value("siteurl"), t.Id),
|
||||||
Link: fmt.Sprintf("%s/p/%d", config.Options.Value("siteurl"), t.Id),
|
Link: fmt.Sprintf("%s/p/%d", wpconfig.Options.Value("siteurl"), t.Id),
|
||||||
Description: desc,
|
Description: desc,
|
||||||
PubDate: t.PostDateGmt.Format(timeFormat),
|
PubDate: t.PostDateGmt.Format(timeFormat),
|
||||||
}
|
}
|
||||||
|
@ -174,8 +174,8 @@ func postFeed(arg ...any) (x string, err error) {
|
||||||
rs := templateRss
|
rs := templateRss
|
||||||
|
|
||||||
rs.Title = fmt.Sprintf("《%s》的评论", post.PostTitle)
|
rs.Title = fmt.Sprintf("《%s》的评论", post.PostTitle)
|
||||||
rs.AtomLink = fmt.Sprintf("%s/p/%d/feed", config.Options.Value("siteurl"), post.Id)
|
rs.AtomLink = fmt.Sprintf("%s/p/%d/feed", wpconfig.Options.Value("siteurl"), post.Id)
|
||||||
rs.Link = fmt.Sprintf("%s/p/%d", config.Options.Value("siteurl"), post.Id)
|
rs.Link = fmt.Sprintf("%s/p/%d", wpconfig.Options.Value("siteurl"), post.Id)
|
||||||
rs.LastBuildDate = time.Now().Format(timeFormat)
|
rs.LastBuildDate = time.Now().Format(timeFormat)
|
||||||
if post.PostPassword != "" {
|
if post.PostPassword != "" {
|
||||||
if len(comments) > 0 {
|
if len(comments) > 0 {
|
||||||
|
@ -184,7 +184,7 @@ func postFeed(arg ...any) (x string, err error) {
|
||||||
rs.Items = []rss2.Item{
|
rs.Items = []rss2.Item{
|
||||||
{
|
{
|
||||||
Title: fmt.Sprintf("评价者:%s", t.CommentAuthor),
|
Title: fmt.Sprintf("评价者:%s", t.CommentAuthor),
|
||||||
Link: fmt.Sprintf("%s/p/%d#comment-%d", config.Options.Value("siteurl"), post.Id, t.CommentId),
|
Link: fmt.Sprintf("%s/p/%d#comment-%d", wpconfig.Options.Value("siteurl"), post.Id, t.CommentId),
|
||||||
Creator: t.CommentAuthor,
|
Creator: t.CommentAuthor,
|
||||||
PubDate: t.CommentDateGmt.Format(timeFormat),
|
PubDate: t.CommentDateGmt.Format(timeFormat),
|
||||||
Guid: fmt.Sprintf("%s#comment-%d", post.Guid, t.CommentId),
|
Guid: fmt.Sprintf("%s#comment-%d", post.Guid, t.CommentId),
|
||||||
|
@ -197,7 +197,7 @@ func postFeed(arg ...any) (x string, err error) {
|
||||||
rs.Items = helper.SliceMap(comments, func(t wp.Comments) rss2.Item {
|
rs.Items = helper.SliceMap(comments, func(t wp.Comments) rss2.Item {
|
||||||
return rss2.Item{
|
return rss2.Item{
|
||||||
Title: fmt.Sprintf("评价者:%s", t.CommentAuthor),
|
Title: fmt.Sprintf("评价者:%s", t.CommentAuthor),
|
||||||
Link: fmt.Sprintf("%s/p/%d#comment-%d", config.Options.Value("siteurl"), post.Id, t.CommentId),
|
Link: fmt.Sprintf("%s/p/%d#comment-%d", wpconfig.Options.Value("siteurl"), post.Id, t.CommentId),
|
||||||
Creator: t.CommentAuthor,
|
Creator: t.CommentAuthor,
|
||||||
PubDate: t.CommentDateGmt.Format(timeFormat),
|
PubDate: t.CommentDateGmt.Format(timeFormat),
|
||||||
Guid: fmt.Sprintf("%s#comment-%d", post.Guid, t.CommentId),
|
Guid: fmt.Sprintf("%s#comment-%d", post.Guid, t.CommentId),
|
||||||
|
@ -229,9 +229,9 @@ func commentsFeed(args ...any) (r []string, err error) {
|
||||||
c := args[0].(*gin.Context)
|
c := args[0].(*gin.Context)
|
||||||
commens := common.RecentComments(c, 10)
|
commens := common.RecentComments(c, 10)
|
||||||
rs := templateRss
|
rs := templateRss
|
||||||
rs.Title = fmt.Sprintf("\"%s\"的评论", config.Options.Value("blogname"))
|
rs.Title = fmt.Sprintf("\"%s\"的评论", wpconfig.Options.Value("blogname"))
|
||||||
rs.LastBuildDate = time.Now().Format(timeFormat)
|
rs.LastBuildDate = time.Now().Format(timeFormat)
|
||||||
rs.AtomLink = fmt.Sprintf("%s/comments/feed", config.Options.Value("siteurl"))
|
rs.AtomLink = fmt.Sprintf("%s/comments/feed", wpconfig.Options.Value("siteurl"))
|
||||||
com, err := common.GetCommentByIds(c, helper.SliceMap(commens, func(t wp.Comments) uint64 {
|
com, err := common.GetCommentByIds(c, helper.SliceMap(commens, func(t wp.Comments) uint64 {
|
||||||
return t.CommentId
|
return t.CommentId
|
||||||
}))
|
}))
|
||||||
|
@ -252,7 +252,7 @@ func commentsFeed(args ...any) (r []string, err error) {
|
||||||
}
|
}
|
||||||
return rss2.Item{
|
return rss2.Item{
|
||||||
Title: fmt.Sprintf("%s对《%s》的评论", t.CommentAuthor, post.PostTitle),
|
Title: fmt.Sprintf("%s对《%s》的评论", t.CommentAuthor, post.PostTitle),
|
||||||
Link: fmt.Sprintf("%s/p/%d#comment-%d", config.Options.Value("siteurl"), post.Id, t.CommentId),
|
Link: fmt.Sprintf("%s/p/%d#comment-%d", wpconfig.Options.Value("siteurl"), post.Id, t.CommentId),
|
||||||
Creator: t.CommentAuthor,
|
Creator: t.CommentAuthor,
|
||||||
Description: desc,
|
Description: desc,
|
||||||
PubDate: t.CommentDateGmt.Format(timeFormat),
|
PubDate: t.CommentDateGmt.Format(timeFormat),
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github/fthvgb1/wp-go/actions/common"
|
"github/fthvgb1/wp-go/actions/common"
|
||||||
"github/fthvgb1/wp-go/config"
|
"github/fthvgb1/wp-go/config/wpconfig"
|
||||||
"github/fthvgb1/wp-go/helper"
|
"github/fthvgb1/wp-go/helper"
|
||||||
"github/fthvgb1/wp-go/models"
|
"github/fthvgb1/wp-go/models"
|
||||||
"github/fthvgb1/wp-go/models/wp"
|
"github/fthvgb1/wp-go/models/wp"
|
||||||
|
@ -42,7 +42,7 @@ type indexHandle struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newIndexHandle(ctx *gin.Context) *indexHandle {
|
func newIndexHandle(ctx *gin.Context) *indexHandle {
|
||||||
size := config.Options.Value("posts_per_page")
|
size := wpconfig.Options.Value("posts_per_page")
|
||||||
si, _ := strconv.Atoi(size)
|
si, _ := strconv.Atoi(size)
|
||||||
return &indexHandle{
|
return &indexHandle{
|
||||||
c: ctx,
|
c: ctx,
|
||||||
|
@ -50,8 +50,8 @@ func newIndexHandle(ctx *gin.Context) *indexHandle {
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: si,
|
pageSize: si,
|
||||||
paginationStep: 1,
|
paginationStep: 1,
|
||||||
titleL: config.Options.Value("blogname"),
|
titleL: wpconfig.Options.Value("blogname"),
|
||||||
titleR: config.Options.Value("blogdescription"),
|
titleR: wpconfig.Options.Value("blogdescription"),
|
||||||
where: models.SqlBuilder{
|
where: models.SqlBuilder{
|
||||||
{"post_type", "in", ""},
|
{"post_type", "in", ""},
|
||||||
{"post_status", "in", ""},
|
{"post_status", "in", ""},
|
||||||
|
@ -95,7 +95,7 @@ func (h *indexHandle) parseParams() (err error) {
|
||||||
})
|
})
|
||||||
ss := fmt.Sprintf("%s年%s月", year, strings.TrimLeft(month, "0"))
|
ss := fmt.Sprintf("%s年%s月", year, strings.TrimLeft(month, "0"))
|
||||||
h.header = fmt.Sprintf("月度归档: <span>%s</span>", ss)
|
h.header = fmt.Sprintf("月度归档: <span>%s</span>", ss)
|
||||||
h.setTitleLR(ss, config.Options.Value("blogname"))
|
h.setTitleLR(ss, wpconfig.Options.Value("blogname"))
|
||||||
h.scene = plugins.Archive
|
h.scene = plugins.Archive
|
||||||
}
|
}
|
||||||
category := h.c.Param("category")
|
category := h.c.Param("category")
|
||||||
|
@ -133,7 +133,7 @@ func (h *indexHandle) parseParams() (err error) {
|
||||||
}, []string{
|
}, []string{
|
||||||
"left join", "wp_terms d", "c.term_id=d.term_id",
|
"left join", "wp_terms d", "c.term_id=d.term_id",
|
||||||
})
|
})
|
||||||
h.setTitleLR(category, config.Options.Value("blogname"))
|
h.setTitleLR(category, wpconfig.Options.Value("blogname"))
|
||||||
h.scene = plugins.Category
|
h.scene = plugins.Category
|
||||||
}
|
}
|
||||||
s := h.c.Query("s")
|
s := h.c.Query("s")
|
||||||
|
@ -146,7 +146,7 @@ func (h *indexHandle) parseParams() (err error) {
|
||||||
}, []string{"post_password", ""})
|
}, []string{"post_password", ""})
|
||||||
h.postType = append(h.postType, "page", "attachment")
|
h.postType = append(h.postType, "page", "attachment")
|
||||||
h.header = fmt.Sprintf("%s的搜索结果", s)
|
h.header = fmt.Sprintf("%s的搜索结果", s)
|
||||||
h.setTitleLR(helper.StrJoin(`"`, s, `"`, "的搜索结果"), config.Options.Value("blogname"))
|
h.setTitleLR(helper.StrJoin(`"`, s, `"`, "的搜索结果"), wpconfig.Options.Value("blogname"))
|
||||||
h.search = s
|
h.search = s
|
||||||
h.scene = plugins.Search
|
h.scene = plugins.Search
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ func (h *indexHandle) parseParams() (err error) {
|
||||||
h.page = 1
|
h.page = 1
|
||||||
}
|
}
|
||||||
if h.page > 1 && (h.category != "" || h.search != "" || month != "") {
|
if h.page > 1 && (h.category != "" || h.search != "" || month != "") {
|
||||||
h.setTitleLR(fmt.Sprintf("%s-第%d页", h.titleL, h.page), config.Options.Value("blogname"))
|
h.setTitleLR(fmt.Sprintf("%s-第%d页", h.titleL, h.page), wpconfig.Options.Value("blogname"))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ func Index(c *gin.Context) {
|
||||||
categoryItems := common.Categories(c)
|
categoryItems := common.Categories(c)
|
||||||
recentComments := common.RecentComments(c, 5)
|
recentComments := common.RecentComments(c, 5)
|
||||||
ginH := gin.H{
|
ginH := gin.H{
|
||||||
"options": config.Options,
|
"options": wpconfig.Options,
|
||||||
"recentPosts": recent,
|
"recentPosts": recent,
|
||||||
"archives": archive,
|
"archives": archive,
|
||||||
"categories": categoryItems,
|
"categories": categoryItems,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-contrib/sessions"
|
"github.com/gin-contrib/sessions"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github/fthvgb1/wp-go/config"
|
"github/fthvgb1/wp-go/config/wpconfig"
|
||||||
"github/fthvgb1/wp-go/helper"
|
"github/fthvgb1/wp-go/helper"
|
||||||
"github/fthvgb1/wp-go/phpass"
|
"github/fthvgb1/wp-go/phpass"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -33,7 +33,7 @@ func Login(c *gin.Context) {
|
||||||
c.Error(err)
|
c.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cohash := fmt.Sprintf("wp-postpass_%s", helper.StringMd5(config.Options.Value("siteurl")))
|
cohash := fmt.Sprintf("wp-postpass_%s", helper.StringMd5(wpconfig.Options.Value("siteurl")))
|
||||||
c.SetCookie(cohash, pass, 24*3600, "/", "", false, false)
|
c.SetCookie(cohash, pass, 24*3600, "/", "", false, false)
|
||||||
|
|
||||||
c.Redirect(http.StatusFound, ref)
|
c.Redirect(http.StatusFound, ref)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package config
|
package wpconfig
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -1,4 +1,4 @@
|
||||||
package config
|
package wpconfig
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
9
main.go
9
main.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"github/fthvgb1/wp-go/actions"
|
"github/fthvgb1/wp-go/actions"
|
||||||
"github/fthvgb1/wp-go/actions/common"
|
"github/fthvgb1/wp-go/actions/common"
|
||||||
"github/fthvgb1/wp-go/config"
|
"github/fthvgb1/wp-go/config"
|
||||||
|
"github/fthvgb1/wp-go/config/wpconfig"
|
||||||
"github/fthvgb1/wp-go/db"
|
"github/fthvgb1/wp-go/db"
|
||||||
"github/fthvgb1/wp-go/logs"
|
"github/fthvgb1/wp-go/logs"
|
||||||
"github/fthvgb1/wp-go/mail"
|
"github/fthvgb1/wp-go/mail"
|
||||||
|
@ -59,11 +60,11 @@ func initConf(c string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
models.InitDB(db.NewSqlxDb(db.Db))
|
models.InitDB(db.NewSqlxDb(db.Db))
|
||||||
err = config.InitOptions()
|
err = wpconfig.InitOptions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = config.InitTerms()
|
err = wpconfig.InitTerms()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -103,9 +104,9 @@ func reload() {
|
||||||
}()
|
}()
|
||||||
err := config.InitConfig(confPath)
|
err := config.InitConfig(confPath)
|
||||||
logs.ErrPrintln(err, "获取配置文件失败", confPath)
|
logs.ErrPrintln(err, "获取配置文件失败", confPath)
|
||||||
err = config.InitOptions()
|
err = wpconfig.InitOptions()
|
||||||
logs.ErrPrintln(err, "获取网站设置WpOption失败")
|
logs.ErrPrintln(err, "获取网站设置WpOption失败")
|
||||||
err = config.InitTerms()
|
err = wpconfig.InitTerms()
|
||||||
logs.ErrPrintln(err, "获取WpTerms表失败")
|
logs.ErrPrintln(err, "获取WpTerms表失败")
|
||||||
if middleWareReloadFn != nil {
|
if middleWareReloadFn != nil {
|
||||||
middleWareReloadFn()
|
middleWareReloadFn()
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github/fthvgb1/wp-go/config"
|
"github/fthvgb1/wp-go/config"
|
||||||
|
"github/fthvgb1/wp-go/config/wpconfig"
|
||||||
"github/fthvgb1/wp-go/logs"
|
"github/fthvgb1/wp-go/logs"
|
||||||
"github/fthvgb1/wp-go/mail"
|
"github/fthvgb1/wp-go/mail"
|
||||||
"io"
|
"io"
|
||||||
|
@ -42,7 +43,7 @@ func RecoverAndSendMail(w io.Writer) func(ctx *gin.Context) {
|
||||||
|
|
||||||
er := mail.SendMail(
|
er := mail.SendMail(
|
||||||
[]string{config.Conf.Load().Mail.User},
|
[]string{config.Conf.Load().Mail.User},
|
||||||
fmt.Sprintf("%s%s %s 发生错误", fmt.Sprintf(config.Options.Value("siteurl")), c.FullPath(), time.Now().Format(time.RFC1123Z)), content)
|
fmt.Sprintf("%s%s %s 发生错误", fmt.Sprintf(wpconfig.Options.Value("siteurl")), c.FullPath(), time.Now().Format(time.RFC1123Z)), content)
|
||||||
|
|
||||||
if er != nil {
|
if er != nil {
|
||||||
logs.ErrPrintln(er, "recover send mail fail", fmt.Sprintf("%v", err))
|
logs.ErrPrintln(er, "recover send mail fail", fmt.Sprintf("%v", err))
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github/fthvgb1/wp-go/actions"
|
"github/fthvgb1/wp-go/actions"
|
||||||
"github/fthvgb1/wp-go/config"
|
"github/fthvgb1/wp-go/config"
|
||||||
|
"github/fthvgb1/wp-go/config/wpconfig"
|
||||||
"github/fthvgb1/wp-go/middleware"
|
"github/fthvgb1/wp-go/middleware"
|
||||||
"github/fthvgb1/wp-go/static"
|
"github/fthvgb1/wp-go/static"
|
||||||
"github/fthvgb1/wp-go/templates"
|
"github/fthvgb1/wp-go/templates"
|
||||||
|
@ -36,7 +37,7 @@ func SetupRouter() (*gin.Engine, func()) {
|
||||||
return t.Format("2006年 01月 02日")
|
return t.Format("2006年 01月 02日")
|
||||||
},
|
},
|
||||||
"getOption": func(k string) string {
|
"getOption": func(k string) string {
|
||||||
return config.Options.Value(k)
|
return wpconfig.Options.Value(k)
|
||||||
},
|
},
|
||||||
}).SetTemplate()
|
}).SetTemplate()
|
||||||
validServerName, reloadValidServerNameFn := middleware.ValidateServerNames()
|
validServerName, reloadValidServerNameFn := middleware.ValidateServerNames()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user