template

package
v0.8.43 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Funcs template.FuncMap = map[string]interface{}{
	"GoVer": func() string {
		return strings.Title(runtime.Version())
	},
	"UseHTTPS": func() bool {
		return strings.HasPrefix(setting.AppUrl, "https")
	},
	"AppName": func() string {
		return setting.AppName
	},
	"AppSubUrl": func() string {
		return setting.AppSubUrl
	},
	"AppUrl": func() string {
		return setting.AppUrl
	},
	"AppVer": func() string {
		return setting.AppVer
	},
	"AppDomain": func() string {
		return setting.Domain
	},
	"DisableGravatar": func() bool {
		return setting.DisableGravatar
	},
	"LoadTimes": func(startTime time.Time) string {
		return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
	},
	"AvatarLink":   base.AvatarLink,
	"Safe":         Safe,
	"Str2html":     Str2html,
	"TimeSince":    base.TimeSince,
	"RawTimeSince": base.RawTimeSince,
	"FileSize":     base.FileSize,
	"Subtract":     base.Subtract,
	"Add": func(a, b int) int {
		return a + b
	},
	"ActionIcon": ActionIcon,
	"DateFmtLong": func(t time.Time) string {
		return t.Format(time.RFC1123Z)
	},
	"DateFmtShort": func(t time.Time) string {
		return t.Format("Jan 02, 2006")
	},
	"List": List,
	"Mail2Domain": func(mail string) string {
		if !strings.Contains(mail, "@") {
			return "try.gogs.io"
		}

		return strings.SplitN(mail, "@", 2)[1]
	},
	"SubStr": func(str string, start, length int) string {
		if len(str) == 0 {
			return ""
		}
		end := start + length
		if length == -1 {
			end = len(str)
		}
		if len(str) < end {
			return str
		}
		return str[start:end]
	},
	"DiffTypeToStr":         DiffTypeToStr,
	"DiffLineTypeToStr":     DiffLineTypeToStr,
	"Sha1":                  Sha1,
	"ShortSha":              base.ShortSha,
	"MD5":                   base.EncodeMD5,
	"ActionContent2Commits": ActionContent2Commits,
	"ToUtf8":                ToUtf8,
	"EscapePound": func(str string) string {
		return strings.Replace(strings.Replace(str, "%", "%25", -1), "#", "%23", -1)
	},
	"RenderCommitMessage": RenderCommitMessage,
	"ThemeColorMetaTag": func() string {
		return setting.ThemeColorMetaTag
	},
}

Functions

func ActionContent2Commits

func ActionContent2Commits(act Actioner) *models.PushCommits

func ActionIcon

func ActionIcon(opType int) string

ActionIcon accepts a int that represents action operation type and returns a icon class name.

func DiffLineTypeToStr

func DiffLineTypeToStr(diffType int) string

func DiffTypeToStr

func DiffTypeToStr(diffType int) string

func List

func List(l *list.List) chan interface{}

func Range

func Range(l int) []int

func RenderCommitMessage

func RenderCommitMessage(full bool, msg, urlPrefix string, metas map[string]string) template.HTML

RenderCommitMessage renders commit message with XSS-safe and special links.

func ReplaceLeft

func ReplaceLeft(s, old, new string) string

Replaces all prefixes 'old' in 's' with 'new'.

func Safe

func Safe(raw string) template.HTML

func Sha1

func Sha1(str string) string

func Str2html

func Str2html(raw string) template.HTML

func ToUtf8

func ToUtf8(content string) string

func ToUtf8WithErr

func ToUtf8WithErr(content []byte) (error, string)

Types

type Actioner

type Actioner interface {
	GetOpType() int
	GetActUserName() string
	GetActEmail() string
	GetRepoUserName() string
	GetRepoName() string
	GetRepoPath() string
	GetRepoLink() string
	GetBranch() string
	GetContent() string
	GetCreate() time.Time
	GetIssueInfos() []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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