Documentation ¶
Index ¶
- Constants
- Variables
- func GetRootFilePath(fetcher fetcher.Fetcher) (string, error)
- func NSSelect(namespace, localName string) string
- func ParseClockValue(raw string) *float64
- func ParseEncryption(document *xmlquery.Node) (ret map[string]manifest.Encryption)
- func ParseNCX(document *xmlquery.Node, filePath string) map[string]manifest.LinkList
- func ParseNavDoc(document *xmlquery.Node, filePath string) map[string]manifest.LinkList
- func PositionsServiceFactory(reflowableStrategy ReflowableStrategy) pub.ServiceFactory
- func SelectNodeAttrNs(n *xmlquery.Node, ns, name string) string
- type ArchiveEntryLength
- type DefaultVocab
- type DeobfuscatingResource
- type Deobfuscator
- type EPUBLink
- type EPUBMetadata
- type Item
- type ItemRef
- type LinkMetadataAdapter
- 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) Identifier() 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
- 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) Identifier() string
- func (m PubMetadataAdapter) Languages() []string
- 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) Metadata() manifest.Metadata
- func (m PubMetadataAdapter) Modified() *time.Time
- func (m *PubMetadataAdapter) OtherMetadata() map[string]interface{}
- func (m *PubMetadataAdapter) Presentation() manifest.Presentation
- func (m PubMetadataAdapter) Published() *time.Time
- func (m *PubMetadataAdapter) ReadingProgression() manifest.ReadingProgression
- func (m *PubMetadataAdapter) Subjects() []manifest.Subject
- 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" 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#" 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, }
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 ParseClockValue ¶
Parse clock values as defined in https://www.w3.org/TR/SMIL/smil-timing.html#q2
func ParseEncryption ¶
func ParseEncryption(document *xmlquery.Node) (ret map[string]manifest.Encryption)
func ParseNavDoc ¶
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) Read ¶
func (d DeobfuscatingResource) Read(start, end int64) ([]byte, *fetcher.ResourceError)
func (DeobfuscatingResource) Stream ¶
func (d DeobfuscatingResource) Stream(w io.Writer, start int64, end int64) (int64, *fetcher.ResourceError)
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 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) Identifier ¶
func (m MetadataItem) Identifier() 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 string) *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 ¶
func (l OriginalLength) PositionCount(resource fetcher.Resource) uint
PositionCount implements ReflowableStrategy
type PackageDocument ¶
type PackageDocument struct { Path string EPUBVersion float64 EPUBVersionString string Manifest []Item Spine Spine // contains filtered or unexported fields }
func ParsePackageDocument ¶
func ParsePackageDocument(document *xmlquery.Node, filePath string) (*PackageDocument, error)
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() []manifest.Locator
Positions implements pub.PositionsService
func (*PositionsService) PositionsByReadingOrder ¶
func (s *PositionsService) PositionsByReadingOrder() [][]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) Identifier ¶
func (m *PubMetadataAdapter) Identifier() string
func (PubMetadataAdapter) Languages ¶
func (m PubMetadataAdapter) Languages() []string
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) 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) Presentation ¶
func (m *PubMetadataAdapter) Presentation() manifest.Presentation
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
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.