From 66c8ba9de91ea18e6816939269553ced0b5c8d5f Mon Sep 17 00:00:00 2001 From: xing Date: Sat, 14 Jan 2023 12:21:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9B=AE=E5=BD=95=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=8F=8A=E5=B0=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/actions/comment.go | 2 +- internal/actions/detail.go | 27 ++++++----- internal/actions/feed.go | 20 ++++---- internal/actions/index.go | 27 ++++++----- internal/cmd/main.go | 4 +- internal/{ => cmd}/route/route.go | 48 +++++++++---------- internal/{ => pkg}/cache/cache.go | 38 +++++++-------- internal/{ => pkg}/cache/comments.go | 0 internal/{ => pkg}/cache/postmeta.go | 0 internal/{ => pkg}/cache/posts.go | 0 internal/{ => pkg}/cache/users.go | 0 internal/{ => pkg}/dao/comments.go | 0 internal/{ => pkg}/dao/common.go | 0 internal/{ => pkg}/dao/postmeta.go | 0 internal/{ => pkg}/dao/posts.go | 0 internal/{ => pkg}/dao/users.go | 0 .../static/wp-includes/css/classic-themes.css | 18 +++++++ .../wp-includes/css/classic-themes.min.css | 2 + internal/templates/templatefs.go | 11 +++++ .../twentyfifteen/layout/base.gohtml | 2 +- .../twentyfifteen/layout/head.gohtml | 2 +- 21 files changed, 121 insertions(+), 80 deletions(-) rename internal/{ => cmd}/route/route.go (60%) rename internal/{ => pkg}/cache/cache.go (61%) rename internal/{ => pkg}/cache/comments.go (100%) rename internal/{ => pkg}/cache/postmeta.go (100%) rename internal/{ => pkg}/cache/posts.go (100%) rename internal/{ => pkg}/cache/users.go (100%) rename internal/{ => pkg}/dao/comments.go (100%) rename internal/{ => pkg}/dao/common.go (100%) rename internal/{ => pkg}/dao/postmeta.go (100%) rename internal/{ => pkg}/dao/posts.go (100%) rename internal/{ => pkg}/dao/users.go (100%) create mode 100755 internal/static/wp-includes/css/classic-themes.css create mode 100755 internal/static/wp-includes/css/classic-themes.min.css diff --git a/internal/actions/comment.go b/internal/actions/comment.go index 16cd4af..5436d89 100644 --- a/internal/actions/comment.go +++ b/internal/actions/comment.go @@ -7,8 +7,8 @@ import ( "github.com/gin-gonic/gin" "github/fthvgb1/wp-go/cache" "github/fthvgb1/wp-go/helper" - cache2 "github/fthvgb1/wp-go/internal/cache" "github/fthvgb1/wp-go/internal/mail" + cache2 "github/fthvgb1/wp-go/internal/pkg/cache" "github/fthvgb1/wp-go/internal/pkg/config" "github/fthvgb1/wp-go/internal/pkg/logs" "github/fthvgb1/wp-go/internal/wpconfig" diff --git a/internal/actions/detail.go b/internal/actions/detail.go index d2be751..2be9fff 100644 --- a/internal/actions/detail.go +++ b/internal/actions/detail.go @@ -5,10 +5,11 @@ import ( "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" "github/fthvgb1/wp-go/helper" - "github/fthvgb1/wp-go/internal/cache" + cache2 "github/fthvgb1/wp-go/internal/pkg/cache" "github/fthvgb1/wp-go/internal/pkg/logs" "github/fthvgb1/wp-go/internal/pkg/models" "github/fthvgb1/wp-go/internal/plugins" + "github/fthvgb1/wp-go/internal/templates" "github/fthvgb1/wp-go/internal/wpconfig" "math/rand" "net/http" @@ -28,10 +29,10 @@ func Detail(c *gin.Context) { hh := detailHandler{ c, } - recent := cache.RecentPosts(c, 5) - archive := cache.Archives(c) - categoryItems := cache.Categories(c) - recentComments := cache.RecentComments(c, 5) + recent := cache2.RecentPosts(c, 5) + archive := cache2.Archives(c) + categoryItems := cache2.Categories(c) + recentComments := cache2.RecentComments(c, 5) var h = gin.H{ "title": wpconfig.Options.Value("blogname"), "options": wpconfig.Options, @@ -51,7 +52,11 @@ func Detail(c *gin.Context) { if isApproveComment == true { return } - c.HTML(status, helper.StrJoin(wpconfig.Options.Value("template"), "/posts/detail.gohtml"), h) + tmlp := wpconfig.Options.Value("template") + if i, err := templates.IsTemplateIsExist(tmlp); err != nil || !i { + tmlp = "twentyfifteen" + } + c.HTML(status, helper.StrJoin(tmlp, "/posts/detail.gohtml"), h) }() id := c.Param("id") Id := 0 @@ -62,12 +67,12 @@ func Detail(c *gin.Context) { } } ID := uint64(Id) - maxId, err := cache.GetMaxPostId(c) + maxId, err := cache2.GetMaxPostId(c) logs.ErrPrintln(err, "get max post id") if ID > maxId || err != nil { return } - post, err := cache.GetPostById(c, ID) + post, err := cache2.GetPostById(c, ID) if post.Id == 0 || err != nil { return } @@ -76,7 +81,7 @@ func Detail(c *gin.Context) { if post.CommentCount > 0 || post.CommentStatus == "open" { showComment = true } - user := cache.GetUserById(c, post.PostAuthor) + user := cache2.GetUserById(c, post.PostAuthor) plugins.PasswordProjectTitle(&post) if post.PostPassword != "" && pw != post.PostPassword { plugins.PasswdProjectContent(&post) @@ -89,10 +94,10 @@ func Detail(c *gin.Context) { return } plugins.ApplyPlugin(plugins.NewPostPlugin(c, plugins.Detail), &post) - comments, err := cache.PostComments(c, post.Id) + comments, err := cache2.PostComments(c, post.Id) logs.ErrPrintln(err, "get post comment", post.Id) commentss := treeComments(comments) - prev, next, err := cache.GetContextPost(c, post.Id, post.PostDate) + prev, next, err := cache2.GetContextPost(c, post.Id, post.PostDate) logs.ErrPrintln(err, "get pre and next post", post.Id, post.PostDate) h["title"] = fmt.Sprintf("%s-%s", post.PostTitle, wpconfig.Options.Value("blogname")) h["post"] = post diff --git a/internal/actions/feed.go b/internal/actions/feed.go index 769517a..857d39e 100644 --- a/internal/actions/feed.go +++ b/internal/actions/feed.go @@ -5,7 +5,7 @@ import ( "github.com/gin-gonic/gin" "github/fthvgb1/wp-go/cache" "github/fthvgb1/wp-go/helper" - cache2 "github/fthvgb1/wp-go/internal/cache" + cache3 "github/fthvgb1/wp-go/internal/pkg/cache" "github/fthvgb1/wp-go/internal/pkg/logs" models2 "github/fthvgb1/wp-go/internal/pkg/models" "github/fthvgb1/wp-go/internal/plugins" @@ -78,11 +78,11 @@ func Feed(c *gin.Context) { func feed(arg ...any) (xml []string, err error) { c := arg[0].(*gin.Context) - r := cache2.RecentPosts(c, 10) + r := cache3.RecentPosts(c, 10) ids := helper.SliceMap(r, func(t models2.Posts) uint64 { return t.Id }) - posts, err := cache2.GetPostsByIds(c, ids) + posts, err := cache3.GetPostsByIds(c, ids) if err != nil { return } @@ -102,7 +102,7 @@ func feed(arg ...any) (xml []string, err error) { } else if t.CommentStatus == "open" && t.CommentCount == 0 { l = fmt.Sprintf("%s/p/%d#respond", wpconfig.Options.Value("siteurl"), t.Id) } - user := cache2.GetUserById(c, t.PostAuthor) + user := cache3.GetUserById(c, t.PostAuthor) return rss2.Item{ Title: t.PostTitle, @@ -158,17 +158,17 @@ func postFeed(arg ...any) (x string, err error) { } } ID := uint64(Id) - maxId, err := cache2.GetMaxPostId(c) + maxId, err := cache3.GetMaxPostId(c) logs.ErrPrintln(err, "get max post id") if ID > maxId || err != nil { return } - post, err := cache2.GetPostById(c, ID) + post, err := cache3.GetPostById(c, ID) if post.Id == 0 || err != nil { return } plugins.PasswordProjectTitle(&post) - comments, err := cache2.PostComments(c, post.Id) + comments, err := cache3.PostComments(c, post.Id) if err != nil { return } @@ -228,19 +228,19 @@ func CommentsFeed(c *gin.Context) { func commentsFeed(args ...any) (r []string, err error) { c := args[0].(*gin.Context) - commens := cache2.RecentComments(c, 10) + commens := cache3.RecentComments(c, 10) rs := templateRss rs.Title = fmt.Sprintf("\"%s\"的评论", wpconfig.Options.Value("blogname")) rs.LastBuildDate = time.Now().Format(timeFormat) rs.AtomLink = fmt.Sprintf("%s/comments/feed", wpconfig.Options.Value("siteurl")) - com, err := cache2.GetCommentByIds(c, helper.SliceMap(commens, func(t models2.Comments) uint64 { + com, err := cache3.GetCommentByIds(c, helper.SliceMap(commens, func(t models2.Comments) uint64 { return t.CommentId })) if nil != err { return []string{}, err } rs.Items = helper.SliceMap(com, func(t models2.Comments) rss2.Item { - post, _ := cache2.GetPostById(c, t.CommentPostId) + post, _ := cache3.GetPostById(c, t.CommentPostId) plugins.PasswordProjectTitle(&post) desc := "评论受保护:要查看请输入密码。" content := t.CommentContent diff --git a/internal/actions/index.go b/internal/actions/index.go index 680c915..9bc2156 100644 --- a/internal/actions/index.go +++ b/internal/actions/index.go @@ -5,10 +5,11 @@ import ( "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" "github/fthvgb1/wp-go/helper" - "github/fthvgb1/wp-go/internal/cache" - dao "github/fthvgb1/wp-go/internal/dao" + cache2 "github/fthvgb1/wp-go/internal/pkg/cache" + dao "github/fthvgb1/wp-go/internal/pkg/dao" "github/fthvgb1/wp-go/internal/pkg/models" "github/fthvgb1/wp-go/internal/plugins" + "github/fthvgb1/wp-go/internal/templates" "github/fthvgb1/wp-go/internal/wpconfig" "github/fthvgb1/wp-go/model" "math" @@ -114,7 +115,7 @@ func (h *indexHandle) parseParams() (err error) { h.category = category username := h.c.Param("author") if username != "" { - user, er := cache.GetUserByName(h.c, username) + user, er := cache2.GetUserByName(h.c, username) if er != nil { err = er return @@ -181,10 +182,10 @@ func Index(c *gin.Context) { var postIds []models.Posts var totalRaw int var err error - archive := cache.Archives(c) - recent := cache.RecentPosts(c, 5) - categoryItems := cache.Categories(c) - recentComments := cache.RecentComments(c, 5) + archive := cache2.Archives(c) + recent := cache2.RecentPosts(c, 5) + categoryItems := cache2.Categories(c) + recentComments := cache2.RecentComments(c, 5) ginH := gin.H{ "options": wpconfig.Options, "recentPosts": recent, @@ -201,7 +202,11 @@ func Index(c *gin.Context) { stat = http.StatusInternalServerError return } - c.HTML(stat, helper.StrJoin(wpconfig.Options.Value("template"), "/posts/index.gohtml"), ginH) + tmlp := wpconfig.Options.Value("template") + if i, err := templates.IsTemplateIsExist(tmlp); err != nil || !i { + tmlp = "twentyfifteen" + } + c.HTML(stat, helper.StrJoin(tmlp, "/posts/index.gohtml"), ginH) }() err = h.parseParams() if err != nil { @@ -209,14 +214,14 @@ func Index(c *gin.Context) { } ginH["title"] = h.getTitle() if c.Param("month") != "" { - postIds, totalRaw, err = cache.GetMonthPostIds(c, c.Param("year"), c.Param("month"), h.page, h.pageSize, h.order) + postIds, totalRaw, err = cache2.GetMonthPostIds(c, c.Param("year"), c.Param("month"), h.page, h.pageSize, h.order) if err != nil { return } } else if h.search != "" { - postIds, totalRaw, err = cache.SearchPost(c, h.getSearchKey(), c, h.where, h.page, h.pageSize, model.SqlBuilder{{h.orderBy, h.order}}, h.join, h.postType, h.status) + postIds, totalRaw, err = cache2.SearchPost(c, h.getSearchKey(), c, h.where, h.page, h.pageSize, model.SqlBuilder{{h.orderBy, h.order}}, h.join, h.postType, h.status) } else { - postIds, totalRaw, err = cache.PostLists(c, h.getSearchKey(), c, h.where, h.page, h.pageSize, model.SqlBuilder{{h.orderBy, h.order}}, h.join, h.postType, h.status) + postIds, totalRaw, err = cache2.PostLists(c, h.getSearchKey(), c, h.where, h.page, h.pageSize, model.SqlBuilder{{h.orderBy, h.order}}, h.join, h.postType, h.status) } if err != nil { return diff --git a/internal/cmd/main.go b/internal/cmd/main.go index 436f1a3..78e3302 100644 --- a/internal/cmd/main.go +++ b/internal/cmd/main.go @@ -4,13 +4,13 @@ import ( "flag" "fmt" "github/fthvgb1/wp-go/internal/actions" - "github/fthvgb1/wp-go/internal/cache" + "github/fthvgb1/wp-go/internal/cmd/route" "github/fthvgb1/wp-go/internal/mail" + "github/fthvgb1/wp-go/internal/pkg/cache" "github/fthvgb1/wp-go/internal/pkg/config" "github/fthvgb1/wp-go/internal/pkg/db" "github/fthvgb1/wp-go/internal/pkg/logs" "github/fthvgb1/wp-go/internal/plugins" - "github/fthvgb1/wp-go/internal/route" "github/fthvgb1/wp-go/internal/wpconfig" "github/fthvgb1/wp-go/model" "log" diff --git a/internal/route/route.go b/internal/cmd/route/route.go similarity index 60% rename from internal/route/route.go rename to internal/cmd/route/route.go index 9cbce7c..ab23c64 100644 --- a/internal/route/route.go +++ b/internal/cmd/route/route.go @@ -6,8 +6,8 @@ import ( "github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions/cookie" "github.com/gin-gonic/gin" - actions2 "github/fthvgb1/wp-go/internal/actions" - middleware2 "github/fthvgb1/wp-go/internal/middleware" + "github/fthvgb1/wp-go/internal/actions" + "github/fthvgb1/wp-go/internal/middleware" "github/fthvgb1/wp-go/internal/pkg/config" "github/fthvgb1/wp-go/internal/static" "github/fthvgb1/wp-go/internal/templates" @@ -40,14 +40,14 @@ func SetupRouter() (*gin.Engine, func()) { return wpconfig.Options.Value(k) }, }).SetTemplate() - validServerName, reloadValidServerNameFn := middleware2.ValidateServerNames() - fl, flReload := middleware2.FlowLimit(c.MaxRequestSleepNum, c.MaxRequestNum, c.SleepTime) + validServerName, reloadValidServerNameFn := middleware.ValidateServerNames() + fl, flReload := middleware.FlowLimit(c.MaxRequestSleepNum, c.MaxRequestNum, c.SleepTime) r.Use( gin.Logger(), validServerName, - middleware2.RecoverAndSendMail(gin.DefaultErrorWriter), + middleware.RecoverAndSendMail(gin.DefaultErrorWriter), fl, - middleware2.SetStaticFileCache, + middleware.SetStaticFileCache, ) //gzip 因为一般会用nginx做反代时自动使用gzip,所以go这边本身可以不用 if c.Gzip { @@ -65,24 +65,24 @@ func SetupRouter() (*gin.Engine, func()) { })) store := cookie.NewStore([]byte("secret")) r.Use(sessions.Sessions("go-wp", store)) - sl, slRload := middleware2.SearchLimit(c.SingleIpSearchNum) - r.GET("/", sl, actions2.Index) - r.GET("/page/:page", actions2.Index) - r.GET("/p/category/:category", actions2.Index) - r.GET("/p/category/:category/page/:page", actions2.Index) - r.GET("/p/tag/:tag", actions2.Index) - r.GET("/p/tag/:tag/page/:page", actions2.Index) - r.GET("/p/date/:year/:month", actions2.Index) - r.GET("/p/date/:year/:month/page/:page", actions2.Index) - r.GET("/p/author/:author", actions2.Index) - r.GET("/p/author/:author/page/:page", actions2.Index) - r.POST("/login", actions2.Login) - r.GET("/p/:id", actions2.Detail) - r.GET("/p/:id/feed", actions2.PostFeed) - r.GET("/feed", actions2.Feed) - r.GET("/comments/feed", actions2.CommentsFeed) - cfl, _ := middleware2.FlowLimit(c.MaxRequestSleepNum, 5, c.SleepTime) - r.POST("/comment", cfl, actions2.PostComment) + sl, slRload := middleware.SearchLimit(c.SingleIpSearchNum) + r.GET("/", sl, actions.Index) + r.GET("/page/:page", actions.Index) + r.GET("/p/category/:category", actions.Index) + r.GET("/p/category/:category/page/:page", actions.Index) + r.GET("/p/tag/:tag", actions.Index) + r.GET("/p/tag/:tag/page/:page", actions.Index) + r.GET("/p/date/:year/:month", actions.Index) + r.GET("/p/date/:year/:month/page/:page", actions.Index) + r.GET("/p/author/:author", actions.Index) + r.GET("/p/author/:author/page/:page", actions.Index) + r.POST("/login", actions.Login) + r.GET("/p/:id", actions.Detail) + r.GET("/p/:id/feed", actions.PostFeed) + r.GET("/feed", actions.Feed) + r.GET("/comments/feed", actions.CommentsFeed) + cfl, _ := middleware.FlowLimit(c.MaxRequestSleepNum, 5, c.SleepTime) + r.POST("/comment", cfl, actions.PostComment) if gin.Mode() != gin.ReleaseMode { pprof.Register(r, "dev/pprof") } diff --git a/internal/cache/cache.go b/internal/pkg/cache/cache.go similarity index 61% rename from internal/cache/cache.go rename to internal/pkg/cache/cache.go index ed9eee2..d2d775f 100644 --- a/internal/cache/cache.go +++ b/internal/pkg/cache/cache.go @@ -3,15 +3,15 @@ package cache import ( "context" "github/fthvgb1/wp-go/cache" - dao "github/fthvgb1/wp-go/internal/dao" "github/fthvgb1/wp-go/internal/pkg/config" + "github/fthvgb1/wp-go/internal/pkg/dao" "github/fthvgb1/wp-go/internal/pkg/logs" models2 "github/fthvgb1/wp-go/internal/pkg/models" "sync" "time" ) -var postContextCache *cache.MapCache[uint64, dao.PostContext] +var postContextCache *cache.MapCache[uint64, common.PostContext] var archivesCaches *Arch var categoryCaches *cache.SliceCache[models2.TermsMy] var recentPostsCaches *cache.SliceCache[models2.Posts] @@ -22,8 +22,8 @@ var postsCache *cache.MapCache[uint64, models2.Posts] var postMetaCache *cache.MapCache[uint64, map[string]any] var monthPostsCache *cache.MapCache[string, []uint64] -var postListIdsCache *cache.MapCache[string, dao.PostIds] -var searchPostIdsCache *cache.MapCache[string, dao.PostIds] +var postListIdsCache *cache.MapCache[string, common.PostIds] +var searchPostIdsCache *cache.MapCache[string, common.PostIds] var maxPostIdCache *cache.SliceCache[uint64] var usersCache *cache.MapCache[uint64, models2.Users] @@ -34,36 +34,36 @@ func InitActionsCommonCache() { c := config.Conf.Load() archivesCaches = &Arch{ mutex: &sync.Mutex{}, - setCacheFunc: dao.Archives, + setCacheFunc: common.Archives, } - searchPostIdsCache = cache.NewMapCacheByFn[string, dao.PostIds](dao.SearchPostIds, c.SearchPostCacheTime) + searchPostIdsCache = cache.NewMapCacheByFn[string, common.PostIds](common.SearchPostIds, c.SearchPostCacheTime) - postListIdsCache = cache.NewMapCacheByFn[string, dao.PostIds](dao.SearchPostIds, c.PostListCacheTime) + postListIdsCache = cache.NewMapCacheByFn[string, common.PostIds](common.SearchPostIds, c.PostListCacheTime) - monthPostsCache = cache.NewMapCacheByFn[string, []uint64](dao.MonthPost, c.MonthPostCacheTime) + monthPostsCache = cache.NewMapCacheByFn[string, []uint64](common.MonthPost, c.MonthPostCacheTime) - postContextCache = cache.NewMapCacheByFn[uint64, dao.PostContext](dao.GetPostContext, c.ContextPostCacheTime) + postContextCache = cache.NewMapCacheByFn[uint64, common.PostContext](common.GetPostContext, c.ContextPostCacheTime) - postsCache = cache.NewMapCacheByBatchFn[uint64, models2.Posts](dao.GetPostsByIds, c.PostDataCacheTime) + postsCache = cache.NewMapCacheByBatchFn[uint64, models2.Posts](common.GetPostsByIds, c.PostDataCacheTime) - postMetaCache = cache.NewMapCacheByBatchFn[uint64, map[string]any](dao.GetPostMetaByPostIds, c.PostDataCacheTime) + postMetaCache = cache.NewMapCacheByBatchFn[uint64, map[string]any](common.GetPostMetaByPostIds, c.PostDataCacheTime) - categoryCaches = cache.NewSliceCache[models2.TermsMy](dao.Categories, c.CategoryCacheTime) + categoryCaches = cache.NewSliceCache[models2.TermsMy](common.Categories, c.CategoryCacheTime) - recentPostsCaches = cache.NewSliceCache[models2.Posts](dao.RecentPosts, c.RecentPostCacheTime) + recentPostsCaches = cache.NewSliceCache[models2.Posts](common.RecentPosts, c.RecentPostCacheTime) - recentCommentsCaches = cache.NewSliceCache[models2.Comments](dao.RecentComments, c.RecentCommentsCacheTime) + recentCommentsCaches = cache.NewSliceCache[models2.Comments](common.RecentComments, c.RecentCommentsCacheTime) - postCommentCaches = cache.NewMapCacheByFn[uint64, []uint64](dao.PostComments, c.PostCommentsCacheTime) + postCommentCaches = cache.NewMapCacheByFn[uint64, []uint64](common.PostComments, c.PostCommentsCacheTime) - maxPostIdCache = cache.NewSliceCache[uint64](dao.GetMaxPostId, c.MaxPostIdCacheTime) + maxPostIdCache = cache.NewSliceCache[uint64](common.GetMaxPostId, c.MaxPostIdCacheTime) - usersCache = cache.NewMapCacheByFn[uint64, models2.Users](dao.GetUserById, c.UserInfoCacheTime) + usersCache = cache.NewMapCacheByFn[uint64, models2.Users](common.GetUserById, c.UserInfoCacheTime) - usersNameCache = cache.NewMapCacheByFn[string, models2.Users](dao.GetUserByName, c.UserInfoCacheTime) + usersNameCache = cache.NewMapCacheByFn[string, models2.Users](common.GetUserByName, c.UserInfoCacheTime) - commentsCache = cache.NewMapCacheByBatchFn[uint64, models2.Comments](dao.GetCommentByIds, c.CommentsCacheTime) + commentsCache = cache.NewMapCacheByBatchFn[uint64, models2.Comments](common.GetCommentByIds, c.CommentsCacheTime) } func ClearCache() { diff --git a/internal/cache/comments.go b/internal/pkg/cache/comments.go similarity index 100% rename from internal/cache/comments.go rename to internal/pkg/cache/comments.go diff --git a/internal/cache/postmeta.go b/internal/pkg/cache/postmeta.go similarity index 100% rename from internal/cache/postmeta.go rename to internal/pkg/cache/postmeta.go diff --git a/internal/cache/posts.go b/internal/pkg/cache/posts.go similarity index 100% rename from internal/cache/posts.go rename to internal/pkg/cache/posts.go diff --git a/internal/cache/users.go b/internal/pkg/cache/users.go similarity index 100% rename from internal/cache/users.go rename to internal/pkg/cache/users.go diff --git a/internal/dao/comments.go b/internal/pkg/dao/comments.go similarity index 100% rename from internal/dao/comments.go rename to internal/pkg/dao/comments.go diff --git a/internal/dao/common.go b/internal/pkg/dao/common.go similarity index 100% rename from internal/dao/common.go rename to internal/pkg/dao/common.go diff --git a/internal/dao/postmeta.go b/internal/pkg/dao/postmeta.go similarity index 100% rename from internal/dao/postmeta.go rename to internal/pkg/dao/postmeta.go diff --git a/internal/dao/posts.go b/internal/pkg/dao/posts.go similarity index 100% rename from internal/dao/posts.go rename to internal/pkg/dao/posts.go diff --git a/internal/dao/users.go b/internal/pkg/dao/users.go similarity index 100% rename from internal/dao/users.go rename to internal/pkg/dao/users.go diff --git a/internal/static/wp-includes/css/classic-themes.css b/internal/static/wp-includes/css/classic-themes.css new file mode 100755 index 0000000..d77a25a --- /dev/null +++ b/internal/static/wp-includes/css/classic-themes.css @@ -0,0 +1,18 @@ +/** + * These rules are needed for backwards compatibility. + * They should match the button element rules in the base theme.json file. + */ +.wp-block-button__link { + color: #ffffff; + background-color: #32373c; + border-radius: 9999px; /* 100% causes an oval, but any explicit but really high value retains the pill shape. */ + + /* This needs a low specificity so it won't override the rules from the button element if defined in theme.json. */ + box-shadow: none; + text-decoration: none; + + /* The extra 2px are added to size solids the same as the outline versions.*/ + padding: calc(0.667em + 2px) calc(1.333em + 2px); + + font-size: 1.125em; +} diff --git a/internal/static/wp-includes/css/classic-themes.min.css b/internal/static/wp-includes/css/classic-themes.min.css new file mode 100755 index 0000000..695cb3c --- /dev/null +++ b/internal/static/wp-includes/css/classic-themes.min.css @@ -0,0 +1,2 @@ +/*! This file is auto-generated */ +.wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em} \ No newline at end of file diff --git a/internal/templates/templatefs.go b/internal/templates/templatefs.go index 1cafee8..a88662d 100644 --- a/internal/templates/templatefs.go +++ b/internal/templates/templatefs.go @@ -42,3 +42,14 @@ func (t FsTemplate) Instance(name string, data any) render.Render { Data: data, } } + +func IsTemplateIsExist(tml string) (r bool, err error) { + arr, err := TemplateFs.ReadDir(tml) + if err != nil { + return + } + if len(arr) > 0 { + r = true + } + return +} diff --git a/internal/templates/twentyfifteen/layout/base.gohtml b/internal/templates/twentyfifteen/layout/base.gohtml index 559d6af..87569c8 100644 --- a/internal/templates/twentyfifteen/layout/base.gohtml +++ b/internal/templates/twentyfifteen/layout/base.gohtml @@ -1,6 +1,6 @@ {{ define "layout/base"}} - + {{template "layout/head" .}} {{block "head" .}} diff --git a/internal/templates/twentyfifteen/layout/head.gohtml b/internal/templates/twentyfifteen/layout/head.gohtml index 0bad834..f6f3309 100644 --- a/internal/templates/twentyfifteen/layout/head.gohtml +++ b/internal/templates/twentyfifteen/layout/head.gohtml @@ -1,5 +1,5 @@ {{define "layout/head"}} - +