guidednavigation

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatNPTTime

func FormatNPTTime(d time.Duration) string

FormatNPTTime formats a duration as a Normal Play Time value in seconds, rounded to the millisecond, e.g. "123.4". https://www.w3.org/TR/media-frags/#npttimedef

Types

type Clip

type Clip struct {
	Begin *time.Duration // Offset from the start of the media, or nil for its beginning.
	End   *time.Duration // Offset from the start of the media, or nil for its end.
}

Clip is the temporal fragment of a media resource (the "t" dimension of a media fragment, in Normal Play Time format).

func (Clip) MediaFragment

func (c Clip) MediaFragment() string

MediaFragment returns the "t" media fragment dimension denoting the clip, e.g. "t=10.5,20", or an empty string for an unbounded clip. It can be used as the fragment of a media resource URL.

type GuidedNavigationDescription

type GuidedNavigationDescription struct {
	AudioRef url.URL              `json:"audioref,omitempty"` // References an audio resource or a fragment of it.
	ImgRef   url.URL              `json:"imgref,omitempty"`   // References an image or a fragment of it.
	TextRef  url.URL              `json:"textref,omitempty"`  // References a textual resource or a fragment of it.
	VideoRef url.URL              `json:"videoref,omitempty"` // References a video resource or a fragment of it.
	Text     GuidedNavigationText `json:"text,omitempty"`     // Textual description.
}

Readium Guided Navigation Description Object https://readium.org/guided-navigation/schema/description.schema.json Serialized as a plain string when it only carries plain text.

func NewTextDescription

func NewTextDescription(text string) GuidedNavigationDescription

NewTextDescription creates a description carrying only plain text.

func (GuidedNavigationDescription) AudioClip

func (d GuidedNavigationDescription) AudioClip() *Clip

AudioClip returns the temporal fragment of the description's audio reference, or nil when the whole resource is referenced.

func (GuidedNavigationDescription) AudioFile

func (d GuidedNavigationDescription) AudioFile() url.URL

AudioFile returns the audio resource referenced by the description, without its media fragment.

func (GuidedNavigationDescription) Empty

func (GuidedNavigationDescription) ImageFile

func (d GuidedNavigationDescription) ImageFile() url.URL

ImageFile returns the image referenced by the description, without its media fragment.

func (GuidedNavigationDescription) ImagePolygon

func (d GuidedNavigationDescription) ImagePolygon() *Polygon

ImagePolygon returns the polygonal fragment of the description's image reference, or nil when no polygonal region is referenced.

func (GuidedNavigationDescription) ImageRegion

func (d GuidedNavigationDescription) ImageRegion() *Region

ImageRegion returns the rectangular fragment of the description's image reference, or nil when no rectangular region is referenced.

func (GuidedNavigationDescription) MarshalJSON

func (d GuidedNavigationDescription) MarshalJSON() ([]byte, error)

func (GuidedNavigationDescription) TextFile

func (d GuidedNavigationDescription) TextFile() url.URL

TextFile returns the textual resource referenced by the description, without its fragment.

func (GuidedNavigationDescription) TextFragmentID

func (d GuidedNavigationDescription) TextFragmentID() string

TextFragmentID returns the fragment id of the description's text reference, or an empty string when there is none.

func (GuidedNavigationDescription) TextFragments

func (d GuidedNavigationDescription) TextFragments() []TextFragment

TextFragments returns the text fragments of the description's text reference, or nil when there are none.

func (*GuidedNavigationDescription) UnmarshalJSON

func (d *GuidedNavigationDescription) UnmarshalJSON(data []byte) error

func (GuidedNavigationDescription) VideoClip

func (d GuidedNavigationDescription) VideoClip() *Clip

VideoClip returns the temporal fragment of the description's video reference, or nil when no time range is referenced.

func (GuidedNavigationDescription) VideoFile

func (d GuidedNavigationDescription) VideoFile() url.URL

VideoFile returns the video resource referenced by the description, without its media fragment.

func (GuidedNavigationDescription) VideoRegion

func (d GuidedNavigationDescription) VideoRegion() *Region

VideoRegion returns the rectangular fragment of the description's video reference, or nil when no region is referenced.

type GuidedNavigationDocument

