base

package
v1.22.6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 22 Imported by: 898

Documentation

Index

Constants

View Source
const TimeLimitCodeLength = 12 + 6 + 40

TimeLimitCodeLength default value for time limit code

Variables

This section is empty.

Functions

func BasicAuthDecode

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

BasicAuthDecode decode basic auth string

func CreateTimeLimitCode

func CreateTimeLimitCode[T time.Time | string](data string, minutes int, startTimeGeneric T, h hash.Hash) string

CreateTimeLimitCode create a time-limited code. Format: 12 length date time string + 6 minutes string (not used) + 40 hash string, some other code depends on this fixed length If h is nil, then use the default hmac hash.

func EllipsisString

func EllipsisString(str string, length int) string

EllipsisString returns a truncated short string, it appends '...' in the end of the length of string is too large.

func EncodeSha256 added in v1.9.0

func EncodeSha256(str string) string

EncodeSha256 string to sha256 hex value.

func EntryIcon added in v1.5.0

func EntryIcon(entry *git.TreeEntry) string

EntryIcon returns the octicon class for displaying files/directories

func FileSize

func FileSize(s int64) string

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

func FormatNumberSI added in v1.13.0

func FormatNumberSI(data any) string

FormatNumberSI format a number

func Int64sToStrings

func Int64sToStrings(ints []int64) []string

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

func NaturalSortLess added in v1.3.0

func NaturalSortLess(s1, s2 string) bool

NaturalSortLess compares two strings so that they could be sorted in natural order

func SetupGiteaRoot added in v1.9.0

func SetupGiteaRoot() string

SetupGiteaRoot Sets GITEA_ROOT if it is not already set and returns the value

func ShortSha

func ShortSha(sha1 string) string

ShortSha is basically just truncating. It is DEPRECATED and will be removed in the future.

func StringsToInt64s

func StringsToInt64s(strs []string) ([]int64, error)

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

func TruncateString

func TruncateString(str string, limit int) string

TruncateString returns a truncated string with given limit, it returns input string if length is not reached limit.

func VerifyTimeLimitCode

func VerifyTimeLimitCode(now time.Time, data string, minutes int, code string) bool

VerifyTimeLimitCode verify time limit code

Types

type TplName

type TplName string

TplName template relative path type

Jump to

Keyboard shortcuts

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