{"modulePath":"github.com/developerspl/gogs","version":"v0.5.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package base\n\n## Constants\n\n```go\nconst (\n\tTPL_CREATE_REPO    = `\u003ca href=\"/user/%s\"\u003e%s\u003c/a\u003e created repository \u003ca href=\"/%s\"\u003e%s\u003c/a\u003e`\n\tTPL_COMMIT_REPO    = `\u003ca href=\"/user/%s\"\u003e%s\u003c/a\u003e pushed to \u003ca href=\"/%s/src/%s\"\u003e%s\u003c/a\u003e at \u003ca href=\"/%s\"\u003e%s\u003c/a\u003e%s`\n\tTPL_COMMIT_REPO_LI = `\u003cdiv\u003e\u003cimg src=\"%s?s=16\" alt=\"user-avatar\"/\u003e \u003ca href=\"/%s/commit/%s\" rel=\"nofollow\"\u003e%s\u003c/a\u003e %s\u003c/div\u003e`\n\tTPL_CREATE_ISSUE   = `\u003ca href=\"/user/%s\"\u003e%s\u003c/a\u003e opened issue \u003ca href=\"/%s/issues/%s\"\u003e%s#%s\u003c/a\u003e\n\u003cdiv\u003e\u003cimg src=\"%s?s=16\" alt=\"user-avatar\"/\u003e %s\u003c/div\u003e`\n\tTPL_TRANSFER_REPO = `\u003ca href=\"/user/%s\"\u003e%s\u003c/a\u003e transfered repository \u003ccode\u003e%s\u003c/code\u003e to \u003ca href=\"/%s\"\u003e%s\u003c/a\u003e`\n\tTPL_PUSH_TAG      = `\u003ca href=\"/user/%s\"\u003e%s\u003c/a\u003e pushed tag \u003ca href=\"/%s/src/%s\" rel=\"nofollow\"\u003e%s\u003c/a\u003e at \u003ca href=\"/%s\"\u003e%s\u003c/a\u003e`\n\tTPL_COMMENT_ISSUE = `\u003ca href=\"/user/%s\"\u003e%s\u003c/a\u003e commented on issue \u003ca href=\"/%s/issues/%s\"\u003e%s#%s\u003c/a\u003e\n\u003cdiv\u003e\u003cimg src=\"%s?s=16\" alt=\"user-avatar\"/\u003e %s\u003c/div\u003e`\n)\n```\nTODO: Legacy\n\n```go\nconst (\n\tMinute = 60\n\tHour   = 60 * Minute\n\tDay    = 24 * Hour\n\tWeek   = 7 * Day\n\tMonth  = 30 * Day\n\tYear   = 12 * Month\n)\n```\nSeconds-based time units\n\n```go\nconst (\n\tByte  = 1\n\tKByte = Byte * 1024\n\tMByte = KByte * 1024\n\tGByte = MByte * 1024\n\tTByte = GByte * 1024\n\tPByte = TByte * 1024\n\tEByte = PByte * 1024\n)\n```\n\n```go\nconst TimeLimitCodeLength = 12 + 6 + 40\n```\n\n## Variables\n\n```go\nvar GoGetMetas = make(map[string]bool)\n```\n\n```go\nvar (\n\tMentionPattern = regexp.MustCompile(`@[0-9a-zA-Z_]{1,}`)\n)\n```\n\n```go\nvar TemplateFuncs template.FuncMap = map[string]interface{}{\n\t\"GoVer\": func() string {\n\t\treturn strings.Title(runtime.Version())\n\t},\n\t\"AppName\": func() string {\n\t\treturn setting.AppName\n\t},\n\t\"AppVer\": func() string {\n\t\treturn setting.AppVer\n\t},\n\t\"AppDomain\": func() string {\n\t\treturn setting.Domain\n\t},\n\t\"CdnMode\": func() bool {\n\t\treturn setting.ProdMode \u0026\u0026 !setting.OfflineMode\n\t},\n\t\"LoadTimes\": func(startTime time.Time) string {\n\t\treturn fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + \"ms\"\n\t},\n\t\"AvatarLink\": AvatarLink,\n\t\"str2html\":   Str2html,\n\t\"Str2html\":   Str2html,\n\t\"TimeSince\":  TimeSince,\n\t\"FileSize\":   FileSize,\n\t\"Subtract\":   Subtract,\n\t\"Add\": func(a, b int) int {\n\t\treturn a + b\n\t},\n\t\"ActionIcon\": ActionIcon,\n\t\"ActionDesc\": ActionDesc,\n\t\"DateFormat\": DateFormat,\n\t\"List\":       List,\n\t\"Mail2Domain\": func(mail string) string {\n\t\tif !strings.Contains(mail, \"@\") {\n\t\t\treturn \"try.gogits.org\"\n\t\t}\n\n\t\tsuffix := strings.SplitN(mail, \"@\", 2)[1]\n\t\tdomain, ok := mailDomains[suffix]\n\t\tif !ok {\n\t\t\treturn \"mail.\" + suffix\n\t\t}\n\t\treturn domain\n\t},\n\t\"SubStr\": func(str string, start, length int) string {\n\t\treturn str[start : start+length]\n\t},\n\t\"DiffTypeToStr\":         DiffTypeToStr,\n\t\"DiffLineTypeToStr\":     DiffLineTypeToStr,\n\t\"ShortSha\":              ShortSha,\n\t\"Md5\":                   EncodeMd5,\n\t\"ActionContent2Commits\": ActionContent2Commits,\n\t\"Oauth2Icon\":            Oauth2Icon,\n\t\"Oauth2Name\":            Oauth2Name,\n\t\"ToUtf8\":                ToUtf8,\n}\n```\n\n## Functions\n\n```go\nfunc ActionDesc(act Actioner) string\n```\nTODO: Legacy ActionDesc accepts int that represents action operation type and returns the description.\n\n```go\nfunc ActionIcon(opType int) string\n```\nActionIcon accepts a int that represents action operation type and returns a icon class name.\n\n```go\nfunc AvatarLink(email string) string\n```\nAvatarLink returns avatar link by given e-mail.\n\n```go\nfunc CreateTimeLimitCode(data string, minutes int, startInf interface{}) string\n```\ncreate a time limit code code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string\n\n```go\nfunc DateFormat(t time.Time, format string) string\n```\nDate takes a PHP like date func to Go's time format.\n\n```go\nfunc DateParse(dateString, format string) (time.Time, error)\n```\nParse Date use PHP time format.\n\n```go\nfunc DiffLineTypeToStr(diffType int) string\n```\n\n```go\nfunc DiffTypeToStr(diffType int) string\n```\n\n```go\nfunc EncodeMd5(str string) string\n```\nEncode string to md5 hex value\n\n```go\nfunc FileSize(s int64) string\n```\nFileSize calculates the file size and generate user-friendly string.\n\n```go\nfunc GetRandomString(n int, alphabets ...byte) string\n```\nGetRandomString generate random string by specify chars.\n\n```go\nfunc IsImageFile(data []byte) (string, bool)\n```\n\n```go\nfunc IsMarkdownFile(name string) bool\n```\n\n```go\nfunc IsReadmeFile(name string) bool\n```\n\n```go\nfunc IsTextFile(data []byte) (string, bool)\n```\n\n```go\nfunc List(l *list.List) chan interface{}\n```\n\n```go\nfunc Oauth2Icon(t int) string\n```\n\n```go\nfunc Oauth2Name(t int) string\n```\n\n```go\nfunc PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte\n```\n[http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto](http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto)\n\n```go\nfunc Range(l int) []int\n```\n\n```go\nfunc RenderMarkdown(rawBytes []byte, urlPrefix string) []byte\n```\n\n```go\nfunc RenderMarkdownString(raw, urlPrefix string) string\n```\n\n```go\nfunc RenderRawMarkdown(body []byte, urlPrefix string) []byte\n```\n\n```go\nfunc RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte\n```\n\n```go\nfunc ShortSha(sha1 string) string\n```\n\n```go\nfunc Str2html(raw string) template.HTML\n```\n\n```go\nfunc Subtract(left interface{}, right interface{}) interface{}\n```\nSubtract deals with subtraction of all types of number.\n\n```go\nfunc TimeSince(t time.Time, lang string) template.HTML\n```\nTimeSince calculates the time interval and generate user-friendly string.\n\n```go\nfunc TimeSincePro(then time.Time) string\n```\nTimeSincePro calculates the time interval and generate full user-friendly string.\n\n```go\nfunc ToUtf8(content string) string\n```\n\n```go\nfunc ToUtf8WithErr(content []byte) (error, string)\n```\n\n```go\nfunc VerifyTimeLimitCode(data string, minutes int, code string) bool\n```\nverify time limit code\n\n## Types\n\n```go\ntype Actioner interface {\n\tGetOpType() int\n\tGetActUserName() string\n\tGetActEmail() string\n\tGetRepoUserName() string\n\tGetRepoName() string\n\tGetBranch() string\n\tGetContent() string\n}\n```\n\n```go\ntype ApiJsonErr struct {\n\tMessage string `json:\"message\"`\n\tDocUrl  string `json:\"documentation_url\"`\n}\n```\n\n```go\ntype CustomRender struct {\n\tgfm.Renderer\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (options *CustomRender) Link(out *bytes.Buffer, link []byte, title []byte, content []byte)\n```\n\n```go\ntype PushCommit struct {\n\tSha1        string\n\tMessage     string\n\tAuthorEmail string\n\tAuthorName  string\n}\n```\n\n```go\ntype PushCommits struct {\n\tLen     int\n\tCommits []*PushCommit\n}\n```\n\n```go\nfunc ActionContent2Commits(act Actioner) *PushCommits\n```\n\n```go\ntype TplName string\n```\n\n","path":"github.com/developerspl/gogs/modules/base","name":"base","synopsis":"","isRedistributable":true}
