manifest

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: BSD-3-Clause Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const InferredAccessibilityMetadataKey = "https://readium.org/webpub-manifest#inferredAccessibility"
View Source
const PresentationDefaultClipped = false // Default value for Presentation.Clipped
View Source
const PresentationDefaultContinuous = false // Default value for Presentation.Continuous
View Source
const ProfileAudiobook = Profile("https://readium.org/webpub-manifest/profiles/audiobook")

Profile for audiobooks

View Source
const ProfileDivina = Profile("https://readium.org/webpub-manifest/profiles/divina")

Profile for visual narratives (comics, manga and bandes dessinées)

View Source
const ProfileEPUB = Profile("https://readium.org/webpub-manifest/profiles/epub")

Profile for EPUB publications

View Source
const ProfilePDF = Profile("https://readium.org/webpub-manifest/profiles/pdf")

Profile for PDF documents

View Source
const UndefinedLanguage = "und"
View Source
const WebpubManifestContext = "https://readium.org/webpub-manifest/context.jsonld"

Variables

This section is empty.

Functions

func IsHorizontal

func IsHorizontal(progression ReadingProgression) *bool

func LinkHrefNormalizerIdentity

func LinkHrefNormalizerIdentity(href string) (string, error)

Default href normalizer for Link, doing nothing.

Types

type A11y

type A11y struct {
	ConformsTo            []A11yProfile             `json:"conformsTo,omitempty"`           // An established standard to which the described resource conforms.
	Certification         *A11yCertification        `json:"certification,omitempty"`        // Certification of accessible publications.
	Summary               string                    `json:"summary,omitempty"`              // A human-readable summary of specific accessibility features or deficiencies, consistent with the other accessibility metadata but expressing subtleties such as "short descriptions are present but long descriptions will be needed for non-visual users" or "short descriptions are present and no long descriptions are needed."
	AccessModes           []A11yAccessMode          `json:"accessMode,omitempty"`           // The human sensory perceptual system or cognitive faculty through which a person may process or perceive information.
	AccessModesSufficient [][]A11yPrimaryAccessMode `json:"accessModeSufficient,omitempty"` //  A list of single or combined accessModes that are sufficient to understand all the intellectual content of a resource.
	Features              []A11yFeature             `json:"feature,omitempty"`              // Content features of the resource, such as accessible media, alternatives and supported enhancements for accessibility.
	Hazards               []A11yHazard              `json:"hazard,omitempty"`               // A characteristic of the described resource that is physiologically dangerous to some users.
}

A11y holds the accessibility metadata of a Publication.

https://www.w3.org/2021/a11y-discov-vocab/latest/ https://readium.org/webpub-manifest/schema/a11y.schema.json

func A11yFromJSON

func A11yFromJSON(rawJSON map[string]interface{}) (*A11y, error)

func NewA11y

func NewA11y() A11y

NewA11y creates a new empty A11y.

func (A11y) IsEmpty

func (a A11y) IsEmpty() bool

func (*A11y) Merge

func (a *A11y) Merge(other *A11y)

Merge extends or overwrites the current A11y with the given one.

func (*A11y) UnmarshalJSON

func (e *A11y) UnmarshalJSON(data []byte) error

type A11yAccessMode

type A11yAccessMode string

A11yAccessMode is a human sensory perceptual system or cognitive faculty through which a person may process or perceive information.

const (
	// Indicates that the resource contains information encoded in auditory form.
	A11yAccessModeAuditory A11yAccessMode = "auditory"

	// Indicates that the resource contains charts encoded in visual form.
	A11yAccessModeChartOnVisual A11yAccessMode = "chartOnVisual"

	// Indicates that the resource contains chemical equations encoded in visual form.
	A11yAccessModeChemOnVisual A11yAccessMode = "chemOnVisual"

	// Indicates that the resource contains information encoded such that color perception is necessary.
	A11yAccessModeColorDependent A11yAccessMode = "colorDependent"

	// Indicates that the resource contains diagrams encoded in visual form.
	A11yAccessModeDiagramOnVisual A11yAccessMode = "diagramOnVisual"

	// Indicates that the resource contains mathematical notations encoded in visual form.
	A11yAccessModeMathOnVisual A11yAccessMode = "mathOnVisual"

	// Indicates that the resource contains musical notation encoded in visual form.
	A11yAccessModeMusicOnVisual A11yAccessMode = "musicOnVisual"

	// Indicates that the resource contains information encoded in tactile form.
	//
	// Note that although an indication of a tactile mode often indicates the content is encoded
	// using a braille system, this is not always the case. Tactile perception may also indicate,
	// for example, the use of tactile graphics to convey information.
	A11yAccessModeTactile A11yAccessMode = "tactile"

	// Indicates that the resource contains text encoded in visual form.
	A11yAccessModeTextOnVisual A11yAccessMode = "textOnVisual"

	// Indicates that the resource contains information encoded in textual form.
	A11yAccessModeTextual A11yAccessMode = "textual"

	// Indicates that the resource contains information encoded in visual form.
	A11yAccessModeVisual A11yAccessMode = "visual"
)

