Documentation
¶
Index ¶
- Constants
- Variables
- func GetRootFilePath(ctx context.Context, fetcher fetcher.Fetcher) (url.URL, error)
- func MediaOverlayFactory() pub.ServiceFactory
- func ParseClockValue(raw string) *float64
- func ParseEncryption(document *xmlquery.Node, scheme string) (ret map[string]manifest.Encryption)
- func ParseNCX(document *xmlquery.Node, filePath url.URL) map[string]manifest.LinkList
- func ParseNavDoc(document *xmlquery.Node, filePath url.URL) map[string]manifest.LinkList
- func ParseSMILDocument(document *xmlquery.Node, filePath url.URL) (*manifest.GuidedNavigationDocument, error)
- func ParseSMILPar(par *xmlquery.Node, filePath url.URL) (*manifest.GuidedNavigationObject, error)
- func ParseSMILSeq(seq *xmlquery.Node, filePath url.URL) ([]manifest.GuidedNavigationObject, error)
- func PositionsServiceFactory(reflowableStrategy ReflowableStrategy) pub.ServiceFactory
- func SelectNodeAttrNs(n *xmlquery.Node, ns, name string) string
- type ArchiveEntryLength
- type DefaultVocab
- type DeobfuscatingResource
- func (d DeobfuscatingResource) CRC32Checksum(ctx context.Context) *uint32
- func (d DeobfuscatingResource) CompressedAs(compressionMethod archive.CompressionMethod) bool
- func (d DeobfuscatingResource) CompressedLength(ctx context.Context) int64
- func (d DeobfuscatingResource) Read(ctx context.Context, start, end int64) ([]byte, *fetcher.ResourceError)
- func (d DeobfuscatingResource) ReadCompressed(ctx context.Context) ([]byte, *fetcher.ResourceError)
- func (d DeobfuscatingResource) ReadCompressedGzip(ctx context.Context) ([]byte, *fetcher.ResourceError)
- func (d DeobfuscatingResource) Stream(ctx context.Context, w io.Writer, start int64, end int64) (int64, *fetcher.ResourceError)
- func (d DeobfuscatingResource) StreamCompressed(ctx context.Context, w io.Writer) (int64, *fetcher.ResourceError)
- func (d DeobfuscatingResource) StreamCompressedGzip(ctx context.Context, w io.Writer) (int64, *fetcher.ResourceError)
- type Deobfuscator
- type EPUBLink
- type EPUBMetadata
- type Item
- type ItemRef
- type LinkMetadataAdapter
- type MediaOverlayService
- func (s *MediaOverlayService) Close()
- func (s *MediaOverlayService) Get(ctx context.Context, link manifest.Link) (fetcher.Resource, bool)
- func (s *MediaOverlayService) GuideForResource(ctx context.Context, href string) (*manifest.GuidedNavigationDocument, error)
- func (s *MediaOverlayService) HasGuideForResource(href string) bool
- func (s *MediaOverlayService) Links() manifest.LinkList
- type MetadataItem
- func (m MetadataItem) AlternateScript() map[string]string
- func (m MetadataItem) Authority() string
- func (m MetadataItem) CollectionType() string
- func (m MetadataItem) DisplaySeq() *int
- func (m MetadataItem) FileAs() (string, string)
- func (m MetadataItem) FirstValue(property string) string
- func (m MetadataItem) GroupPosition() *float64
- func (m MetadataItem) Identifiers() []string
- func (m MetadataItem) LocalizedString() manifest.LocalizedString
- func (m MetadataItem) Role() string
- func (m MetadataItem) Term() string
- func (m MetadataItem) TitleType() string
- func (m MetadataItem) ToCollection() (string, *manifest.Contributor, error)
- func (m MetadataItem) ToContributor() (string, *manifest.Contributor, error)
- func (m MetadataItem) ToMap() interface{}
- func (m MetadataItem) ToSubject() (*manifest.Subject, error)
- func (m MetadataItem) ToTitle() (*Title, error)
- type MetadataParser
- type OriginalLength
- type PackageDocument
- type Parser
- type PositionsService
- func (s *PositionsService) Close()
- func (s *PositionsService) Get(ctx context.Context, link manifest.Link) (fetcher.Resource, bool)
- func (s *PositionsService) Links() manifest.LinkList
- func (s *PositionsService) Positions(ctx context.Context) []manifest.Locator
- func (s *PositionsService) PositionsByReadingOrder(ctx context.Context) [][]manifest.Locator
- type PubMetadataAdapter
- func (m PubMetadataAdapter) Accessibility() *manifest.A11y
- func (m PubMetadataAdapter) BelongsToCollections() []manifest.Collection
- func (m PubMetadataAdapter) BelongsToSeries() []manifest.Collection
- func (m *PubMetadataAdapter) Contributors(role string) []manifest.Contributor
- func (m PubMetadataAdapter) Cover() string
- func (m PubMetadataAdapter) Description() string
- func (m PubMetadataAdapter) Duration() *float64
- func (m PubMetadataAdapter) First(property string) (item MetadataItem, ok bool)
- func (m PubMetadataAdapter) FirstLink(rel string) (EPUBLink, bool)
- func (m PubMetadataAdapter) FirstLinkRefining(rel string, refinedID string) (EPUBLink, bool)
- func (m PubMetadataAdapter) FirstValue(property string) string
- func (m *PubMetadataAdapter) Identifiers() (string, []manifest.AltIdentifier)
- func (m PubMetadataAdapter) Languages() []string
- func (m *PubMetadataAdapter) Layout() manifest.Layout
- func (m PubMetadataAdapter) Links(rel string) []EPUBLink
- func (m PubMetadataAdapter) LocalizedSortAs() *manifest.LocalizedString
- func (m PubMetadataAdapter) LocalizedSubtitle() *manifest.LocalizedString
- func (m PubMetadataAdapter) LocalizedTitle() manifest.LocalizedString
- func (m *PubMetadataAdapter) MediaOverlay() *manifest.MediaOverlay
- func (m PubMetadataAdapter) Metadata() manifest.Metadata
- func (m PubMetadataAdapter) Modified() *time.Time
- func (m *PubMetadataAdapter) OtherMetadata() map[string]interface{}
- func (m PubMetadataAdapter) Published() *time.Time
- func (m *PubMetadataAdapter) ReadingProgression() manifest.ReadingProgression
- func (m *PubMetadataAdapter) Subjects() []manifest.Subject
- func (m PubMetadataAdapter) TDM() *manifest.TDM
- func (m PubMetadataAdapter) Values(property string) []string
- type PublicationFactory
- type ReflowableStrategy
- type Spine
- type Title
Constants ¶
const ( NamespaceOPC = "urn:oasis:names:tc:opendocument:xmlns:container" NamespaceENC = "http://www.w3.org/2001/04/xmlenc#" NamespaceSIG = "http://www.w3.org/2000/09/xmldsig#" NamespaceCOMP = "http://www.idpf.org/2016/encryption#compression" NamespaceOPF = "http://www.idpf.org/2007/opf" NamespaceDC = "http://purl.org/dc/elements/1.1/" NamespaceOPS = "http://www.idpf.org/2007/ops" NamespaceXHTML = "http://www.w3.org/1999/xhtml" NamespaceSMIL = "http://www.w3.org/ns/SMIL" NamespaceSMIL2 = "http://www.w3.org/2001/SMIL20/" NamespaceNCX = "http://www.daisy.org/z3986/2005/ncx/" )
Namespaces
const ( VocabularyMeta = "http://idpf.org/epub/vocab/package/meta/#" VocabularyLink = "http://idpf.org/epub/vocab/package/link/#" VocabularyItem = "http://idpf.org/epub/vocab/package/item/#" VocabularyItemref = "http://idpf.org/epub/vocab/package/itemref/#" VocabularyMedia = "http://www.idpf.org/epub/vocab/overlays/#" VocabularyRendition = "http://www.idpf.org/vocab/rendition/#" VocabularyType = "http://idpf.org/epub/vocab/structure/#" // this is a guessed value VocabularyDCTerms = "http://purl.org/dc/terms/" VocabularyA11Y = "http://www.idpf.org/epub/vocab/package/a11y/#" VocabularyMARC = "http://id.loc.gov/vocabulary/" VocabularyONIX = "http://www.editeur.org/ONIX/book/codelists/current.html#" VocabularySchema = "http://schema.org/" VocabularyXSD = "http://www.w3.org/2001/XMLSchema#" VocabularyTDM = "http://www.w3.org/ns/tdmrep#" VocabularyMSV = "http://www.idpf.org/epub/vocab/structure/magazine/#" VocabularyPRISM = "http://www.prismstandard.org/specifications/3.0/PRISM_CV_Spec_3.0.htm#" )
Vocabularies
const ( DefaultVocabMeta = iota DefaultVocabLink DefaultVocabItem DefaultVocabItemref DefaultVocabType )
Variables ¶
var ContentReservedPrefixes = map[string]string{ "msv": VocabularyMSV, "prism": VocabularyPRISM, }
var DefaultVocabMap = map[DefaultVocab]string{ DefaultVocabMeta: VocabularyMeta, DefaultVocabLink: VocabularyLink, DefaultVocabItem: VocabularyItem, DefaultVocabItemref: VocabularyItemref, DefaultVocabType: VocabularyType, }
var PackageReservedPrefixes = map[string]string{ "dcterms": VocabularyDCTerms, "media": VocabularyMedia, "rendition": VocabularyRendition, "a11y": VocabularyA11Y, "marc": VocabularyMARC, "onix": VocabularyONIX, "schema": VocabularySchema, "xsd": VocabularyXSD, "tdm": VocabularyTDM, }
var RecommendedReflowableStrategy = ArchiveEntryLength{PageLength: 1024}
Recommended historical strategy: archive entry length split by 1024 bytes pages.
This strategy is used by Adobe RMSDK as well. See https://github.com/readium/architecture/issues/123
Functions ¶
func GetRootFilePath ¶
func MediaOverlayFactory ¶ added in v0.5.0
func MediaOverlayFactory() pub.ServiceFactory
func ParseClockValue ¶
Parse clock values as defined in https://www.w3.org/TR/SMIL/smil-timing.html#q2
func ParseEncryption ¶
func ParseNavDoc ¶
func ParseSMILDocument ¶ added in v0.5.0
func ParseSMILPar ¶ added in v0.5.0
func ParseSMILSeq ¶ added in v0.5.0
func PositionsServiceFactory ¶
func PositionsServiceFactory(reflowableStrategy ReflowableStrategy) pub.ServiceFactory
Types ¶
type ArchiveEntryLength ¶
type ArchiveEntryLength struct {
PageLength int
}
Use the archive entry length (whether it is compressed or stored) and split it by the given [PageLength].
func (ArchiveEntryLength) PositionCount ¶
func (l ArchiveEntryLength) PositionCount(resource fetcher.Resource) uint
PositionCount implements ReflowableStrategy
type DefaultVocab ¶
type DefaultVocab int
type DeobfuscatingResource ¶
type DeobfuscatingResource struct {
fetcher.ProxyResource
// contains filtered or unexported fields
}
func (DeobfuscatingResource) CRC32Checksum ¶ added in v0.13.0
func (d DeobfuscatingResource) CRC32Checksum(ctx context.Context) *uint32
func (DeobfuscatingResource) CompressedAs ¶ added in v0.5.0
func (d DeobfuscatingResource) CompressedAs(compressionMethod archive.CompressionMethod) bool
CompressedAs implements CompressedResource
func (DeobfuscatingResource) CompressedLength ¶ added in v0.5.0
func (d DeobfuscatingResource) CompressedLength(ctx context.Context) int64
CompressedLength implements CompressedResource
func (DeobfuscatingResource) Read ¶
func (d DeobfuscatingResource) Read(ctx context.Context, start, end int64) ([]byte, *fetcher.ResourceError)
func (DeobfuscatingResource) ReadCompressed ¶ added in v0.5.0
func (d DeobfuscatingResource) ReadCompressed(ctx context.Context) ([]byte, *fetcher.ResourceError)
ReadCompressed implements CompressedResource
func (DeobfuscatingResource) ReadCompressedGzip ¶ added in v0.5.0
func (d DeobfuscatingResource) ReadCompressedGzip(ctx context.Context) ([]byte, *fetcher.ResourceError)
ReadCompressedGzip implements CompressedResource
func (DeobfuscatingResource) Stream ¶
func (d DeobfuscatingResource) Stream(ctx context.Context, w io.Writer, start int64, end int64) (int64, *fetcher.ResourceError)
func (DeobfuscatingResource) StreamCompressed ¶ added in v0.5.0
func (d DeobfuscatingResource) StreamCompressed(ctx context.Context, w io.Writer) (int64, *fetcher.ResourceError)
StreamCompressed implements CompressedResource
func (DeobfuscatingResource) StreamCompressedGzip ¶ added in v0.5.0
func (d DeobfuscatingResource) StreamCompressedGzip(ctx context.Context, w io.Writer) (int64, *fetcher.ResourceError)
StreamCompressedGzip implements CompressedResource
type Deobfuscator ¶
type Deobfuscator struct {
// contains filtered or unexported fields
}
func NewDeobfuscator ¶
func NewDeobfuscator(identifier string) Deobfuscator
type EPUBMetadata ¶
type EPUBMetadata struct {
// contains filtered or unexported fields
}
type Item ¶
type LinkMetadataAdapter ¶
type LinkMetadataAdapter = metadataAdapter
type MediaOverlayService ¶ added in v0.5.0
type MediaOverlayService struct {
// contains filtered or unexported fields
}
func (*MediaOverlayService) Close ¶ added in v0.5.0
func (s *MediaOverlayService) Close()
func (*MediaOverlayService) GuideForResource ¶ added in v0.5.0
func (s *MediaOverlayService) GuideForResource(ctx context.Context, href string) (*manifest.GuidedNavigationDocument, error)
func (*MediaOverlayService) HasGuideForResource ¶ added in v0.5.0
func (s *MediaOverlayService) HasGuideForResource(href string) bool
func (*MediaOverlayService) Links ¶ added in v0.5.0
func (s *MediaOverlayService) Links() manifest.LinkList
type MetadataItem ¶
type MetadataItem struct {
// contains filtered or unexported fields
}
MetadataItem
func (MetadataItem) AlternateScript ¶
func (m MetadataItem) AlternateScript() map[string]string
func (MetadataItem) Authority ¶
func (m MetadataItem) Authority() string
func (MetadataItem) CollectionType ¶
func (m MetadataItem) CollectionType() string
func (MetadataItem) DisplaySeq ¶
func (m MetadataItem) DisplaySeq() *int
func (MetadataItem) FileAs ¶
func (m MetadataItem) FileAs() (string, string)
func (MetadataItem) FirstValue ¶
func (m MetadataItem) FirstValue(property string) string
func (MetadataItem) GroupPosition ¶
func (m MetadataItem) GroupPosition() *float64
func (MetadataItem) Identifiers ¶ added in v0.11.0
func (m MetadataItem) Identifiers() []string
func (MetadataItem) LocalizedString ¶
func (m MetadataItem) LocalizedString() manifest.LocalizedString
func (MetadataItem) Role ¶
func (m MetadataItem) Role() string
func (MetadataItem) Term ¶
func (m MetadataItem) Term() string
func (MetadataItem) TitleType ¶
func (m MetadataItem) TitleType() string
func (MetadataItem) ToCollection ¶
func (m MetadataItem) ToCollection() (string, *manifest.Contributor, error)
func (MetadataItem) ToContributor ¶
func (m MetadataItem) ToContributor() (string, *manifest.Contributor, error)
func (MetadataItem) ToMap ¶
func (m MetadataItem) ToMap() interface{}
func (MetadataItem) ToTitle ¶
func (m MetadataItem) ToTitle() (*Title, error)
type MetadataParser ¶
type MetadataParser struct {
// contains filtered or unexported fields
}
Reference: https://github.com/readium/architecture/blob/master/streamer/parser/metadata.md
func NewMetadataParser ¶
func NewMetadataParser(epubVersion float64, prefixMap map[string]string) MetadataParser
func (MetadataParser) Parse ¶
func (m MetadataParser) Parse(document *xmlquery.Node, filePath url.URL) *EPUBMetadata
type OriginalLength ¶
type OriginalLength struct {
PageLength int
}
Use the original length of each resource (before compression and encryption) and split it by the given [PageLength].
func (OriginalLength) PositionCount ¶
PositionCount implements ReflowableStrategy
type PackageDocument ¶
type PackageDocument struct {
Path url.URL
EPUBVersion float64
EPUBVersionString string
Manifest []Item
Spine Spine
// contains filtered or unexported fields
}
func ParsePackageDocument ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewParser ¶
func NewParser(strategy ReflowableStrategy) Parser
type PositionsService ¶
type PositionsService struct {
// contains filtered or unexported fields
}
Positions Service for an EPUB from its [readingOrder] and fetcher.
The [presentation] is used to apply different calculation strategy if the resource has a reflowable or fixed layout.
https://github.com/readium/architecture/blob/master/models/locators/best-practices/format.md#epub https://github.com/readium/architecture/issues/101
func (*PositionsService) Close ¶
func (s *PositionsService) Close()
func (*PositionsService) Links ¶
func (s *PositionsService) Links() manifest.LinkList
func (*PositionsService) Positions ¶
func (s *PositionsService) Positions(ctx context.Context) []manifest.Locator
Positions implements pub.PositionsService
func (*PositionsService) PositionsByReadingOrder ¶
func (s *PositionsService) PositionsByReadingOrder(ctx context.Context) [][]manifest.Locator
PositionsByReadingOrder implements PositionsService
type PubMetadataAdapter ¶
type PubMetadataAdapter struct {
// contains filtered or unexported fields
}
func (PubMetadataAdapter) Accessibility ¶
func (m PubMetadataAdapter) Accessibility() *manifest.A11y
func (PubMetadataAdapter) BelongsToCollections ¶
func (m PubMetadataAdapter) BelongsToCollections() []manifest.Collection
func (PubMetadataAdapter) BelongsToSeries ¶
func (m PubMetadataAdapter) BelongsToSeries() []manifest.Collection
func (*PubMetadataAdapter) Contributors ¶
func (m *PubMetadataAdapter) Contributors(role string) []manifest.Contributor
func (PubMetadataAdapter) Cover ¶
func (m PubMetadataAdapter) Cover() string
func (PubMetadataAdapter) Description ¶
func (m PubMetadataAdapter) Description() string
func (PubMetadataAdapter) First ¶
func (m PubMetadataAdapter) First(property string) (item MetadataItem, ok bool)
func (PubMetadataAdapter) FirstLinkRefining ¶
func (PubMetadataAdapter) FirstValue ¶
func (*PubMetadataAdapter) Identifiers ¶ added in v0.11.0
func (m *PubMetadataAdapter) Identifiers() (string, []manifest.AltIdentifier)
func (PubMetadataAdapter) Languages ¶
func (m PubMetadataAdapter) Languages() []string
func (*PubMetadataAdapter) Layout ¶ added in v0.11.0
func (m *PubMetadataAdapter) Layout() manifest.Layout
func (PubMetadataAdapter) LocalizedSortAs ¶
func (m PubMetadataAdapter) LocalizedSortAs() *manifest.LocalizedString
func (PubMetadataAdapter) LocalizedSubtitle ¶
func (m PubMetadataAdapter) LocalizedSubtitle() *manifest.LocalizedString
func (PubMetadataAdapter) LocalizedTitle ¶
func (m PubMetadataAdapter) LocalizedTitle() manifest.LocalizedString
func (*PubMetadataAdapter) MediaOverlay ¶ added in v0.5.0
func (m *PubMetadataAdapter) MediaOverlay() *manifest.MediaOverlay
func (PubMetadataAdapter) Metadata ¶
func (m PubMetadataAdapter) Metadata() manifest.Metadata
func (PubMetadataAdapter) Modified ¶
func (m PubMetadataAdapter) Modified() *time.Time
func (*PubMetadataAdapter) OtherMetadata ¶
func (m *PubMetadataAdapter) OtherMetadata() map[string]interface{}
func (PubMetadataAdapter) Published ¶
func (m PubMetadataAdapter) Published() *time.Time
func (*PubMetadataAdapter) ReadingProgression ¶
func (m *PubMetadataAdapter) ReadingProgression() manifest.ReadingProgression
func (*PubMetadataAdapter) Subjects ¶
func (m *PubMetadataAdapter) Subjects() []manifest.Subject
func (PubMetadataAdapter) TDM ¶ added in v0.7.1
func (m PubMetadataAdapter) TDM() *manifest.TDM
https://www.w3.org/community/reports/tdmrep/CG-FINAL-tdmrep-20240510/#sec-epub3
type PublicationFactory ¶
type PublicationFactory struct {
FallbackTitle string
PackageDocument PackageDocument
EncryptionData map[string]manifest.Encryption
DisplayOptions map[string]string
// contains filtered or unexported fields
}
func (PublicationFactory) Create ¶
func (f PublicationFactory) Create() manifest.Manifest
type ReflowableStrategy ¶
type ReflowableStrategy interface {
PositionCount(resource fetcher.Resource) uint // Returns the number of positions in the given [resource] according to the strategy.
}
Strategy used to calculate the number of positions in a reflowable resource.
Note that a fixed-layout resource always has a single position.