templates

package
v0.0.0-...-d417536 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 21 Imported by: 0

Documentation

Overview

Post formatting renderer. MUST BE KEPT IN SYNC WITH ts/templates/body.ts!

Template structs, helper routines and context providers. MUST BE KEPT IN SYNC WITH ts/templates/isomorph.ts!

Package templates generates and stores HTML templates

Index

Constants

Variables

View Source
var (
	RollQueryRe = regexp.MustCompile(`^(0|[1-9][0-9]?)-([1-9][0-9]?[0-9]?)$`)
	FlipQueryRe = regexp.MustCompile(`^([1-9][0-9]?)%$`)
)
View Source
var BodyEmbeds = func() map[string]*regexp.Regexp {
	m := make(map[string]*regexp.Regexp, len(embeds))
	for provider, patternSrc := range embeds {
		m[provider] = regexp.MustCompile(patternSrc)
	}
	return m
}()
View Source
var LinkEmbeds = func() map[string]*regexp.Regexp {
	m := make(map[string]*regexp.Regexp, len(embeds))
	for provider, patternSrc := range embeds {
		m[provider] = regexp.MustCompile("^" + patternSrc)
	}
	return m
}()

Functions

func Admin

func Admin(
	p Params,
	cs config.BoardConfigs,
	staff auth.Staff,
	bans auth.BanRecords,
	log auth.ModLogRecords,
) []byte

func Board

func Board(
	p Params,
	title string,
	page, total int,
	catalog bool,
	threadHTML []byte,
) []byte

func CalculateOmit

func CalculateOmit(t common.Thread) (int, int)

CalculateOmit returns the omitted post and image counts for a thread

func ChangePassword

func ChangePassword(l string) string

ChangePassword renders a form for changing an account's password

func CompileMustache

func CompileMustache() (err error)

func ConfigureServer

func ConfigureServer(l string, conf config.ServerConfig) string

Renders the form for changing server configuration.

func Landing

func Landing(p Params) []byte

func Page

func Page(p Params, title, html string, status bool) []byte

func Stickers

func Stickers(p Params, stickHTML []byte) []byte

func Thread

func Thread(
	p Params,
	id uint64,
	board, title string,
	abbrev bool,
	postHTML []byte,
) []byte

Types

type BacklinksContext

type BacklinksContext struct {
	LReplies  string
	Backlinks []string
}

type FileContext

type FileContext struct {
	SHA1       string
	HasTitle   bool
	LCopy      string
	Title      string
	HasVideo   bool
	HasAudio   bool
	HasLength  bool
	Length     string
	Record     bool
	Size       string
	TWidth     uint16
	THeight    uint16
	Width      uint16
	Height     uint16
	DName      string
	SourcePath string
	ThumbPath  string
}

type Params

type Params struct {
	Req     *http.Request
	Session *auth.Session
	Lang    string
}

Params are essential params for any rendered page.

type PostContext

type PostContext struct {
	Lang     string
	ID       uint64
	TID      uint64
	Index    bool
	OP       bool
	HasBoard bool
	Board    string
	Subject  string
	Badge    bool
	Auth     string
	Name     string
	Time     string
	HasFiles bool
	// contains filtered or unexported fields
}

func MakePostContext

func MakePostContext(l string, t common.Thread, p *common.Post, bls common.Backlinks, index bool, all bool) PostContext
func (ctx *PostContext) Backlinks() string

func (*PostContext) Body

func (ctx *PostContext) Body() string

func (*PostContext) Files

func (ctx *PostContext) Files() (files []string)

func (*PostContext) PostClass

func (ctx *PostContext) PostClass() string

func (PostContext) Render

func (ctx PostContext) Render() string

func (*PostContext) URL

func (ctx *PostContext) URL() (url string)

type PostLinkContext

type PostLinkContext struct {
	ID    string
	URL   string
	Cross bool
}

Jump to

Keyboard shortcuts

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