type GuidedNavigationDocument struct {
	Links  manifest.LinkList        `json:"links,omitempty"` // References to other resources that are related to the current Guided Navigation Document.
	Guided []GuidedNavigationObject `json:"guided"`          // A sequence of resources and/or media fragments into these resources, meant to be presented sequentially to the user.
}

Readium Guided Navigation Document https://readium.org/guided-navigation/schema/document.schema.json

type GuidedNavigationObject

type GuidedNavigationObject struct {
	ID          string                      `json:"id,omitempty"`          // Identifier for the object, referenced from the SSML representation of a sibling text (e.g. <readium:image id="..."/>).
	AudioRef    url.URL                     `json:"audioref,omitempty"`    // References an audio resource or a fragment of it.
	ImgRef      url.URL                     `json:"imgref,omitempty"`      // References an image or a fragment of it.
	TextRef     url.URL                     `json:"textref,omitempty"`     // References a textual resource or a fragment of it.
	VideoRef    url.URL                     `json:"videoref,omitempty"`    // References a video resource or a fragment of it.
	Text        GuidedNavigationText        `json:"text,omitempty"`        // Textual equivalent of the resources or fragment of the resources referenced by the current Guided Navigation Object.
	Role        []GuidedNavigationRole      `json:"role,omitempty"`        // Convey the structural semantics of a publication
	Children    []GuidedNavigationObject    `json:"children,omitempty"`    // Items that are children of the containing Guided Navigation Object.
	Description GuidedNavigationDescription `json:"description,omitempty"` // Text, audio or image description for the current Guided Navigation Object.
}

Readium Guided Navigation Object https://readium.org/guided-navigation/schema/object.schema.json

func (GuidedNavigationObject) AudioClip

func (o GuidedNavigationObject) AudioClip() *Clip

AudioClip returns the temporal fragment of the object's audio reference, or nil when the whole resource is referenced.

func (GuidedNavigationObject) AudioFile

func (o GuidedNavigationObject) AudioFile() url.URL

AudioFile returns the audio resource referenced by the object, without its media fragment.

func (GuidedNavigationObject) ChildrenOnly

func (o GuidedNavigationObject) ChildrenOnly() bool

ChildrenOnly reports whether the object carries no information of its own besides its children. Such objects are transparent wrappers (e.g. from <div> or <span>) whose children can be spliced into the parent's children.

func (GuidedNavigationObject) Empty

func (o GuidedNavigationObject) Empty() bool

func (GuidedNavigationObject) ImageFile

func (o GuidedNavigationObject) ImageFile() url.URL

ImageFile returns the image referenced by the object, without its media fragment.

func (GuidedNavigationObject) ImagePolygon

func (o GuidedNavigationObject) ImagePolygon() *Polygon

ImagePolygon returns the polygonal fragment of the object's image reference, or nil when no polygonal region is referenced.

func (GuidedNavigationObject) ImageRegion

func (o GuidedNavigationObject) ImageRegion() *Region

ImageRegion returns the rectangular fragment of the object's image reference, or nil when no rectangular region is referenced.

func (GuidedNavigationObject) MarshalJSON

func (o GuidedNavigationObject) MarshalJSON() ([]byte, error)

func (GuidedNavigationObject) TextFile

func (o GuidedNavigationObject) TextFile() url.URL

TextFile returns the textual resource referenced by the object, without its fragment.

func (GuidedNavigationObject) TextFragmentID

func (o GuidedNavigationObject) TextFragmentID() string

TextFragmentID returns the fragment id of the object's text reference (e.g. "par1" for "chapter.html#par1"), or an empty string when there is none.

func (GuidedNavigationObject) TextFragments

func (o GuidedNavigationObject) TextFragments() []TextFragment

TextFragments returns the text fragments of the object's text reference (e.g. "chapter.html#:~:text=some,text"), or nil when there are none.

func (GuidedNavigationObject) TextOnly

func (o GuidedNavigationObject) TextOnly() bool

func (GuidedNavigationObject) VideoClip

func (o GuidedNavigationObject) VideoClip() *Clip

VideoClip returns the temporal fragment of the object's video reference, or nil when no time range is referenced.

