wp

package
v0.0.0-...-1f40810 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	None = iota
	Low
	High
	Fatal
)

Variables

View Source
var CacheComponent = reload.BuildMapFnWithAnyParams[string]("cacheComponents", cacheComponentFn)
View Source
var GetAndHookComponents = reload.BuildMapFnWithAnyParams[string]("calComponents", HookComponent)
View Source
var GetCustomHeaderImgFn = reload.BuildValFnWithConfirm("headerImages", customHeadImag, 5)
View Source
var GetCustomLog = reload.BuildValFn("customLogo", CalCustomLogo)
View Source
var GetInitHandleFn = reload.BuildValFnWithAnyParams("themeArgAndConfig", SetConfigHandle, false)
View Source
var GetPostsPlugin = reload.BuildValFnWithAnyParams("postPlugins", UsePostsPlugins)
View Source
var GetStickMapPosts = reload.BuildValFn("stickPostsMap", StickMapPosts)
View Source
var GetStickPosts = reload.BuildValFnWithConfirm("stickPostsSlice", ParseStickPosts)

Functions

func AdditionScript

func AdditionScript(h *Handle)

func BuildHandler

func BuildHandler(pipeScene string, keyFn func(*Handle, string) string,
	handleHook func(*Handle, string,
		map[string][]func(HandleCall) (HandleCall, bool),
		map[string][]HandleCall) []HandleCall) func(*Handle) []HandleCall

func BuildHandlers

func BuildHandlers(pipeScene string, keyFn func(*Handle, string) string,
	handleHookFn func(*Handle, string,
		map[string][]func(HandleCall) (HandleCall, bool),
		map[string][]HandleCall) []HandleCall) func(HandleFn[*Handle], *Handle)

func BuildPipe

func BuildPipe(scene string) func(*Handle)

func CalComponent

func CalComponent(h *Handle) func(string) string

func CalCustomCss

func CalCustomCss(h *Handle) (r string)
func CalCustomLogo(h *Handle) (r string)

func CalSiteIcon

func CalSiteIcon(h *Handle) (r string)

func CustomVideo

func CustomVideo(h *Handle, scene ...string) (ok bool)

func Detail

func Detail(h *Handle)

func DetailRender

func DetailRender(h *Handle)

func Digest

func Digest(next PostsPlugin, h *Handle, post *models.Posts)

Digest 生成摘要

func GetComponentsArgs

func GetComponentsArgs[T any](k string, defaults T) T

func GetFn

func GetFn[T any](fnType string, name string) []T

func GetFnHook

func GetFnHook[T any](fnType string, name string) []T

func GetListPostPlugins

func GetListPostPlugins(name []string, m map[string]func(PostsPlugin, *Handle, *models.Posts)) []func(PostsPlugin, *Handle, *models.Posts)

func GetMimeType

func GetMimeType(file string) string

func GetVideoSetting

func GetVideoSetting(h *Handle, u string) (string, error)

func Index

func Index(h *Handle)

func IndexRender

func IndexRender(h *Handle)

func InitHandle

func InitHandle(configFn func(*Handle), h *Handle)

func InitPipe

func InitPipe(h *Handle)

func ListPostPlugins

func ListPostPlugins() map[string]func(PostsPlugin, *Handle, *models.Posts)

func MergeComponentsArgsForMap

func MergeComponentsArgsForMap[K comparable, V any](name string, m map[K]V)

func MiddlewareKey

func MiddlewareKey(h *Handle, pipScene string) string

func NothingToDo

func NothingToDo(h *Handle)

func ParseStickPosts

func ParseStickPosts(h *Handle) (r []models.Posts, ok bool)

func PasswordProject

func PasswordProject(next PostsPlugin, h *Handle, post *models.Posts)

PasswordProject 标题和内容密码保护

func PipeKey

func PipeKey(h *Handle, pipScene string) string

func PreCodeAndStats

func PreCodeAndStats(h *Handle)

func PreRenderTemplate

func PreRenderTemplate(h *Handle)

