xtemplate

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsThemeName

func IsThemeName(s string) bool

func NewMultiManager

func NewMultiManager(templateDir string, managers ...driver.Manager) driver.Manager

func NewStaticDir

func NewStaticDir(dir string, trimPrefix ...string) http.FileSystem

func RGB2Hex

func RGB2Hex(rgb string) string

func Register

func Register(group string, t *Template)

func Unregister

func Unregister(group string)

Types

type FileInfo

type FileInfo struct {
	fs.FileInfo
	Embed bool
}

type FileSystems

type FileSystems []http.FileSystem

func NewFileSystems

func NewFileSystems() FileSystems

func (FileSystems) IsEmpty

func (f FileSystems) IsEmpty() bool

func (FileSystems) Open

func (f FileSystems) Open(name string) (file http.File, err error)

func (FileSystems) ReadDir

func (f FileSystems) ReadDir(name string) (dirs []fs.FileInfo, err error)

func (FileSystems) ReadFile

func (f FileSystems) ReadFile(name string) (content []byte, err error)

func (*FileSystems) Register

func (f *FileSystems) Register(fileSystem http.FileSystem)

func (FileSystems) Size

func (f FileSystems) Size() int

func (FileSystems) Stat

func (f FileSystems) Stat(name string) (fi fs.FileInfo, err error)

type MultiManager

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

func (*MultiManager) AddAllow

func (b *MultiManager) AddAllow(allows ...string)

func (*MultiManager) AddCallback

func (b *MultiManager) AddCallback(rootDir string, callback func(name, typ, event string))

func (*MultiManager) AddIgnore

func (b *MultiManager) AddIgnore(ignores ...string)

func (*MultiManager) AddWatchDir

func (b *MultiManager) AddWatchDir(ppath string) (err error)

func (*MultiManager) CancelWatchDir

func (b *MultiManager) CancelWatchDir(oldDir string) (err error)

func (*MultiManager) ChangeWatchDir

func (b *MultiManager) ChangeWatchDir(oldDir string, newDir string) (err error)

func (*MultiManager) ClearAllows

func (b *MultiManager) ClearAllows()

func (*MultiManager) ClearCache

func (b *MultiManager) ClearCache()

func (*MultiManager) ClearCallback

func (b *MultiManager) ClearCallback()

func (*MultiManager) ClearIgnores

func (b *MultiManager) ClearIgnores()

func (*MultiManager) Close

func (b *MultiManager) Close()

func (*MultiManager) DelAllow

func (b *MultiManager) DelAllow(allow string)

func (*MultiManager) DelCallback

func (b *MultiManager) DelCallback(rootDir string)

func (*MultiManager) DelIgnore

func (b *MultiManager) DelIgnore(ignore string)

func (*MultiManager) GetManagers

func (b *MultiManager) GetManagers() []driver.Manager

func (*MultiManager) GetTemplate

func (b *MultiManager) GetTemplate(filename string) (content []byte, err error)

func (*MultiManager) HasBindata

func (b *MultiManager) HasBindata() bool

func (*MultiManager) SetLogger

func (b *MultiManager) SetLogger(logger logger.Logger)

func (*MultiManager) SetTemplate

func (b *MultiManager) SetTemplate(filename string, content []byte) error

func (*MultiManager) Start

func (b *MultiManager) Start() error

func (*MultiManager) TemplateDir

func (b *MultiManager) TemplateDir() string

type PathFixer

type PathFixer func(subdir, tmpl string) string

type PathFixers

type PathFixers map[string][]PathFixer //模版路径 {subdir:func}

func (*PathFixers) Add

func (p *PathFixers) Add(dirName string, fixer PathFixer) *PathFixers

func (*PathFixers) AddDir

func (p *PathFixers) AddDir(dirName string, parentPath string) *PathFixers

func (*PathFixers) Delete

func (p *PathFixers) Delete(names ...string) *PathFixers

func (*PathFixers) Fix

func (p *PathFixers) Fix(ctx echo.Context, t *Template, theme string, tmpl string) (string, bool)

Fix 模版路径修复

func (*PathFixers) Keys

func (p *PathFixers) Keys() []string

func (*PathFixers) MakeFixer

func (p *PathFixers) MakeFixer(parentPath string) PathFixer

type PathHandle

type PathHandle func(c echo.Context, theme string, tmpl string) string

type SortFileInfoByFileType

type SortFileInfoByFileType []FileInfo

func (SortFileInfoByFileType) Len

func (s SortFileInfoByFileType) Len() int

func (SortFileInfoByFileType) Less

func (s SortFileInfoByFileType) Less(i, j int) bool

func (SortFileInfoByFileType) Swap

func (s SortFileInfoByFileType) Swap(i, j int)

type StaticDir

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

func (*StaticDir) Open

func (s *StaticDir) Open(name string) (http.File, error)

type Storer

type Storer interface {
	Put(echo.Context, string, *ThemeInfo) error
	Get(echo.Context, string) (*ThemeInfo, error)
}

func NewFileStore

func NewFileStore(kind string) Storer

type Template

type Template struct {
	TmplDir string
	Kind    string
	*PathFixers
	// contains filtered or unexported fields
}