func A11yAccessModesFromStrings

func A11yAccessModesFromStrings(strings []string) []A11yAccessMode

type A11yCertification

type A11yCertification struct {
	CertifiedBy string `json:"certifiedBy,omitempty"` // Identifies a party responsible for the testing and certification of the accessibility of a Publication.
	Credential  string `json:"credential,omitempty"`  // Identifies a credential or badge that establishes the authority of the party identified in the associated `certifiedBy` property to certify content accessible.
	Report      string `json:"report,omitempty"`      // Provides a link to an accessibility report created by the party identified in the associated `certifiedBy` property.
}

A11yCertification represents a certification for an accessible publication.

func (A11yCertification) IsEmpty

func (c A11yCertification) IsEmpty() bool

type A11yFeature

type A11yFeature string

A11yFeature is a content feature of the described resource, such as accessible media, alternatives and supported enhancements for accessibility.

const (
	// The work includes annotations from the author, instructor and/or others.
	A11yFeatureAnnotations A11yFeature = "annotations"

	// Indicates the resource includes ARIA roles to organize and improve the structure and navigation.
	//
	// The use of this value corresponds to the inclusion of Document Structure, Landmark,
	// Live Region, and Window roles [WAI-ARIA].
	A11yFeatureAria A11yFeature = "ARIA"

	// The work includes bookmarks to facilitate navigation to key points.
	A11yFeatureBookmarks A11yFeature = "bookmark"

	// The work includes an index to the content.
	A11yFeatureIndex A11yFeature = "index"

	// The work includes equivalent print page numbers. This setting is most commonly used
	// with ebooks for which there is a print equivalent.
	A11yFeaturePrintPageNumbers A11yFeature = "printPageNumbers"

	// The reading order of the content is clearly defined in the markup
	// (e.g., figures, sidebars and other secondary content has been marked up to allow it
	// to be skipped automatically and/or manually escaped from).
	A11yFeatureReadingOrder A11yFeature = "readingOrder"

	// The use of headings in the work fully and accurately reflects the document hierarchy,
	// allowing navigation by assistive technologies.
	A11yFeatureStructuralNavigation A11yFeature = "structuralNavigation"

	// The work includes a table of contents that provides links to the major sections of the content.
	A11yFeatureTableOfContents A11yFeature = "tableOfContents"

	// The contents of the PDF have been tagged to permit access by assistive technologies.
	A11yFeatureTaggedPDF A11yFeature = "taggedPDF"

	// Alternative text is provided for visual content (e.g., via the HTML `alt` attribute).
	A11yFeatureAlternativeText A11yFeature = "alternativeText"

	// Audio descriptions are available (e.g., via an HTML `track` element with its `kind`
	// attribute set to "descriptions".
	A11yFeatureAudioDescription A11yFeature = "audioDescription"

	// Indicates that synchronized captions are available for audio and video content.
	A11yFeatureCaptions A11yFeature = "captions"

	// Textual descriptions of math equations are included, whether in the alt attribute
	// for image-based equations,
	A11yFeatureDescribedMath A11yFeature = "describeMath"

	// Descriptions are provided for image-based visual content and/or complex structures
	// such as tables, mathematics, diagrams, and charts.
	A11yFeatureLongDescription A11yFeature = "longDescription"

	// Indicates that `ruby` annotations HTML are provided in the content. Ruby annotations
	// are used as pronunciation guides for the logographic characters for languages like
	// Chinese or Japanese. It makes difficult Kanji or CJK ideographic characters more accessible.
	//
	// The absence of rubyAnnotations implies that no CJK ideographic characters have ruby.
	A11yFeatureRubyAnnotations A11yFeature = "rubyAnnotations"

	// Sign language interpretation is available for audio and video content.
	A11yFeatureSignLanguage A11yFeature = "signLanguage"

	// Indicates that a transcript of the audio content is available.
	A11yFeatureTranscript A11yFeature = "transcript"

	// Display properties are controllable by the user. This property can be set, for example,
	// if custom CSS style sheets can be applied to the content to control the appearance.
	// It can also be used to indicate that styling in document formats like Word and PDF
	// can be modified.
	A11yFeatureDisplayTransformability A11yFeature = "displayTransformability"

	// Describes a resource that offers both audio and text, with information that allows them
	// to be rendered simultaneously. The granularity of the synchronization is not specified.
	// This term is not recommended when the only material that is synchronized is
	// the document headings.
	A11yFeatureSynchronizedAudioText A11yFeature = "synchronizedAudioText"

	// For content with timed interaction, this value indicates that the user can control
	// the timing to meet their needs (e.g., pause and reset)
	A11yFeatureTimingControl A11yFeature = "timingControl"

	// No digital rights management or other content restriction protocols have been applied
	// to the resource.
	A11yFeatureUnlocked A11yFeature = "unlocked"

	// Identifies that chemical information is encoded using the ChemML markup language.
	A11yFeatureChemML A11yFeature = "ChemML"

	// Identifies that mathematical equations and formulas are encoded in the LaTeX
	// typesetting system.
	A11yFeatureLatex A11yFeature = "latex"

	// Identifies that mathematical equations and formulas are encoded in MathML.
	A11yFeatureMathML A11yFeature = "MathML"

	// One or more of SSML, Pronunciation-Lexicon, and CSS3-Speech properties has been used
	// to enhance text-to-speech playback quality.
	A11yFeatureTTSMarkup A11yFeature = "ttsMarkup"

	// Audio content with speech in the foreground meets the contrast thresholds set out
	// in WCAG Success Criteria 1.4.7.
	A11yFeatureHighContrastAudio A11yFeature = "highContrastAudio"

	// Content meets the visual contrast threshold set out in WCAG Success Criteria 1.4.6.
	A11yFeatureHighContrastDisplay A11yFeature = "highContrastDisplay"

	// The content has been formatted to meet large print guidelines.
	//
	// The property is not set if the font size can be increased. See DisplayTransformability.
	A11yFeatureLargePrint A11yFeature = "largePrint"

	// The content is in braille format, or alternatives are available in braille.
	A11yFeatureBraille A11yFeature = "braille"

	// When used with creative works such as books, indicates that the resource includes
	// tactile graphics. When used to describe an image resource or physical object,
	// indicates that the resource is a tactile graphic.
	A11yFeatureTactileGraphic A11yFeature = "tactileGraphic"

	// When used with creative works such as books, indicates that the resource includes models
	// to generate tactile 3D objects. When used to describe a physical object,
	// indicates that the resource is a tactile 3D object.
	A11yFeatureTactileObject A11yFeature = "tactileObject"

	// Indicates that the resource does not contain any accessibility features.
	A11yFeatureNone A11yFeature = "none"
)