func PreTemplate

func PreTemplate(h *Handle)

func ProjectTitle

func ProjectTitle(t models.Posts) models.Posts

func PushComponentsArgsForSlice

func PushComponentsArgsForSlice[T any](name string, v ...T)

func PushFn

func PushFn[T any](fnType string, name string, fns ...T) error

func PushFnHook

func PushFnHook[T any](fnType string, name string, fns ...T) error

func PushIndexHandler

func PushIndexHandler(pipeScene string, h *Handle, call HandleCall)

func RenderComment

func RenderComment(ctx context.Context, page int, render plugins.CommentHtml, ids []uint64, timeout time.Duration, isTLS bool) (string, error)

func ReplyCommentJs

func ReplyCommentJs(h *Handle)

func Run

func Run(h *Handle, conf func(*Handle))

func SetComponentsArgs

func SetComponentsArgs(key string, value any)

func SetComponentsArgsForMap

func SetComponentsArgsForMap[K comparable, V any](name string, key K, v V)

func StickMapPosts

func StickMapPosts(h *Handle) map[uint64]models.Posts

func TermClass

func TermClass(term models.TermsMy) string

Types

type CommentHandle

type CommentHandle struct {
	// contains filtered or unexported fields
}

type Components

type Components[T any] struct {
	Name   string
	Val    T
	Fn     func(*Handle) T
	Order  float64
	Cached bool
}

Components Order 为执行顺序,降序执行

func GetComponents

func GetComponents(scene, key string) (r []Components[string])

func HookComponent

func HookComponent(a ...any) []Components[string]

func NewComponent

func NewComponent(name, val string, cached bool, order float64, fn func(handle *Handle) string) Components[string]

type DetailHandle

type DetailHandle struct {
	*Handle
	CommentRender  plugins.CommentHtml
	Comments       []uint64
	Page           int
	Limit          int
	Post           models.Posts
	CommentPageEle pagination.Render
	TotalRaw       int
	TotalPage      int
	CommentStep    int
}

func NewDetailHandle

func NewDetailHandle(handle *Handle) *DetailHandle

func (*DetailHandle) BuildDetailData

func (d *DetailHandle) BuildDetailData() (err error)

func (*DetailHandle) CheckAndGetPost

func (d *DetailHandle) CheckAndGetPost() (err error)

func (*DetailHandle) CommentData

func (d *DetailHandle) CommentData()

func (*DetailHandle) ContextPost

func (d *DetailHandle) ContextPost()

func (*DetailHandle) PasswordProject

func (d *DetailHandle) PasswordProject()

func (*DetailHandle) RenderComment

func (d *DetailHandle) RenderComment()

type Handle

type Handle struct {
	C *gin.Context

	Session sessions.Session

	Code  int
	Stats string
	// contains filtered or unexported fields
}

func NewHandle

func NewHandle(c *gin.Context, scene string, theme string) *Handle

func SetConfigHandle

func SetConfigHandle(a ...any) Handle

func (*Handle) Abort

func (h *Handle) Abort()

func (*Handle) AddActionFilter

func (h *Handle) AddActionFilter(name string, fns ...func(*Handle, string, ...any) string)

func (*Handle) AddCacheComponent

func (h *Handle) AddCacheComponent(scene, componentType, name string, order float64, fn func(*Handle) string)

func (*Handle) BodyClass

func (h *Handle) BodyClass() string

func (*Handle) CommonComponents

func (h *Handle) CommonComponents()

func (*Handle) CommonThemeMods

func (h *Handle) CommonThemeMods() wpconfig.ThemeMods

func (*Handle) ComponentHook

func (h *Handle) ComponentHook() *safety.Map[string, map[string][]func(Components[string]) (Components[string], bool)]

func (*Handle) Components

func (h *Handle) Components() *safety.Map[string, map[string][]Components[string]]

func (*Handle) DeleteComponents

func (h *Handle) DeleteComponents(scene, componentKey, componentName string)

func (*Handle) DeleteHandle

