utils

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 22 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 SendToastMessage added in v0.11.0

func SendToastMessage(message string, t string, closeDialog bool, c echo.Context, trigger string)

func ServerFaultError added in v0.0.31

func ServerFaultError(c echo.Context) error

func SetBoolWithFallback

func SetBoolWithFallback(value *bool, fallback bool)

func SetHxTrigger added in v0.11.0

func SetHxTrigger(c echo.Context, data map[string]any)

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

FirstPart returns the first part of the pagination.

func (*Pagination) GetActivePageWrapper

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

GetActivePageWrapper returns an HTML string representing the active page link for pagination. The function takes a `text` parameter, which is the text to be displayed inside the link. It generates an HTML string with the active page link using the provided `text`.

func (*Pagination) GetAvailablePageWrapper

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

GetAvailablePageWrapper returns a string representing a pagination link with the given href, page number, and htmxUrl. If htmxTarget is specified, it adds the hx-target attribute to the link.

func (*Pagination) GetDisabledPageWrapper

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

GetDisabledPageWrapper returns a disabled page wrapper HTML element for pagination. It takes a `text` parameter representing the text to be displayed within the wrapper. The method returns a string containing the disabled page wrapper HTML element.

func (*Pagination) GetDots

func (p *Pagination) GetDots() string

GetDots returns the HTML representation of the dots used for pagination ellipsis.

func (*Pagination) GetNextButton

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

GetNextButton returns the HTML code for the next button in the pagination. If the current page is the last page, it returns the disabled page wrapper. Otherwise, it returns the URL for the next page with the specified text.

func (*Pagination) GetPreviousButton

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

GetPreviousButton returns the HTML string for the previous button in the pagination. If the current page is the first page, it returns a disabled button. Otherwise, it returns a button with the URL for the previous page and the specified text.

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

LastPart returns the last part of the pagination.

func (*Pagination) MiddlePart

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

MiddlePart returns the middle part of the pagination.

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