model

package
v1.38.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: MIT Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackTo added in v1.27.0

type BackTo struct {
	AnchorFragment string       `json:"anchor_fragment"`
	Text           Localisation `json:"text"`
}
BackTo maps the back to component.

AnchorFragment refers to the anchor fragment on the page to link to, leave empty to display the default '#'. Text refers to the display text that can be either a 'Localisation.Text' or a 'Localisation.LocaleKey'.

type Collapsible added in v1.10.6

type Collapsible struct {
	Title            Localisation      `json:"title"`
	CollapsibleItems []CollapsibleItem `json:"collapsible_item"`
}
Collapsible maps the collapsible UI component.

The title text can be either a 'Title' or a 'LocaliseKey', the question mark will always render at the end. The 'LocaliseKey' has to correspond to the localisation key found in the toml files within assets/locales, otherwise the page will error. LocalisePluralInt refers to the plural int used in the toml file.

type CollapsibleItem added in v1.10.6

type CollapsibleItem struct {
	Subheading string   `json:"subheading"`
	Content    []string `json:"content"`
}

CollapsibleItem is an individual representation of the data required in a collapsible item

type CompactSearch added in v1.21.0

type CompactSearch struct {
	ElementId  string       `json:"element_id"`
	InputName  string       `json:"input_name"`
	Language   string       `json:"language"`
	Label      Localisation `json:"label"`
	SearchTerm string       `json:"search_term"`
}
CompactSearch provides an input for a search term.

ElementId is the id in the document. InputName is the name submitted in a form. Language should be passed in from the Page model. Label states the purpose of the search term. SearchTerm is the user input submitted in a form.

type ContentSection added in v1.19.0

type ContentSection struct {
	Current bool         `json:"current"`
	Title   Localisation `json:"title"`
}
ContentSection maps the content details.

The visible text can be either a 'Localisation.Text' or a 'Localisation.LocaleKey'. The 'LocaleKey' has to correspond to the localisation key found in the toml files within assets/locales, otherwise the page will error. Plural refers to the plural int used in the toml file.

type CookiesPolicy

type CookiesPolicy struct {
	Essential bool `json:"essential"`
	Usage     bool `json:"usage"`
}

CookiesPolicy contains data for the users cookie policy

type EmergencyBanner added in v1.10.0

type EmergencyBanner struct {
	Type        string `json:"type"`
	Title       string `json:"title"`
	Description string `json:"description"`
	URI         string `json:"uri"`
	LinkText    string `json:"link_text"`
}

EmergencyBanner data

type Error added in v1.9.2

type Error struct {
	Title       string `json:"title"`
	Description string `json:"description"`
}

Error contains data to display a page error

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type FeatureFlags

type FeatureFlags struct {
	HideCookieBanner       bool   `json:"hide_cookie_banner"`
	ONSDesignSystemVersion string `json:"ons_design_system_version"`
	SixteensVersion        string `json:"legacy_sixteens_version"`
	EnableCensusTile       bool   `json:"enable_census_tile"`
	EnableCensusBanner     bool   `json:"enable_census_banner"`
	EnableCensusResults    bool   `json:"enable_census_results"`
}

FeatureFlags contains toggles for certain features on the website

type InputCheckBox added in v1.28.0

type InputCheckBox struct {
	Language    string       `json:"language"`
	Id          string       `json:"id"`
	Name        string       `json:"name"`
	Checked     bool         `json:"checked"`
	Count       string       `json:"count"`
	Title       Localisation `json:"title"`
	LocaleKey   Localisation `json:"localeKey"`
	Description Localisation `json:"description"`
}
InputCheckbox provides an input for a checkbox.

Language should be passed in from the Page model. Id is the id in the document. Name is the name in the document. Checked is flag that shows up it the value it true Title states the purpose of the InputCheckbox.

type InputDate added in v1.23.0

