Documentation
¶
Index ¶
- Constants
- Variables
- type Asset
- type AssetDescriptor
- type Book
- func (b *Book) AddTag(tag string) error
- func (b Book) ChaptersAndSubchapters() []*Chapter
- func (b *Book) EnsureValid() error
- func (b *Book) NormalizeAllTags() error
- func (b *Book) SetDatePublishedEndFromString(input string) error
- func (b *Book) SetDatePublishedStartFromString(input string) error
- func (b *Book) SetInputPath(inputPath string) error
- func (b *Book) SetUniqueID(uniqueID string)
- type Chapter
- func (c *Chapter) EnsureValid() error
- func (c Chapter) GetAbsoluteInputPath() (string, error)
- func (c Chapter) HasSubchapters() bool
- func (c *Chapter) SetBook(book *Book) error
- func (c *Chapter) SetDatePublishedFromString(input string) error
- func (c *Chapter) SetDateUpdatedFromString(input string) error
- func (c *Chapter) SetInputPath(inputPath string) error
- func (c *Chapter) SetUniqueID(uniqueID string)
- func (c Chapter) Subchapters() []*Chapter
- type Content
- func (c *Content) AddFormat(format string, content any)
- func (c *Content) Format(format string) (any, error)
- func (c *Content) MarshalJSON() ([]byte, error)
- func (c *Content) MarshalText() ([]byte, error)
- func (c *Content) MarshalYAML() ([]byte, error)
- func (c *Content) UnmarshalJSON(text []byte) error
- func (c *Content) UnmarshalText(text []byte) error
- func (c *Content) UnmarshalYAML(text []byte) error
- type Copyright
- type DateTime
- type ErrAssetMismatchedDescriptorType
- type ErrBookEmptyTag
- type ErrReferenceMissingAddress
- type ErrReferenceTooManyNestedDomains
- type ErrStatusMarshalUnrecognized
- type ErrStatusUnmarshalUnrecognized
- type License
- type Profile
- type Reference
- type Series
- type Status
Constants ¶
const ( BookConfigFileName = "pub.yml" BookChaptersConfigFileName = "nav.yml" BookAssetsDirName = "assets" BookChaptersDirName = "chapters" )
Variables ¶
var ( ErrAssetMissingObjects = errors.New("asset: could not find objects/descriptors") ErrAssetDescriptorMissingName = errors.New("asset descriptor: missing Name") )
var ( ErrBookMissingLanguageCode = errors.New("missing LanguageCode") ErrBookMissingUniqueID = errors.New("missing UniqueID (value must contain at least 1 non-space character)") ErrBookMissingTitle = errors.New("missing Title") )
var ( ErrChapterMissingBookPointer = errors.New("missing pointer to Book") ErrChapterMissingUniqueID = errors.New("missing UniqueID (must have at least 1 non-space character)") )
var ( ErrContentParsedUninitialized = errors.New("parsed content map is not initialized") ErrContentFormatNotFound = errors.New("parsed content format does not exist") )
var (
DateTimeLayouts = []string{
"2006-01-02T15:04:05Z07:00",
"2006-01-02 15:04:05Z07:00",
"2006-01-02T15:04Z07:00",
"2006-01-02 15:04Z07:00",
"2006-01-02TZ07:00",
"2006-01-02 Z07:00",
"2006-01TZ07:00",
"2006-01 Z07:00",
"2006TZ07:00",
"2006 Z07:00",
"2006-01-02T15:04:05",
"2006-01-02 15:04:05",
"2006-01-02T15:04",
"2006-01-02 15:04",
"2006-01-02",
"2006-01",
"2006",
}
)
var (
ErrProfileMissingName = errors.New("profile: missing Name")
)
var (
ErrReferenceMissingName = errors.New("reference: missing Name")
)
var (
ErrSeriesMissingTitle = errors.New("series: missing title")
)
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset struct { Objects []AssetDescriptor AlternativeText string Caption Content }
Asset represents a media element such as an image or video. Supports specifying multiple [AssetDescriptor]s which will be used as fallback formats (in the specified order) when the asset is not supported by the application.
func (*Asset) EnsureValid ¶
func (*Asset) MainDescriptor ¶
func (a *Asset) MainDescriptor() AssetDescriptor
func (*Asset) OtherDescriptors ¶
func (a *Asset) OtherDescriptors() []AssetDescriptor
type AssetDescriptor ¶
AssetDescriptor represents an individual file format of a media element.
func (*AssetDescriptor) CheckValid ¶
func (a *AssetDescriptor) CheckValid() error
type Book ¶
type Book struct { UniqueID string `json:"unique_id"` Title string `json:"title"` Subtitle string `json:"subtitle"` TitlesAlternate []string `json:"titles_alternate"` Description string `json:"description"` Tagline string `json:"tagline"` Content Content `json:"content"` Authors []Profile `json:"authors"` Contributors []Profile `json:"contributors"` Publishers []Profile `json:"publishers"` Tags []string `json:"tags"` Status Status `json:"status"` Series []Series `json:"series"` Edition string `json:"edition"` URL string `json:"url"` LanguageCode string `json:"language_code"` DatePublishedStart *DateTime `json:"date_published_start"` DatePublishedEnd *DateTime `json:"date_published_end"` LinksFunding []Reference `json:"links_funding"` LinksMirrors []Reference `json:"links_mirrors"` LinksOther []Reference `json:"links_other"` Assets []Asset `json:"assets"` IDs map[string]any `json:"ids"` Copyright Copyright `json:"copyright"` Chapters []Chapter `json:"chapters"` Extra map[string]any `json:"extra"` InputPath string }
Book represents a written work, which generally has an ordered list of 1 or more [Chapter]s.
func (Book) ChaptersAndSubchapters ¶
func (*Book) EnsureValid ¶
func (*Book) NormalizeAllTags ¶
Trim trailing spaces/newlines and remove duplicates in book tags list
func (*Book) SetDatePublishedEndFromString ¶
func (*Book) SetDatePublishedStartFromString ¶
func (*Book) SetInputPath ¶
func (*Book) SetUniqueID ¶
type Chapter ¶
type Chapter struct { UniqueID string `json:"unique_id"` Title string `json:"title"` Subtitle string `json:"subtitle"` Authors []Profile `json:"authors"` Contributors []Profile `json:"contributors"` Publishers []Profile `json:"publishers"` ContentFileName string `json:"content_file_name"` Content Content `json:"content"` AuthorsNotePrefix Content `json:"authors_note_prefix"` AuthorsNoteSuffix Content `json:"authors_note_suffix"` URL string `json:"url"` LanguageCode string `json:"language_code"` DatePublished *DateTime `json:"date_published"` DateUpdated *DateTime `json:"date_updated"` IDs map[string]string `json:"ids"` Copyright Copyright `json:"copyright"` Extra map[string]any `json:"extra"` Chapters []Chapter `json:"chapters"` Previous *Chapter Next *Chapter Book *Book InputPath string }
Chapter represents a division in a Book that contains its primary Content.
func (*Chapter) EnsureValid ¶
func (Chapter) GetAbsoluteInputPath ¶
func (Chapter) HasSubchapters ¶
func (*Chapter) SetDatePublishedFromString ¶
func (*Chapter) SetDateUpdatedFromString ¶
func (*Chapter) SetInputPath ¶
func (*Chapter) SetUniqueID ¶
func (Chapter) Subchapters ¶
type Content ¶
type Content struct { Raw []byte // contains filtered or unexported fields }
Content represents a body of text that is/can be parsed into different formats (e.g. Markdown to HTML, etc.).
func (*Content) MarshalJSON ¶
func (*Content) MarshalText ¶
func (*Content) MarshalYAML ¶
func (*Content) UnmarshalJSON ¶
func (*Content) UnmarshalText ¶
func (*Content) UnmarshalYAML ¶
type DateTime ¶
func (DateTime) MarshalJSON ¶
func (DateTime) MarshalText ¶
func (DateTime) MarshalYAML ¶
func (*DateTime) UnmarshalJSON ¶
func (*DateTime) UnmarshalText ¶
func (*DateTime) UnmarshalYAML ¶
type ErrAssetMismatchedDescriptorType ¶
type ErrAssetMismatchedDescriptorType struct { AssetType string DescriptorName string DescriptorType string }
func (ErrAssetMismatchedDescriptorType) Error ¶
func (e ErrAssetMismatchedDescriptorType) Error() string
type ErrBookEmptyTag ¶
func (ErrBookEmptyTag) Error ¶
func (e ErrBookEmptyTag) Error() string
type ErrReferenceMissingAddress ¶
type ErrReferenceMissingAddress struct {
Name string
}
func (ErrReferenceMissingAddress) Error ¶
func (e ErrReferenceMissingAddress) Error() string
type ErrReferenceTooManyNestedDomains ¶
func (ErrReferenceTooManyNestedDomains) Error ¶
func (e ErrReferenceTooManyNestedDomains) Error() string
type ErrStatusMarshalUnrecognized ¶
type ErrStatusMarshalUnrecognized struct {
Value Status
}
func (ErrStatusMarshalUnrecognized) Error ¶
func (e ErrStatusMarshalUnrecognized) Error() string
type ErrStatusUnmarshalUnrecognized ¶
type ErrStatusUnmarshalUnrecognized struct {
StatusString string
}
func (ErrStatusUnmarshalUnrecognized) Error ¶
func (e ErrStatusUnmarshalUnrecognized) Error() string
type Profile ¶
type Profile struct { Name string `json:"name"` NamesAlternate []string `json:"names_alternate"` Content Content `json:"content"` External []Reference `json:"external"` }
Profile may represent an individual or an organization that is credited as either an author, contributor or publisher affliated with a Book.
func (*Profile) EnsureValid ¶
type Reference ¶
type Reference struct { Name string `json:"name"` Address string `json:"address"` NotClickable bool `json:"not_clickable"` DomainsAlternate []Reference `json:"domains_alternate"` }
Reference represents an external link/address that is generally clickable.
func (*Reference) EnsureValid ¶
type Series ¶
type Series struct { Title string `json:"title"` TitlesAlternate []string `json:"titles_alternate"` Number float64 `json:"number"` Description string `json:"description"` Content Content `json:"content"` External []Reference `json:"external"` }
Series describes a Book's relation to a set of other Book objects (i.e. prequels, sequels, side stories, sharing the same world/universe, etc.)