Documentation ¶
Index ¶
- Variables
- func ActionContent2Commits(act Actioner) *repository.PushCommits
- func AssetFS() *assetfs.LayeredFS
- func AvatarHTML(src string, size int, class, name string) template.HTML
- func BuiltinAssets() *assetfs.Layer
- func CustomAssets() *assetfs.Layer
- func HandleTemplateRenderingError(err error) string
- func ListMailTemplateAssetNames(assets *assetfs.LayeredFS) ([]string, error)
- func ListWebTemplateAssetNames(assets *assetfs.LayeredFS) ([]string, error)
- func Mailer(ctx context.Context) (*texttmpl.Template, *template.Template)
- func NewFuncMap() template.FuncMap
- func QueryBuild(a ...any) template.URL
- func ReloadHTMLTemplates() error
- func SanitizeHTML(s string) template.HTML
- func TimeSince(then any) template.HTML
- type Actioner
- type AvatarUtils
- type DateUtils
- type HTMLRender
- type JsonUtils
- type RenderUtils
- func (ut *RenderUtils) MarkdownToHtml(input string) template.HTML
- func (ut *RenderUtils) RenderCommitBody(msg string, metas map[string]string) template.HTML
- func (ut *RenderUtils) RenderCommitMessage(msg string, metas map[string]string) template.HTML
- func (ut *RenderUtils) RenderCommitMessageLinkSubject(msg, urlDefault string, metas map[string]string) template.HTML
- func (ut *RenderUtils) RenderEmoji(text string) template.HTML
- func (ut *RenderUtils) RenderIssueSimpleTitle(text string) template.HTML
- func (ut *RenderUtils) RenderIssueTitle(text string, metas map[string]string) template.HTML
- func (ut *RenderUtils) RenderLabel(label *issues_model.Label) template.HTML
- func (ut *RenderUtils) RenderLabels(labels []*issues_model.Label, repoLink string, issue *issues_model.Issue) template.HTML
- type SliceUtils
- type StringUtils
- func (su *StringUtils) Contains(s, substr string) bool
- func (su *StringUtils) Cut(s, sep string) []any
- func (su *StringUtils) EllipsisString(s string, maxLength int) string
- func (su *StringUtils) HasPrefix(s, prefix string) bool
- func (su *StringUtils) Join(a []string, sep string) string
- func (su *StringUtils) Split(s, sep string) []string
- func (su *StringUtils) ToString(v any) string
- func (su *StringUtils) ToUpper(s string) string
- func (su *StringUtils) TrimPrefix(s, prefix string) string
- type TemplateExecutor
Constants ¶
This section is empty.
Variables ¶
var ErrTemplateNotInitialized = errors.New("template system is not initialized, check your log for errors")
Functions ¶
func ActionContent2Commits ¶
func ActionContent2Commits(act Actioner) *repository.PushCommits
ActionContent2Commits converts action content to push commits
func AvatarHTML ¶ added in v1.14.0
AvatarHTML creates the HTML for an avatar
func BuiltinAssets ¶ added in v1.20.0
func CustomAssets ¶ added in v1.20.0
func HandleTemplateRenderingError ¶ added in v1.20.0
func ListMailTemplateAssetNames ¶ added in v1.20.0
func ListWebTemplateAssetNames ¶ added in v1.20.0
func NewFuncMap ¶
NewFuncMap returns functions for injecting to templates
func QueryBuild ¶
QueryBuild builds a query string from a list of key-value pairs. It omits the nil and empty strings, but it doesn't omit other zero values, because the zero value of number types may have a meaning.
func ReloadHTMLTemplates ¶ added in v1.20.0
func ReloadHTMLTemplates() error
func SanitizeHTML ¶ added in v1.22.0
SanitizeHTML sanitizes the input by pre-defined markdown rules
Types ¶
type Actioner ¶
type Actioner interface { GetOpType() activities_model.ActionType GetActUserName(ctx context.Context) string GetRepoUserName(ctx context.Context) string GetRepoName(ctx context.Context) string GetRepoPath(ctx context.Context) string GetRepoLink(ctx context.Context) string GetBranch() string GetContent() string GetCreate() time.Time GetIssueInfos() []string }
Actioner describes an action
type AvatarUtils ¶ added in v1.21.0
type AvatarUtils struct {
// contains filtered or unexported fields
}
func NewAvatarUtils ¶ added in v1.21.0
func NewAvatarUtils(ctx context.Context) *AvatarUtils
func (*AvatarUtils) Avatar ¶ added in v1.21.0
func (au *AvatarUtils) Avatar(item any, others ...any) template.HTML
Avatar renders user avatars. args: user, size (int), class (string)
func (*AvatarUtils) AvatarByAction ¶ added in v1.21.0
func (au *AvatarUtils) AvatarByAction(action *activities_model.Action, others ...any) template.HTML
AvatarByAction renders user avatars from action. args: action, size (int), class (string)
func (*AvatarUtils) AvatarByEmail ¶ added in v1.21.0
func (au *AvatarUtils) AvatarByEmail(email, name string, others ...any) template.HTML
AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
type DateUtils ¶
type DateUtils struct{}
func NewDateUtils ¶
func NewDateUtils() *DateUtils
func (*DateUtils) AbsoluteLong ¶
AbsoluteLong renders in "January 01, 2006" format
func (*DateUtils) AbsoluteShort ¶
AbsoluteShort renders in "Jan 01, 2006" format
func (*DateUtils) ParseLegacy ¶
ParseLegacy parses the datetime in legacy format, eg: "2016-01-02" in server's timezone. It shouldn't be used in new code. New code should use Time or TimeStamp as much as possible.
type HTMLRender ¶ added in v1.20.0
type HTMLRender struct {
// contains filtered or unexported fields
}
func HTMLRenderer ¶ added in v1.6.0
func HTMLRenderer() *HTMLRender
HTMLRenderer init once and returns the globally shared html renderer
func (*HTMLRender) CompileTemplates ¶ added in v1.20.0
func (h *HTMLRender) CompileTemplates() error
func (*HTMLRender) TemplateLookup ¶ added in v1.20.0
func (h *HTMLRender) TemplateLookup(name string, ctx context.Context) (TemplateExecutor, error)
type JsonUtils ¶ added in v1.20.0
type JsonUtils struct{} //nolint:revive
func NewJsonUtils ¶ added in v1.20.0
func NewJsonUtils() *JsonUtils
func (*JsonUtils) EncodeToString ¶ added in v1.20.0
func (*JsonUtils) PrettyIndent ¶ added in v1.20.0
type RenderUtils ¶
type RenderUtils struct {
// contains filtered or unexported fields
}
func NewRenderUtils ¶
func NewRenderUtils(ctx context.Context) *RenderUtils
func (*RenderUtils) MarkdownToHtml ¶
func (ut *RenderUtils) MarkdownToHtml(input string) template.HTML
func (*RenderUtils) RenderCommitBody ¶
RenderCommitBody extracts the body of a commit message without its title.
func (*RenderUtils) RenderCommitMessage ¶
RenderCommitMessage renders commit message with XSS-safe and special links.
func (*RenderUtils) RenderCommitMessageLinkSubject ¶
func (ut *RenderUtils) RenderCommitMessageLinkSubject(msg, urlDefault string, metas map[string]string) template.HTML
RenderCommitMessageLinkSubject renders commit message as a XSS-safe link to the provided default url, handling for special links without email to links.
func (*RenderUtils) RenderEmoji ¶
func (ut *RenderUtils) RenderEmoji(text string) template.HTML
RenderEmoji renders html text with emoji post processors
func (*RenderUtils) RenderIssueSimpleTitle ¶
func (ut *RenderUtils) RenderIssueSimpleTitle(text string) template.HTML
RenderIssueSimpleTitle only renders with emoji and inline code block
func (*RenderUtils) RenderIssueTitle ¶
RenderIssueTitle renders issue/pull title with defined post processors
func (*RenderUtils) RenderLabel ¶
func (ut *RenderUtils) RenderLabel(label *issues_model.Label) template.HTML
RenderLabel renders a label
func (*RenderUtils) RenderLabels ¶
func (ut *RenderUtils) RenderLabels(labels []*issues_model.Label, repoLink string, issue *issues_model.Issue) template.HTML
type SliceUtils ¶ added in v1.20.0
type SliceUtils struct{}
func NewSliceUtils ¶ added in v1.20.0
func NewSliceUtils() *SliceUtils
func (*SliceUtils) Contains ¶ added in v1.20.0
func (su *SliceUtils) Contains(s, v any) bool
type StringUtils ¶ added in v1.20.0
type StringUtils struct{}
func NewStringUtils ¶ added in v1.20.0
func NewStringUtils() *StringUtils
func (*StringUtils) Contains ¶ added in v1.20.0
func (su *StringUtils) Contains(s, substr string) bool
func (*StringUtils) Cut ¶ added in v1.21.0
func (su *StringUtils) Cut(s, sep string) []any
func (*StringUtils) EllipsisString ¶ added in v1.20.0
func (su *StringUtils) EllipsisString(s string, maxLength int) string
func (*StringUtils) HasPrefix ¶ added in v1.20.0
func (su *StringUtils) HasPrefix(s, prefix string) bool
func (*StringUtils) Join ¶ added in v1.20.0
func (su *StringUtils) Join(a []string, sep string) string
func (*StringUtils) Split ¶ added in v1.20.0
func (su *StringUtils) Split(s, sep string) []string
func (*StringUtils) ToString ¶ added in v1.22.0
func (su *StringUtils) ToString(v any) string
func (*StringUtils) ToUpper ¶ added in v1.22.0
func (su *StringUtils) ToUpper(s string) string
func (*StringUtils) TrimPrefix ¶
func (su *StringUtils) TrimPrefix(s, prefix string) string
type TemplateExecutor ¶ added in v1.20.0
type TemplateExecutor scopedtmpl.TemplateExecutor