func Get

func Get(group string) *Template

func New

func New(kind string) *Template

func (*Template) ClearCache

func (t *Template) ClearCache()

func (*Template) Fix

func (t *Template) Fix(ctx echo.Context, theme string, tmpl string) (string, bool)

func (*Template) Handle

func (t *Template) Handle(ctx echo.Context, theme string, tmpl string) string

func (*Template) SetHandler

func (t *Template) SetHandler(h PathHandle) *Template

func (*Template) SetPathFixers

func (t *Template) SetPathFixers(h *PathFixers) *Template

func (*Template) SetStorer

func (t *Template) SetStorer(storer Storer) *Template

func (*Template) SetThemeInfo

func (t *Template) SetThemeInfo(c echo.Context, v *ThemeInfo)

func (*Template) SetTmplDir

func (t *Template) SetTmplDir(tmplDir string) *Template

func (*Template) Storer

func (t *Template) Storer() Storer

func (*Template) ThemeInfo

func (t *Template) ThemeInfo(c echo.Context) *ThemeInfo

type ThemeAuthor

type ThemeAuthor struct {
	Name        string `json:"name,omitempty"`        // 作者网名
	Email       string `json:"email,omitempty"`       // 作者E-mail地址
	URL         string `json:"url,omitempty"`         // 作者网址
	Description string `json:"description,omitempty"` // 作者简介
}

type ThemeColor

type ThemeColor struct {
	Name         string `json:"name,omitempty"`         // 颜色英文名(用于调用相应颜色的css文件)
	Title        string `json:"title,omitempty"`        // 颜色中文标题
	IsDefault    bool   `json:"isDefault,omitempty"`    // 是否为默认颜色
	Color        string `json:"color,omitempty"`        // 颜色值
	PreviewImage string `json:"previewImage,omitempty"` // 预览图
}

func (ThemeColor) HexColor

func (t ThemeColor) HexColor() string

type ThemeColors

type ThemeColors []ThemeColor

func (ThemeColors) HasName

func (t ThemeColors) HasName(colorName string, notDefault ...bool) bool

type ThemeInfo

type ThemeInfo struct {
	Author       ThemeAuthor                  `json:"author,omitempty"`       // 模板作者
	Colors       ThemeColors                  `json:"colors,omitempty"`       // 多种颜色主题时,所有支持的颜色信息
	Version      string                       `json:"version,omitempty"`      // 版本号(格式: 1.0.0)
	Name         string                       `json:"name"`                   // 主题英文名
	Title        string                       `json:"title"`                  // 主题中文标题
	UpdatedAt    string                       `json:"updatedAt,omitempty"`    // 更新时间(格式: 2006-01-02 15:04:05)
	Description  string                       `json:"description,omitempty"`  // 简介
	PreviewImage string                       `json:"previewImage,omitempty"` // 预览图
	PreviewURL   string                       `json:"previewURL,omitempty"`   // 预览网址
	CustomConfig echo.H                       `json:"customConfig,omitempty"` // 可自定义配置的数据
	FormConfig   map[string]formConfig.Config `json:"formConfig,omitempty"`   // 表单配置
	Fallback     []string                     `json:"fallback,omitempty"`     // 兜底主题
	// contains filtered or unexported fields
}

ThemeInfo 模板主题信息

func GetThemeInfoFromContext

func GetThemeInfoFromContext(ctx echo.Context) *ThemeInfo

func NewThemeInfo

func NewThemeInfo() *ThemeInfo

func (*ThemeInfo) AsLite

func (t *ThemeInfo) AsLite() ThemeInfoLite

func (*ThemeInfo) ColorName

func (t *ThemeInfo) ColorName() string

func (*ThemeInfo) Decode

func (t *ThemeInfo) Decode(b []byte) error

func (*ThemeInfo) DecodeFile

func (t *ThemeInfo) DecodeFile(file string) error

func (*ThemeInfo) Embed

func (t *ThemeInfo) Embed() bool

func (*ThemeInfo) Encode

func (t *ThemeInfo) Encode() []byte

func (*ThemeInfo) EncodeToFile

func (t *ThemeInfo) EncodeToFile(destFile string) error

func (*ThemeInfo) HasColorName

func (t *ThemeInfo) HasColorName(colorName string, notDefault ...bool) bool

func (*ThemeInfo) HasForm

func (t *ThemeInfo) HasForm(templateName string) bool

func (*ThemeInfo) IsColorName

func (t *ThemeInfo) IsColorName(colorName string) bool

func (*ThemeInfo) Render

func (t *ThemeInfo) Render(templateName string) template.HTML

func (*ThemeInfo) SaveForm

func (t *ThemeInfo) SaveForm(ctx echo.Context, templateName string, gets ...func(fieldName string, fieldValue string) error) error

func (*ThemeInfo) SetEmbed

func (t *ThemeInfo) SetEmbed() *ThemeInfo

type ThemeInfoLite

type ThemeInfoLite struct {
	Name         string `json:"name"`         // 主题英文名
	Title        string `json:"title"`        // 主题中文标题
	PreviewImage string `json:"previewImage"` // 预览图
}

Jump to

Keyboard shortcuts

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