func (h *Handle) DeleteHandle(pipeScene, scene, name string)

DeleteHandle 写插件的时候用

func (*Handle) DeletePipe

func (h *Handle) DeletePipe(scene, pipeName string) error

func (*Handle) DisplayHeaderText

func (h *Handle) DisplayHeaderText() bool

func (*Handle) DoActionFilter

func (h *Handle) DoActionFilter(name, s string, args ...any) string

func (*Handle) Err

func (h *Handle) Err() error

func (*Handle) ErrLevel

func (h *Handle) ErrLevel() int8

func (*Handle) GetComponentFilterFn

func (h *Handle) GetComponentFilterFn(name string) ([]func(*Handle, string, ...any) string, bool)

func (*Handle) GetCustomHeaderImg

func (h *Handle) GetCustomHeaderImg() (r models.PostThumbnail, isRand bool)

func (*Handle) GetDetailHandle

func (h *Handle) GetDetailHandle() *DetailHandle

func (*Handle) GetHeaderImages

func (h *Handle) GetHeaderImages(theme string) (r []models.PostThumbnail, err error)

func (*Handle) GetIndexHandle

func (h *Handle) GetIndexHandle() *IndexHandle

func (*Handle) GetPassword

func (h *Handle) GetPassword() string

func (*Handle) GetTempl

func (h *Handle) GetTempl() string

func (*Handle) GinH

func (h *Handle) GinH() gin.H

func (*Handle) HandleHook

func (h *Handle) HandleHook() *safety.Map[string, map[string][]func(HandleCall) (HandleCall, bool)]

func (*Handle) Handlers

func (h *Handle) Handlers() *safety.Map[string, map[string][]HandleCall]

func (*Handle) HookHandle

func (h *Handle) HookHandle(pipeScene, scene string, hook func(HandleCall) (HandleCall, bool))

HookHandle 写插件的时候用

func (*Handle) IsHttps

func (h *Handle) IsHttps() bool

func (*Handle) IsStick

func (h *Handle) IsStick(id uint64) bool

func (*Handle) PipeHandleHook

func (h *Handle) PipeHandleHook(name string, calls []HandleCall, m map[string][]HandleCall, key string) []HandleCall

func (*Handle) PostClass

func (h *Handle) PostClass(posts models.Posts) string

func (*Handle) PushCacheGroupFooterScript

func (h *Handle) PushCacheGroupFooterScript(scene, name string, order float64, fns ...func(*Handle) string)

func (*Handle) PushCacheGroupHeadScript

func (h *Handle) PushCacheGroupHeadScript(scene, name string, order float64, fns ...func(*Handle) string)

func (*Handle) PushComponentHooks

func (h *Handle) PushComponentHooks(scene, componentKey string, fn func(Components[string]) (Components[string], bool))

func (*Handle) PushComponents

func (h *Handle) PushComponents(scene, componentType string, components ...Components[string])

func (*Handle) PushDataHandler

func (h *Handle) PushDataHandler(scene string, fns ...HandleCall)

func (*Handle) PushFooterScript

func (h *Handle) PushFooterScript(scene string, components ...Components[string])

func (*Handle) PushGroupCacheComponentFn

func (h *Handle) PushGroupCacheComponentFn(scene, componentType, name string, order float64, fns ...func(*Handle) string)

func (*Handle) PushGroupComponentStr

func (h *Handle) PushGroupComponentStr(scene, componentType, name string, order float64, strs ...string)

func (*Handle) PushGroupFooterScript

func (h *Handle) PushGroupFooterScript(scene, name string, order float64, strs ...string)

func (*Handle) PushGroupHeadScript

func (h *Handle) PushGroupHeadScript(scene, name string, order float64, str ...string)

func (*Handle) PushHandler

func (h *Handle) PushHandler(pipScene string, scene string, fns ...HandleCall)

func (*Handle) PushHandlers

func (h *Handle) PushHandlers(pipeScene string, call HandleCall, statsOrScene ...string)

func (*Handle) PushHeadScript