func (GuidedNavigationObject) VideoFile

func (o GuidedNavigationObject) VideoFile() url.URL

VideoFile returns the video resource referenced by the object, without its media fragment.

func (GuidedNavigationObject) VideoRegion

func (o GuidedNavigationObject) VideoRegion() *Region

VideoRegion returns the rectangular fragment of the object's video reference, or nil when no region is referenced.

type GuidedNavigationRole

type GuidedNavigationRole string

Readium Guided Navigation Roles https://github.com/readium/guided-navigation/blob/main/schema/roles.schema.json

const (
	RoleNone            GuidedNavigationRole = ""                // No role. Shouldn't be used
	RoleAbstract        GuidedNavigationRole = "abstract"        // A short summary of the principle ideas, concepts and conclusions of the work, or of a section or excerpt within it.
	RoleAcknowledgments GuidedNavigationRole = "acknowledgments" // A section or statement that acknowledges significant contributions by persons, organizations, governments and other entities to the realization of the work.
	RoleAfterword       GuidedNavigationRole = "afterword"       // A closing statement from the author or a person of importance, typically providing insight into how the content came to be written, its significance, or related events that have transpired since its timeline.
	RoleAppendix        GuidedNavigationRole = "appendix"        // A section of supplemental information located after the primary content that informs the content but is not central to it.
	RoleArticle         GuidedNavigationRole = "article"         // Represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable
	RoleAside           GuidedNavigationRole = "aside"           // Secondary or supplementary content.
	RoleAudio           GuidedNavigationRole = "audio"           // Embedded sound content in a document.
	RoleBacklink        GuidedNavigationRole = "backlink"        // A link that allows the user to return to a related location in the content (e.g., from a footnote to its reference or from a glossary definition to where a term is used).
	RoleBibliography    GuidedNavigationRole = "bibliography"    // A list of external references cited in the work, which may be to print or digital sources.
	RoleBiblioref       GuidedNavigationRole = "biblioref"       // A reference to a bibliography entry.
	RoleBlockquote      GuidedNavigationRole = "blockquote"      // Represents a section that is quoted from another source.
	RoleBody            GuidedNavigationRole = "body"            // Represents the content of an HTML document.
	RoleCaption         GuidedNavigationRole = "caption"         // A caption for an image or a table.
	RoleChapter         GuidedNavigationRole = "chapter"         // A major thematic section of content in a work.
	RoleCell            GuidedNavigationRole = "cell"            // A single cell of tabular data or content.
	RoleColumnHeader    GuidedNavigationRole = "columnheader"    // The header cell for a column, establishing a relationship between it and the other cells in the same column.
	RoleColophon        GuidedNavigationRole = "colophon"        // A short section of production notes particular to the edition (e.g., describing the typeface used), often located at the end of a work.
	RoleComplementary   GuidedNavigationRole = "complementary"   // A supporting section of the document, designed to be complementary to the main content at a similar level in the DOM hierarchy, but remains meaningful when separated from the main content.
	RoleConclusion      GuidedNavigationRole = "conclusion"      // A concluding section or statement that summarizes the work or wraps up the narrative.
	RoleCover           GuidedNavigationRole = "cover"           // An image that sets the mood or tone for the work and typically includes the title and author.
	RoleCredit          GuidedNavigationRole = "credit"          // An acknowledgment of the source of integrated content from third-party sources, such as photos. Typically identifies the creator, copyright and any restrictions on reuse.
	RoleCredits         GuidedNavigationRole = "credits"         // A collection of credits.
	RoleDedication      GuidedNavigationRole = "dedication"      // An inscription at the front of the work, typically addressed in tribute to one or more persons close to the author.
	RoleDefinition      GuidedNavigationRole = "definition"      // A definition of a term or concept.
	RoleDetails         GuidedNavigationRole = "details"         // A disclosure widget that can be expanded.
	RoleEndnotes        GuidedNavigationRole = "endnotes"        // A collection of notes at the end of a work or a section within it.
	RoleEpigraph        GuidedNavigationRole = "epigraph"        // A quotation set at the start of the work or a section that establishes the theme or sets the mood.
	RoleEpilogue        GuidedNavigationRole = "epilogue"        // A quotation set at the start of the work or a section that establishes the theme or sets the mood.
	RoleErrata          GuidedNavigationRole = "errata"          // A set of corrections discovered after initial publication of the work, sometimes referred to as corrigenda.
	RoleExample         GuidedNavigationRole = "example"         // An illustration of the usage of a defined term or phrase.
	RoleFigure          GuidedNavigationRole = "figure"          // An illustration, diagram, photo, code listing or similar, referenced from the text of a work, and typically annotated with a title, caption and/or credits.
	RoleFootnote        GuidedNavigationRole = "footnote"        // Ancillary information, such as a citation or commentary, that provides additional context to a referenced passage of text.
	RoleForeword        GuidedNavigationRole = "foreword"        // An introductory section that precedes the work, typically written by a person other than the author.
	RoleGlossary        GuidedNavigationRole = "glossary"        // A brief dictionary of new, uncommon, or specialized terms used in the content.
	RoleGlossref        GuidedNavigationRole = "glossref"        // A reference to a glossary definition.
	RoleHeader          GuidedNavigationRole = "header"          // Represents introductory content, typically a group of introductory or navigational aids.
	RoleHeading1        GuidedNavigationRole = "heading1"        // A level 1 heading for a section of the page.
	RoleHeading2        GuidedNavigationRole = "heading2"        // A level 2 heading for a section of the page.
	RoleHeading3        GuidedNavigationRole = "heading3"        // A level 3 heading for a section of the page.
	RoleHeading4        GuidedNavigationRole = "heading4"        // A level 4 heading for a section of the page.
	RoleHeading5        GuidedNavigationRole = "heading5"        // A level 5 heading for a section of the page.
	RoleHeading6        GuidedNavigationRole = "heading6"        // A level 6 heading for a section of the page.
	RoleImage           GuidedNavigationRole = "image"           // Represents an image.
	RoleIndex           GuidedNavigationRole = "index"           // A navigational aid that provides a detailed list of links to key subjects, names and other important topics covered in the work.
	RoleIntroduction    GuidedNavigationRole = "introduction"    // A preliminary section that typically introduces the scope or nature of the work.
	RoleLandmarks       GuidedNavigationRole = "landmarks"       // A short summary of the principle ideas, concepts and conclusions of the work, or of a section or excerpt within it.
	RoleList            GuidedNavigationRole = "list"            // A structure that contains an enumeration of related content items.
	RoleListItem        GuidedNavigationRole = "listItem"        // A single item in an enumeration.
	RoleLoa             GuidedNavigationRole = "loa"             // A listing of audio clips included in the work.
	RoleLoi             GuidedNavigationRole = "loi"             // A listing of illustrations included in the work.
	RoleLot             GuidedNavigationRole = "lot"             // A listing of tables included in the work.
	RoleLov             GuidedNavigationRole = "lov"             // A listing of video clips included in the work.
	RoleMain            GuidedNavigationRole = "main"            // Content that is directly related to or expands upon the central topic of the document.
	RoleMath            GuidedNavigationRole = "math"            // Content that represents a mathematical expression.
	RoleNavigation      GuidedNavigationRole = "navigation"      // Represents a section of a page that links to other pages or to parts within the page: a section with navigation links.
	RoleNoteref         GuidedNavigationRole = "noteref"         // A reference to a footnote or endnote, typically appearing as a superscripted number or symbol in the main body of text.
	RoleNotice          GuidedNavigationRole = "notice"          // Notifies the user of consequences that might arise from an action or event. Examples include warnings, cautions and dangers.
	RolePagebreak       GuidedNavigationRole = "pagebreak"       // A separator denoting the position before which a break occurs between two contiguous pages in a statically paginated version of the content.
	RolePagelist        GuidedNavigationRole = "pagelist"        // A navigational aid that provides a list of links to the pagebreaks in the content.
	RoleParagraph       GuidedNavigationRole = "paragraph"       // Represents a paragraph.
	RolePart            GuidedNavigationRole = "part"            // A major structural division in a work that contains a set of related sections dealing with a particular subject, narrative arc or similar encapsulated theme.
	RolePreface         GuidedNavigationRole = "preface"         // An introductory section that precedes the work, typically written by the author of the work.
	RolePreformatted    GuidedNavigationRole = "preformatted"    // Represents preformatted text which is to be presented exactly as written.
	RolePresentation    GuidedNavigationRole = "presentation"    // Represents an element being used only for presentation and therefore that does not have any accessibility semantics.
	RolePrologue        GuidedNavigationRole = "prologue"        // An introductory section that sets the background to a work, typically part of the narrative.
	RolePullquote       GuidedNavigationRole = "pullquote"       // A distinctively placed or highlighted quotation from the current content designed to draw attention to a topic or highlight a key point.
	RoleQna             GuidedNavigationRole = "qna"             // A section of content structured as a series of questions and answers, such as an interview or list of frequently asked questions.
	RoleRegion          GuidedNavigationRole = "region"          // Represents content that is relevant to a specific, author-specified purpose and sufficiently important that users will likely want to be able to navigate to the section easily and to have it listed in a summary of the page.
	RoleRow             GuidedNavigationRole = "row"             // A row of data or content in a tabular structure.
	RoleRowHeader       GuidedNavigationRole = "rowheader"       // The header cell for a row, establishing a relationship between it and the other cells in the same row.
	RoleSection         GuidedNavigationRole = "section"         // Represents a generic standalone section of a document, which doesn't have a more specific semantic element to represent it.
	RoleSeparator       GuidedNavigationRole = "separator"       // Indicates the element is a divider that separates and distinguishes sections of content or groups of menuitems.
	RoleSequence        GuidedNavigationRole = "sequence"        // A sequence of related Guided Navigation Objects.
	RoleSubtitle        GuidedNavigationRole = "subtitle"        // An explanatory or alternate title for the work, or a section or component within it.
	RoleSummary         GuidedNavigationRole = "summary"         // A summary of an element contained in details.
	RoleTable           GuidedNavigationRole = "table"           // A structure containing data or content laid out in tabular form.
	RoleTerm            GuidedNavigationRole = "term"            // A word or phrase with a corresponding definition.
	RoleTip             GuidedNavigationRole = "tip"             // Helpful information that clarifies some aspect of the content or assists in its comprehension.
	RoleToc             GuidedNavigationRole = "toc"             // A navigational aid that provides an ordered list of links to the major sectional headings in the content. A table of contents may cover an entire work, or only a smaller section of it.
	RoleVideo           GuidedNavigationRole = "video"           // Embedded videos, movies, or audio files with captions in a document.
)

