template

package
v0.0.0-...-89b6d9c Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New creates a new tokenizer

func SetActive

func SetActive(a ActivableSlice, s string) bool

SetActive sets an active bit in a slice

Types

type ActivableSlice

type ActivableSlice interface {
	GetChildren(i int) ActivableSlice
	GetMatcher(i int) *regexp.Regexp
	SetActive(i int, a bool)
	Len() int
}

ActivableSlice a slice where each element has an active bit which can be set based on a string

type Common

type Common struct {
	Language  string
	Localizer *language.Localizer

	FooterScripts []Script
	HeadLinks     []HeadLink
	NavBar        Navbar
	PageTitle     string
	User          *models.FediAccount
}

Common contains the variables used in nearly every template

func (*Common) AddFooterScript

func (t *Common) AddFooterScript(s Script)

AddFooterScript adds a footer script to the template

func (t *Common) AddHeadLink(l HeadLink)

AddHeadLink adds a headder link to the template

func (*Common) SetLanguage

func (t *Common) SetLanguage(l string)

SetLanguage sets the template's default language

func (*Common) SetLocalizer

func (t *Common) SetLocalizer(l *language.Localizer)

SetLocalizer sets the localizer the template will use to generate text

func (*Common) SetNavbar

func (t *Common) SetNavbar(nodes Navbar)

SetNavbar sets the top level navbar used by the template

func (*Common) SetUser

func (t *Common) SetUser(user *models.FediAccount)

SetUser sets the currently logged-in account

type HeadLink struct {
	HRef        string
	Rel         string
	Integrity   string
	CrossOrigin string
	Sizes       string
	Type        string
}

HeadLink is the data for a header link

type HomeTemplate

type HomeTemplate struct {
	Common
}

HomeTemplate contains the variables for the "home" template.

type InitTemplate

type InitTemplate interface {
	AddHeadLink(l HeadLink)
	AddFooterScript(s Script)
	SetLanguage(l string)
	SetLocalizer(l *language.Localizer)
	SetNavbar(nodes Navbar)
	SetUser(user *models.FediAccount)
}

InitTemplate are the functions a template implementing Common will have

type LoginTemplate

type LoginTemplate struct {
	Common

	BotImage string

	FormError   string
	FormAccount string
}

LoginTemplate contains the variables for the "login" template.

type Navbar []NavbarNode

Navbar is a navbar that can be added to a page

func (n *Navbar) ActivateFromPath(path string)

ActivateFromPath sets the active bool based on the match regex

func (n *Navbar) GetChildren(i int) ActivableSlice

GetChildren returns the children of the node or nil if no children

func (n *Navbar) GetMatcher(i int) *regexp.Regexp

GetMatcher returns the matcher of the node or nil if no matcher

func (n *Navbar) Len() int

Len returns the matcher of the node or nil if no matcher

func (n *Navbar) SetActive(i int, a bool)

SetActive sets the active bool based on the match regex

type NavbarNode struct {
	Text     string
	URL      string
	MatchStr *regexp.Regexp
	FAIcon   string

	Active   bool
	Disabled bool

	Children Navbar
}

NavbarNode is an entry on a navbar, can be nested one level

type Pagination

type Pagination []PaginationNode

Pagination is a pagination element that can be added to a webpage

func MakePagination

func MakePagination(c *PaginationConfig) Pagination

MakePagination creates a pagination element from the provided parameters

type PaginationConfig

type PaginationConfig struct {
	Count         int    // item count
	DisplayCount  int    // how many items to display per page
	HRef          string // href to add query to
	HRefCount     int    // count to include in the href, if 0 no count is added
	MaxPagination int    // the max number of pages to show
	Page          int    // current page
}

PaginationConfig contains the config to construct pagination

type PaginationNode

type PaginationNode struct {
	Text        string
	DisplayHTML string
	HRef        string

	Active   bool
	Disabled bool
}

PaginationNode is an element in a pagination element

type Script

type Script struct {
	Src         string
	Integrity   string
	CrossOrigin string
}

Script is a javascript script

type Sidebar []SidebarNode

Sidebar is a sidebar that can be added to a page

func (*Sidebar) ActivateFromPath

func (s *Sidebar) ActivateFromPath(path string)

ActivateFromPath sets the active bool based on the match regex

func (*Sidebar) GetChildren

func (s *Sidebar) GetChildren(i int) ActivableSlice

GetChildren returns the children of the node or nil if no children

func (*Sidebar) GetMatcher

func (s *Sidebar) GetMatcher(i int) *regexp.Regexp

GetMatcher returns the matcher of the node or nil if no matcher

func (*Sidebar) Len

func (s *Sidebar) Len() int

Len returns the matcher of the node or nil if no matcher

func (*Sidebar) SetActive

func (s *Sidebar) SetActive(i int, a bool)

SetActive sets the active bool based on the match regex

type SidebarNode

type SidebarNode struct {
	Text     string
	URL      string
	MatchStr *regexp.Regexp
	Icon     string
	Label    string

	Active   bool
	Disabled bool

	Children Sidebar
}

SidebarNode is an entry on a sidebar

Jump to

Keyboard shortcuts

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