func A11yFeaturesFromStrings

func A11yFeaturesFromStrings(strings []string) []A11yFeature

type A11yHazard

type A11yHazard string

A11yHazard is a characteristic of the described resource that is physiologically dangerous to some users.

const (
	// Indicates that the resource presents a flashing hazard for photosensitive persons.
	A11yHazardFlashing A11yHazard = "flashing"

	// Indicates that the resource does not present a flashing hazard.
	A11yHazardNoFlashingHazard A11yHazard = "noFlashingHazard"

	// Indicates that the resource contains instances of motion simulation that
	// may affect some individuals.
	//
	// Some examples of motion simulation include video games with a first-person perspective
	// and CSS-controlled backgrounds that move when a user scrolls a page.
	A11yHazardMotionSimulation A11yHazard = "motionSimulation"

	// Indicates that the resource does not contain instances of motion simulation.
	A11yHazardNoMotionSimulationHazard A11yHazard = "noMotionSimulationHazard"

	// Indicates that the resource contains auditory sounds that may affect some individuals.
	A11yHazardSound A11yHazard = "sound"

	// Indicates that the resource does not contain auditory hazards.
	A11yHazardNoSoundHazard A11yHazard = "noSoundHazard"

	// Indicates that the author is not able to determine if the resource presents any hazards.
	A11yHazardUnknown A11yHazard = "unknown"

	// Indicates that the resource does not contain any hazards.
	A11yHazardNone A11yHazard = "none"
)

func A11yHazardsFromStrings

func A11yHazardsFromStrings(strings []string) []A11yHazard

type A11yPrimaryAccessMode

type A11yPrimaryAccessMode string

A11yPrimaryAccessMode is a human primary sensory perceptual system or cognitive faculty through which a person may process or perceive information.

const (
	// Indicates that auditory perception is necessary to consume the information.
	A11yPrimaryAccessModeAuditory A11yPrimaryAccessMode = "auditory"

	// Indicates that tactile perception is necessary to consume the information.
	A11yPrimaryAccessModeTactile A11yPrimaryAccessMode = "tactile"

	// Indicates that the ability to read textual content is necessary to consume the information.
	//
	// Note that reading textual content does not require visual perception, as textual content
	// can be rendered as audio using a text-to-speech capable device or assistive technology.
	A11yPrimaryAccessModeTextual A11yPrimaryAccessMode = "textual"

	// Indicates that visual perception is necessary to consume the information.
	A11yPrimaryAccessModeVisual A11yPrimaryAccessMode = "visual"
)

func A11yPrimaryAccessModesFromStrings

func A11yPrimaryAccessModesFromStrings(strings []string) []A11yPrimaryAccessMode

type A11yProfile

type A11yProfile string

A11yProfile represents an established accessibility standard a publication can conform to.

const (
	// EPUB Accessibility 1.0 - WCAG 2.0 Level A
	EPUBA11y10WCAG20A A11yProfile = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"
	// EPUB Accessibility 1.0 - WCAG 2.0 Level AA
	EPUBA11y10WCAG20AA A11yProfile = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"
	// EPUB Accessibility 1.0 - WCAG 2.0 Level AAA
	EPUBA11y10WCAG20AAA A11yProfile = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"
)

func A11yProfilesFromStrings

