上传目录
This commit is contained in:
parent
3d07fffc82
commit
8af7556511
@ -78,4 +78,6 @@ port: 8082
|
||||
# 主题 为空值为option template,没有就默认为twentyfifteen
|
||||
theme: "twentyfifteen"
|
||||
# 文档排序默认升序还是降序
|
||||
postOrder: "desc"
|
||||
postOrder: "desc"
|
||||
# 上传的目录
|
||||
uploadDir: ""
|
@ -44,13 +44,20 @@ func SetupRouter() (*gin.Engine, func()) {
|
||||
})))
|
||||
}
|
||||
|
||||
f := static.Fs{FS: static.FsEx, Path: "wp-includes"}
|
||||
r.StaticFileFS("/favicon.ico", "favicon.ico", http.FS(static.FsEx))
|
||||
f := static.Fs{FS: static.FsDir, Path: "wp-includes"}
|
||||
r.StaticFileFS("/favicon.ico", "favicon.ico", http.FS(static.FsDir))
|
||||
r.StaticFS("/wp-includes", http.FS(f))
|
||||
r.StaticFS("/wp-content", http.FS(static.Fs{
|
||||
FS: static.FsEx,
|
||||
Path: "wp-content",
|
||||
r.StaticFS("/wp-content/plugins", http.FS(static.Fs{
|
||||
FS: static.FsDir,
|
||||
Path: "wp-content/plugins",
|
||||
}))
|
||||
r.StaticFS("/wp-content/themes", http.FS(static.Fs{
|
||||
FS: static.FsDir,
|
||||
Path: "wp-content/themes",
|
||||
}))
|
||||
if c.UploadDir != "" {
|
||||
r.Static("/wp-content/uploads", c.UploadDir)
|
||||
}
|
||||
store := cookie.NewStore([]byte("secret"))
|
||||
r.Use(sessions.Sessions("go-wp", store))
|
||||
sl, slRload := middleware.SearchLimit(c.SingleIpSearchNum)
|
||||
|
@ -40,6 +40,7 @@ type Config struct {
|
||||
TrustServerNames []string `yaml:"trustServerNames"`
|
||||
Theme string `yaml:"theme"`
|
||||
PostOrder string `yaml:"postOrder"`
|
||||
UploadDir string `yaml:"uploadDir"`
|
||||
}
|
||||
|
||||
type Ssl struct {
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"github.com/fthvgb1/wp-go/helper/slice"
|
||||
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
||||
"github.com/fthvgb1/wp-go/internal/plugins"
|
||||
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
||||
"github.com/fthvgb1/wp-go/model"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
@ -44,7 +43,8 @@ func GetPostsByIds(ids ...any) (m map[uint64]models.Posts, err error) {
|
||||
}
|
||||
postsMap[post.Id] = v
|
||||
}
|
||||
host, _ := wpconfig.Options.Load("siteurl")
|
||||
//host, _ := wpconfig.Options.Load("siteurl")
|
||||
host := ""
|
||||
meta, _ := GetPostMetaByPostIds(ctx, id)
|
||||
for k, pp := range postsMap {
|
||||
if len(pp.Categories) > 0 {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
//go:embed wp-content wp-includes favicon.ico
|
||||
var FsEx embed.FS
|
||||
var FsDir embed.FS
|
||||
|
||||
type Fs struct {
|
||||
embed.FS
|
||||
|
@ -50,11 +50,11 @@
|
||||
<link rel='stylesheet' id='twentyseventeen-style-css' href='/wp-content/themes/twentyseventeen/style.css?ver=20221101' media='all' />
|
||||
<link rel='stylesheet' id='twentyseventeen-block-style-css' href='/wp-content/themes/twentyseventeen/assets/css/blocks.css?ver=20220912' media='all' />
|
||||
<!--[if lt IE 9]>
|
||||
<link rel='stylesheet' id='twentyseventeen-ie8-css' href='http://wp.test/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]-->
|
||||
<link rel='stylesheet' id='enlighterjs-css' href='http://wp.test/wp-content/plugins/enlighter/cache/enlighterjs.min.css?ver=0A0B0C' media='all' />
|
||||
<link rel='stylesheet' id='enlighterjs-css' href='/wp-content/plugins/enlighter/cache/enlighterjs.min.css?ver=0A0B0C' media='all' />
|
||||
<!--[if lt IE 9]>
|
||||
<script src='http://wp.test/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]-->
|
||||
|
||||
|
||||
|
@ -88,7 +88,8 @@ func Hook(status int, c *gin.Context, h gin.H, scene, stats int) {
|
||||
h["HeaderImage"] = getHeaderImage(c)
|
||||
post := h["post"].(models.Posts)
|
||||
h["bodyClass"] = bodyClass(scene, int(post.Id))
|
||||
host, _ := wpconfig.Options.Load("siteurl")
|
||||
//host, _ := wpconfig.Options.Load("siteurl")
|
||||
host := ""
|
||||
img := plugins.Thumbnail(post.Thumbnail.OriginAttachmentData, "thumbnail", host, "thumbnail", "post-thumbnail")
|
||||
img.Width = img.OriginAttachmentData.Width
|
||||
img.Height = img.OriginAttachmentData.Height
|
||||
@ -149,12 +150,13 @@ func getHeaderImage(c *gin.Context) (r models.PostThumbnail) {
|
||||
logs.ErrPrintln(err, "获取主题背景图信息错误")
|
||||
return
|
||||
}
|
||||
host, _ := wpconfig.Options.Load("siteurl")
|
||||
//host, _ := wpconfig.Options.Load("siteurl")
|
||||
host := ""
|
||||
m.Thumbnail = plugins.Thumbnail(m.AttachmentMetadata, "thumbnail", host, "thumbnail", "post-thumbnail", "twentyseventeen-thumbnail-avatar")
|
||||
if m.Thumbnail.Path != "" {
|
||||
r = m.Thumbnail
|
||||
if len(m.AttachmentMetadata.Sizes) > 0 {
|
||||
r.Srcset = str.Join(r.Path, " 2000vw, ", r.Srcset)
|
||||
r.Srcset = str.Join(r.Path, " 2000w, ", r.Srcset)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user