type InputDate struct {
	Language        string       `json:"language"`
	Id              string       `json:"id"`
	InputNameDay    string       `json:"input_name_day"`
	InputNameMonth  string       `json:"input_name_month"`
	InputNameYear   string       `json:"input_name_year"`
	InputValueDay   string       `json:"input_value_day"`
	InputValueMonth string       `json:"input_value_month"`
	InputValueYear  string       `json:"input_value_year"`
	Title           Localisation `json:"title"`
	Description     Localisation `json:"description"`
}
InputDate provides an input for a date.

Language should be passed in from the Page model. Id is the id in the document. InputNameDay is the name submitted for the day in a form. InputNameMonth is the name submitted for the month in a form. InputNameYear is the name submitted for the year in a form. InputValueDay is the user input submitted for the day in a form. InputValueMonth is the user input submitted for the month in a form. InputValueYear is the user input submitted for the year in a form. Title states the purpose of the date. Description offers a further explanation for the purpose of the date.

type InputRadioBox added in v1.28.0

type InputRadioBox struct {
	Language    string       `json:"language"`
	Id          string       `json:"id"`
	Name        string       `json:"name"`
	Value       string       `json:"value"`
	Checked     bool         `json:"checked"`
	Count       string       `json:"count"`
	Title       Localisation `json:"title"`
	LocaleKey   Localisation `json:"localeKey"`
	Description Localisation `json:"description"`
}
InputRadioBox provides an input for a checkbox.

Language should be passed in from the Page model. Id is the id in the document. Name is the name in the document. Checked is flag that shows up it the value it true Title states the purpose of the InputCheckbox.

type Localisation added in v1.25.0

type Localisation struct {
	Text      string `json:"text"`
	LocaleKey string `json:"locale_key"`
	Plural    int    `json:"plural"`
}
Localisation offers text or a localised substitute.

Text is displayed as-is. LocaleKey is a key into the toml files found in assets/locales. Plural chooses the singular or plural form of the phrase selected by LocaleKey.

func (Localisation) FuncLocalise added in v1.25.3

func (localisation Localisation) FuncLocalise(language string) string

Localise by preference when a LocaleKey is provided, defaulting to Text otherwise.

type Metadata

type Metadata struct {
	Title       string   `json:"title"`
	Description string   `json:"description"`
	ServiceName string   `json:"serviceName"`
	Keywords    []string `json:"keywords"`
}

Metadata ...

type Page

type Page struct {
	Count                            int             `json:"count"`
	Type                             string          `json:"type"`
	DatasetId                        string          `json:"dataset_id"`
	DatasetTitle                     string          `json:"dataset_title"`
	URI                              string          `json:"uri"`
	Taxonomy                         []TaxonomyNode  `json:"taxonomy"`
	Breadcrumb                       []TaxonomyNode  `json:"breadcrumb"`
	IsInFilterBreadcrumb             bool            `json:"is_in_filter_breadcrumb"`
	ServiceMessage                   string          `json:"service_message"`
	Metadata                         Metadata        `json:"metadata"`
	SearchDisabled                   bool            `json:"search_disabled"`
	SiteDomain                       string          `json:"-"`
	PatternLibraryAssetsPath         string          `json:"-"`
	Language                         string          `json:"language"`
	IncludeAssetsIntegrityAttributes bool            `json:"-"`
	ReleaseDate                      string          `json:"release_date"`
	BetaBannerEnabled                bool            `json:"beta_banner_enabled"`
	CookiesPreferencesSet            bool            `json:"cookies_preferences_set"`
	CookiesPolicy                    CookiesPolicy   `json:"cookies_policy"`
	HasJSONLD                        bool            `json:"has_jsonld"`
	FeatureFlags                     FeatureFlags    `json:"feature_flags"`
	Error                            Error           `json:"error"`
	EmergencyBanner                  EmergencyBanner `json:"emergency_banner"`
	Collapsible                      Collapsible     `json:"collapsible"`
	Pagination                       Pagination      `json:"pagination"`
	TableOfContents                  TableOfContents `json:"table_of_contents"`
	BackTo                           BackTo          `json:"back_to"`
	SearchNoIndexEnabled             bool            `json:"search_no_index_enabled"`
}

Page contains data re-used for each page type a Data struct for data specific to the page type

