base

package
v0.7.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2015 License: MIT Imports: 28 Imported by: 0

Documentation

Index

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 DOC_URL = "https://github.com/gogits/go-gogs-client/wiki"
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").Matching(regexp.MustCompile(`[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&]*`)).OnElements("code")

Functions

func AvatarLink(email string) string

AvatarLink returns avatar link by given e-mail.

func BasicAuthDecode added in v0.5.8

func BasicAuthDecode(encoded string) (string, string, error)

func BasicAuthEncode added in v0.5.8

func BasicAuthEncode(username, password string) string

func CreateTimeLimitCode

func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string

create a time limit code code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string

func DetectEncoding added in v0.5.9

func DetectEncoding(content []byte) (string, error)

func EncodeMD5 added in v0.7.22

func EncodeMD5(str string) string

EncodeMD5 encodes string to md5 hex value.

func EncodeSha1 added in v0.5.8

func EncodeSha1(str string) string

Encode string to sha1 hex value.

func ExecPath added in v0.7.6

func ExecPath() (string, error)

ExecPath returns the executable path.

func FileSize

func FileSize(s int64) string

FileSize calculates the file size and generate user-friendly string.

func GetRandomString

func GetRandomString(n int, alphabets ...byte) string

GetRandomString generate random string by specify chars.

func Int64sToMap added in v0.6.5

func Int64sToMap(ints []int64) map[int64]bool

Int64sToMap converts a slice of int64 to a int64 map.

func Int64sToStrings added in v0.6.9

func Int64sToStrings(ints []int64) []string

Int64sToStrings converts a slice of int64 to a slice of string.

func IsImageFile

func IsImageFile(data []byte) (string, bool)

func IsMarkdownFile

func IsMarkdownFile(name string) bool

func IsReadmeFile

func IsReadmeFile(name string) bool

IsReadmeFile returns true if given file name suppose to be a README file.

func IsTextFile

func IsTextFile(data []byte) (string, bool)

func PBKDF2 added in v0.3.0

func PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte

http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto

func PostProcessMarkdown added in v0.6.1

func PostProcessMarkdown(rawHtml []byte, urlPrefix string) []byte

PostProcessMarkdown treats different types of HTML differently, and only renders special links for plain text blocks.

func RawTimeSince added in v0.6.5

func RawTimeSince(t time.Time, lang string) string

func RenderIssueIndexPattern added in v0.5.9

func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte

func RenderMarkdown

func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte

func RenderMarkdownString added in v0.3.0

func RenderMarkdownString(raw, urlPrefix string) string

func RenderRawMarkdown added in v0.4.0

func RenderRawMarkdown(body []byte, urlPrefix string) []byte

func RenderSha1CurrentPattern added in v0.5.9

func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte
func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte

func ShortSha

func ShortSha(sha1 string) string

func StringsToInt64s added in v0.6.5

func StringsToInt64s(strs []string) []int64

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 TimeSince

func TimeSince(t time.Time, lang string) template.HTML

TimeSince calculates the time interval and generate user-friendly string.

func TimeSincePro

func TimeSincePro(then time.Time) string

TimeSincePro calculates the time interval and generate full user-friendly string.

func VerifyTimeLimitCode

func VerifyTimeLimitCode(data string, minutes int, code string) bool

verify time limit code

Types

type CustomRender

type CustomRender struct {
	blackfriday.Renderer
	// contains filtered or unexported fields
}

func (*CustomRender) Image added in v0.5.8

func (options *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte)
func (options *CustomRender) Link(out *bytes.Buffer, link []byte, title []byte, content []byte)

type TplName added in v0.5.0

type TplName string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL