Compare commits
No commits in common. "1b1e3bf8f351ae1e527172a717ea936fc400f25b" and "477d8fe6f9d990a18ff9fbcbbbdc95a7413e6911" have entirely different histories.
1b1e3bf8f3
...
477d8fe6f9
|
@ -11,6 +11,16 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
var commonClass = map[int]string{
|
||||
constraints.Home: "home blog ",
|
||||
constraints.Archive: "archive date ",
|
||||
constraints.Category: "archive category ",
|
||||
constraints.Tag: "archive category ",
|
||||
constraints.Search: "search ",
|
||||
constraints.Author: "archive author ",
|
||||
constraints.Detail: "post-template-default single single-post ",
|
||||
}
|
||||
|
||||
func (h *Handle) CalBodyClass() {
|
||||
h.GinH["bodyClass"] = h.BodyClass(h.Class...)
|
||||
}
|
||||
|
@ -20,21 +30,13 @@ func (h *Handle) BodyClass(class ...string) string {
|
|||
return "error404"
|
||||
}
|
||||
switch h.Scene {
|
||||
case constraints.Home:
|
||||
class = append(class, "home", "blog")
|
||||
|
||||
case constraints.Archive:
|
||||
class = append(class, "archive", "date")
|
||||
|
||||
case constraints.Search:
|
||||
s := "search-no-results"
|
||||
if len(h.Index.Posts) > 0 {
|
||||
s = "search-results"
|
||||
}
|
||||
class = append(class, "search", s)
|
||||
|
||||
class = append(class, s)
|
||||
case constraints.Category, constraints.Tag:
|
||||
class = append(class, "archive", "category")
|
||||
cat := h.Index.Param.Category
|
||||
_, cate := slice.SearchFirst(cache.CategoriesTags(h.C, h.Scene), func(my models.TermsMy) bool {
|
||||
return my.Name == cat
|
||||
|
@ -45,7 +47,6 @@ func (h *Handle) BodyClass(class ...string) string {
|
|||
class = append(class, str.Join("category-", number.ToString(cate.Terms.TermId)))
|
||||
|
||||
case constraints.Author:
|
||||
class = append(class, "archive", "author")
|
||||
author := h.Index.Param.Author
|
||||
user, _ := cache.GetUserByName(h.C, author)
|
||||
class = append(class, str.Join("author-", number.ToString(user.Id)))
|
||||
|
@ -54,7 +55,6 @@ func (h *Handle) BodyClass(class ...string) string {
|
|||
}
|
||||
|
||||
case constraints.Detail:
|
||||
class = append(class, "post-template-default", "single", "single-post")
|
||||
class = append(class, str.Join("postid-", number.ToString(h.Detail.Post.Id)))
|
||||
if len(h.ThemeMods.ThemeSupport.PostFormats) > 0 {
|
||||
class = append(class, "single-format-standard")
|
||||
|
@ -69,5 +69,6 @@ func (h *Handle) BodyClass(class ...string) string {
|
|||
if h.ThemeMods.ThemeSupport.ResponsiveEmbeds {
|
||||
class = append(class, "wp-embed-responsive")
|
||||
}
|
||||
return strings.Join(class, " ")
|
||||
class = append(class, strings.Fields(commonClass[h.Scene])...)
|
||||
return strings.Join(slice.Reverse(class), " ")
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ type Handle struct {
|
|||
Class []string
|
||||
Scripts map[string][]func(*Handle) string
|
||||
ThemeMods wpconfig.ThemeMods
|
||||
HandleFns []HandleFn[*Handle]
|
||||
HandleFns []func(*Handle)
|
||||
}
|
||||
|
||||
func NewHandle(c *gin.Context, scene int, theme string) *Handle {
|
||||
|
@ -47,11 +47,11 @@ func NewHandle(c *gin.Context, scene int, theme string) *Handle {
|
|||
}
|
||||
}
|
||||
|
||||
func (h *Handle) PushHandleFn(fns ...HandleFn[*Handle]) {
|
||||
func (h *Handle) PushHandleFn(fns ...func(*Handle)) {
|
||||
h.HandleFns = append(h.HandleFns, fns...)
|
||||
}
|
||||
|
||||
func (h *Handle) PlushComponent(name string, fn func(*Handle) string) {
|
||||
func (h *Handle) AutoCal(name string, fn func(*Handle) string) {
|
||||
v, ok := reload.GetStr(name)
|
||||
if !ok {
|
||||
v = fn(h)
|
||||
|
@ -86,7 +86,7 @@ func (h *Handle) Render() {
|
|||
fn(h)
|
||||
}
|
||||
h.PushHeadScript(constraints.HeadScript, CalSiteIcon, CalCustomCss)
|
||||
h.PlushComponent("customLogo", CalCustomLogo)
|
||||
h.AutoCal("customLogo", CalCustomLogo)
|
||||
h.CalMultipleScript()
|
||||
h.CalBodyClass()
|
||||
|
||||
|
|
|
@ -50,22 +50,21 @@ func pagination[T Model](db dbQuery, ctx context.Context, q QueryCondition) (r [
|
|||
}
|
||||
q.Offset = offset
|
||||
m := ctx.Value("handle=>")
|
||||
if m == nil {
|
||||
r, err = finds[T](db, ctx, q)
|
||||
return
|
||||
}
|
||||
mm, ok := m.(string)
|
||||
if ok && mm == "toMap" {
|
||||
v := ctx.Value("map")
|
||||
mx, er := findToStringMap[T](db, ctx, q)
|
||||
if er != nil {
|
||||
err = er
|
||||
if m != nil {
|
||||
mm, ok := m.(string)
|
||||
if ok && mm == "toMap" {
|
||||
v := ctx.Value("map")
|
||||
mx, er := findToStringMap[T](db, ctx, q)
|
||||
if er != nil {
|
||||
err = er
|
||||
return
|
||||
}
|
||||
vv := v.(*[]map[string]string)
|
||||
*vv = mx
|
||||
return
|
||||
}
|
||||
vv := v.(*[]map[string]string)
|
||||
*vv = mx
|
||||
return
|
||||
}
|
||||
r, err = finds[T](db, ctx, q)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user