ortfomk

package module
v0.0.0-...-696197c Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: GPL-3.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TranslationStringDelimiterOpen  = "[=[=[={{{"
	TranslationStringDelimiterClose = "}}}=]=]=]"
)

This is the ugliest delimiter pair I could come up with. The idea is to prevent conflicts with any potential input.

View Source
const MaxInt = int(^uint(0) >> 1)
View Source
const SourceLanguage = "en"

Variables

View Source
var DynamicPathExpressionsCache = map[string]*exprVM.Program{}

Functions

func AddOctothorpeIfNeeded

func AddOctothorpeIfNeeded(colorValue string) string

AddOctothorpeIfNeeded adds a leading "#" to colorValue if it's a valid color hexstring

func AllLinks(document string) (links mapset.Set)

AllLinks returns set of all HTTP links in a given document (so no duplicates).

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

func BuildCollectionPages(using string) (built []string)

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

func BuildRegularPage(path string) (built []string)

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

func BuildSitePages(using string) (built []string)

BuildSitePages builds all site pages using the template at the given filename

func BuildTagPages

func BuildTagPages(using string) (built []string)

BuildTagPages builds all tag pages using the given filename

func BuildTechPages

func BuildTechPages(using string) (built []string)

BuildTechPages builds all technology pages using `using`

func BuildWorkPages

func BuildWorkPages(using string) (built []string)

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

func CompileTemplate(templateName string, templateContent []byte) ([]byte, error)

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 Deadlinks(links mapset.Set) (deadlinks []string, err error)

func Dependencies

func Dependencies(content string) []string

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

func DependentsOf(searchIn string, pageFilepath string, maxDepth uint) (dependents []string)

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

func DynamicPathExpressions(path string) (expressions []string)

DynamicPathExpressions returns a list of all dynamic path expressions if the given path.

func EvaluateDynamicPath

func EvaluateDynamicPath(h *Hydration, path string) (string, error)

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

func ExtractDynamicPathExpression(path string, extension string) string

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

func FindInArrayLax(haystack []string, needle string) (string, error)

FindInArrayLax checks if needle is in haystack, ignoring case and whitespace around values

func GeneralContentType

func GeneralContentType(media db.Media) string

func GenerateJSFile

func GenerateJSFile(hydration *Hydration, templateName string, compiledPugTemplate string) (string, error)

func GetPathRelativeToSrcDir

func GetPathRelativeToSrcDir(absPath string) string

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

func IsColorHexstring(s string) bool

IsColorHexstring determines if the given string is a valid 6-character hexstring

func IsLinkDead

func IsLinkDead(link string) (bool, error)

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 LoadAdditionalData(filesToLoad []string) (additionalData map[string]interface{}, err error)

func LogDebug

func LogDebug(message string, fmtArgs ...interface{})

LogDebug logs debug messages.

func LogError

func LogError(message string, fmtArgs ...interface{})

LogError logs non-fatal errors.

func LogFatal

func LogFatal(message string, fmtArgs ...interface{})

LogFatal logs fatal errors.

func LogInfo

func LogInfo(message string, fmtArgs ...interface{})

LogInfo logs infos.

func LogWarning

func LogWarning(message string, fmtArgs ...interface{})

LogWarning logs warnings.

func LowerCaseWithUnderscores

func LowerCaseWithUnderscores(name string) string

LowerCaseWithUnderscores one strategy to SetNamingStrategy for. It will change HelloWorld to hello_world.

func MarkdownParagraphToHTML

func MarkdownParagraphToHTML(markdown string) string

MarkdownParagraphToHTML returns the HTML equivalent of the given markdown string, without the outer <p>…</p> tag

func NameOfTemplate

func NameOfTemplate(name string, hydration Hydration) string

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

func ParseCreationDate(datestring string) (time.Time, error)

ParseCreationDate parses datestring using iso8601. If the year is "????", replace it with year 9999

func PreprocessDynamicPathExpression

func PreprocessDynamicPathExpression(expression string) string

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 ScanAll

func ScanAll(in string) (toBuild []string, err error)

