template

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const AdminAccountName = "admin_account"

AdminAccountName is the name of the admin block list template.

View Source
const AdminBlockName = "admin_block"

AdminBlockName is the name of the admin block list template.

View Source
const AdminHomeName = "admin_home"

AdminHomeName is the name of the admin home template.

View Source
const AdminInstanceName = "admin_instance"

AdminInstanceName is the name of the admin block list template.

View Source
const AdminInstanceViewName = "admin_instance_view"

AdminInstanceViewName is the name of the admin block list template.

View Source
const AdminJobsName = "admin_jobs"

AdminJobsName is the name of the admin jobs template.

View Source
const AdminStatisticsName = "admin_statistics"

AdminStatisticsName is the name of the admin statistics template.

View Source
const BlocksName = "blocks"

BlocksName is the name of the blocks template.

View Source
const ErrorName = "error"

ErrorPageName is the name of the error template.

View Source
const HomeName = "home"

HomeName is the name of the home template.

View Source
const InstanceName = "instance"

InstanceName is the name of the my instance template.

View Source
const LoginName = "login"

LoginName is the name of the login template.

View Source
const LogsName = "logs"

LogsName is the name of the logs template.

View Source
const SettingsName = "settings"

SettingsName is the name of the home template.

Variables

This section is empty.

Functions

func New

func New(tokz *token.Tokenizer) (*template.Template, error)

New creates a new template.

Types

type AdminAccount added in v0.4.2

type AdminAccount struct {
	Common

	Accounts   []*models.Account
	Pagination libtemplate.Pagination
}

AdminAccount contains the variables for the admin block list template.

type AdminBlock

type AdminBlock struct {
	Common

	Blocks     []*models.Block
	Pagination libtemplate.Pagination

	FormAddError            *libtemplate.Alert
	FormAddAction           libtemplate.FormInput
	FormAddDomain           libtemplate.FormInput
	FormAddObfuscatedDomain libtemplate.FormInput
	FormAddBlockSubdomains  libtemplate.FormInput

	FormDeleteError  *libtemplate.Alert
	FormDeleteAction libtemplate.FormInput
	FormDeleteToken  libtemplate.FormInput

	FormEditError            *libtemplate.Alert
	FormEditAction           libtemplate.FormInput
	FormEditToken            libtemplate.FormInput
	FormEditDomain           libtemplate.FormInput
	FormEditObfuscatedDomain libtemplate.FormInput
	FormEditBlockSubdomains  libtemplate.FormInput

	FormImportError           *libtemplate.Alert
	FormImportAction          libtemplate.FormInput
	FormImportFile            libtemplate.FormInput
	FormImportBlockSubdomains libtemplate.FormInput
}

AdminBlock contains the variables for the admin block list template.

type AdminHome

type AdminHome struct {
	Common

	FormHomeBody            libtemplate.FormTextarea
	FormRobotsAllowIndexing libtemplate.FormInput

	FormNotificationTelegramEnabled libtemplate.FormInput
	FormNotificationTelegramToken   libtemplate.FormInput
}

AdminHome contains the variables for the admin home template.

type AdminInstance

type AdminInstance struct {
	Common

	Instances  []*models.Instance
	Pagination libtemplate.Pagination
}

AdminInstance contains the variables for the admin block list template.

type AdminInstanceView added in v0.4.0

type AdminInstanceView struct {
	Common

	Instance    *models.Instance
	Breadcrumbs *[]Breadcrumb

	FormKickError  *libtemplate.Alert
	FormKickAction libtemplate.FormInput
	FormKickToken  libtemplate.FormInput
}

AdminInstanceView contains the variables for the admin block list template.

type AdminJobs added in v0.6.0

type AdminJobs struct {
	Common

	Jobs []logic.SchedulerJob

	FormRunJobError  *libtemplate.Alert
	FormRunJobAction libtemplate.FormInput
	FormRunJobJob    FormSelect
}