func A11yProfilesFromStrings(strings []string) []A11yProfile

type Collection

type Collection = Contributor

type Collections

type Collections = Contributors

type Contributor

type Contributor struct {
	LocalizedName   LocalizedString  `json:"name" validate:"required"` // The name of the contributor.
	LocalizedSortAs *LocalizedString `json:"sortAs,omitempty"`         // The string used to sort the name of the contributor.
	Identifier      string           `json:"identifier,omitempty"`     // An unambiguous reference to this contributor.
	Roles           Strings          `json:"role,omitempty"`           // The roles of the contributor in the making of the publication.
	Position        *float64         `json:"position,omitempty"`       // The position of the publication in this collection/series, when the contributor represents a collection. TODO validator
	Links           []Link           `json:"links,omitempty"`          // Used to retrieve similar publications for the given contributor.
}

Contributor https://github.com/readium/webpub-manifest/tree/master/contexts/default#contributors https://github.com/readium/webpub-manifest/schema/contributor-object.schema.json

func ContributorFromJSON

func ContributorFromJSON(rawJson interface{}, normalizeHref LinkHrefNormalizer) (*Contributor, error)

Parses a Contributor from its RWPM JSON representation. A contributor can be parsed from a single string, or a full-fledged object. The [links]' href and their children's will be normalized recursively using the provided [normalizeHref] closure.

func ContributorFromJSONArray

func ContributorFromJSONArray(rawJsonArray interface{}, normalizeHref LinkHrefNormalizer) ([]Contributor, error)

func (Contributor) MarshalJSON

func (c Contributor) MarshalJSON() ([]byte, error)

func (Contributor) Name

func (c Contributor) Name() string

func (Contributor) SortAs

func (c Contributor) SortAs() string

func (*Contributor) UnmarshalJSON

func (c *Contributor) UnmarshalJSON(data []byte) error

type Contributors

type Contributors []Contributor

TODO replace with generic

func (Contributors) MarshalJSON

func (c Contributors) MarshalJSON() ([]byte, error)

type EPUBLayout

type EPUBLayout string

Hints how the layout of the resource should be presented. https://readium.org/webpub-manifest/schema/extensions/epub/metadata.schema.json

const (
	EPUBLayoutFixed      EPUBLayout = "fixed"
	EPUBLayoutReflowable EPUBLayout = "reflowable"
)

type Encryption

type Encryption struct {
	Scheme         string `json:"scheme,omitempty"`
	Profile        string `json:"profile,omitempty"`
	Algorithm      string `json:"algorithm,omitempty"`
	Compression    string `json:"compression,omitempty"`
	OriginalLength int64  `json:"originalLength,omitempty"`
}

Encryption contains metadata from encryption xml

func EncryptionFromJSON

func EncryptionFromJSON(rawJson map[string]interface{}) (*Encryption, error)

func (Encryption) ToMap

func (m Encryption) ToMap() map[string]interface{}

func (*Encryption) UnmarshalJSON

func (e *Encryption) UnmarshalJSON(data []byte) error

type Fit

type Fit string // Suggested method for constraining a resource inside the viewport.
const (
	FitWidth   Fit = "width"
	FitHeight  Fit = "height"
	FitContain Fit = "contain"
	FitCover   Fit = "cover"
)
type Link struct {
	Href       string     `json:"href"`                 // URI or URI template of the linked resource.
	Type       string     `json:"type,omitempty"`       // MIME type of the linked resource.
	Templated  bool       `json:"templated,omitempty"`  // Indicates that a URI template is used in href.
	Title      string     `json:"title,omitempty"`      // Title of the linked resource.
	Rels       Strings    `json:"rel,omitempty"`        // Relation between the linked resource and its containing collection.
	Properties Properties `json:"properties,omitempty"` // Properties associated to the linked resource.
	Height     uint       `json:"height,omitempty"`     // Height of the linked resource in pixels.
	Width      uint       `json:"width,omitempty"`      // Width of the linked resource in pixels.
	Bitrate    float64    `json:"bitrate,omitempty"`    // Bitrate of the linked resource in kbps.
	Duration   float64    `json:"duration,omitempty"`   // Length of the linked resource in seconds.
	Languages  Strings    `json:"language,omitempty"`   // Expected language of the linked resource (BCP 47 tag).
	Alternates LinkList   `json:"alternate,omitempty"`  // Alternate resources for the linked resource.
	Children   LinkList   `json:"children,omitempty"`   // Resources that are children of the linked resource, in the context of a given collection role.
}

Link https://github.com/readium/webpub-manifest/blob/master/README.md#24-the-link-object https://github.com/readium/webpub-manifest/blob/master/schema/link.schema.json

func LinkFromJSON

func LinkFromJSON(rawJson map[string]interface{}, normalizeHref LinkHrefNormalizer) (*Link, error)

Creates an Link from its RWPM JSON representation.

func LinksFromJSONArray

func LinksFromJSONArray(rawJsonArray []interface{}, normalizeHref LinkHrefNormalizer) ([]Link, error)

func (Link) ExpandTemplate

