functions

package
v0.0.0-...-d2401b3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsoluteDate

func AbsoluteDate(t time.Time) string

func HasField

func HasField(v any, name string) bool

func HumanDuration

func HumanDuration(d time.Duration) string

func IsImageThread

func IsImageThread(v string) bool

IsImageThread tells you if the thread is an image thread

func IsRobot

func IsRobot(user any) bool

func IsValidThread

func IsValidThread(v string) bool

IsValidThread tells you if a thread is valid, that is not-empty or is the literal 'none'

func MediaDuration

func MediaDuration(d time.Duration) string

func NewWithVersionFunc

func NewWithVersionFunc(ctx context.Context, prefix string, fsys fs.FS) *withVersion

func PrettyDuration

func PrettyDuration(d time.Duration) string

func PrintJSON

func PrintJSON(v any) (template.HTML, error)

func Reverse

func Reverse(s any) any

Reverse reverses a slice input and returns an iter.Seq2 with both index and element, this means you always need to use {{range $i, $v := Reverse <slice>}} to get both values out, using a single only gets you the index.

func SafeHTML

func SafeHTML(v any) (template.HTML, error)

func SafeHTMLAttr

func SafeHTMLAttr(v any) (template.HTMLAttr, error)

func SafeURL

func SafeURL(v any) (template.URL, error)

func TemplateFuncs

func TemplateFuncs() template.FuncMap

func TimeAgo

func TimeAgo(now func() time.Time) func(time.Time, string) string

example usage: {{ TimeAgo .CreatedAt "%y foo, %d, %h hours, %mbar" }} -> "2 foo, 23, 11 hours, 12bar" if >0 years have passed, otherwise "23, 11 hours, 12bar" etc.

func TimeagoDuration

func TimeagoDuration(d time.Duration) string

Types

type SongPairing

type SongPairing struct {
	*radio.Song
	Data any
}

func SongPair

func SongPair(song radio.Song, data any) SongPairing

type StatefulFuncs

type StatefulFuncs struct {
	// contains filtered or unexported fields
}

func NewStatefulFunctions

func NewStatefulFunctions(cfg config.Config, status util.StreamValuer[radio.Status]) *StatefulFuncs

func (*StatefulFuncs) FuncMap

func (sf *StatefulFuncs) FuncMap() template.FuncMap

func (*StatefulFuncs) SongFileSize

func (sf *StatefulFuncs) SongFileSize(song any) string

func (*StatefulFuncs) Status

func (sf *StatefulFuncs) Status() radio.Status

func (*StatefulFuncs) UpdateWithVersion

func (sf *StatefulFuncs) UpdateWithVersion(wv *withVersion)

func (*StatefulFuncs) WithVersion

func (sf *StatefulFuncs) WithVersion(urlPath string) template.URL

Jump to

Keyboard shortcuts

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