Documentation ¶
Index ¶
- Constants
- Variables
- func ActionDesc(act Actioner) string
- func ActionIcon(opType int) string
- func AvatarLink(email string) string
- func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string
- func DateFormat(t time.Time, format string) string
- func DateParse(dateString, format string) (time.Time, error)
- func DiffLineTypeToStr(diffType int) string
- func DiffTypeToStr(diffType int) string
- func EncodeMd5(str string) string
- func ExecDir() (string, error)
- func FileSize(s int64) string
- func GetRandomString(n int, alphabets ...byte) string
- 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 NewConfigContext()
- func NewServices()
- func Range(l int) []int
- func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte
- func ShortSha(sha1 string) string
- func Str2html(raw string) template.HTML
- func Subtract(left interface{}, right interface{}) interface{}
- func TimeSince(then time.Time) string
- func TimeSincePro(then time.Time) string
- func ToStr(value interface{}, args ...int) (s string)
- func VerifyTimeLimitCode(data string, minutes int, code string) bool
- type Actioner
- type CustomRender
- type Mailer
- type PushCommit
- type PushCommits
- type StrTo
- type TmplData
Constants ¶
View Source
const ( Minute = 60 Hour = 60 * Minute Day = 24 * Hour Week = 7 * Day Month = 30 * Day Year = 12 * Month )
Seconds-based time units
View Source
const ( Byte = 1 KByte = Byte * 1024 MByte = KByte * 1024 GByte = MByte * 1024 TByte = GByte * 1024 PByte = TByte * 1024 EByte = PByte * 1024 )
View Source
const ( TPL_CREATE_REPO = `<a href="/user/%s">%s</a> created repository <a href="/%s">%s</a>` TPL_COMMIT_REPO = `<a href="/user/%s">%s</a> pushed to <a href="/%s/src/%s">%s</a> at <a href="/%s">%s</a>%s` TPL_COMMIT_REPO_LI = `<div><img src="%s?s=16" alt="user-avatar"/> <a href="/%s/commit/%s">%s</a> %s</div>` TPL_CREATE_Issue = `<a href="/user/%s">%s</a> opened issue <a href="/%s/issues/%s">%s#%s</a> <div><img src="%s?s=16" alt="user-avatar"/> %s</div>` )
View Source
const TimeLimitCodeLength = 12 + 6 + 40
Variables ¶
View Source
var ( AppVer string AppName string AppLogo string AppUrl string Domain string SecretKey string RunUser string RepoRootPath string InstallLock bool LogInRememberDays int CookieUserName string CookieRememberName string Cfg *goconfig.ConfigFile MailService *Mailer LogMode string LogConfig string Cache cache.Cache CacheAdapter string CacheConfig string SessionProvider string SessionConfig *session.Config SessionManager *session.Manager PictureService string )
View Source
var Service struct { RegisterEmailConfirm bool DisenableRegisteration bool RequireSignInView bool EnableCacheAvatar bool NotifyMail bool ActiveCodeLives int ResetPwdCodeLives int }
View Source
var TemplateFuncs template.FuncMap = map[string]interface{}{ "AppName": func() string { return AppName }, "AppVer": func() string { return AppVer }, "AppDomain": func() string { return Domain }, "LoadTimes": func(startTime time.Time) string { return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" }, "AvatarLink": AvatarLink, "str2html": Str2html, "TimeSince": TimeSince, "FileSize": FileSize, "Subtract": Subtract, "ActionIcon": ActionIcon, "ActionDesc": ActionDesc, "DateFormat": DateFormat, "List": List, "Mail2Domain": func(mail string) string { 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 { return str[start : start+length] }, "DiffTypeToStr": DiffTypeToStr, "DiffLineTypeToStr": DiffLineTypeToStr, "ShortSha": ShortSha, }
Functions ¶
func ActionDesc ¶
ActionDesc accepts int that represents action operation type and returns the description.
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 CreateTimeLimitCode ¶
create a time limit code code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string
func DateFormat ¶
Date takes a PHP like date func to Go's time format.
func DiffLineTypeToStr ¶
func DiffTypeToStr ¶
func GetRandomString ¶
GetRandomString generate random string by specify chars.
func IsImageFile ¶
func IsMarkdownFile ¶
func IsReadmeFile ¶
func IsTextFile ¶
func NewConfigContext ¶
func NewConfigContext()
func NewServices ¶
func NewServices()
func RenderMarkdown ¶
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.
Types ¶
type CustomRender ¶
type PushCommit ¶
type PushCommits ¶
type PushCommits struct { Len int Commits []*PushCommit }
Click to show internal directories.
Click to hide internal directories.