func NewPage

func NewPage(path, domain string) Page

NewPage instantiates the base Page type with configurable fields

type PageToDisplay

type PageToDisplay struct {
	PageNumber int    `json:"page_number"`
	URL        string `json:"url"`
}

PageToDisplay represents a page to display in pagination with their corresponding URL

type Pagination

type Pagination struct {
	CurrentPage       int             `json:"current_page"`
	PagesToDisplay    []PageToDisplay `json:"pages_to_display"`
	FirstAndLastPages []PageToDisplay `json:"first_and_last_pages"`
	TotalPages        int             `json:"total_pages"`
	Limit             int             `json:"limit"`
	LimitOptions      []int           `json:"limit_options,omitempty"`
}

Pagination represents all information regarding pagination of search results

func (Pagination) FuncPhraseCurrentPage added in v1.25.4

func (pagination Pagination) FuncPhraseCurrentPage(progress, language string) string

Produces a string of the form "Current page (Page 5 of 10)"

func (Pagination) FuncPhraseGoToFirstPage added in v1.25.4

func (pagination Pagination) FuncPhraseGoToFirstPage(language string) string

Produces a string of the form "Go to the first page (Page 1)"

func (Pagination) FuncPhraseGoToLastPage added in v1.25.4

func (pagination Pagination) FuncPhraseGoToLastPage(language string) string

Produces a string of the form "Go to the last page (Page 10)"

func (Pagination) FuncPhraseGoToNextPage added in v1.25.4

func (pagination Pagination) FuncPhraseGoToNextPage(language string) string

Produces a string of the form "Go to the next page (Page 6)"

func (Pagination) FuncPhraseGoToPreviousPage added in v1.25.4

func (pagination Pagination) FuncPhraseGoToPreviousPage(language string) string

Produces a string of the form "Go to the previous page (Page 4)"

func (Pagination) FuncPhrasePageNOfTotal added in v1.25.4

func (pagination Pagination) FuncPhrasePageNOfTotal(n int, language string) string

Produces a string of the form "Page 1 of 10"

func (Pagination) FuncPhrasePaginationProgress added in v1.25.4

func (pagination Pagination) FuncPhrasePaginationProgress(progress, language string) string

Produces a string of the form "Pagination (Page 1 of 10)"

func (Pagination) FuncPickNextURL added in v1.25.4

func (pagination Pagination) FuncPickNextURL() string

func (Pagination) FuncPickPreviousURL added in v1.25.4

func (pagination Pagination) FuncPickPreviousURL() string

func (Pagination) FuncShowLinkToFirst added in v1.25.4

func (pagination Pagination) FuncShowLinkToFirst() bool

func (Pagination) FuncShowLinkToLast added in v1.25.4

func (pagination Pagination) FuncShowLinkToLast() bool
type ShareLink struct {
	Type               SocialType
	Url                string
	RequiresJavaScript bool
}

Represents an instance of a link URL for a specific shared resource

type SocialType added in v1.38.0

type SocialType int

Enumerates known social types that allow sharing a resource via a link URL

const (
	SocialUnknown SocialType = iota
	SocialEmail
	SocialFacebook
	SocialLinkedin
	SocialTwitter
)
func (s SocialType) CreateLink(title, target string) ShareLink

Creates a ShareLink from the supplied resource title and target URL

func (SocialType) String added in v1.38.0

func (s SocialType) String() string

Stringer interface

type TableOfContents added in v1.19.0

type TableOfContents struct {
	AriaLabel    Localisation              `json:"aria_label"`
	Title        Localisation              `json:"title"`
	Sections     map[string]ContentSection `json:"sections"`
	DisplayOrder []string                  `json:"display_order"`
}

TableOfContents contains the contents of the page

type TaxonomyNode

type TaxonomyNode struct {
	Title    string         `json:"title"`
	URI      string         `json:"uri"`
	Type     string         `json:"type,omitempty"`
	Children []TaxonomyNode `json:"children,omitempty"`
}

TaxonomyNode ...

Jump to

Keyboard shortcuts

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