utils

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TemplateFuncs = template.FuncMap{

	"now":            time.Now,
	"timeSince":      time.Since,
	"timeUntil":      time.Until,
	"formatTime":     formatTime,
	"approxDuration": approxDuration,

	"uppercase":    strings.ToUpper,
	"lowercase":    strings.ToLower,
	"pluralize":    pluralize,
	"slugify":      Slugify,
	"safeHTML":     safeHTML,
	"strippedHTML": StrippedHTML,
	"removeExt":    RemoveExtension,

	"join": strings.Join,

	"incr":        incr,
	"incrBy":      incrBy,
	"decr":        decr,
	"decrBy":      decrBy,
	"formatInt":   formatInt,
	"formatFloat": formatFloat,

	"yesno": yesno,

	"urlSetParam":        urlSetParam,
	"urlDelParam":        urlDelParam,
	"getFileNameFromUrl": GetFileNameFromUrl,

	"marshalJSON": marshalJSON,
}

Functions

func AssetUrl

func AssetUrl(path string) string

func Decompress

func Decompress(in io.Reader, out io.Writer) error

func ExtractIdFromString added in v0.0.31

func ExtractIdFromString(s string) string

ExtractIdFromString extracts the ID from a string.

func GetFileNameFromUrl

func GetFileNameFromUrl(url string, extension bool) string

func IsHtmxRequest

func IsHtmxRequest(c echo.Context) bool

IsHtmxRequest checks if the request is an htmx request by checking the value of the "HX-Request" header.

func NotFoundError added in v0.0.31

func NotFoundError(c echo.Context) error

NotFoundError is a handler that returns a 404 error page.

func RemoveExtension

func RemoveExtension(s string) string

func ServerFaultError added in v0.0.31

func ServerFaultError(c echo.Context) error

func SetBoolWithFallback

func SetBoolWithFallback(value *bool, fallback bool)

func Slugify

func Slugify(s string) string

func StrippedHTML

func StrippedHTML(s string) string

Types

type Century

type Century struct {
	Century   string
	Composers []Composer
}

type Composer

type Composer struct {
	Name     string
	Date     string
	Language string
	Songs    []Song
}

type Pagination

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

func NewPagination

func NewPagination(totalAmount, perPage, currentPage int, baseUrl string, htmxTarget string, htmxUrl string) *Pagination

constructor

func (*Pagination) FirstPart

func (p *Pagination) FirstPart() []string

func (*Pagination) GetActivePageWrapper

func (p *Pagination) GetActivePageWrapper(text string) string

func (*Pagination) GetAvailablePageWrapper

func (p *Pagination) GetAvailablePageWrapper(href, page, htmxUrl string) string

func (*Pagination) GetDisabledPageWrapper

func (p *Pagination) GetDisabledPageWrapper(text string) string

func (*Pagination) GetDots

func (p *Pagination) GetDots() string

func (*Pagination) GetNextButton

func (p *Pagination) GetNextButton(text string) string

func (*Pagination) GetPreviousButton

func (p *Pagination) GetPreviousButton(text string) string

func (*Pagination) HasPages

func (p *Pagination) HasPages() bool

HasPages returns true if there are more than one pages in the pagination.

func (*Pagination) LastPart

func (p *Pagination) LastPart() []string

func (*Pagination) MiddlePart

func (p *Pagination) MiddlePart() []string

func (*Pagination) Render

func (p *Pagination) Render() template.HTML

Render generates the HTML for the pagination component and returns it as a template.HTML value.

func (*Pagination) TotalPages

func (p *Pagination) TotalPages() int

TotalPages returns the total number of pages in the pagination.

type Song

type Song struct {
	ID     uuid.UUID
	Title  string
	URL    string
	Source []string
}

type UrlData

type UrlData struct {
	Url string
	ID  uuid.UUID
}

func ParseMusicListToUrls

func ParseMusicListToUrls(filePath string) ([]UrlData, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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