AdminJobs contains the variables for the admin jobs template.

type AdminStatistics added in v0.4.2

type AdminStatistics struct {
	Common

	Nav Nav
}

AdminStatistics contains the variables for the admin statistics template.

type Blocks added in v0.2.0

type Blocks struct {
	Common

	Blocks []*models.Block
}

Blocks contains the variables for the blocks template.

type Breadcrumb struct {
	HRef string
	Text string
}

type Common

type Common struct {
	Language  string
	Localizer *language.Localizer

	Account *models.Account

	Alerts            *[]libtemplate.Alert
	FooterScripts     []libtemplate.Script
	FooterExtraScript []string
	HeadLinks         []libtemplate.HeadLink

	NavBar     Navbar
	NavBarDark bool
	PageTitle  string
}

Common contains the variables used in nearly every template.

func (*Common) AddFooterExtraScript

func (t *Common) AddFooterExtraScript(s string)

AddFooterExtraScript adds a footer script to the template.

func (*Common) AddFooterScript

func (t *Common) AddFooterScript(s libtemplate.Script)

AddFooterScript adds a footer script to the template.

func (t *Common) AddHeadLink(l libtemplate.HeadLink)

AddHeadLink adds a headder link to the template.

func (*Common) SetAccount

func (t *Common) SetAccount(account *models.Account)

SetAccount sets the currently logged-in account.

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) SetNavbarDark

func (t *Common) SetNavbarDark(dark bool)

SetNavbarDark sets the navbar theme.

type Error

type Error struct {
	Common

	Header      string
	Image       string
	SubHeader   string
	Paragraph   string
	ButtonHRef  string
	ButtonLabel string
}

Error contains the variables for the error template.

type FormSelect added in v0.6.0

type FormSelect struct {
	ID       string
	Name     string
	Label    *libtemplate.FormLabel
	Options  []FormSelectOption
	Disabled bool
	Required bool

	Validation *libtemplate.FormValidation
}

type FormSelectOption added in v0.6.0

type FormSelectOption struct {
	Text     string
	Value    string
	Selected bool
}

type Home

type Home struct {
	Common

	HomeBody string

	FollowingInstances []*models.Instance
}

Home contains the variables for the home template.

type InitTemplate

type InitTemplate interface {
	AddHeadLink(l libtemplate.HeadLink)
	AddFooterScript(s libtemplate.Script)
	SetAccount(account *models.Account)
	SetLanguage(l string)
	SetLocalizer(l *language.Localizer)
	SetNavbar(nodes Navbar)
	SetNavbarDark(dark bool)
}

InitTemplate are the functions a template implementing Common will have.

type Instance added in v0.7.0

type Instance struct {
	Common

	Instance *models.Instance

	FormKickError  *libtemplate.Alert
	FormKickAction libtemplate.FormInput
	FormKickToken  libtemplate.FormInput
}

Instance contains the variables for the my instance template.

type Login

type Login struct {
	Common

	FormError    string
	FormInstance string
}

Login contains the variables for the "login" template.

type Logs added in v0.3.0

type Logs struct {
	Common

	Logs       []*models.LogEntry
	Pagination libtemplate.Pagination
}

Logs contains the variables for the logs template.

type Nav struct {
	Classes []string
	Nodes   []NavNode
}
type NavNode struct {
	Active  bool
	Classes []string
	HRef    string
	Text    *language.LocalizedString
}
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) libtemplate.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
	Divider  bool

	Children Navbar
}

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

type Settings added in v0.2.0

type Settings struct {
	Common

	FormGeneralAccount libtemplate.FormInput
	FormGeneralIsMod   libtemplate.FormInput
	FormGeneralIsAdmin libtemplate.FormInput

	FormNotificationDisplay         bool
	FormNotificationTelegramEnabled libtemplate.FormInput
	FormNotificationTelegramChatID  libtemplate.FormInput
}

Settings contains the variables for the home template.

Jump to

Keyboard shortcuts

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