Documentation ¶
Index ¶
- Constants
- Variables
- func BasicAuthDecode(encoded string) (string, string, error)
- func BasicAuthEncode(username, password string) string
- func EncodeMD5(str string) string
- func EncodeSha1(str string) string
- func ExecPath() (string, error)
- func FileSize(s int64) string
- func GetRandomString(n int, alphabets ...byte) string
- func Int64sToMap(ints []int64) map[int64]bool
- func Int64sToStrings(ints []int64) []string
- func IsImageFile(data []byte) (string, bool)
- func IsMarkdownFile(name string) bool
- func IsReadmeFile(name string) bool
- func IsTextFile(data []byte) (string, bool)
- func PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte
- func PostProcessMarkdown(rawHtml []byte, urlPrefix string, metas map[string]string) []byte
- func PreProcessMarkdown(rawHTML []byte, urlPrefix string) []byte
- func RawTimeSince(t time.Time, lang string) string
- func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string, metas map[string]string) []byte
- func RenderMarkdown(rawBytes []byte, urlPrefix string, metas map[string]string) []byte
- func RenderMarkdownString(raw string) string
- func RenderRawMarkdown(body []byte, urlPrefix string) []byte
- func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte
- func ShortSha(sha1 string) string
- 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
- type CustomRender
- type TplName
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 TimeLimitCodeLength = 12 + 6 + 40
Variables ¶
View Source
var GoGetMetas = make(map[string]bool)
View Source
var (
MentionPattern = regexp.MustCompile(`(\s|^)@[0-9a-zA-Z_\.]+`)
)
View Source
var Sanitizer = bluemonday.UGCPolicy().AllowAttrs("class", "data-original", "rel", "src").Matching(regexp.MustCompile(`[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&]*`)).OnElements("code")
Functions ¶
func BasicAuthEncode ¶
func GetRandomString ¶
GetRandomString generate random string by specify chars.
func Int64sToMap ¶
Int64sToMap converts a slice of int64 to a int64 map.
func Int64sToStrings ¶
Int64sToStrings converts a slice of int64 to a slice of string.
func IsImageFile ¶
func IsMarkdownFile ¶
func IsReadmeFile ¶
IsReadmeFile returns true if given file name suppose to be a README file.
func IsTextFile ¶
func PostProcessMarkdown ¶
PostProcessMarkdown treats different types of HTML differently, and only renders special links for plain text blocks.
func PreProcessMarkdown ¶
PreProcessMarkdown renders full links of commits, issues and pulls to shorter version.
func RenderIssueIndexPattern ¶
func RenderMarkdown ¶
func RenderMarkdownString ¶
func RenderRawMarkdown ¶
func StringsToInt64s ¶
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.
Types ¶
type CustomRender ¶
type CustomRender struct { blackfriday.Renderer // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.