starter

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package starter - what a new site starts with (app install), as data: starter.yaml describes the site's look, image styles, fields, content types, Views and menus; Apply creates them. Its labels, descriptions and titles are English, translated into the site's language on install (i18n-extract puts them in the catalogs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentType

type ContentType struct {
	Name          string             `yaml:"name"`
	Label         string             `yaml:"label"`
	Description   string             `yaml:"description"`
	Comments      entity.CommentMode `yaml:"comments"`
	ShowSubmitted bool               `yaml:"show_submitted"`
	Promote       bool               `yaml:"promote"`
	Revisions     bool               `yaml:"revisions"`
	// Preview - the form's Preview (entity.ContentTypeDef.NoPreview); on
	// unless false.
	Preview *bool   `yaml:"preview"`
	Fields  []Field `yaml:"fields"`
}

ContentType - a content type with its fields (entity.ContentTypeDef): the default comment mode, whether the author and date are shown, whether a new item is promoted to the front page, whether the type keeps the history of changes and whether its form previews.

func (ContentType) NoPreview

func (t ContentType) NoPreview() bool

NoPreview - the type's form without Preview: "preview: false".

type Field

type Field struct {
	Storage          string   `yaml:"storage"`
	Label            string   `yaml:"label"`
	Widget           string   `yaml:"widget"`
	TextFormats      []string `yaml:"text_formats"`
	ShowOnDetail     bool     `yaml:"show_on_detail"`
	ShowLabel        bool     `yaml:"show_label"`
	RendersInBody    bool     `yaml:"renders_in_body"`
	DetailImageStyle string   `yaml:"detail_image_style"`
	ListImageStyle   string   `yaml:"list_image_style"`
	SortOrder        int      `yaml:"sort_order"`
	DisplayOrder     int      `yaml:"display_order"`
}

Field - a field storage on a content type (entity.FieldInstanceDef): the widget, the text formats it allows (by machine name), where it is shown and in what order on the form (SortOrder) and the page (DisplayOrder).

type FieldStorage

type FieldStorage struct {
	Name string                      `yaml:"name"`
	Type entity.ContentTypeFieldType `yaml:"type"`
}

FieldStorage - a field the content types share (entity.FieldStorageDef).

type ImageStyle

type ImageStyle struct {
	Name   string `yaml:"name"`
	Label  string `yaml:"label"`
	Width  int    `yaml:"width"`
	Height int    `yaml:"height"`
	Mode   string `yaml:"mode"`
	Anchor string `yaml:"anchor"`
	// HiDPI - its derivatives at double size too (srcset 2x).
	HiDPI bool `yaml:"hidpi"`
}

ImageStyle - an image style (entity.ImageStyleDef).

type Link struct {
	Title string `yaml:"title"`
	URL   string `yaml:"url"`
}

Link - a menu link to an address on the site.

type Menu struct {
	Name   string `yaml:"name"`
	Label  string `yaml:"label"`
	Region string `yaml:"region"`
	Links  []Link `yaml:"links"`
}

Menu - a menu with its links, placed in a region of the site's theme.

type Result

type Result struct {
	Storages map[string]int
}

Result - what Apply created that the demo content builds on: the field storages' ids by name.

type Set

type Set struct {
	Site          Site           `yaml:"site"`
	ImageStyles   []ImageStyle   `yaml:"image_styles"`
	FieldStorages []FieldStorage `yaml:"field_storages"`
	ContentTypes  []ContentType  `yaml:"content_types"`
	Views         []View         `yaml:"views"`
	Menus         []Menu         `yaml:"menus"`
}

Set - the starter set (starter.yaml).

func Load

func Load() (*Set, error)

Load reads the starter set and checks its references.

func (*Set) Apply

func (s *Set) Apply(ctx context.Context, c *generated.Client, createdBy int, label func(string) string) (Result, error)

Apply creates the set on a new site through c (the install's transaction): its image styles, field storages, content types with their fields, Views, menus (placed in the site theme's regions) and the front page; createdBy is their author, label translates their labels into the site's language.

type Site

type Site struct {
	Theme         string `yaml:"theme"`
	FrontPageView string `yaml:"front_page_view"`
}

Site - the site's theme (its directory) and front page (a View of the set). The logo is the theme's (theme.yaml "logo") until one is uploaded on Site information.

type View

type View struct {
	Name        string                  `yaml:"name"`
	Label       string                  `yaml:"label"`
	DisplayType entity.ViewDisplayType  `yaml:"display_type"`
	Style       entity.ViewDisplayStyle `yaml:"style"`
	Pager       bool                    `yaml:"pager"`
	PageSize    int                     `yaml:"page_size"`
	Fields      []ViewField             `yaml:"fields"`
	Filters     []ViewFilter            `yaml:"filters"`
	Sorts       []ViewSort              `yaml:"sorts"`
}

View - a View of content (entity.ViewDisplayDef) with its fields, filters and sorts, in their order.

type ViewField

type ViewField struct {
	Storage    string `yaml:"storage"`
	Builtin    string `yaml:"builtin"`
	ImageStyle string `yaml:"image_style"`
	LinkTo     string `yaml:"link_to"`
	DateFormat string `yaml:"date_format"`
	TrimLength int    `yaml:"trim_length"`
}

ViewField - a View's column: a field storage or a built-in field.

type ViewFilter

type ViewFilter struct {
	Builtin    string `yaml:"builtin"`
	Operator   string `yaml:"operator"`
	Value      string `yaml:"value"`
	Contextual bool   `yaml:"contextual"`
}

ViewFilter - a View's filter on a built-in field; Contextual - it reads the page being rendered (has_current_term: the term page's term).

type ViewSort

type ViewSort struct {
	Builtin   string `yaml:"builtin"`
	Direction string `yaml:"direction"`
}

ViewSort - a View's sort on a built-in field.

Jump to

Keyboard shortcuts

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