epub

package
v0.4.3 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: 23 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

View Source
const (
	DefaultVocabMeta = iota
	DefaultVocabLink
	DefaultVocabItem
	DefaultVocabItemref
	DefaultVocabType
)

Variables

View Source
var ContentReservedPrefixes = map[string]string{
	"msv":   VocabularyMSV,
	"prism": VocabularyPRISM,
}
View Source
var PackageReservedPrefixes = map[string]string{
	"dcterms":   VocabularyDCTerms,
	"media":     VocabularyMedia,
	"rendition": VocabularyRendition,
	"a11y":      VocabularyA11Y,
	"marc":      VocabularyMARC,
	"onix":      VocabularyONIX,
	"schema":    VocabularySchema,
	"xsd":       VocabularyXSD,
}
View Source
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 GetRootFilePath(fetcher fetcher.Fetcher) (string, error)

func NSSelect

func NSSelect(namespace, localName string) string

func ParseClockValue

func ParseClockValue(raw string) *float64

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 ParseNCX

func ParseNCX(document *xmlquery.Node, filePath string) map[string]manifest.LinkList

func ParseNavDoc

func ParseNavDoc(document *xmlquery.Node, filePath string) map[string]manifest.LinkList

func PositionsServiceFactory

func PositionsServiceFactory(reflowableStrategy ReflowableStrategy) pub.ServiceFactory

func SelectNodeAttrNs

func SelectNodeAttrNs(n *xmlquery.Node, ns, name string) string

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

func (Deobfuscator) Transform

func (d Deobfuscator) Transform(resource fetcher.Resource) fetcher.Resource
type EPUBLink struct {
	// contains filtered or unexported fields
}

type EPUBMetadata

type EPUBMetadata struct {
	// contains filtered or unexported fields
}

type Item

type Item struct {
	Href string
	ID   string

	MediaType  string
	Properties []string
	// contains filtered or unexported fields
}

func ParseItem

func ParseItem(element *xmlquery.Node, filePath string, prefixMap map[string]string) *Item

type ItemRef

type ItemRef struct {
	// contains filtered or unexported fields
}

func ParseItemRef

func ParseItemRef(element *xmlquery.Node, prefixMap map[string]string) *ItemRef

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) ToSubject

func (m MetadataItem) ToSubject() (*manifest.Subject, error)

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

func (Parser) Parse

func (p Parser) Parse(asset asset.PublicationAsset, f fetcher.Fetcher) (*pub.Builder, error)

Parse implements PublicationParser

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) Get

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) Duration

func (m PubMetadataAdapter) Duration() *float64

func (PubMetadataAdapter) First

func (m PubMetadataAdapter) First(property string) (item MetadataItem, ok bool)
func (m PubMetadataAdapter) FirstLink(rel string) (EPUBLink, bool)

func (PubMetadataAdapter) FirstLinkRefining

func (m PubMetadataAdapter) FirstLinkRefining(rel string, refinedID string) (EPUBLink, bool)

func (PubMetadataAdapter) FirstValue

func (m PubMetadataAdapter) FirstValue(property string) string

func (*PubMetadataAdapter) Identifier

func (m *PubMetadataAdapter) Identifier() string

func (PubMetadataAdapter) Languages

func (m PubMetadataAdapter) Languages() []string
func (m PubMetadataAdapter) Links(rel string) []EPUBLink

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

func (PubMetadataAdapter) Values

func (m PubMetadataAdapter) Values(property string) []string

type PublicationFactory

type PublicationFactory struct {
	FallbackTitle   string
	PackageDocument PackageDocument
	NavigationData  map[string]manifest.LinkList
	EncryptionData  map[string]manifest.Encryption
	DisplayOptions  map[string]string
	// contains filtered or unexported fields
}

func (PublicationFactory) Create

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.

type Spine

type Spine struct {
	TOC string
	// contains filtered or unexported fields
}

func ParseSpine

func ParseSpine(element *xmlquery.Node, prefixMap map[string]string, epubVersion float64) Spine

type Title

type Title struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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