|
|
@ -22,86 +22,88 @@ import ( |
|
|
|
"github.com/gogits/gogs/modules/setting" |
|
|
|
"github.com/gogits/gogs/modules/setting" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var Funcs template.FuncMap = map[string]interface{}{ |
|
|
|
func NewFuncMap() []template.FuncMap { |
|
|
|
"GoVer": func() string { |
|
|
|
return []template.FuncMap{map[string]interface{}{ |
|
|
|
return strings.Title(runtime.Version()) |
|
|
|
"GoVer": func() string { |
|
|
|
}, |
|
|
|
return strings.Title(runtime.Version()) |
|
|
|
"UseHTTPS": func() bool { |
|
|
|
}, |
|
|
|
return strings.HasPrefix(setting.AppUrl, "https") |
|
|
|
"UseHTTPS": func() bool { |
|
|
|
}, |
|
|
|
return strings.HasPrefix(setting.AppUrl, "https") |
|
|
|
"AppName": func() string { |
|
|
|
}, |
|
|
|
return setting.AppName |
|
|
|
"AppName": func() string { |
|
|
|
}, |
|
|
|
return setting.AppName |
|
|
|
"AppSubUrl": func() string { |
|
|
|
}, |
|
|
|
return setting.AppSubUrl |
|
|
|
"AppSubUrl": func() string { |
|
|
|
}, |
|
|
|
return setting.AppSubUrl |
|
|
|
"AppUrl": func() string { |
|
|
|
}, |
|
|
|
return setting.AppUrl |
|
|
|
"AppUrl": func() string { |
|
|
|
}, |
|
|
|
return setting.AppUrl |
|
|
|
"AppVer": func() string { |
|
|
|
}, |
|
|
|
return setting.AppVer |
|
|
|
"AppVer": func() string { |
|
|
|
}, |
|
|
|
return setting.AppVer |
|
|
|
"AppDomain": func() string { |
|
|
|
}, |
|
|
|
return setting.Domain |
|
|
|
"AppDomain": func() string { |
|
|
|
}, |
|
|
|
return setting.Domain |
|
|
|
"DisableGravatar": func() bool { |
|
|
|
}, |
|
|
|
return setting.DisableGravatar |
|
|
|
"DisableGravatar": func() bool { |
|
|
|
}, |
|
|
|
return setting.DisableGravatar |
|
|
|
"LoadTimes": func(startTime time.Time) string { |
|
|
|
}, |
|
|
|
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" |
|
|
|
"LoadTimes": func(startTime time.Time) string { |
|
|
|
}, |
|
|
|
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" |
|
|
|
"AvatarLink": base.AvatarLink, |
|
|
|
}, |
|
|
|
"Safe": Safe, |
|
|
|
"AvatarLink": base.AvatarLink, |
|
|
|
"Str2html": Str2html, |
|
|
|
"Safe": Safe, |
|
|
|
"TimeSince": base.TimeSince, |
|
|
|
"Str2html": Str2html, |
|
|
|
"RawTimeSince": base.RawTimeSince, |
|
|
|
"TimeSince": base.TimeSince, |
|
|
|
"FileSize": base.FileSize, |
|
|
|
"RawTimeSince": base.RawTimeSince, |
|
|
|
"Subtract": base.Subtract, |
|
|
|
"FileSize": base.FileSize, |
|
|
|
"Add": func(a, b int) int { |
|
|
|
"Subtract": base.Subtract, |
|
|
|
return a + b |
|
|
|
"Add": func(a, b int) int { |
|
|
|
}, |
|
|
|
return a + b |
|
|
|
"ActionIcon": ActionIcon, |
|
|
|
}, |
|
|
|
"DateFmtLong": func(t time.Time) string { |
|
|
|
"ActionIcon": ActionIcon, |
|
|
|
return t.Format(time.RFC1123Z) |
|
|
|
"DateFmtLong": func(t time.Time) string { |
|
|
|
}, |
|
|
|
return t.Format(time.RFC1123Z) |
|
|
|
"DateFmtShort": func(t time.Time) string { |
|
|
|
}, |
|
|
|
return t.Format("Jan 02, 2006") |
|
|
|
"DateFmtShort": func(t time.Time) string { |
|
|
|
}, |
|
|
|
return t.Format("Jan 02, 2006") |
|
|
|
"List": List, |
|
|
|
}, |
|
|
|
"Mail2Domain": func(mail string) string { |
|
|
|
"List": List, |
|
|
|
if !strings.Contains(mail, "@") { |
|
|
|
"Mail2Domain": func(mail string) string { |
|
|
|
return "try.gogs.io" |
|
|
|
if !strings.Contains(mail, "@") { |
|
|
|
} |
|
|
|
return "try.gogs.io" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return strings.SplitN(mail, "@", 2)[1] |
|
|
|
return strings.SplitN(mail, "@", 2)[1] |
|
|
|
}, |
|
|
|
}, |
|
|
|
"SubStr": func(str string, start, length int) string { |
|
|
|
"SubStr": func(str string, start, length int) string { |
|
|
|
if len(str) == 0 { |
|
|
|
if len(str) == 0 { |
|
|
|
return "" |
|
|
|
return "" |
|
|
|
} |
|
|
|
} |
|
|
|
end := start + length |
|
|
|
end := start + length |
|
|
|
if length == -1 { |
|
|
|
if length == -1 { |
|
|
|
end = len(str) |
|
|
|
end = len(str) |
|
|
|
} |
|
|
|
} |
|
|
|
if len(str) < end { |
|
|
|
if len(str) < end { |
|
|
|
return str |
|
|
|
return str |
|
|
|
} |
|
|
|
} |
|
|
|
return str[start:end] |
|
|
|
return str[start:end] |
|
|
|
}, |
|
|
|
}, |
|
|
|
"DiffTypeToStr": DiffTypeToStr, |
|
|
|
"DiffTypeToStr": DiffTypeToStr, |
|
|
|
"DiffLineTypeToStr": DiffLineTypeToStr, |
|
|
|
"DiffLineTypeToStr": DiffLineTypeToStr, |
|
|
|
"Sha1": Sha1, |
|
|
|
"Sha1": Sha1, |
|
|
|
"ShortSha": base.ShortSha, |
|
|
|
"ShortSha": base.ShortSha, |
|
|
|
"MD5": base.EncodeMD5, |
|
|
|
"MD5": base.EncodeMD5, |
|
|
|
"ActionContent2Commits": ActionContent2Commits, |
|
|
|
"ActionContent2Commits": ActionContent2Commits, |
|
|
|
"ToUtf8": ToUtf8, |
|
|
|
"ToUtf8": ToUtf8, |
|
|
|
"EscapePound": func(str string) string { |
|
|
|
"EscapePound": func(str string) string { |
|
|
|
return strings.Replace(strings.Replace(str, "%", "%25", -1), "#", "%23", -1) |
|
|
|
return strings.Replace(strings.Replace(str, "%", "%25", -1), "#", "%23", -1) |
|
|
|
}, |
|
|
|
}, |
|
|
|
"RenderCommitMessage": RenderCommitMessage, |
|
|
|
"RenderCommitMessage": RenderCommitMessage, |
|
|
|
"ThemeColorMetaTag": func() string { |
|
|
|
"ThemeColorMetaTag": func() string { |
|
|
|
return setting.ThemeColorMetaTag |
|
|
|
return setting.ThemeColorMetaTag |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
}} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func Safe(raw string) template.HTML { |
|
|
|
func Safe(raw string) template.HTML { |
|
|
|