top

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultStarIcon = `fa-star-o`
	StarIcons       = map[VSTAR]string{
		STAR_EMPTY: `fa-star-o`,
		STAR_FULL:  `fa-star`,
		STAR_HALF:  `fa-star-half-o`,
	}
	DefaultStarName = `empty`
	StarNames       = map[VSTAR]string{
		STAR_EMPTY: `empty`,
		STAR_FULL:  `full`,
		STAR_HALF:  `half`,
	}
)
View Source
var (
	ErrInvalidDuration = errors.New("invalid duration")
	DurationDay        = time.Hour * 24
	DurationMonth      = DurationDay * 30
	DurationWeek       = DurationDay * 7
	DurationYear       = DurationDay * 365
	MonthMaxSeconds    = 31 * 86400 // 月份中可能的最大秒数
)
View Source
var PinyinDict = pinyin.NewDict()
View Source
var SlugifyMaxWidth = 255

Functions

func AbsoluteURL

func AbsoluteURL(purl string) string

func Base36Decode

func Base36Decode(v string) uint64

func Base36Encode

func Base36Encode(i uint64) string

func CN2Number

func CN2Number(cn string) (uint64, error)

func CondFindInSet

func CondFindInSet(key string, value interface{}, useFulltextIndex ...bool) db.Compound

func CopyFormDataBy

func CopyFormDataBy(ctx echo.Context, formData map[string][]string)

func Dump

func Dump(m interface{})

func FirstLetter

func FirstLetter(s string) string

func GenSN

func GenSN(prefixes ...string) (string, error)

GenSN 生成唯一序列号 (经密码加密) 生成结果长度一般为 15 个字符

func GetValidated

func GetValidated(ctx echo.Context) interface{}

func HashID

func HashID() *hashids.HashID

func HashIDDecode

func HashIDDecode(encoded string) (uint64, error)

func HashIDEncode

func HashIDEncode(id uint64) (string, error)

func HashIDOnce

func HashIDOnce() *hashids.HashID

func HeaderP3P

func HeaderP3P(ctx echo.Context)

func HideContent

func HideContent(content string, contype string, hide HideDetector) (result string)

func ImageProxyURL

func ImageProxyURL(values ...interface{}) string

ImageProxyURL 图片代理网址

func IsMobile

func IsMobile(userAgent string) bool

func IsSameDay

func IsSameDay(last time.Time, nows ...time.Time) bool

IsSameDay 是否为同一天

func IsSameMonth

func IsSameMonth(last time.Time, nows ...time.Time) bool

IsSameMonth 是否为同一月

func IsWechat

func IsWechat(userAgent string) bool

func MakeKVCallback

func MakeKVCallback(cb func(k interface{}, v interface{}) error, args ...interface{}) (err error)

func MakeListURL

func MakeListURL(urlPrefix string, params param.StringMap,
	filterParamNames []string, sep string, args ...interface{}) string

func MakeValuesURLPath

func MakeValuesURLPath(args echo.H, sep string, keys ...string) string

MakeValuesURLPath 生成带参数值的网址路径

func MonthDay

func MonthDay(year int, month int) (days int)

MonthDay 计算某个月的天数

func MonthDayByTime

func MonthDayByTime(t time.Time) int

MonthDayByTime 计算某个月的天数

func NewHashID

func NewHashID(salt string) *hashids.HashID

func NewSNCodec

func NewSNCodec() *hashids.HashID

func OutputContent

func OutputContent(content string, contypes ...string) interface{}

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration 解析持续时间(在支持标准库time.ParseDuration的基础上增加了年(y)月(mo)周(w)日(d)的支持)

func ParseURLPathKV

func ParseURLPathKV(path string) param.StringMap

ParseURLPathKV 解析网址路径表示的键值数据 /键1/值1/键2/值2

func ParseURLPathValues

func ParseURLPathValues(path string, sep string, keys ...string) param.StringMap

ParseURLPathValues 解析网址路径表示的值数据 /值1_值2 通过传入参数keys来指定各个对应位置的key