func (l Link) ExpandTemplate(parameters map[string]string) Link

Expands the HREF by replacing URI template variables by the given parameters.

func (Link) MarshalJSON

func (l Link) MarshalJSON() ([]byte, error)

func (Link) MediaType

func (l Link) MediaType() mediatype.MediaType

func (Link) TemplateParameters

func (l Link) TemplateParameters() []string

List of URI template parameter keys, if the Link is templated.

func (Link) ToURL

func (l Link) ToURL(baseURL string) string

Computes an absolute URL to the link, relative to the given [baseUrl]. If the link's [href] is already absolute, the [baseUrl] is ignored.

func (*Link) UnmarshalJSON

func (l *Link) UnmarshalJSON(b []byte) error

type LinkHrefNormalizer

type LinkHrefNormalizer func(href string) (string, error)

Function used to recursively transform the href of a Link when parsing its JSON representation.

type LinkList []Link

Slice of links

func (LinkList) AllAreAudio

func (ll LinkList) AllAreAudio() bool

Returns whether all the resources in the collection are audio clips.

func (LinkList) AllAreBitmap

func (ll LinkList) AllAreBitmap() bool

Returns whether all the resources in the collection are bitmaps.

func (LinkList) AllAreHTML

func (ll LinkList) AllAreHTML() bool

Returns whether all the resources in the collection are HTML documents.

func (LinkList) AllAreVideo

func (ll LinkList) AllAreVideo() bool

Returns whether all the resources in the collection are video clips.

func (LinkList) AllAreVisual

func (ll LinkList) AllAreVisual() bool

Returns whether all the resources in the collection are bitmaps or video clips.

func (LinkList) AllMatchMediaType

func (ll LinkList) AllMatchMediaType(mt ...*mediatype.MediaType) bool

Returns whether all the resources in the collection are matching the given media type.

func (LinkList) FilterByMediaType

func (ll LinkList) FilterByMediaType(mt ...*mediatype.MediaType) LinkList

Finds all the links matching any of the given media types.

func (LinkList) FilterByRel

func (ll LinkList) FilterByRel(rel string) LinkList

Finds all the links with the given relation.

func (LinkList) FirstWithHref

func (ll LinkList) FirstWithHref(href string) *Link

Finds the first link matching the given HREF.

func (LinkList) FirstWithMediaType

func (ll LinkList) FirstWithMediaType(mt *mediatype.MediaType) *Link

Finds the first link matching the given media type.

func (LinkList) FirstWithRel

func (ll LinkList) FirstWithRel(rel string) *Link

Finds the first link with the given relation.

func (LinkList) IndexOfFirstWithHref

func (ll LinkList) IndexOfFirstWithHref(href string) int

Returns the first Link with the given [href], or null if not found.

type LocalizedString

type LocalizedString struct {
	Translations map[string]string
}

func LocalizedStringFromJSON

func LocalizedStringFromJSON(d interface{}) (*LocalizedString, error)

func NewLocalizedStringFromString

func NewLocalizedStringFromString(value string) LocalizedString

func NewLocalizedStringFromStrings

func NewLocalizedStringFromStrings(strings map[string]string) LocalizedString

Shortcut to create a LocalizedString using a map of translations indexed by the BCP 47 language tag.

func (*LocalizedString) DefaultTranslation

func (l *LocalizedString) DefaultTranslation() string

func (*LocalizedString) GetOrFallback

func (l *LocalizedString) GetOrFallback(language string) string

GetOrFallback Returns the first translation for the given [language] BCP–47 tag.

func (*LocalizedString) Length

func (l *LocalizedString) Length() int

func (LocalizedString) MarshalJSON

func (l LocalizedString) MarshalJSON() ([]byte, error)

func (*LocalizedString) SetDefaultTranslation

func (l *LocalizedString) SetDefaultTranslation(value string)

func (*LocalizedString) SetTranslation

func (l *LocalizedString) SetTranslation(language string, value string)

func (*LocalizedString) String

func (l *LocalizedString) String() string

func (*LocalizedString) UnmarshalJSON

func (l *LocalizedString) UnmarshalJSON(data []byte) error

type Locations

type Locations struct {
	Fragments        []string               `json:"fragments,omitempty"`        // Contains one or more fragment in the resource referenced by the [Locator].
	Progression      *float64               `json:"progression,omitempty"`      // Progression in the resource expressed as a percentage (between 0 and 1).
	Position         *uint                  `json:"position,omitempty"`         // An index in the publication (>= 1).
	TotalProgression *float64               `json:"totalProgression,omitempty"` // Progression in the publication expressed as a percentage (between 0 and 1).
	OtherLocations   map[string]interface{} // Additional locations for extensions.
}

One or more alternative expressions of the location. https://github.com/readium/architecture/tree/master/models/locators#the-location-object

func LocationsFromJSON

func LocationsFromJSON(rawJson map[string]interface{}) (l Locations, err error)

func (Locations) CSSSelector

func (l Locations) CSSSelector() string

func (Locations) MarshalJSON

