Documentation ¶
Index ¶
- Constants
- 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 DefaultAvatarLink() string
- func DetectEncoding(content []byte) (string, error)
- func EllipsisString(str string, length int) string
- func EncodeMD5(str string) string
- func EncodeSha1(str string) string
- func FileSize(s int64) string
- func GetRandomBytesAsBase64(n int) string
- func GetRandomString(n int) (string, error)
- func HashEmail(email string) string
- func Int64sContains(intsSlice []int64, a int64) bool
- func Int64sToMap(ints []int64) map[int64]bool
- func Int64sToStrings(ints []int64) []string
- func IsImageFile(data []byte) bool
- func IsLetter(ch rune) bool
- func IsPDFFile(data []byte) bool
- func IsTextFile(data []byte) bool
- func IsVideoFile(data []byte) bool
- func MinutesToFriendly(minutes int, lang string) string
- func NaturalSortLess(s1, s2 string) bool
- func RawTimeSince(t time.Time, lang string) string
- func ShortSha(sha1 string) string
- func SizedAvatarLink(email string, size int) string
- func StringsToInt64s(strs []string) ([]int64, error)
- func Subtract(left interface{}, right interface{}) interface{}
- func TimeSince(then time.Time, lang string) template.HTML
- func TimeSincePro(then time.Time, lang string) string
- func TimeSinceUnix(then util.TimeStamp, lang string) template.HTML
- func TruncateString(str string, limit int) string
- func VerifyTimeLimitCode(data string, minutes int, code string) bool
- 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 )
Storage space size types
const DefaultAvatarSize = -1
DefaultAvatarSize is a sentinel value for the default avatar size, as determined by the avatar-hosting service.
const DocURL = "https://godoc.org/github.com/go-gitea/go-sdk/gitea"
DocURL api doc url
const TimeLimitCodeLength = 12 + 6 + 40
TimeLimitCodeLength default value for time limit code
Variables ¶
This section is empty.
Functions ¶
func AvatarLink ¶
AvatarLink returns relative avatar link to the site domain by given email, which includes app sub-url as prefix. However, it is possible to return full URL if user enables Gravatar-like service.
func BasicAuthDecode ¶
BasicAuthDecode decode basic auth string
func BasicAuthEncode ¶
BasicAuthEncode encode basic auth string
func CreateTimeLimitCode ¶
CreateTimeLimitCode create a time limit code code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string
func DefaultAvatarLink ¶ added in v1.1.3
func DefaultAvatarLink() string
DefaultAvatarLink the default avatar link
func DetectEncoding ¶
DetectEncoding detect the encoding of content
func EllipsisString ¶
EllipsisString returns a truncated short string, it appends '...' in the end of the length of string is too large.
func GetRandomBytesAsBase64 ¶ added in v1.1.0
GetRandomBytesAsBase64 generates a random base64 string from n bytes
func GetRandomString ¶
GetRandomString generate random string by specify chars.
func HashEmail ¶
HashEmail hashes email address to MD5 string. https://en.gravatar.com/site/implement/hash/
func Int64sContains ¶ added in v1.3.0
Int64sContains returns if a int64 in a slice of int64
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 ¶
IsImageFile detects if data is an image format
func IsLetter ¶
IsLetter reports whether the rune is a letter (category L). https://github.com/golang/go/blob/master/src/go/scanner/scanner.go#L257
func IsTextFile ¶
IsTextFile returns true if file content format is plain text or empty.
func IsVideoFile ¶ added in v1.0.0
IsVideoFile detects if data is an video format
func MinutesToFriendly ¶ added in v1.2.0
MinutesToFriendly returns a user friendly string with number of minutes converted to hours and minutes.
func NaturalSortLess ¶ added in v1.3.0
NaturalSortLess compares two strings so that they could be sorted in natural order
func RawTimeSince ¶
RawTimeSince retrieves i18n key of time since t
func ShortSha ¶
ShortSha is basically just truncating. It is DEPRECATED and will be removed in the future.
func SizedAvatarLink ¶ added in v1.3.2
SizedAvatarLink returns a sized link to the avatar for the given email address.
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.
func TimeSinceUnix ¶ added in v1.4.0
TimeSinceUnix calculates the time interval and generate user-friendly string.
func TruncateString ¶
TruncateString returns a truncated string with given limit, it returns input string if length is not reached limit.