templates

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package templates centralizes access to template functions that render the power-league content as HTML.

Index

Constants

View Source
const (
	// DefaultBaseDir is the default location of the directory containing the
	// template files.
	DefaultBaseDir = "html/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AboutPageContent

type AboutPageContent struct {
	LoggedIn   bool
	SiteConfig *SiteConfig
}

AboutPageContent describes the power rankings web site.

type AllYearlyLeagues

type AllYearlyLeagues []*YearlyLeagues

AllYearlyLeagues contains leagues for multiple years.

func (AllYearlyLeagues) Len

func (y AllYearlyLeagues) Len() int

func (AllYearlyLeagues) Less

func (y AllYearlyLeagues) Less(i, j int) bool

func (AllYearlyLeagues) Swap

func (y AllYearlyLeagues) Swap(i, j int)

type ErrorPageContent added in v0.2.0

type ErrorPageContent struct {
	Message    string
	LoggedIn   bool
	SiteConfig *SiteConfig
}

ErrorPageContent describes an error that has occurred in the application.

type LeaguesPageContent

type LeaguesPageContent struct {
	AllYears   AllYearlyLeagues
	LoggedIn   bool
	SiteConfig *SiteConfig
}

LeaguesPageContent describes the leagues a user has participated in across multiple years.

type PreviousRank added in v0.3.0

type PreviousRank struct {
	Rank   int
	Offset int
}

PreviousRank defines the rank a team had for a previous week and the offset between that rank and the current rank.

type RankingsPageContent

type RankingsPageContent struct {
	Weeks           int
	League          *goff.League
	LeagueStarted   bool
	SchemeToShow    rankings.Scheme
	Schemes         []rankings.Scheme
	LeaguePowerData []*rankings.LeaguePowerData
	LoggedIn        bool
	SiteConfig      *SiteConfig
}

RankingsPageContent is used to show an given league's power rankings up to a certain week in the season.

type SiteConfig

type SiteConfig struct {
	TLS                 bool
	BaseContext         string
	StaticContext       string
	AnalyticsTrackingID string
}

SiteConfig provides configuration info about the site that can be used on all pages.

type Templates

type Templates interface {
	WriteAboutTemplate(w io.Writer, content *AboutPageContent) error
	WriteErrorTemplate(w io.Writer, content *ErrorPageContent) error
	WriteLeaguesTemplate(w io.Writer, content *LeaguesPageContent) error
	WriteRankingsTemplate(w io.Writer, content *RankingsPageContent) error
}

Templates provides programmtic access to power rankings templates

func NewTemplates

func NewTemplates() Templates

NewTemplates creates new templates using the `DefaultBaseDir`

func NewTemplatesFromDir

func NewTemplatesFromDir(dir string) Templates

NewTemplatesFromDir creates new templates using the given directory as the base

type YearlyLeagues

type YearlyLeagues struct {
	Year    string
	Leagues []goff.League
}

YearlyLeagues describes the leagues for a user for a given year.

Jump to

Keyboard shortcuts

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