assets

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package assets provides the web assets.

Index

Constants

View Source
const (
	BaseStyleFile = "style.css"
	ViewStyleFile = "view.css"
	IconFile      = "xmr.svg"
	LogoFile      = "logo.png"
	IndexFile     = "index.html"
)

Variables

Functions

func ExecuteToBuffer

func ExecuteToBuffer(tmpl *template.Template, args any) ([]byte, error)

ExecuteToBuffer executes a template with the provided args and returns the resulting data as a byte slice.

Types

type LangPack

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

LangPack is a set of localzed data.

type Store

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

Store is a collection of assets.

func New

func New(
	cfg *config.Config,
	internalAssets fs.FS,
	parentLogger *slog.Logger,
) (*Store, error)

New creates a new asset Store instance.

func (*Store) DefaultName

func (st *Store) DefaultName(lang language.Tag) string

DefaultName returns the default name corresponding to the locale.

func (*Store) RequestToLang

func (st *Store) RequestToLang(r *http.Request) language.Tag

RequestToLang attempts to determine the suitable language for a given http request.

func (*Store) ServeAlert

func (st *Store) ServeAlert(w http.ResponseWriter, entry *api.Superchat, lang language.Tag)

ServeAlert serves an alertTemplate, parameterized by `(entry, lang)`.

func (*Store) ServeCheck

func (st *Store) ServeCheck(w http.ResponseWriter, receipt *api.Receipt, lang language.Tag)

ServeCheck serves a checkTemplate, parametereized by `(receipt, lang)`.

func (*Store) ServeError

func (st *Store) ServeError(w http.ResponseWriter, statusCode int, reason api.ErrorReason, lang language.Tag)

ServeError serves an error parameterized by `(statusCode, reason, lang)` as a HTTP response to the writer `w`.

func (*Store) ServeIndexCaptcha

func (st *Store) ServeIndexCaptcha(w http.ResponseWriter, captchaID string, lang language.Tag)

ServeIndexCaptcha serves an indexTemplate, parameterized by `(captchaID, lang)`.

func (*Store) ServePay

func (st *Store) ServePay(w http.ResponseWriter, pendingPayment *api.PendingPayment, lang language.Tag)

ServePay serves a payTemplate, parameterized by `(pendingPayment, lang)`.

func (*Store) ServeView

func (st *Store) ServeView(w http.ResponseWriter, entries []api.Superchat, refreshInterval uint, lang language.Tag)

ServeView serves a viewTemplate, parameterized by `(entries, refreshInterval, lang)`.

func (*Store) StaticContent

func (st *Store) StaticContent(key string, lang language.Tag) ([]byte, error)

StaticContent returns the localized static content identified by `key`.

func (*Store) StaticContentHandler

func (st *Store) StaticContentHandler(fn string) http.HandlerFunc

StaticContentHandler returns a http.Handler backed by static content.

Jump to

Keyboard shortcuts

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