type GuidedNavigationText

type GuidedNavigationText struct {
	Plain    string `json:"plain,omitempty"`    // Plain text
	SSML     string `json:"ssml,omitempty"`     // SSML markup
	Language string `json:"language,omitempty"` // BCP-47 language tag
}

func (GuidedNavigationText) Empty

func (t GuidedNavigationText) Empty() bool

func (GuidedNavigationText) MarshalJSON

func (t GuidedNavigationText) MarshalJSON() ([]byte, error)

func (*GuidedNavigationText) UnmarshalJSON

func (t *GuidedNavigationText) UnmarshalJSON(data []byte) error

type Point

type Point struct {
	X float64
	Y float64
}

A point of a polygonal region.

type Polygon

type Polygon struct {
	Unit   RegionUnit
	Points []Point // At least three points.
}

Polygon is a polygonal region of a resource, as defined by EPUB Region-Based Navigation (the "xyn" fragment parameter).

type Region

type Region struct {
	Unit   RegionUnit
	X      float64
	Y      float64
	Width  float64
	Height float64
}

Region is a rectangular spatial fragment of a resource (the "xywh" dimension of a media fragment).

type RegionUnit

type RegionUnit string

The unit of a spatial fragment's coordinates.

const (
	RegionUnitPixel   RegionUnit = "pixel"
	RegionUnitPercent RegionUnit = "percent"
)

type TextFragment

type TextFragment struct {
	Prefix    string // Text immediately before the target, or empty.
	TextStart string // Start of the target text.
	TextEnd   string // End of the target text when it's a range, or empty.
	Suffix    string // Text immediately after the target, or empty.
}

TextFragment is a text fragment of a textual resource, as defined by the URL Fragment Text Directives specification (":~:text=" fragments).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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