func (h *Handle) PushHeadScript(scene string, components ...Components[string])

func (*Handle) PushPipe

func (h *Handle) PushPipe(scene string, pipes ...Pipe) error

func (*Handle) PushPipeHandleHook

func (h *Handle) PushPipeHandleHook(name string, fn ...func([]HandleCall) []HandleCall) error

func (*Handle) PushPipeHook

func (h *Handle) PushPipeHook(scene string, pipes ...func(Pipe) (Pipe, bool)) error

func (*Handle) PushPostPlugin

func (h *Handle) PushPostPlugin(plugin ...PostsPlugin)

func (*Handle) PushPostsPlugin

func (h *Handle) PushPostsPlugin(name string, fn func(PostsPlugin, *Handle, *models.Posts))

func (*Handle) PushRender

func (h *Handle) PushRender(statsOrScene string, fns ...HandleCall)

func (*Handle) RenderHtml

func (h *Handle) RenderHtml(t *template.Template, statsCode int, name string)

func (*Handle) ReplaceComponents

func (h *Handle) ReplaceComponents(scene, componentKey, componentName string, components Components[string])

func (*Handle) ReplaceHandle

func (h *Handle) ReplaceHandle(pipeScene, scene, name string, fn HandleFn[*Handle])

ReplaceHandle 写插件的时候用

func (*Handle) ReplacePipe

func (h *Handle) ReplacePipe(scene, pipeName string, pipe Pipe) error

func (*Handle) Scene

func (h *Handle) Scene() string

func (*Handle) SetData

func (h *Handle) SetData(k string, v any)

func (*Handle) SetDatas

func (h *Handle) SetDatas(GinH gin.H)

func (*Handle) SetErr

func (h *Handle) SetErr(err error, level int8)

func (*Handle) SetErrLevel

func (h *Handle) SetErrLevel(errLevel int8)

func (*Handle) SetScene

func (h *Handle) SetScene(scene string)

func (*Handle) SetTempl

func (h *Handle) SetTempl(templ string)

func (*Handle) StopHandle

func (h *Handle) StopHandle()

func (*Handle) StopPipe

func (h *Handle) StopPipe()

func (*Handle) Theme

func (h *Handle) Theme() string

type HandleCall

type HandleCall struct {
	Fn    HandleFn[*Handle]
	Order float64
	Name  string
}

func HookHandles

func HookHandles(hooks map[string][]func(HandleCall) (HandleCall, bool),
	handlers map[string][]HandleCall, sceneOrStats ...string) []HandleCall

func NewHandleFn

func NewHandleFn(fn HandleFn[*Handle], order float64, name string) HandleCall

func PipeDataHandle

func PipeDataHandle(h *Handle, key string,
	hooks map[string][]func(HandleCall) (HandleCall, bool),
	handlers map[string][]HandleCall) []HandleCall

func PipeMiddlewareHandle

func PipeMiddlewareHandle(h *Handle, key string,
	hooks map[string][]func(HandleCall) (HandleCall, bool),
	handlers map[string][]HandleCall) []HandleCall

func PipeRender

func PipeRender(h *Handle, key string,
	hooks map[string][]func(HandleCall) (HandleCall, bool),
	handlers map[string][]HandleCall) []HandleCall

type HandleFn

type HandleFn[T any] func(T)

func HandlePipe

func HandlePipe[T any](initial func(T), fns ...HandlePipeFn[T]) HandleFn[T]

HandlePipe 方便把功能写在其它包里

type HandlePipeFn

type HandlePipeFn[T any] func(HandleFn[T], T)

type HandlePlugins

type HandlePlugins map[string]HandleFn[*Handle]

type IndexHandle

type IndexHandle struct {
	*Handle
	Param *IndexParams
	Posts []models.Posts

	TotalRows int
	// contains filtered or unexported fields
}

func NewIndexHandle

func NewIndexHandle(handle *Handle) *IndexHandle

func (*IndexHandle) BuildIndexData

func (i *IndexHandle) BuildIndexData() (err error)