ScanAll scans the given directory for paths to build, recursively.

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

func SetJSONNamingStrategy(decoder jsoniter.API, translate func(string) string)

SetJSONNamingStrategy rename struct fields uniformly

func SetTranslationsOnGlobalData

func SetTranslationsOnGlobalData(translations map[string]*TranslationsOneLang)

func StartDevServer

func StartDevServer(host string, language string)

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

func StringsLooselyMatch(s1 string, sn ...string) bool

StringsLooselyMatch checks if s1 is equal to any of sn, but case-insensitively.

func SummarizeString

func SummarizeString(s string, targetLength uint32) string

SummarizeString summarizes s to at most targetLength characters TODO: do not cut in between of a word/punctuation mark, etc.

func ToBuildTotalCount

func ToBuildTotalCount(in string) (count int)

func Translate

func Translate(language string, root *html.Node) string

TranslateToLanguage translates the given html node to french or english, removing translation-related attributes

func UpdateExtendsStatement

func UpdateExtendsStatement(in string, from string, to string)

UpdateExtendsStatement renames the file referenced by an extends statement

func UpdateSpinner

func UpdateSpinner()

func VariablesOfExpression

func VariablesOfExpression(expression string) ([]string, error)

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 WritePDF

func WritePDF(html string, to string) error

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

type ByMsgIdAndCtx []po.Message

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 Cell

type Cell struct {
	Type  string
	Index int
}

Cell represents a cell of a layout

func ParseStringCell

func ParseStringCell(stringCell string) (cell Cell, err error)

func (Cell) String

func (c Cell) String() string

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

func LoadDatabase(databaseDir string) (Database, error)

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 Flags

type Flags struct {
	ProgressFile string
	Silent       bool
}

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

func (h *Hydration) GetDistFilepath(srcFilepath string) (string, error)

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

func (h *Hydration) IsCollection() bool

func (*Hydration) IsSite

func (h *Hydration) IsSite() bool

func (*Hydration) IsTag

func (h *Hydration) IsTag() bool

IsTag returns true if the current hydration contains a Tag

func (*Hydration) IsTech

func (h *Hydration) IsTech() bool

IsTech returns true if the current hydration contains a Tech

func (*Hydration) IsWork

func (h *Hydration) IsWork() bool

IsWork returns true if the current hydration contains a Work

func (*Hydration) Name

func (h *Hydration) Name() string

Name returns the identifier of the object in the hydration, and defaults to the empty string if the current hydration is empty

func (*Hydration) WriteDistFile

func (h *Hydration) WriteDistFile(fileName string, content string, language string) string

WriteDistFile writes the given content to the dist/ equivalent of the given fileName and returns that equivalent's path

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

func (l Layout) PositionsMap() map[string][][]int

type OutputTemplates

type OutputTemplates struct {
	Media      string
	Translated string
	Rest       string
}

type ProgressDetails

type ProgressDetails struct {
	Resolution int
	File       string
	Language   string
	OutFile    string
}

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

type Spinner interface {
	Start() error
	Stop() error
	Message(string)
	Pause() error
	Unpause() error
}

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 LoadTags

func LoadTags(filename string) (tags []Tag, err error)

LoadTags loads the tags from the given yaml file into a []Tag

func (Tag) Freeze

func (t Tag) Freeze() tagFrozen

func (*Tag) ReferredToBy

func (t *Tag) ReferredToBy(name string) bool

ReferredToBy returns whether the given name refers to the tag

func (Tag) String

func (t Tag) String() string

String returns the string representation of the tag. Should be the one used in URLs, as GetDistFilepath uses this.

func (Tag) URLName

func (t Tag) URLName() string

URLName computes the identifier to use in the tag's page's URL

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 URLString

type URLString = string

type Work

type Work struct {
	db.Work
	Metadata WorkMetadata
}

func LoadWorks

func LoadWorks(filename string) (works []Work, err error)

LoadWorks reads the database file at filename into a []Work

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)

func (Work) String

func (work Work) String() string

String returns a string representation of the work. This is used to construct output paths (and therefore future URLs).

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

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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