Documentation
¶
Index ¶
- Constants
- Variables
- func AddOctothorpeIfNeeded(colorValue string) string
- func AllLinks(document string) (links mapset.Set)
- func BuildAll(in string, workersCount int) (built []string, httpLinks map[string][]string, err error)
- func BuildCollectionPages(using string) (built []string)
- func BuildPage(javascriptRuntime *v8.Isolate, pageName string, compiledTemplate []byte, ...) (built []string)
- func BuildRegularPage(path string) (built []string)
- func BuildSitePages(using string) (built []string)
- func BuildTagPages(using string) (built []string)
- func BuildTechPages(using string) (built []string)
- func BuildWorkPages(using string) (built []string)
- func BuildingForProduction() bool
- func CompileTemplate(templateName string, templateContent []byte) ([]byte, error)
- func ComputeTotalToBuildCount()
- func CoolDown()
- func Deadlinks(links mapset.Set) (deadlinks []string, err error)
- func Dependencies(content string) []string
- func DependentsOf(searchIn string, pageFilepath string, maxDepth uint) (dependents []string)
- func DynamicPathExpressions(path string) (expressions []string)
- func EvaluateDynamicPath(h *Hydration, path string) (string, error)
- func EvaluateDynamicPathExpression(h *Hydration, expression string) (stringResult string, boolResult bool, err error)
- func ExtractDynamicPathExpression(path string, extension string) string
- func FindInArrayLax(haystack []string, needle string) (string, error)
- func GeneralContentType(media db.Media) string
- func GenerateJSFile(hydration *Hydration, templateName string, compiledPugTemplate string) (string, error)
- func GetPathRelativeToSrcDir(absPath string) string
- func IncrementProgress() error
- func IsColorHexstring(s string) bool
- func IsLinkDead(link string) (bool, error)
- func LoadAdditionalData(filesToLoad []string) (additionalData map[string]interface{}, err error)
- func LogDebug(message string, fmtArgs ...interface{})
- func LogError(message string, fmtArgs ...interface{})
- func LogFatal(message string, fmtArgs ...interface{})
- func LogInfo(message string, fmtArgs ...interface{})
- func LogWarning(message string, fmtArgs ...interface{})
- func LowerCaseWithUnderscores(name string) string
- func MarkdownParagraphToHTML(markdown string) string
- func NameOfTemplate(name string, hydration Hydration) string
- func ParseCreationDate(datestring string) (time.Time, error)
- func PreprocessDynamicPathExpression(expression string) string
- func PrintTemplateErrorMessage(whileDoing string, templateName string, templateContent string, err error, ...)
- func RunTemplate(javascriptRuntime *v8.Isolate, hydration *Hydration, templateName string, ...) (string, error)
- func ScanAll(in string) (toBuild []string, err error)
- func SetCurrentObjectID(objectID string)
- func SetDatabaseOnGlobalData(database Database)
- func SetGlobalData(data *GlobalData)
- func SetJSONNamingStrategy(decoder jsoniter.API, translate func(string) string)
- func SetTranslationsOnGlobalData(translations map[string]*TranslationsOneLang)
- func StartDevServer(host string, language string)
- func StartWatcher(db Database)
- func Status(step BuildStep, details ProgressDetails)
- func StringsLooselyMatch(s1 string, sn ...string) bool
- func SummarizeString(s string, targetLength uint32) string
- func ToBuildTotalCount(in string) (count int)
- func Translate(language string, root *html.Node) string
- func UpdateExtendsStatement(in string, from string, to string)
- func UpdateSpinner()
- func VariablesOfExpression(expression string) ([]string, error)
- func WarmUp(data *GlobalData)
- func WritePDF(html string, to string) error
- func WriteProgressFile() error
- type AntonmedvExpression
- type BuildStep
- type ByMsgIdAndCtx
- type Cell
- type Collection
- type CollectionOneLang
- type Configuration
- type Database
- type DummySpinner
- type ExternalSite
- type Flags
- type GlobalData
- type HTMLString
- type Hydration
- func (h *Hydration) GetDistFilepath(srcFilepath string) (string, error)
- func (h *Hydration) IsCollection() bool
- func (h *Hydration) IsSite() bool
- func (h *Hydration) IsTag() bool
- func (h *Hydration) IsTech() bool
- func (h *Hydration) IsWork() bool
- func (h *Hydration) Name() string
- func (h *Hydration) WriteDistFile(fileName string, content string, language string) string
- type LayedOutElement
- type Layout
- type OutputTemplates
- type ProgressDetails
- type ProgressFile
- type Spinner
- type Tag
- type Technology
- type Translations
- type TranslationsOneLang
- func (t TranslationsOneLang) GetTranslation(msgid string, msgctxt string) (string, error)
- func (t TranslationsOneLang) GetTranslationOrMsgid(msgid string, msgctx string) string
- func (t TranslationsOneLang) SavePO()
- func (t TranslationsOneLang) TranslateHydrated(content string) string
- func (t TranslationsOneLang) TranslateTranslationStrings(content string) string
- func (t TranslationsOneLang) WriteUnusedMessages() error
- type URLString
- type Work
- type WorkMetadata
- type WorkOneLang
- func (w WorkOneLang) ColorsCSS() string
- func (w WorkOneLang) ColorsMap() map[string]string
- func (work *WorkOneLang) Created() time.Time
- func (w WorkOneLang) Freeze() workOneLangFrozen
- func (work WorkOneLang) IsWIP() bool
- func (work WorkOneLang) LayedOut() (layout Layout, err error)
- func (w WorkOneLang) Summary() string
Constants ¶
const ( TranslationStringDelimiterOpen = "[=[=[={{{" TranslationStringDelimiterClose = "}}}=]=]=]" )
This is the ugliest delimiter pair I could come up with. The idea is to prevent conflicts with any potential input.
const MaxInt = int(^uint(0) >> 1)
const SourceLanguage = "en"
Variables ¶
var DynamicPathExpressionsCache = map[string]*exprVM.Program{}
Functions ¶
func AddOctothorpeIfNeeded ¶
AddOctothorpeIfNeeded adds a leading "#" to colorValue if it's a valid color hexstring
func BuildAll ¶
func BuildAll(in string, workersCount int) (built []string, httpLinks map[string][]string, err error)
BuildAll builds pages from templates found in the given directory in parallel, using the given number of goroutines (workersCount). if workersCount is 0 or less, it is set to the number of page templates to compile.
func BuildCollectionPages ¶
BuildCollectionPages builds all collection pages using the given filename
func BuildPage ¶
func BuildPage(javascriptRuntime *v8.Isolate, pageName string, compiledTemplate []byte, hydration *Hydration) (built []string)
BuildPage builds a single page
func BuildRegularPage ¶
BuildRegularPage builds a given page that isn't dynamic (i.e. does not require object data, as opposed to work, tag and tech pages)
func BuildSitePages ¶
BuildSitePages builds all site pages using the template at the given filename
func BuildTagPages ¶
BuildTagPages builds all tag pages using the given filename
func BuildTechPages ¶
BuildTechPages builds all technology pages using `using`
func BuildWorkPages ¶
BuildWorkPages builds all work pages using the given filepath
func BuildingForProduction ¶
func BuildingForProduction() bool
BuildingForProduction returns true if the environment file declares ENVIRONMENT to not "dev"
func CompileTemplate ¶
CompileTemplate compiles a pug template using the CLI tool pug.
func ComputeTotalToBuildCount ¶
func ComputeTotalToBuildCount()
func CoolDown ¶
func CoolDown()
CoolDown needs to be stop before the program exits. It properly stops the spinner.
func Dependencies ¶
Dependencies returns all the .pug files referenced in extends or include statements by content. All the dependencies' paths are as-is (meaning relative to content's file's parent directory), except that .pug is added when it's missing.
func DependentsOf ¶
DependentsOf returns an array of pages' filepaths that depend on the given filepath (through `extends` or `intoGallery`) This function is recursive, dependents of dependents are also included. The returned array is has the same order as the build order required to correctly update dependencies before their dependents maxDepth is used to specify how deeply it should recurse (i.e. how many times it should call itself)
func DynamicPathExpressions ¶
DynamicPathExpressions returns a list of all dynamic path expressions if the given path.
func EvaluateDynamicPath ¶
EvaluateDynamicPathExpression evaluates a path that mau contain parts that are dynamic path expressions.
func EvaluateDynamicPathExpression ¶
func EvaluateDynamicPathExpression(h *Hydration, expression string) (stringResult string, boolResult bool, err error)
EvaluateDynamicPathExpression evaluates a path expression (that does not contain the leading ":" or the surrounding "[" and "]" and returns the evaluated expression, as a boolean (second return value) if the result is a boolean or as a string (first return value) if the result is anything else (stringifying the type with "%s"). If the result is an empty string, it becomes indistinguishable from a false boolean result. This is within expectations: an empty string, as well as a false boolean, means that this hydration with this path should not be rendered.
func ExtractDynamicPathExpression ¶
ExtractDynamicPathExpression extracts the path expression from a path. If the path is not a path expression, it returns an empty string. The extension argument is used to strip a potential extension from the path, to not let it be part of the expression when using the ":expression" syntax.
func FindInArrayLax ¶
FindInArrayLax checks if needle is in haystack, ignoring case and whitespace around values
func GeneralContentType ¶
func GenerateJSFile ¶
func GetPathRelativeToSrcDir ¶
GetPathRelativeToSrcDir takes an _absolute_ path and returns the part after (not containing) source
func IncrementProgress ¶
func IncrementProgress() error
IncrementProgress increments the number of processed works and writes the progress to a file if --write-progress is set.
func IsColorHexstring ¶
IsColorHexstring determines if the given string is a valid 6-character hexstring
func IsLinkDead ¶
IsLinkDead returns (true, nil) if the given link is dead (i.e. rotten). An non-nil error is returned if an error occured while trying to make a GET request to the link (e.g. no Internet connection).
func LoadAdditionalData ¶
func LogError ¶
func LogError(message string, fmtArgs ...interface{})
LogError logs non-fatal errors.
func LowerCaseWithUnderscores ¶
LowerCaseWithUnderscores one strategy to SetNamingStrategy for. It will change HelloWorld to hello_world.
func MarkdownParagraphToHTML ¶
MarkdownParagraphToHTML returns the HTML equivalent of the given markdown string, without the outer <p>…</p> tag
func NameOfTemplate ¶
NameOfTemplate returns the name given to a template that is applied to multiple objects, e.g. :work.pug<portfolio>. Falls back to template.Name() if hydration is empty
func ParseCreationDate ¶
ParseCreationDate parses datestring using iso8601. If the year is "????", replace it with year 9999
func PreprocessDynamicPathExpression ¶
PreprocessDynamicPathExpression expands some custom syntax added on top of regular antonmedv expressions. Output is a valid antonmedv expression. The expansions are the following:
… is … -> 1 == 2 ? 1 : "" … except … -> 1 != 2 ? 1 : ""
func PrintTemplateErrorMessage ¶
func PrintTemplateErrorMessage(whileDoing string, templateName string, templateContent string, err error, templateLanguage string)
PrintTemplateErrorMessage prints a nice error message with a preview of the code where the error occured
func RunTemplate ¶
func RunTemplate(javascriptRuntime *v8.Isolate, hydration *Hydration, templateName string, compiledTemplate []byte) (string, error)
RunTemplate parses a given (HTML) template.
func SetCurrentObjectID ¶
func SetCurrentObjectID(objectID string)
SetCurrentObjectID sets the current object ID and updates the spinner.
func SetDatabaseOnGlobalData ¶
func SetDatabaseOnGlobalData(database Database)
func SetGlobalData ¶
func SetGlobalData(data *GlobalData)
func SetJSONNamingStrategy ¶
SetJSONNamingStrategy rename struct fields uniformly
func SetTranslationsOnGlobalData ¶
func SetTranslationsOnGlobalData(translations map[string]*TranslationsOneLang)
func StartDevServer ¶
func StartWatcher ¶
func StartWatcher(db Database)
StartWatcher starts a watcher that listents for file changes in src/*.pug and i18n/*.mo - Re-build only the necessary files when content changes, - Stops when gallery.pug is moved - Updates references to a file when it is moved - Warns when deleting a file that is depended upon
func Status ¶
func Status(step BuildStep, details ProgressDetails)
Status updates the current progress and writes the progress to a file if --write-progress is set.
func StringsLooselyMatch ¶
StringsLooselyMatch checks if s1 is equal to any of sn, but case-insensitively.
func SummarizeString ¶
SummarizeString summarizes s to at most targetLength characters TODO: do not cut in between of a word/punctuation mark, etc.
func ToBuildTotalCount ¶
func Translate ¶
TranslateToLanguage translates the given html node to french or english, removing translation-related attributes
func UpdateExtendsStatement ¶
UpdateExtendsStatement renames the file referenced by an extends statement
func UpdateSpinner ¶
func UpdateSpinner()
func VariablesOfExpression ¶
func WarmUp ¶
func WarmUp(data *GlobalData)
WarmUp needs to be run before any building starts. It sets the global data, scans the template directory to determine the total number of pages to build, and starts the spinner.
func WriteProgressFile ¶
func WriteProgressFile() error
WriteProgressFile writes the progress to a file if --write-progress is set.
Types ¶
type AntonmedvExpression ¶
type AntonmedvExpression = string
type BuildStep ¶
type BuildStep string
const ( StepDeadLinks BuildStep = "dead links" StepBuildPage BuildStep = "build page" StepGeneratePDF BuildStep = "pdf generation" StepLoadWorks BuildStep = "load works" StepLoadTechnologies BuildStep = "load technologies" StepLoadExternalSites BuildStep = "load external sites" StepLoadCollections BuildStep = "load collections" StepLoadTags BuildStep = "load tags" StepLoadTranslations BuildStep = "load translations" )
type ByMsgIdAndCtx ¶
ByMsgIdAndCtx implement sorting gettext messages by their msgid+msgctxt
func (ByMsgIdAndCtx) Len ¶
func (b ByMsgIdAndCtx) Len() int
func (ByMsgIdAndCtx) Less ¶
func (b ByMsgIdAndCtx) Less(i, j int) bool
func (ByMsgIdAndCtx) Swap ¶
func (b ByMsgIdAndCtx) Swap(i, j int)
type Collection ¶
type Collection struct { ID string Title map[string]string Description map[string]HTMLString LearnMoreAt URLString `yaml:"learn more at"` Includes AntonmedvExpression Aliases []string Works []Work }
func LoadCollections ¶
func LoadCollections(filename string, works []Work, tags []Tag, technologies []Technology) (collections []Collection, err error)
func (*Collection) InLanguage ¶
func (c *Collection) InLanguage(language string) CollectionOneLang
func (Collection) String ¶
func (c Collection) String() string
type CollectionOneLang ¶
type CollectionOneLang struct { Language string ID string Title string Description HTMLString LearnMoreAt URLString `yaml:"learn more at"` Includes AntonmedvExpression Aliases []string Works []WorkOneLang }
func (CollectionOneLang) Contains ¶
func (c CollectionOneLang) Contains(work WorkOneLang, works []Work, tags []Tag, technologies []Technology) (bool, error)
func (CollectionOneLang) Freeze ¶
func (c CollectionOneLang) Freeze() collectionOneLangFrozen
func (CollectionOneLang) String ¶
func (c CollectionOneLang) String() string
type Configuration ¶
type Configuration struct { Development struct { OutputTo OutputTemplates `yaml:"output to"` } Production struct { UploadTo OutputTemplates `yaml:"upload to"` AvailableAt OutputTemplates `yaml:"available at"` } AdditionalData []string `yaml:"additional data"` }
func DefaultConfiguration ¶
func DefaultConfiguration() Configuration
func LoadConfiguration ¶
func LoadConfiguration(path string) (Configuration, error)
type Database ¶
type Database struct { Works []Work Technologies []Technology Tags []Tag Sites []ExternalSite Collections []Collection }
Database holds works & other metadata
func LoadDatabase ¶
LoadDatabase loads works, technologies and tags into a Database Standard filepaths relative to databaseDir are assumed: - database.json for the works - tags.yaml for the tags - technologies.yaml for the technologies
type DummySpinner ¶
type DummySpinner struct { }
func (DummySpinner) Message ¶
func (d DummySpinner) Message(string)
func (DummySpinner) Pause ¶
func (d DummySpinner) Pause() error
func (DummySpinner) Start ¶
func (d DummySpinner) Start() error
func (DummySpinner) Stop ¶
func (d DummySpinner) Stop() error
func (DummySpinner) Unpause ¶
func (d DummySpinner) Unpause() error
type ExternalSite ¶
type ExternalSite struct { Name string `yaml:"name"` URL string `yaml:"url"` Purpose string `yaml:"purpose"` Username string `yaml:"username"` }
ExternalSite represents an external site (e.g. social media or email address)
func LoadExternalSites ¶
func LoadExternalSites(filename string) (sites []ExternalSite, err error)
LoadExternalSites loads the sites from the given yaml file into a []Site
func (ExternalSite) String ¶
func (s ExternalSite) String() string
String returns the string representation of the external site. Should be the one used in URLs, as GetDistFilepath uses this.
type GlobalData ¶
type GlobalData struct { Translations Translations Database // Maps each link to the pages in which they appear HTTPLinks map[string][]string Spinner Spinner CurrentObjectID string CurrentOutputFile string CurrentLanguage string Progress struct { Step BuildStep Resolution int File string Current int Total int } Flags Flags Configuration Configuration OutputDirectory string TemplatesDirectory string AdditionalData map[string]interface{} // contains filtered or unexported fields }
GlobalData holds data that is used throughout the whole build process
func (*GlobalData) ProgressFileData ¶
func (g *GlobalData) ProgressFileData() ProgressFile
ProgressFileData returns a ProgressData struct ready to be marshalled to JSON for --write-progress.
func (*GlobalData) ProgressPercent ¶
func (g *GlobalData) ProgressPercent() int
ProgressPercent returns the current progress as a percentage.
func (*GlobalData) PublicWorks ¶
func (g *GlobalData) PublicWorks() (works []Work)
PublicWorks returns Works that are not private
type HTMLString ¶
type HTMLString = string
type Hydration ¶
type Hydration struct {
// contains filtered or unexported fields
}
Hydration represents a Tag, Technology or Work
func (*Hydration) GetDistFilepath ¶
GetDistFilepath evaluates dynamic paths and replaces src/ with dist/. An empty return value means the path shouldn't be rendered with this hydration.
func (*Hydration) IsCollection ¶
type LayedOutElement ¶
type LayedOutElement struct { // Either media, paragraph, link or spacer. Type string // Index in the layout specification (e.g. 3rd paragraph) LayoutIndex int // The positions on the grid. List of [row, cell] pairs. Positions [][]int // Convenience content type, first part of content type except // for application/, where application/pdf becomes pdf and (maybe) others GeneralContentType string // The three possible cells ortfodb.Media ortfodb.Paragraph ortfodb.Link // Metadata from the work Metadata *WorkMetadata }
func (LayedOutElement) CSS ¶
func (l LayedOutElement) CSS() string
CSS returns CSS statements to declare the position of that element in the content grid.
func (LayedOutElement) ID ¶
func (l LayedOutElement) ID() string
ID Returns a layed out cell's ID, removing ambiguity (since a cell cannot be two things at the same time, .ID will be .Paragraph.ID for a paragraph, etc.)
func (LayedOutElement) PositionBounds ¶
func (l LayedOutElement) PositionBounds() (int, int, int, int)
Returns (starting row, ending row, starting column, ending column).
func (LayedOutElement) String ¶
func (l LayedOutElement) String() string
func (LayedOutElement) Title ¶
func (l LayedOutElement) Title() string
Title Returns a layed out cell's Title, removing ambiguity (since a cell cannot be two things at the same time, .Title will be .Media.Title for a media, etc.)
type Layout ¶
type Layout []LayedOutElement
func AutoLayout ¶
func AutoLayout(work *WorkOneLang) (layout Layout)
AutoLayout creates a layout from a given work, placing all paragraphs first, then all mediæ, and finally all links. No columns are created
func (Layout) PositionsMap ¶
type OutputTemplates ¶
type ProgressDetails ¶
type ProgressFile ¶
type ProgressFile struct { Total int `json:"total"` Processed int `json:"processed"` Percent int `json:"percent"` Current struct { ID string `json:"id"` Step BuildStep `json:"step"` // The resolution of the thumbnail being generated. 0 when step is not "thumbnails" Resolution int `json:"resolution"` // The file being processed: // // - original media when making thumbnails or during media analysis, // // - media the colors are being extracted from, or // // - the description.md file when parsing description File string `json:"file"` Language string `json:"language"` Output string `json:"output"` } `json:"current"` }
ProgressFile holds the data that gets written to the progress file as JSON.
type Spinner ¶
A yacspin spinner or a dummy spinner that does nothing. Used to avoid having to check for nil pointers everywhere when --silent is set.
func CreateSpinner ¶
func CreateSpinner() Spinner
type Tag ¶
type Tag struct { Singular string `yaml:"singular"` // Plural form display name Plural string `yaml:"plural"` // Singular form display name Aliases []string `yaml:"aliases"` // Works with a tag name in this array will be considered as tagged by the Tag Description string `yaml:"description"` // A description of what works that have this tag are. LearnMoreURL string `yaml:"learn more at"` // A URL to a page where more about that tag can be learnt }
Tag represents a tag
func (*Tag) ReferredToBy ¶
ReferredToBy returns whether the given name refers to the tag
type Technology ¶
type Technology struct { URLName string `yaml:"slug"` // (unique) identifier used in the URL DisplayName string `yaml:"name"` // name displayed to the user Aliases []string `yaml:"aliases"` // aliases pointing to the canonical URL (built from URLName) Author string `yaml:"by"` // What company is behind the tech? (to display i.e. 'Adobe Photoshop' instead of 'Photoshop') LearnMoreURL string `yaml:"learn more at"` // The technology's website Description string `yaml:"description"` // A short description of the technology }
Technology represents something that a work was made with used for the /using/_technology path
func LoadTechnologies ¶
func LoadTechnologies(filename string) (technologies []Technology, err error)
LoadTechnologies loads the technologies from the given yaml file into a []Technology
func (*Technology) ReferredToBy ¶
func (t *Technology) ReferredToBy(name string) bool
ReferredToBy returns whether the given name refers to the tech
func (Technology) String ¶
func (t Technology) String() string
String returns the string representation of the technology. Should be the one used in URLs, as GetDistFilepath uses this.
type Translations ¶
type Translations map[string]*TranslationsOneLang
func LoadTranslations ¶
func LoadTranslations() (Translations, error)
LoadTranslations reads from i18n/fr.po to load translations
type TranslationsOneLang ¶
type TranslationsOneLang struct {
// contains filtered or unexported fields
}
TranslationsOneLang holds both the gettext catalog from the .mo file and a po file object used to update the .po file (e.g. when discovering new translatable strings)
func (TranslationsOneLang) GetTranslation ¶
func (t TranslationsOneLang) GetTranslation(msgid string, msgctxt string) (string, error)
GetTranslation returns the msgstr corresponding to msgid and msgctxt from the .po file If not found, it returns an error
func (TranslationsOneLang) GetTranslationOrMsgid ¶
func (t TranslationsOneLang) GetTranslationOrMsgid(msgid string, msgctx string) string
GetTranslationOrMsgid is like GetTranslation but it returns the given msgid verbatim instead of returning an error
func (TranslationsOneLang) SavePO ¶
func (t TranslationsOneLang) SavePO()
SavePO writes the .po file to the disk, with its potential modifications It removes duplicate messages beforehand
func (TranslationsOneLang) TranslateHydrated ¶
func (t TranslationsOneLang) TranslateHydrated(content string) string
TranslateHydrated translates an hydrated HTML page, removing i18n tags and attributes and replacing translatable content with their translations
func (TranslationsOneLang) TranslateTranslationStrings ¶
func (t TranslationsOneLang) TranslateTranslationStrings(content string) string
TranslateTranslationStrings applies translations to a string containing translation strings as substrings. See TranslationStringDelimiterOpen, TranslationStringDelimiterClose. If those two are respectively [ and ], this function replaces
you have [{value: "%d friends", args: [8]}] online
with, given that t.GetTranslation("%d friends") returns "%d amis":
you have 8 amis
TODO: use ICU message syntax instead.
func (TranslationsOneLang) WriteUnusedMessages ¶
func (t TranslationsOneLang) WriteUnusedMessages() error
type Work ¶
type Work struct { db.Work Metadata WorkMetadata }
func (Work) InLanguage ¶
func (work Work) InLanguage(lang string) WorkOneLang
InLanguage returns a Work object with data from only the selected language (or the default if not found)
type WorkMetadata ¶
type WorkMetadata struct { Created string Started string Finished string Tags []string Layout []interface{} LayoutProper [][]string // For testing purposes, writing with []interface{}s is cumbersome af. MadeWith []string `json:"made with"` Colors struct { Primary string Secondary string Tertiary string } PageBackground string `json:"page background"` Title string WIP bool `json:"wip"` Thumbnails map[string]map[uint16]string Private bool Thumbnail string // Key in Thumbnails for the thumbnail to use to represent this work }
WorkMetadata represents metadata from the metadata field in the database file
func (WorkMetadata) LayoutHomogeneous ¶
func (metadata WorkMetadata) LayoutHomogeneous() (homo [][]string, err error)
LayoutHomogeneous turns a an untyped layout from metadata into a [][]string, turning string elements into a one-element slice, so that it can be used in loops without type errors
type WorkOneLang ¶
type WorkOneLang struct { ID string Metadata WorkMetadata Title string Paragraphs []db.Paragraph Media []db.Media Links []db.Link Footnotes db.Footnotes Language string }
WorkOneLang represents a work in a single language: language-dependent items have been replaced with their corresponding values in a language, there is no "language" map anymore.
func GetOneLang ¶
func GetOneLang(lang string, works ...Work) []WorkOneLang
GetOneLang returns an array of works with .InLanguage applied to each
func (WorkOneLang) ColorsCSS ¶
func (w WorkOneLang) ColorsCSS() string
func (WorkOneLang) ColorsMap ¶
func (w WorkOneLang) ColorsMap() map[string]string
getColorsMap returns a mapping of "primary", "secondary", etc to the color values, with an added "#" prefix if needed
func (*WorkOneLang) Created ¶
func (work *WorkOneLang) Created() time.Time
Created returns the creation date of a work
func (WorkOneLang) Freeze ¶
func (w WorkOneLang) Freeze() workOneLangFrozen
func (WorkOneLang) IsWIP ¶
func (work WorkOneLang) IsWIP() bool
IsWIP returns true if the work is a work in progress or has no starting date nor creation or finish date
func (WorkOneLang) LayedOut ¶
func (work WorkOneLang) LayedOut() (layout Layout, err error)
LayedOut fills the LayoutIndices of every work content element (paragraphs, mediæ and links.)
func (WorkOneLang) Summary ¶
func (w WorkOneLang) Summary() string