func (l Locations) MarshalJSON() ([]byte, error)

func (*Locations) UnmarshalJSON

func (l *Locations) UnmarshalJSON(b []byte) error

type Locator

type Locator struct {
	Href      string    `json:"href"`
	Type      string    `json:"type"`
	Title     string    `json:"title,omitempty"`
	Locations Locations `json:"locations,omitempty"`
	Text      Text      `json:"text,omitempty"`
}

Locator provides a precise location in a publication in a format that can be stored and shared.

There are many different use cases for locators:

  • getting back to the last position in a publication
  • bookmarks
  • highlights & annotations
  • search results
  • human-readable (and shareable) reference in a publication

https://github.com/readium/architecture/tree/master/locators

func LocatorFromJSON

func LocatorFromJSON(rawJson map[string]interface{}) (Locator, error)

func (Locator) MarshalJSON

func (l Locator) MarshalJSON() ([]byte, error)

func (*Locator) UnmarshalJSON

func (l *Locator) UnmarshalJSON(b []byte) error

type Manifest

type Manifest struct {
	Context         Strings  `json:"@context,omitempty"`
	Metadata        Metadata `json:"metadata"`
	Links           LinkList `json:"links"`
	ReadingOrder    LinkList `json:"readingOrder,omitempty"`
	Resources       LinkList `json:"resources,omitempty"` //Replaces the manifest but less redundant
	TableOfContents LinkList `json:"toc,omitempty"`

	Subcollections PublicationCollectionMap `json:"-"` //Extension point for collections that shouldn't show up in the manifest

}

Manifest Main structure for a publication

func ManifestFromJSON

func ManifestFromJSON(rawJson map[string]interface{}, packaged bool) (*Manifest, error)

Parses a Manifest from its RWPM JSON representation.

TODO log [warnings] ? https://readium.org/webpub-manifest/ https://readium.org/webpub-manifest/schema/publication.schema.json

func (Manifest) ConformsTo

func (m Manifest) ConformsTo(profile Profile) bool

Returns whether this manifest conforms to the given Readium Web Publication Profile.

func (Manifest) LinkWithHref

func (m Manifest) LinkWithHref(href string) *Link

Finds the first Link with the given href in the manifest's links. Searches through (in order) the reading order, resources and links recursively following alternate and children links. If there's no match, tries again after removing any query parameter and anchor from the given href.

func (Manifest) LinkWithRel

func (m Manifest) LinkWithRel(rel string) *Link

Finds the first Link with the given relation in the manifest's links.

func (Manifest) LinksWithRel

func (m Manifest) LinksWithRel(rel string) []Link

Finds all [Link]s having the given [rel] in the manifest's links.

func (m Manifest) LocatorFromLink(link Link) *Locator

Creates a new Locator object from a Link to a resource of this manifest. Returns nil if the resource is not found in this manifest.

func (Manifest) MarshalJSON

func (m Manifest) MarshalJSON() ([]byte, error)

func (Manifest) ToMap

func (m Manifest) ToMap(selfLink *Link) map[string]interface{}

func (*Manifest) UnmarshalJSON

func (m *Manifest) UnmarshalJSON(b []byte) error

type Metadata

type Metadata struct {
	Identifier         string                 `json:"identifier,omitempty"`
	Type               string                 `json:"@type,omitempty"`
	ConformsTo         Profiles               `json:"conformsTo,omitempty"`
	LocalizedTitle     LocalizedString        `json:"title" validate:"required"`
	LocalizedSubtitle  *LocalizedString       `json:"subtitle,omitempty"`
	LocalizedSortAs    *LocalizedString       `json:"sortAs,omitempty"`
	Accessibility      *A11y                  `json:"accessibility,omitempty"`
	Modified           *time.Time             `json:"modified,omitempty"`
	Published          *time.Time             `json:"published,omitempty"`
	Languages          Strings                `json:"language,omitempty" validate:"BCP47"` // TODO validator
	Subjects           []Subject              `json:"subject,omitempty"`
	Authors            Contributors           `json:"author,omitempty"`
	Translators        Contributors           `json:"translator,omitempty"`
	Editors            Contributors           `json:"editor,omitempty"`
	Artists            Contributors           `json:"artist,omitempty"`
	Illustrators       Contributors           `json:"illustrator,omitempty"`
	Letterers          Contributors           `json:"letterer,omitempty"`
	Pencilers          Contributors           `json:"penciler,omitempty"`
	Colorists          Contributors           `json:"colorist,omitempty"`
	Inkers             Contributors           `json:"inker,omitempty"`
	Narrators          Contributors           `json:"narrator,omitempty"`
	Contributors       Contributors           `json:"contributor,omitempty"`
	Publishers         Contributors           `json:"publisher,omitempty"`
	Imprints           Contributors           `json:"imprint,omitempty"`
	ReadingProgression ReadingProgression     `json:"readingProgression,omitempty" validate:"readingProgression"` // TODO validator.
	Description        string                 `json:"description,omitempty"`
	Duration           *float64               `json:"duration,omitempty" validator:"positive"` // TODO validator
	NumberOfPages      *uint                  `json:"numberOfPages,omitempty"`
	BelongsTo          map[string]Collections `json:"belongsTo,omitempty"`
	Presentation       *Presentation          `json:"presentation,omitempty"`

	OtherMetadata map[string]interface{} `json:"-"` // Extension point for other metadata. TODO implement
}