func (*IndexHandle) ExecPostsPlugin

func (i *IndexHandle) ExecPostsPlugin()

func (*IndexHandle) GetIndexData

func (i *IndexHandle) GetIndexData() (posts []models.Posts, totalRaw int, err error)

func (*IndexHandle) ListPlugin

func (i *IndexHandle) ListPlugin() func(*Handle, *models.Posts)

func (*IndexHandle) MarkSticky

func (i *IndexHandle) MarkSticky(posts *[]models.Posts)

func (*IndexHandle) PageEle

func (i *IndexHandle) PageEle() pagination.Render

func (*IndexHandle) Pagination

func (i *IndexHandle) Pagination()

func (*IndexHandle) ParseIndex

func (i *IndexHandle) ParseIndex(parm *IndexParams) (err error)

func (*IndexHandle) SetListPlugin

func (i *IndexHandle) SetListPlugin(listPlugin func(*Handle, *models.Posts))

func (*IndexHandle) SetPageEle

func (i *IndexHandle) SetPageEle(pageEle pagination.Render)

type IndexParams

type IndexParams struct {
	ParseSearch       func()
	ParseArchive      func() error
	ParseCategory     func() error
	ParseTag          func() error
	ParseAuthor       func() error
	CategoryCondition func()
	ParseParams       func()
	Ctx               *gin.Context
	Page              int
	PageSize          int
	Title             string
	TitleL            string
	TitleR            string
	Search            string
	Author            string
	TotalPage         int
	Category          string
	CategoryType      string
	Where             model.SqlBuilder
	OrderBy           string
	Order             string
	Month             string
	Year              string
	Join              model.SqlBuilder
	PostType          []any
	PostStatus        []any
	Header            string
	PaginationStep    int
	CacheKey          string
	BlogName          string
}

func NewIndexParams

func NewIndexParams(ctx *gin.Context) *IndexParams

func (*IndexParams) CategoryConditions

func (i *IndexParams) CategoryConditions()

func (*IndexParams) ParseArchives

func (i *IndexParams) ParseArchives() error

func (*IndexParams) ParseAuthors

func (i *IndexParams) ParseAuthors() (err error)

func (*IndexParams) ParseCategorys

func (i *IndexParams) ParseCategorys() error

func (*IndexParams) ParseParamss

func (i *IndexParams) ParseParamss()

func (*IndexParams) ParseSearchs

func (i *IndexParams) ParseSearchs()

func (*IndexParams) ParseTags

func (i *IndexParams) ParseTags() error

type Pipe

type Pipe struct {
	Name  string
	Order float64
	Fn    HandlePipeFn[*Handle]
}

func NewPipe

func NewPipe(name string, order float64, fn HandlePipeFn[*Handle]) Pipe

type PostsPlugin

type PostsPlugin func(*Handle, *models.Posts)

func PostPlugin

func PostPlugin(calls ...PostsPlugin) PostsPlugin

func PostsPlugins

func PostsPlugins(initial PostsPlugin, calls ...func(PostsPlugin, *Handle, *models.Posts)) PostsPlugin

func UsePostsPlugins

func UsePostsPlugins(_ ...any) PostsPlugin

type VideoPlay

type VideoPlay struct {
	Pause      string `json:"pause,omitempty"`
	Play       string `json:"play,omitempty"`
	PauseSpeak string `json:"pauseSpeak,omitempty"`
	PlaySpeak  string `json:"playSpeak,omitempty"`
}

type VideoSetting

type VideoSetting struct {
	MimeType  string    `json:"mimeType,omitempty"`
	PosterUrl string    `json:"posterUrl,omitempty"`
	VideoUrl  string    `json:"videoUrl,omitempty"`
	Width     int       `json:"width,omitempty"`
	Height    int       `json:"height,omitempty"`
	MinWidth  int       `json:"minWidth,omitempty"`
	MinHeight int       `json:"minHeight,omitempty"`
	L10n      VideoPlay `json:"l10n"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL