templates

package
v0.0.0-...-ff8e54b Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: AGPL-3.0, AGPL-3.0-or-later Imports: 20 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(
	ss *auth.Session,
	l string,
	cs config.BoardConfigs,
	staff auth.Staff,
	bans auth.BanRecords,
	log auth.ModLogRecords,
) []byte

func Board

func Board(
	l, title string,
	page, total int,
	ss *auth.Session,
	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(ss *auth.Session, l string) []byte

func Page

func Page(ss *auth.Session, l, title, html string, status bool) []byte

func Stickers

func Stickers(ss *auth.Session, l string, stickHTML []byte) []byte

func Thread

func Thread(
	id uint64,
	l, board, title string,
	abbrev bool,
	ss *auth.Session,
	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
	BlurPath   string
	ThumbPng   bool
}

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
	Color     string
	ShowColor bool
	Time      string
	HasFiles  bool
	Reacts    common.Reacts
	// 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