Metadata for the default context in WebPub

func MetadataFromJSON

func MetadataFromJSON(rawJson map[string]interface{}, normalizeHref LinkHrefNormalizer) (*Metadata, error)

func (Metadata) BelongsToCollections

func (m Metadata) BelongsToCollections() []Collection

func (Metadata) BelongsToSeries

func (m Metadata) BelongsToSeries() []Collection

func (Metadata) EffectiveReadingProgression

func (m Metadata) EffectiveReadingProgression() ReadingProgression

func (Metadata) InferredAccessibility

func (m Metadata) InferredAccessibility() *A11y

InferredAccessibility returns the accessibility metadata inferred from the manifest and stored in OtherMetadata.

func (Metadata) MarshalJSON

func (m Metadata) MarshalJSON() ([]byte, error)

func (Metadata) SetOtherMetadata

func (m Metadata) SetOtherMetadata(key string, value interface{}) error

SetOtherMetadata marshalls the value to a JSON map before storing it in OtherMetadata under the given key.

func (Metadata) SortAs

func (m Metadata) SortAs() string

func (Metadata) Subtitle

func (m Metadata) Subtitle() string

func (Metadata) Title

func (m Metadata) Title() string

func (*Metadata) UnmarshalJSON

func (m *Metadata) UnmarshalJSON(b []byte) error

type Orientation

type Orientation string // Suggested orientation for the device when displaying the linked resource.
const (
	OrientationAuto      Orientation = "auto"
	OrientationLandscape Orientation = "landscape"
	OrientationPortrait  Orientation = "portrait"
)

type Overflow

type Overflow string // Suggested method for handling overflow while displaying the linked resource.
const (
	OverflowAuto      Overflow = "auto"
	OverflowPaginated Overflow = "paginated"
	OverflowScrolled  Overflow = "scrolled"
)

type Page

type Page string // Indicates how the linked resource should be displayed in a reading environment that displays synthetic spreads.
const (
	PageLeft   Page = "left"
	PageRight  Page = "right"
	PageCenter Page = "center"
)

type Presentation

type Presentation struct {
	Clipped     *bool        `json:"clipped,omitempty"`     // Specifies whether or not the parts of a linked resource that flow out of the viewport are clipped.
	Continuous  *bool        `json:"continuous,omitempty"`  // Indicates how the progression between resources from the [readingOrder] should be handled.
	Fit         *Fit         `json:"fit,omitempty"`         // Suggested method for constraining a resource inside the viewport.
	Orientation *Orientation `json:"orientation,omitempty"` // Suggested orientation for the device when displaying the linked resource.
	Overflow    *Overflow    `json:"overflow,omitempty"`    // Suggested method for handling overflow while displaying the linked resource.
	Spread      *Spread      `json:"spread,omitempty"`      // Indicates the condition to be met for the linked resource to be rendered within a synthetic spread.
	Layout      *EPUBLayout  `json:"layout,omitempty"`      // Hints how the layout of the resource should be presented (EPUB extension).
}

*

func NewPresentation

func NewPresentation() *Presentation

func (Presentation) LayoutOf

func (p Presentation) LayoutOf(link Link) EPUBLayout

Get the layout of the given resource in this publication. Falls back on REFLOWABLE.

func (Presentation) MarshalJSON

func (p Presentation) MarshalJSON() ([]byte, error)

func (*Presentation) UnmarshalJSON

func (p *Presentation) UnmarshalJSON(data []byte) error

type Profile

type Profile string

type Profiles

type Profiles []Profile

TODO replace with generic

func (Profiles) MarshalJSON

func (p Profiles) MarshalJSON() ([]byte, error)

type Properties

type Properties map[string]interface{}

func PropertiesFromJSON

func PropertiesFromJSON(rawJson interface{}) (Properties, error)

func (Properties) Clipped

func (p Properties) Clipped() *bool

Specifies whether or not the parts of a linked resource that flow out of the viewport are clippped.

func (Properties) Contains

func (p Properties) Contains() []string

func (Properties) Encryption

func (p Properties) Encryption() *Encryption

func (Properties) Fit

func (p Properties) Fit() Fit

Suggested method for constraining a resource inside the viewport.

func (*Properties) Get

func (p *Properties) Get(key string) interface{}

func (Properties) GetBool

func (p Properties) GetBool(key string) *bool

func (Properties) GetString

func (p Properties) GetString(key string) string

func (Properties) Layout

func (p Properties) Layout() EPUBLayout

Hints how the layout of the resource should be presented.

func (Properties) Orientation

func (p Properties) Orientation() Orientation

Suggested orientation for the device when displaying the linked resource.

func (Properties) Overflow

func (p Properties) Overflow() Overflow

