models

package
v0.10.13 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: Apache-2.0 Imports: 19 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDataSource is returned when no datasource could be found
	ErrDataSource = "!Error"
	// ErrDataSourceMissing raises when the datasource could not be found
	ErrDataSourceMissing = errors.New("Missing")
)
View Source
var (
	// Empty - Generic Item
	Empty = GenericItem{Slug: "empty"}
	// Unresolved - a slug to an item that has not been requested
	Unresolved = GenericItem{Slug: "unresolved"}
)

Functions

func AddDataSource

func AddDataSource(ds DataSource)

AddDataSource - register a datasource

func ApplyContentTransforms

func ApplyContentTransforms(data string) string

ApplyContentTransforms - add the markdown / sanitization / shortcodes

func ConfigureShortcodeTemplatePath

func ConfigureShortcodeTemplatePath(cfg *Config)

ConfigureShortcodeTemplatePath sets the directory where the short codes will be loaded from

func CreateTemplateView

func CreateTemplateView(routeRegistry *RouteRegistry, trans i18n.TranslateFunc, ctx *RenderContext, templatePath string) *jet.Set

CreateTemplateView - create a template view

func GetCast

func GetCast(f *Film) []string

GetCast - extact the cast members from the film

func GetCountries

func GetCountries(f *Film) []string

GetCountries - extract the countries from the film

func GetDataSources

func GetDataSources() map[string]DataSource

GetDataSources returns all registered data sources

func GetGenres

func GetGenres(f *Film) []string

GetGenres - extract the genres from the film

func GetTVSeasonYear

func GetTVSeasonYear(t *TVSeason) []string

GetTVSeasonYear - extract the year from the tv season

func GetTVShowCast

func GetTVShowCast(t *TVSeason) []string

GetTVShowCast - extact the cast members from the tv show

func GetTVShowCountries

func GetTVShowCountries(t *TVSeason) []string

GetTVShowCountries - extract the countries from the film

func GetTVShowGenres

func GetTVShowGenres(t *TVSeason) []string

GetTVShowGenres - extract the genres from the tv show

func GetYear

func GetYear(f *Film) []string

GetYear - extract the year from the film

func ReplaceURLArgumentsWithEntityValues

func ReplaceURLArgumentsWithEntityValues(routePrefix string, urlPath string, args []RouteArgument, entity interface{}) string

ReplaceURLArgumentsWithEntityValues replaces expected arguments with

func ValidateRouteWithDatasource

func ValidateRouteWithDatasource(urlPath string, ds DataSource) error

ValidateRouteWithDatasource will check the urlPath is valid for a data source

Types

type BonusContent

type BonusContent struct {
	Slug         string
	Number       int
	Title        string
	Images       ImageSet
	Subtitles    []SubtitleTrack
	Runtime      Runtime
	Overview     string
	CustomFields CustomFields
}

BonusContent - bonus content model

func (BonusContent) GetGenericItem

func (bonus BonusContent) GetGenericItem() GenericItem

GetGenericItem - returns a generic item based on the film bonus

type BonusContentCollection

type BonusContentCollection []BonusContent

BonusContentCollection - all bonus content for a film or season

type Bundle

