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 LoadMailTemplates(ctx context.Context, loadedTemplates *atomic.Pointer[MailTemplates])
- func NewFuncMap() template.FuncMap
- func QueryBuild(a ...any) template.URL
- func ReloadHTMLTemplates() error
- func SafeHTML(s string) template.HTML
- func SanitizeHTML(s string) template.HTML
- func TimeSince(then any) template.HTML
- type Actioner
- type AvatarUtils
- type DateUtils
- type HTMLRender
- type JsonUtils
- type MailTemplates
- type RenderUtils
- func (ut *RenderUtils) MarkdownToHtml(input string) template.HTML
- func (ut *RenderUtils) RenderCommitBody(msg string, repo *repo.Repository) template.HTML
- func (ut *RenderUtils) RenderCommitMessage(msg string, repo *repo.Repository) template.HTML
- func (ut *RenderUtils) RenderCommitMessageLinkSubject(msg, urlDefault string, repo *repo.Repository) template.HTML
- func (ut *RenderUtils) RenderEmoji(text string) template.HTML
- func (ut *RenderUtils) RenderIssueSimpleTitle(text string) template.HTML
- func (ut *RenderUtils) RenderIssueTitle(text string, repo *repo.Repository) template.HTML
- func (ut *RenderUtils) RenderLabel(label *issues_model.Label) template.HTML
- func (ut *RenderUtils) RenderLabelWithLink(label *issues_model.Label, link any) template.HTML
- func (ut *RenderUtils) RenderLabels(labels []*issues_model.Label, repoLink string, issue *issues_model.Issue) template.HTML
- func (ut *RenderUtils) RenderThemeItem(info *webtheme.ThemeMetaInfo, iconSize int) 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) HasSuffix(s, suffix string) bool
- func (su *StringUtils) Join(a []string, sep string) string
- func (su *StringUtils) Split(s, sep string) []string
- func (su *StringUtils) ToLower(s 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
- type TplName
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ActionContent2Commits ¶
func ActionContent2Commits(act Actioner) *repository.PushCommits
ActionContent2Commits converts action content to push commits
func AvatarHTML ¶
AvatarHTML creates the HTML for an avatar
func ListMailTemplateAssetNames ¶
func ListWebTemplateAssetNames ¶
func LoadMailTemplates ¶
func LoadMailTemplates(ctx context.Context, loadedTemplates *atomic.Pointer[MailTemplates])
LoadMailTemplates provides the templates required for sending notification mails.
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, false, zero int/int64 and empty string values, because they are default empty values for "ctx.FormXxx" calls. If 0 or false need to be included, use string values: "0" and "false". Build rules: * Even parameters: always build as query string: a=b&c=d * Odd parameters: * * {"/anything", param-pairs...} => "/?param-paris" * * {"anything?old-params", new-param-pairs...} => "anything?old-params&new-param-paris" * * Otherwise: {"old¶ms", new-param-pairs...} => "old¶ms&new-param-paris" * * Other behaviors are undefined yet.
func SafeHTML ¶
SafeHTML marks a string as safe HTML (no sanitization). Use with caution - only for trusted admin content.
func SanitizeHTML ¶
SanitizeHTML sanitizes the input by default sanitization 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 ¶
type AvatarUtils struct {
// contains filtered or unexported fields
}
func NewAvatarUtils ¶
func NewAvatarUtils(ctx context.Context) *AvatarUtils
func (*AvatarUtils) Avatar ¶
func (au *AvatarUtils) Avatar(item any, others ...any) template.HTML
Avatar renders user avatars. args: user, size (int), class (string)
func (*AvatarUtils) AvatarByAction ¶
func (au *AvatarUtils) AvatarByAction(action *activities_model.Action, others ...any) template.HTML
AvatarByAction renders user avatars from action. args: action, size (int), class (string)
type DateUtils ¶
type DateUtils struct{}
func (*DateUtils) AbsoluteLong ¶
AbsoluteLong renders in "January 01, 2006" format
func (*DateUtils) AbsoluteShort ¶
AbsoluteShort renders in "Jan 01, 2006" format
func (*DateUtils) FullTime ¶
FullTime renders in "Jan 01, 2006 20:33:44" 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 ¶
type HTMLRender struct {
// contains filtered or unexported fields
}
func HTMLRenderer ¶
func HTMLRenderer() *HTMLRender
HTMLRenderer init once and returns the globally shared html renderer
func (*HTMLRender) CompileTemplates ¶
func (h *HTMLRender) CompileTemplates() error
func (*HTMLRender) HTML ¶
func (*HTMLRender) TemplateLookup ¶
func (h *HTMLRender) TemplateLookup(name string, ctx context.Context) (TemplateExecutor, error)
type JsonUtils ¶
type JsonUtils struct{} //nolint:revive // variable naming triggers on Json, wants JSON
type MailTemplates ¶
type RenderUtils ¶
type RenderUtils struct {
// contains filtered or unexported fields
}
func NewRenderUtils ¶
func NewRenderUtils(ctx reqctx.RequestContext) *RenderUtils
func (*RenderUtils) MarkdownToHtml ¶
func (ut *RenderUtils) MarkdownToHtml(input string) template.HTML
func (*RenderUtils) RenderCommitBody ¶
func (ut *RenderUtils) RenderCommitBody(msg string, repo *repo.Repository) template.HTML
RenderCommitBody extracts the body of a commit message without its title.
func (*RenderUtils) RenderCommitMessage ¶
func (ut *RenderUtils) RenderCommitMessage(msg string, repo *repo.Repository) template.HTML
RenderCommitMessage renders commit message with XSS-safe and special links.
func (*RenderUtils) RenderCommitMessageLinkSubject ¶
func (ut *RenderUtils) RenderCommitMessageLinkSubject(msg, urlDefault string, repo *repo.Repository) 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 ¶
func (ut *RenderUtils) RenderIssueTitle(text string, repo *repo.Repository) template.HTML
RenderIssueTitle renders issue/pull title with defined post processors
func (*RenderUtils) RenderLabel ¶
func (ut *RenderUtils) RenderLabel(label *issues_model.Label) template.HTML
func (*RenderUtils) RenderLabelWithLink ¶
func (ut *RenderUtils) RenderLabelWithLink(label *issues_model.Label, link any) template.HTML
func (*RenderUtils) RenderLabels ¶
func (ut *RenderUtils) RenderLabels(labels []*issues_model.Label, repoLink string, issue *issues_model.Issue) template.HTML
func (*RenderUtils) RenderThemeItem ¶
func (ut *RenderUtils) RenderThemeItem(info *webtheme.ThemeMetaInfo, iconSize int) template.HTML
type SliceUtils ¶
type SliceUtils struct{}
func NewSliceUtils ¶
func NewSliceUtils() *SliceUtils
func (*SliceUtils) Append ¶
func (su *SliceUtils) Append(s, v any) any
Append appends an element to a slice and returns the new slice
func (*SliceUtils) Contains ¶
func (su *SliceUtils) Contains(s, v any) bool
type StringUtils ¶
type StringUtils struct{}
func NewStringUtils ¶
func NewStringUtils() *StringUtils
func (*StringUtils) Contains ¶
func (su *StringUtils) Contains(s, substr string) bool
func (*StringUtils) Cut ¶
func (su *StringUtils) Cut(s, sep string) []any
func (*StringUtils) EllipsisString ¶
func (su *StringUtils) EllipsisString(s string, maxLength int) string
func (*StringUtils) HasPrefix ¶
func (su *StringUtils) HasPrefix(s, prefix string) bool
func (*StringUtils) HasSuffix ¶
func (su *StringUtils) HasSuffix(s, suffix string) bool
func (*StringUtils) Join ¶
func (su *StringUtils) Join(a []string, sep string) string
func (*StringUtils) Split ¶
func (su *StringUtils) Split(s, sep string) []string
func (*StringUtils) ToLower ¶
func (su *StringUtils) ToLower(s string) string
func (*StringUtils) ToString ¶
func (su *StringUtils) ToString(v any) string
func (*StringUtils) ToUpper ¶
func (su *StringUtils) ToUpper(s string) string
func (*StringUtils) TrimPrefix ¶
func (su *StringUtils) TrimPrefix(s, prefix string) string
type TemplateExecutor ¶
type TemplateExecutor scopedtmpl.TemplateExecutor
Source Files
¶
- base.go
- helper.go
- htmlrenderer.go
- mailer.go
- templates_dynamic.go
- util_avatar.go
- util_date.go
- util_dict.go
- util_format.go
- util_json.go
- util_misc.go
- util_render.go
- util_slice.go
- util_string.go