func PictureHTML

func PictureHTML(picURL string, widthAndHeights ...string) template.HTML

func PictureWithDefaultHTML

func PictureWithDefaultHTML(picURL string, defaultURL string, widthAndHeights ...string) template.HTML

func Pinyin

func Pinyin(s string, seps ...string) string

func RawSN

func RawSN() (string, error)

RawSN 生成唯一序列号 (无加密) 生成结果长度一般为 12 个字符

func RecvValidated

func RecvValidated(ctx echo.Context, recvs ...factory.Model) error

func ReplacePlaceholder

func ReplacePlaceholder(content string, values map[string]interface{}, startAndEndTag ...string) string

func ReplacePlaceholderx

func ReplacePlaceholderx(t *fasttemplate.Template, values map[string]interface{}, args ...interface{}) string

func ResizeImageURL

func ResizeImageURL(image string, size string, defaults ...string) string

ResizeImageURL ResizeImageURL(imageURL,`1000x1240`,`default.jpg`)

func Response

func Response(ctx echo.Context) error

func SecretSafeBuilder

func SecretSafeBuilder(ctx echo.Context, secret string) string

SecretSafeBuilder 密钥强化

func Slugify

func Slugify(v string) string

func StrengthenSafeSecret

func StrengthenSafeSecret(ctx echo.Context, secret string) string

StrengthenSafeSecret 强化的安全密钥(包含网络环境)

func TodayTimestamp

func TodayTimestamp() (startTs int64, endTs int64)

func TokenURL

func TokenURL(values ...interface{}) string

TokenURL 带签名网址

func TrimOverflowText

func TrimOverflowText(text string, maxLength int, seperators ...string) string

func Tx

func URLFor

func URLFor(purl string) string

Types

type AsMap

type AsMap interface {
	AsMap() param.Store
}

type AsPartialMap

type AsPartialMap interface {
	AsMap(...string) param.Store
}

type HideDetector

type HideDetector func(hideType string, hideContent string, args ...string) (hide bool, msgOnHide string)

type Pagination

type Pagination struct {
	Page      int                    `json:"page"`
	Rows      int                    `json:"rows"`
	Size      int                    `json:"size"`
	Limit     int                    `json:"limit"`
	Pages     int                    `json:"pages"`
	URLLayout string                 `json:"urlLayout"`
	Data      map[string]interface{} `json:"data"`
}

type ResponseData

type ResponseData struct {
	Code  int         `json:"Code"`
	State string      `json:"State"`
	Info  interface{} `json:"Info,omitempty" xml:"Info,omitempty" swaggertype:"string"`
	Zone  interface{} `json:"Zone,omitempty" xml:"Zone,omitempty" swaggertype:"string"`
	URL   string      `json:"URL,omitempty" xml:"URL,omitempty"`
	Data  interface{} `json:"Data" swaggertype:"object"`
}

type ResponseList

type ResponseList struct {
	List       []interface{} `json:"list"`
	Pagination Pagination    `json:"pagination"`
}

type Stars

type Stars []VSTAR

func StarsSlice

func StarsSlice(cur float64, max ...int) Stars

StarsSlice 生成星标切片

func StarsSlice5 added in v0.3.13

func StarsSlice5(cur float64) Stars

func StarsSlicex

func StarsSlicex(curRating float64, maxRating float64, maxStars ...int) Stars

StarsSlicex 将最大分数按照最大星标数量平分生成星标切片

func StarsSlicex5 added in v0.3.13

func StarsSlicex5(curRating float64, maxRating float64) Stars

func (Stars) HTML

func (s Stars) HTML() template.HTML

type VSTAR

type VSTAR int
const (
	STAR_EMPTY VSTAR = 0
	STAR_FULL  VSTAR = 1
	STAR_HALF  VSTAR = 2
)

func (VSTAR) IconStar

func (v VSTAR) IconStar() string

func (VSTAR) String

func (v VSTAR) String() string

Jump to

Keyboard shortcuts

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