type Bundle struct {
	ID            int
	Slug          string
	Title         string
	TitleSlug     string
	Tagline       string
	Description   string
	Status        string
	Seo           Seo
	Images        ImageSet
	PromoURL      string
	ExternalID    string
	Items         GenericItems
	PublishedDate time.Time
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

Bundle - model

func (Bundle) GetGenericItem

func (bundle Bundle) GetGenericItem() GenericItem

GetGenericItem - returns a generic item

type BundleCollection

type BundleCollection []Bundle

BundleCollection - all bundles

func (BundleCollection) FindBundleByID

func (bundles BundleCollection) FindBundleByID(bundleID int) (*Bundle, error)

FindBundleByID - find the page by id

func (BundleCollection) FindBundleBySlug

func (bundles BundleCollection) FindBundleBySlug(slug string) (*Bundle, error)

FindBundleBySlug - find the bundle by the slug

type CastMember

type CastMember struct {
	Name      string
	Character string
}

CastMember -

type Collection

type Collection struct {
	ID          int
	Slug        string
	Title       string
	TitleSlug   string
	Description string
	DisplayName string
	ItemLayout  string
	ItemsPerRow int
	Images      ImageSet
	Seo         Seo
	Items       []GenericItem
	SearchQuery string
	CreatedAt   string
	UpdatedAt   string
}

Collection - collection of films and tv seasons / episodes

func (Collection) GetGenericItem

func (collection Collection) GetGenericItem() GenericItem

GetGenericItem - returns a generic item

type CollectionCollection

type CollectionCollection []Collection

CollectionCollection - all collections

func (CollectionCollection) FindCollectionByID

func (collections CollectionCollection) FindCollectionByID(collectionID int) (*Collection, error)

FindCollectionByID - find the page by id

func (CollectionCollection) FindCollectionBySlug

func (collections CollectionCollection) FindCollectionBySlug(slug string) (*Collection, error)

FindCollectionBySlug - find the collection by the slug

type Config

type Config struct {
	DefaultLanguage string            `json:"defaultLanguage"`
	Languages       map[string]string `json:"languages"`
	Routes          []Route           `json:"routes"`
	SiteURL         string            `json:"siteUrl"`
	BuilderVersion  string            `json:"builderVersion"`
	Version         string            `json:"version"`
	Name            string            `json:"Name"`
	Private         PrivateConfig     `json:"-"`
	DisableCache    bool              `json:"-"`
	RunAsAdmin      bool              `json:"-"`
	SkipLogin       bool              `json:"-"`
	SiteRootPath    string            `json:"siteRootPath"`
	LiveReload      LiveReloadConfig  `json:"liveReload"`
	ProxyPatterns   []string          `json:"proxy"`
}

Config - template configuration NOTE: Don't use `SiteRootPath directly`, use `Config.SourcePath()` instead.

func (*Config) BuildPath

func (cfg *Config) BuildPath() string

BuildPath returns the build path for current config

func (*Config) FileRootPath

func (cfg *Config) FileRootPath() string

FileRootPath returns the path to be used for copying

func (Config) ShortCodePath

func (cfg Config) ShortCodePath() string

ShortCodePath is the path where the short code templates will be stored

func (Config) SourcePath

func (cfg Config) SourcePath() string

SourcePath is an absolute path to where the Site source files are located. Can be configured in `site.json` - `"siteRootPath"`

type CrewMember

type CrewMember struct {
	Name string
	Job  string
}

CrewMember -

type CustomFields

type CustomFields map[string]interface{}

CustomFields are key-value pairs that can be aded to a film, season, bonus, or episode

func (CustomFields) GetBool

func (fields CustomFields) GetBool(fieldKey string, defaultValue bool) bool

GetBool returns the custom field in bool format

func (CustomFields) GetNumber

func (fields CustomFields) GetNumber(fieldKey string, defaultValue float64) float64

GetNumber returns the custom field in float64 format

func (CustomFields) GetString

func (fields CustomFields) GetString(fieldKey string, defaultValue string) string

GetString returns the custom field in string format

type DataSource

type DataSource interface {
	GetName() string
	GetEntityType() reflect.Type
	Iterator(ctx RenderContext, renderer Renderer) (errorCount int)
	IsSlugMatch(slug string) bool
	GetRouteForEntity(ctx RenderContext, entity interface{}) string
	GetRouteForSlug(ctx RenderContext, slug string) string
	GetRouteArguments() []RouteArgument
}

DataSource provides a set of data for querying and iterating over

func FindDataSource

func FindDataSource(name string) DataSource

FindDataSource - find the data source by name

type FeatureToggles

type FeatureToggles map[string]bool

FeatureToggles - store feature toggles

type Film

type Film struct {
	ID              int
	Slug            string
	Title           string
	TitleSlug       string
	Trailers        []Trailer
	Bonuses         BonusContentCollection
	Cast            []CastMember
	Crew            []CrewMember
	Studio          []string
	Overview        string
	Tagline         string
	ReleaseDate     time.Time
	Runtime         Runtime
	Countries       StringCollection
	Languages       StringCollection
	Genres          StringCollection
	Seo             Seo
	Images          ImageSet
	Recommendations []GenericItem
	Subtitles       []SubtitleTrack
	CustomFields    CustomFields
}

Film - all of the film bits

func (Film) GetGenericItem

func (film Film) GetGenericItem() GenericItem

GetGenericItem - returns a generic item

type FilmCollection

type FilmCollection []Film

FilmCollection - all films

func (FilmCollection) FindFilmByID

func (films FilmCollection) FindFilmByID(filmID int) (*Film, bool)

FindFilmByID - find film by id

func (FilmCollection) FindFilmBySlug

func (films FilmCollection) FindFilmBySlug(slug string) (*Film, bool)

FindFilmBySlug - find the film by the slug

type GenericItem

type GenericItem struct {
	// link to the actual item
	InnerItem interface{}
	// film / show / season/ episode / bundle / page
	ItemType string
	Slug     string
	Title    string
	Images   ImageSet
	Seo      Seo
}

GenericItem - used to store the common properties

func (*GenericItem) GetTitle

func (i *GenericItem) GetTitle(T i18n.TranslateFunc) string

GetTitle - returns the title in the current language expect to be called as item.GetTitle(i18n) where i18n is the translation function for the current language

func (GenericItem) GetTranslatedTitle

func (i GenericItem) GetTranslatedTitle(T i18n.TranslateFunc, i18nKey string) string

GetTranslatedTitle returns an i18n version of a GenericItem title using the specified key as the template

func (GenericItem) IsResolved

func (genericItem GenericItem) IsResolved() bool

IsResolved -

type GenericItems

type GenericItems []GenericItem

GenericItems - a list of generic items e.g. Films from "2005"

func (GenericItems) Len

func (slice GenericItems) Len() int

func (GenericItems) Less

func (slice GenericItems) Less(i, j int) bool

func (GenericItems) Swap

func (slice GenericItems) Swap(i, j int)

type ImageSet

type ImageSet struct {
	Background     string
	Carousel       string
	Landscape      string
	Portrait       string
	Header         string
	Classification string
	Seo            string
}

ImageSet - set of images

type ItemIndex

type ItemIndex map[string]map[string]GenericItem

ItemIndex - an item index

func (ItemIndex) FindEmptySlugs

func (itemIndex ItemIndex) FindEmptySlugs(slugType string) []string

FindEmptySlugs - find the slugs that are missing

func (ItemIndex) FindUnresolvedSlugs

func (itemIndex ItemIndex) FindUnresolvedSlugs(slugType string) []string

FindUnresolvedSlugs - find unresolved slugs

func (ItemIndex) Get

func (itemIndex ItemIndex) Get(slug string) (item GenericItem)

Get - get the slug

func (ItemIndex) MapToUnresolvedItems

func (itemIndex ItemIndex) MapToUnresolvedItems(items []string) GenericItems

MapToUnresolvedItems - create an array of unresolved items from an array of slugs

func (ItemIndex) Print

func (itemIndex ItemIndex) Print()

Print - print the item index

func (ItemIndex) PrintStats

func (itemIndex ItemIndex) PrintStats()

PrintStats - print the stats about the index

func (ItemIndex) Resolve

func (itemIndex ItemIndex) Resolve(gItems GenericItems) GenericItems

Resolve - convert an array of generic items to resolved items

func (ItemIndex) Set

func (itemIndex ItemIndex) Set(slug string, item GenericItem)

Set - an item

type Language

type Language struct {
	Code               string
	Locale             string
	DefinitionFilePath string
	IsDefault          bool
}

Language - instance of a language

type LiveReloadConfig

type LiveReloadConfig struct {
	IgnoredPaths []string `json:"ignoredPaths"`
}

LiveReloadConfig - configuration options for the live_reloader

type Navigation struct {
	Footer []NavigationItem `json:"footer"`
	Header []NavigationItem `json:"header"`
}

Navigation - header and footer

type NavigationItem struct {
	Label string `json:"label"`
	Link  struct {
		PageID      int    `json:"page_id"`
		Slug        string `json:"slug"`
		ExternalURL string `json:"url"`
	} `json:"link"`
	Items []NavigationItem `json:"items"`
}

NavigationItem - nestable structure

type OrderedEntries

type OrderedEntries []OrderedEntry

OrderedEntries - array of entires

func (OrderedEntries) Print

func (t OrderedEntries) Print()

Print - ordered items

type OrderedEntry

type OrderedEntry struct {
	Key   string
	Items GenericItems
}

OrderedEntry - a list of items ordered by keys e.g. Key: Horror

type Page

type Page struct {
	ID              int
	Slug            string
	Title           string
	TitleSlug       string
	Content         string
	Tagline         string
	Seo             Seo
	Images          ImageSet
	PageCollections []PageCollection
	PageType        string
	URL             string
}

Page - page structure

func (Page) GetGenericItem

func (page Page) GetGenericItem() GenericItem

GetGenericItem - returns a generic item

type PageCollection

type PageCollection struct {
	ID          int
	Layout      string
	ItemsPerRow int
	ItemLayout  string
	Slug        string
	TitleSlug   string
	DisplayName string
	Items       []GenericItem
}

PageCollection - part of a page

type Pages

type Pages []Page

Pages -

func (Pages) FindPageByID

func (pages Pages) FindPageByID(pageID int) (*Page, bool)

FindPageByID - find the page by id

func (Pages) FindPageBySlug

func (pages Pages) FindPageBySlug(slug string) (*Page, bool)

FindPageBySlug - find the page by the slug

type Pagination

type Pagination struct {
	Index       int
	Size        int
	Total       int
	PreviousURL string
	NextURL     string
}

Pagination describes a single page of results

type Plan

type Plan struct {
	ID              int
	Slug            string
	Name            string
	NameSlug        string
	Description     string
	Interval        string
	IntervalCount   int
	TrialPeriodDays int
	Page            *Page
	PortraitImage   string
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

Plan -

type PlanCollection

type PlanCollection []Plan

PlanCollection is a list of published plans

type PrivateConfig

type PrivateConfig struct {
	APIKey string `json:"apikey"`
}

PrivateConfig - config loaded from

type RenderContext

type RenderContext struct {
	Route       *Route
	RoutePrefix string
	Site        *Site
	Language    *Language
}

RenderContext - Context passed during rendering / serving

type Renderer

type Renderer interface {
	Initialise()
	Render(templatePath string, filePath string, data jet.VarMap) (errorCount int)
}

Renderer - rendering implementation

type Route

type Route struct {
	Name                string       `json:"name"`
	URLPath             string       `json:"urlPath"`
	TemplatePath        string       `json:"templatePath"`
	PartialURLPath      string       `json:"partialUrlPath"`
	PartialTemplatePath string       `json:"partialTemplatePath"`
	DataSource          string       `json:"datasource"`
	ResolvedDataSouce   DataSource   `json:"-"`
	ResolvedEntityType  reflect.Type `json:"-"`
	PageSize            int          `json:"pageSize"`
	Pagination          Pagination   `json:"-"`
}

Route - represents a route for rendering and

func (*Route) Clone

func (r *Route) Clone() *Route

Clone - create a copy of the route

func (*Route) HasPartial

func (r *Route) HasPartial() bool

HasPartial returns whether the route has partial path (url and template) definitions

type RouteArgument

type RouteArgument struct {
	Name        string
	Description string
	GetValue    func(obj interface{}) string
}

RouteArgument represents an argument that a route can have

type RouteRegistry

type RouteRegistry struct {
	// contains filtered or unexported fields
}

RouteRegistry - stores a list of routes

func NewRouteRegistry

func NewRouteRegistry() *RouteRegistry

NewRouteRegistry - create a new route registry

func NewRouteRegistryFromConfig

func NewRouteRegistryFromConfig(config *Config) *RouteRegistry

NewRouteRegistryFromConfig - create a new route registry from the config

func (*RouteRegistry) FindByName

func (r *RouteRegistry) FindByName(name string) *Route

FindByName - find the route by the name

func (*RouteRegistry) FindBySlugAndRouteName

func (r *RouteRegistry) FindBySlugAndRouteName(slug string, routeName string) *Route

FindBySlugAndRouteName - find a route given a slug and the route name(optional)

func (*RouteRegistry) FindByTypeAndRouteName

func (r *RouteRegistry) FindByTypeAndRouteName(entityType reflect.Type, routeName string) *Route

FindByTypeAndRouteName - find a route given a type of entity and the route name(optional)

func (*RouteRegistry) GetAll

func (r *RouteRegistry) GetAll() []*Route

GetAll - return all routes

func (*RouteRegistry) GetRouteForEntity

func (r *RouteRegistry) GetRouteForEntity(ctx RenderContext, entity interface{}, routeName string) string

GetRouteForEntity - finds the route by the name and type and creates a route from it

func (*RouteRegistry) GetRouteForSlug

func (r *RouteRegistry) GetRouteForSlug(ctx RenderContext, slug string, routeName string) string

GetRouteForSlug - finds the route by the name and type and creates a route from it

type Runtime

type Runtime int

Runtime - Allows us to get accurate measures of hours and minutes.

func (Runtime) Hours

func (rt Runtime) Hours() int

Hours - returns the basic number of hours in the runtime

func (Runtime) Localise

func (rt Runtime) Localise(T i18n.TranslateFunc) string

Localise - returns the localised runtime format

func (Runtime) Minutes

func (rt Runtime) Minutes() int

Minutes - returns the number of minutes (left =over from any hours) in the runtime. This is not the total minutes.

type Seo

type Seo struct {
	SiteName    string
	Title       string
	Description string
	Keywords    string
	Image       string
	VideoURL    string
}

Seo - common seo settings

type ServiceConfig

type ServiceConfig map[string]string

ServiceConfig -

func (ServiceConfig) ForceAbsoluteImagePath

func (cfg ServiceConfig) ForceAbsoluteImagePath(url string) string

ForceAbsoluteImagePath fixes up relative image path by prefixing the `image_root_path` to it.

func (ServiceConfig) GetInt

func (cfg ServiceConfig) GetInt(key string, defaultArgs ...int) int

GetInt - get the key and cast

func (ServiceConfig) GetKeywords

func (cfg ServiceConfig) GetKeywords(keywords string) string

GetKeywords - get the keywords, appending any passed keywords

func (ServiceConfig) GetSEOTitle

func (cfg ServiceConfig) GetSEOTitle(seoTitle, title string) string

GetSEOTitle - get the seo title

func (ServiceConfig) GetSiteName

func (cfg ServiceConfig) GetSiteName() string

GetSiteName - get the site name

func (ServiceConfig) SelectDefaultImageType

func (cfg ServiceConfig) SelectDefaultImageType(landscape, portrait string) string

SelectDefaultImageType - select the default image

type Site

type Site struct {
	Config      ServiceConfig
	SiteConfig  *Config
	Toggles     FeatureToggles
	Navigation  Navigation
	Languages   []Language
	Pages       Pages
	Films       FilmCollection
	TVShows     TVShowCollection
	TVSeasons   TVSeasonCollection
	TVEpisodes  TVEpisodeCollection
	Bundles     BundleCollection
	Collections CollectionCollection
	Plans       PlanCollection
	Taxonomies  Taxonomies
}

Site -

func (*Site) LinkItems

func (site *Site) LinkItems(itemIndex ItemIndex)

LinkItems - link the items to the specific parts

func (Site) PopulateTaxonomyWithFilms

func (s Site) PopulateTaxonomyWithFilms(taxonomy string, finder func(*Film) []string)

PopulateTaxonomyWithFilms - select the taxonomy and the film attribute

func (Site) PopulateTaxonomyWithTVSeasons

func (s Site) PopulateTaxonomyWithTVSeasons(taxonomy string, finder func(*TVSeason) []string)

PopulateTaxonomyWithTVSeasons - select the taxonomy and the tv season attribute

type StringCollection

type StringCollection []string

StringCollection - Allows us to add methods to []string for easing UI array usage

func (StringCollection) Join

func (strings StringCollection) Join(separator string) string

Join - Joins all items in []string using specified separator.

func (StringCollection) String

func (strings StringCollection) String() string

String - overrides String function for []string which joins all items in the array into english readable format.

type SubtitleTrack

type SubtitleTrack struct {
	Language string
	Name     string
	Type     string
	Path     string
}

SubtitleTrack -

type TVEpisode

type TVEpisode struct {
	Title         string
	Slug          string
	TitleSlug     string
	EpisodeNumber int
	Overview      string
	Runtime       Runtime
	Images        ImageSet
	Subtitles     []SubtitleTrack
	CustomFields  CustomFields
	Season        *TVSeason
}

TVEpisode -

func (TVEpisode) GetGenericItem

func (episode TVEpisode) GetGenericItem() GenericItem

GetGenericItem returns a generic item for the specific episode

func (TVEpisode) GetTitle

func (episode TVEpisode) GetTitle(T i18n.TranslateFunc) string

GetTitle return the localised version of the episode title

func (TVEpisode) GetTranslatedTitle

func (episode TVEpisode) GetTranslatedTitle(T i18n.TranslateFunc, i18nKey string) string

GetTranslatedTitle returns an i18n version of an episode title using the specified key as the template

type TVEpisodeCollection

type TVEpisodeCollection []TVEpisode

TVEpisodeCollection is an array of episodes

func (TVEpisodeCollection) FindTVEpisodeBySlug

func (episodes TVEpisodeCollection) FindTVEpisodeBySlug(slug string) (*TVEpisode, bool)

FindTVEpisodeBySlug returns an episode based on the specified slug

type TVSeason

type TVSeason struct {
	Slug         string
	SeasonNumber int
	//TODO: consider removing this
	Title           string
	Tagline         string
	Overview        string
	PublishingState string
	ShowInfo        *TVShow
	Seo             Seo
	Images          ImageSet
	Trailers        []Trailer
	Episodes        []TVEpisode
	Bonuses         BonusContentCollection
	Cast            []CastMember
	Crew            []CrewMember
	Recommendations []GenericItem
	CustomFields    CustomFields
}

TVSeason -

func (TVSeason) GetGenericItem

func (season TVSeason) GetGenericItem() GenericItem

GetGenericItem - returns a generic item

func (TVSeason) GetTitle

func (season TVSeason) GetTitle(T i18n.TranslateFunc) string

GetTitle return the localised version of the season title

func (TVSeason) GetTranslatedTitle

func (season TVSeason) GetTranslatedTitle(T i18n.TranslateFunc, i18nKey string) string

GetTranslatedTitle returns an i18n version of a season title using the specified key as the template

type TVSeasonCollection

type TVSeasonCollection []TVSeason

TVSeasonCollection -

func (TVSeasonCollection) FindTVSeasonBySlug

func (tvSeasons TVSeasonCollection) FindTVSeasonBySlug(slug string) (*TVSeason, bool)

FindTVSeasonBySlug - find the film by the slug

type TVShow

type TVShow struct {
	ID               int
	Slug             string
	Trailers         []Trailer
	Genres           StringCollection
	Overview         string
	Countries        StringCollection
	Languages        StringCollection
	ReleaseDate      time.Time
	Tagline          string
	Studio           []string
	Title            string
	TitleSlug        string
	AvailableSeasons []string           `json:"-"`
	Seasons          TVSeasonCollection `json:"-"`
	Images           ImageSet
}

TVShow -

func (TVShow) GetGenericItem

func (show TVShow) GetGenericItem() GenericItem

GetGenericItem - returns a generic item

type TVShowCollection

type TVShowCollection []TVShow

TVShowCollection -

func (TVShowCollection) FindTVShowByID

func (shows TVShowCollection) FindTVShowByID(showID int) (*TVShow, bool)

FindTVShowByID - find tv show by id

func (TVShowCollection) FindTVShowBySlug

func (shows TVShowCollection) FindTVShowBySlug(slug string) (*TVShow, bool)

FindTVShowBySlug - find the tv show by the slug

type Taxonomies

type Taxonomies map[string]Taxonomy

Taxonomies - list of taxonomies

type Taxonomy

type Taxonomy map[string]GenericItems

Taxonomy - a grouping of related generic items e.g. films from "2005"

func (Taxonomy) Alphabetical

func (t Taxonomy) Alphabetical() OrderedEntries

Alphabetical - sort the keys

func (Taxonomy) Print

func (t Taxonomy) Print()

Print - print a Taxonomy

type Trailer

type Trailer struct {
	URL  string
	Type string
}

Trailer -

Jump to

Keyboard shortcuts

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