Suggested method for handling overflow while displaying the linked resource.

func (Properties) Page

func (p Properties) Page() Page

Indicates how the linked resource should be displayed in a reading environment that displays synthetic spreads.

func (Properties) Spread

func (p Properties) Spread() Spread

Indicates the condition to be met for the linked resource to be rendered within a synthetic spread.

func (*Properties) UnmarshalJSON

func (p *Properties) UnmarshalJSON(data []byte) error

type PublicationCollection

type PublicationCollection struct {
	Metadata       map[string]interface{}   `json:"metadata,omitempty"`
	Links          []Link                   `json:"links,omitempty"`
	Subcollections PublicationCollectionMap `json:"-"`
}

PublicationCollection can be used as extension point in the Readium Web Publication Manifest. https://readium.org/webpub-manifest/schema/subcollection.schema.json

func PublicationCollectionFromJSON

func PublicationCollectionFromJSON(rawJson interface{}, normalizeHref LinkHrefNormalizer) (*PublicationCollection, error)

Parses a PublicationCollection from its RWPM JSON representation.

TODO log [warnings] ?

The [links]' href and their children's will be normalized recursively using the provided [normalizeHref] closure.

func (PublicationCollection) MarshalJSON

func (pc PublicationCollection) MarshalJSON() ([]byte, error)

func (*PublicationCollection) UnmarshalJSON

func (pc *PublicationCollection) UnmarshalJSON(b []byte) error

type PublicationCollectionMap

type PublicationCollectionMap map[string][]PublicationCollection

func PublicationCollectionsFromJSON

func PublicationCollectionsFromJSON(rawJson map[string]interface{}, normalizeHref LinkHrefNormalizer) (PublicationCollectionMap, error)

Parses a map of PublicationCollection indexed by their roles from its RWPM JSON representation.

The [Links]' href and their children's will be normalized recursively using the provided [normalizeHref] closure.

func (PublicationCollectionMap) MarshalJSON

func (pcm PublicationCollectionMap) MarshalJSON() ([]byte, error)

func (*PublicationCollectionMap) UnmarshalJSON

func (pcm *PublicationCollectionMap) UnmarshalJSON(b []byte) error

type ReadingProgression

type ReadingProgression string

ReadingProgression This is not a proper enum replacement! Use the validator to enforce the values

const (
	Auto ReadingProgression = "auto"
	LTR  ReadingProgression = "ltr"
	RTL  ReadingProgression = "rtl"
	TTB  ReadingProgression = "ttb"
	BTT  ReadingProgression = "btt"
)

type Spread

type Spread string // Indicates the condition to be met for the linked resource to be rendered within a synthetic spread.
const (
	SpreadAuto      Spread = "auto"
	SpreadBoth      Spread = "both"
	SpreadNone      Spread = "none"
	SpreadLandscape Spread = "landscape"
)

type Strings

type Strings []string

TODO replace with generic

func (Strings) MarshalJSON

func (s Strings) MarshalJSON() ([]byte, error)

type Subject

type Subject struct {
	LocalizedName   LocalizedString  `json:"name" validate:"required"`
	LocalizedSortAs *LocalizedString `json:"sortAs,omitempty"`
	Scheme          string           `json:"scheme,omitempty"`
	Code            string           `json:"code,omitempty"`
	Links           []Link           `json:"links,omitempty"`
}

Subject https://github.com/readium/webpub-manifest/tree/master/contexts/default#subjects https://github.com/readium/webpub-manifest/blob/master/schema/subject-object.schema.json

func SubjectFromJSON

func SubjectFromJSON(rawJson interface{}, normalizeHref LinkHrefNormalizer) (*Subject, error)

Parses a Subject from its RWPM JSON representation. A subject can be parsed from a single string, or a full-fledged object. The [links]' href and their children's will be normalized recursively using the provided [normalizeHref] closure.

func SubjectFromJSONArray

func SubjectFromJSONArray(rawJsonArray interface{}, normalizeHref LinkHrefNormalizer) ([]Subject, error)

Creates a list of Subject from its RWPM JSON representation. The [links]' href and their children's will be normalized recursively using the provided [normalizeHref] closure.

func (Subject) MarshalJSON

func (s Subject) MarshalJSON() ([]byte, error)

func (Subject) Name

func (s Subject) Name() string

func (Subject) SortAs

func (s Subject) SortAs() string

func (*Subject) UnmarshalJSON

func (s *Subject) UnmarshalJSON(data []byte) error

type Text

type Text struct {
	Before    string `json:"before,omitempty"`    // The text before the locator.
	Highlight string `json:"highlight,omitempty"` // The text at the locator.
	After     string `json:"after,omitempty"`     // The text after the locator.
}

Textual context of the locator. A Locator Text Object contains multiple text fragments, useful to give a context to the Locator or for highlights. https://github.com/readium/architecture/tree/master/models/locators#the-text-object

func TextFromJSON

func TextFromJSON(rawJson map[string]interface{}) (t Text)

Jump to

Keyboard shortcuts

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