Documentation ¶
Index ¶
- Constants
- Variables
- func ActionIcon(opType int) string
- func AvatarLink(email string) string
- func BasicAuthDecode(encoded string) (string, string, error)
- func BasicAuthEncode(username, password string) string
- func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string
- func DetectEncoding(content []byte) (string, error)
- func DiffLineTypeToStr(diffType int) string
- func DiffTypeToStr(diffType int) string
- func EncodeMd5(str string) string
- func EncodeSha1(str string) string
- func FileSize(s int64) string
- func GetRandomString(n int, alphabets ...byte) string
- func Int64sToMap(ints []int64) map[int64]bool
- func IsImageFile(data []byte) (string, bool)
- func IsMarkdownFile(name string) bool
- func IsReadmeFile(name string) bool
- func IsTextFile(data []byte) (string, bool)
- func List(l *list.List) chan interface{}
- func Oauth2Icon(t int) string
- func Oauth2Name(t int) string
- func PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte
- func PostProcessMarkdown(rawHtml []byte, urlPrefix string) []byte
- func Range(l int) []int
- func RawTimeSince(t time.Time, lang string) string
- func RenderCommitMessage(msg, urlPrefix string) template.HTML
- func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte
- func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte
- func RenderMarkdownString(raw, urlPrefix string) string
- func RenderRawMarkdown(body []byte, urlPrefix string) []byte
- func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte
- func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte
- func Safe(raw string) template.HTML
- func Sha1(str string) string
- func ShortSha(sha1 string) string
- func Str2html(raw string) template.HTML
- func StringsToInt64s(strs []string) []int64
- func Subtract(left interface{}, right interface{}) interface{}
- func TimeSince(t time.Time, lang string) template.HTML
- func TimeSincePro(then time.Time) string
- func ToUtf8(content string) string
- func ToUtf8WithErr(content []byte) (error, string)
- func VerifyTimeLimitCode(data string, minutes int, code string) bool
- type Actioner
- type ApiJsonErr
- type CustomRender
- type PushCommit
- type PushCommits
- type TplName
Constants ¶
const ( Minute = 60 Hour = 60 * Minute Day = 24 * Hour Week = 7 * Day Month = 30 * Day Year = 12 * Month )
Seconds-based time units
const ( Byte = 1 KByte = Byte * 1024 MByte = KByte * 1024 GByte = MByte * 1024 TByte = GByte * 1024 PByte = TByte * 1024 EByte = PByte * 1024 )
const DOC_URL = "http://gogs.io/docs"
const TimeLimitCodeLength = 12 + 6 + 40
Variables ¶
var GoGetMetas = make(map[string]bool)
var (
MentionPattern = regexp.MustCompile(`(\s|^)@[0-9a-zA-Z_\.]+`)
)
var Sanitizer = bluemonday.UGCPolicy()
var TemplateFuncs template.FuncMap = map[string]interface{}{ "GoVer": func() string { return strings.Title(runtime.Version()) }, "AppName": func() string { return setting.AppName }, "AppSubUrl": func() string { return setting.AppSubUrl }, "AppVer": func() string { return setting.AppVer }, "AppDomain": func() string { return setting.Domain }, "CdnMode": func() bool { return setting.ProdMode && !setting.OfflineMode }, "DisableGravatar": func() bool { return setting.DisableGravatar }, "LoadTimes": func(startTime time.Time) string { return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" }, "AvatarLink": AvatarLink, "Safe": Safe, "Str2html": Str2html, "TimeSince": TimeSince, "RawTimeSince": RawTimeSince, "FileSize": FileSize, "Subtract": 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" } suffix := strings.SplitN(mail, "@", 2)[1] domain, ok := mailDomains[suffix] if !ok { return "mail." + suffix } return domain }, "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": ShortSha, "Md5": EncodeMd5, "ActionContent2Commits": ActionContent2Commits, "Oauth2Icon": Oauth2Icon, "Oauth2Name": Oauth2Name, "ToUtf8": ToUtf8, "EscapePound": func(str string) string { return strings.Replace(strings.Replace(str, "%", "%25", -1), "#", "%23", -1) }, "RenderCommitMessage": RenderCommitMessage, }
Functions ¶
func ActionIcon ¶
ActionIcon accepts a int that represents action operation type and returns a icon class name.
func AvatarLink ¶
AvatarLink returns avatar link by given e-mail.
func BasicAuthEncode ¶ added in v0.5.8
func CreateTimeLimitCode ¶
create a time limit code code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string
func DetectEncoding ¶ added in v0.5.9
func DiffLineTypeToStr ¶
func DiffTypeToStr ¶
func EncodeSha1 ¶ added in v0.5.8
Encode string to sha1 hex value.
func GetRandomString ¶
GetRandomString generate random string by specify chars.
func Int64sToMap ¶ added in v0.6.5
Int64sToMap converts a slice of int64 to a int64 map.
func IsImageFile ¶
func IsMarkdownFile ¶
func IsReadmeFile ¶
IsReadmeFile returns true if given file name suppose to be a README file.
func IsTextFile ¶
func Oauth2Icon ¶ added in v0.3.0
func Oauth2Name ¶ added in v0.4.0
func PBKDF2 ¶ added in v0.3.0
http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto
func PostProcessMarkdown ¶ added in v0.6.1
PostProcessMarkdown treats different types of HTML differently, and only renders special links for plain text blocks.
func RenderCommitMessage ¶ added in v0.5.13
RenderCommitMessage renders commit message with XSS-safe and special links.
func RenderIssueIndexPattern ¶ added in v0.5.9
func RenderMarkdown ¶
func RenderMarkdownString ¶ added in v0.3.0
func RenderRawMarkdown ¶ added in v0.4.0
func RenderSha1CurrentPattern ¶ added in v0.5.9
func RenderSpecialLink ¶ added in v0.3.0
func StringsToInt64s ¶ added in v0.6.5
StringsToInt64s converts a slice of string to a slice of int64.
func Subtract ¶
func Subtract(left interface{}, right interface{}) interface{}
Subtract deals with subtraction of all types of number.
func TimeSincePro ¶
TimeSincePro calculates the time interval and generate full user-friendly string.
func ToUtf8WithErr ¶ added in v0.5.2
Types ¶
type ApiJsonErr ¶ added in v0.4.0
type CustomRender ¶
type CustomRender struct { blackfriday.Renderer // contains filtered or unexported fields }
type PushCommit ¶
type PushCommits ¶
type PushCommits struct { Len int Commits []*PushCommit CompareUrl string }
func ActionContent2Commits ¶ added in v0.5.0
func ActionContent2Commits(act Actioner) *PushCommits