Documentation
¶
Index ¶
- Variables
- func GetForContentService(ctx context.Context, service ContentService, link manifest.Link) (fetcher.Resource, bool)
- func GetForGuidedNavigationService(ctx context.Context, service GuidedNavigationService, link manifest.Link) (fetcher.Resource, bool)
- func GetForMediaOverlayService(ctx context.Context, service GuidedNavigationService, link manifest.Link) (fetcher.Resource, bool)
- func GetForPositionsService(ctx context.Context, service PositionsService, link manifest.Link) (fetcher.Resource, bool)
- type Builder
- type ContentService
- type Context
- type DefaultContentService
- type GuidedNavigationService
- type HTMLGuidedNavigationService
- func (s *HTMLGuidedNavigationService) Close()
- func (s *HTMLGuidedNavigationService) Get(ctx context.Context, link manifest.Link) (fetcher.Resource, bool)
- func (s *HTMLGuidedNavigationService) GuideForResource(ctx context.Context, href string) (*guidednavigation.GuidedNavigationDocument, error)
- func (s *HTMLGuidedNavigationService) HasGuideForResource(href string) bool
- func (s *HTMLGuidedNavigationService) Links() manifest.LinkList
- type PerResourcePositionsService
- func (s PerResourcePositionsService) Close()
- func (s PerResourcePositionsService) Get(ctx context.Context, link manifest.Link) (fetcher.Resource, bool)
- func (s PerResourcePositionsService) Links() manifest.LinkList
- func (s PerResourcePositionsService) Positions(ctx context.Context) []manifest.Locator
- func (s PerResourcePositionsService) PositionsByReadingOrder(ctx context.Context) [][]manifest.Locator
- type PositionsService
- type Publication
- func (p Publication) BaseURL() url.URL
- func (p Publication) Close()
- func (p Publication) ConformsTo(profile manifest.Profile) bool
- func (p Publication) FindService(serviceName ServiceName) Service
- func (p Publication) Get(ctx context.Context, link manifest.Link) fetcher.Resource
- func (p Publication) JSONManifest() (string, error)
- func (p Publication) LinkWithHref(href url.URL) *manifest.Link
- func (p Publication) LinkWithRel(rel string) *manifest.Link
- func (p Publication) LinksWithRel(rel string) []manifest.Link
- func (p Publication) LocatorFromLink(link manifest.Link) *manifest.Locator
- func (p *Publication) Positions(ctx context.Context) []manifest.Locator
- func (p Publication) PositionsByReadingOrder(ctx context.Context) [][]manifest.Locator
- func (p Publication) PositionsFromManifest(ctx context.Context) []manifest.Locator
- type Service
- type ServiceFactory
- type ServiceName
- type ServicesBuilder
- func (s *ServicesBuilder) Build(context Context) map[ServiceName]Service
- func (s *ServicesBuilder) Decorate(name ServiceName, transform func(*ServiceFactory) ServiceFactory)
- func (s *ServicesBuilder) ExposeLinks(name ServiceName)
- func (s *ServicesBuilder) Get(name ServiceName) *ServiceFactory
- func (s *ServicesBuilder) HideLinks(name ServiceName)
- func (s *ServicesBuilder) Remove(name ServiceName)
- func (s *ServicesBuilder) RemoveExcept(name ...ServiceName)
- func (s *ServicesBuilder) Services() []ServiceName
- func (s *ServicesBuilder) Set(name ServiceName, factory *ServiceFactory)
Constants ¶
This section is empty.
Variables ¶
var ContentLink = manifest.Link{ Href: manifest.MustNewHREFFromString("~readium/content.json", false), MediaType: &mediatype.ReadiumContentDocument, }
Href: manifest.MustNewHREFFromString("~readium/guided-navigation.json{?ref}", true), MediaType: &mediatype.ReadiumGuidedNavigationDocument, }
GuidedNavigationLink is the templated link of the guided navigation service, which generates guided navigation documents from the publication's (X)HTML documents. It is advertised in the manifest's links when the service is public.
var MediaOverlayLink = manifest.Link{ Href: manifest.MustNewHREFFromString("~readium/media-overlay.json{?ref}", true), MediaType: &mediatype.ReadiumGuidedNavigationDocument, }
MediaOverlayLink is the templated link of the media overlay service, which converts a resource's SMIL media overlay into a guided navigation document. It is never advertised in the manifest's links: the service replaces each SMIL alternate with an expansion of this link instead.
var PositionsLink = manifest.Link{ Href: manifest.MustNewHREFFromString("~readium/positions.json", false), MediaType: &mediatype.ReadiumPositionList, }
Functions ¶
func GetForContentService ¶
func GetForGuidedNavigationService ¶ added in v0.5.0
func GetForGuidedNavigationService(ctx context.Context, service GuidedNavigationService, link manifest.Link) (fetcher.Resource, bool)
GetForGuidedNavigationService serves a GuidedNavigationLink expansion from the given service.
func GetForMediaOverlayService ¶ added in v0.16.0
func GetForMediaOverlayService(ctx context.Context, service GuidedNavigationService, link manifest.Link) (fetcher.Resource, bool)
GetForMediaOverlayService serves a MediaOverlayLink expansion from the given service.
func GetForPositionsService ¶
Types ¶
type Builder ¶
type Builder struct {
Manifest manifest.Manifest
Fetcher fetcher.Fetcher
ServicesBuilder ServicesBuilder
}
func NewBuilder ¶
func (Builder) Build ¶
func (b Builder) Build() *Publication
type ContentService ¶
type ContentService interface {
Service
Content(start *manifest.Locator) content.Content // Creates a [Content] starting from the given [start] location.
}
PositionsService implements Service Provides a way to extract the raw [Content] of a Publication.
type DefaultContentService ¶
type DefaultContentService struct {
// contains filtered or unexported fields
}
Implements ContentService
func (DefaultContentService) Close ¶
func (s DefaultContentService) Close()
func (DefaultContentService) Content ¶
func (s DefaultContentService) Content(start *manifest.Locator) content.Content
func (DefaultContentService) Links ¶
func (s DefaultContentService) Links() manifest.LinkList
type GuidedNavigationService ¶ added in v0.5.0
type GuidedNavigationService interface {
Service
}
GuidedNavigationService implements Service Provides a way to access guided navigation documents for resources of a Publication.
type HTMLGuidedNavigationService ¶ added in v0.16.0
type HTMLGuidedNavigationService struct {
// contains filtered or unexported fields
}
HTMLGuidedNavigationService provides guided navigation documents generated from the (X)HTML documents of a publication's reading order and resources.
func (*HTMLGuidedNavigationService) Close ¶ added in v0.16.0
func (s *HTMLGuidedNavigationService) Close()
func (*HTMLGuidedNavigationService) GuideForResource ¶ added in v0.16.0
func (s *HTMLGuidedNavigationService) GuideForResource(ctx context.Context, href string) (*guidednavigation.GuidedNavigationDocument, error)
func (*HTMLGuidedNavigationService) HasGuideForResource ¶ added in v0.16.0
func (s *HTMLGuidedNavigationService) HasGuideForResource(href string) bool
func (*HTMLGuidedNavigationService) Links ¶ added in v0.16.0
func (s *HTMLGuidedNavigationService) Links() manifest.LinkList
type PerResourcePositionsService ¶
type PerResourcePositionsService struct {
// contains filtered or unexported fields
}
PerResourcePositionsService implements PositionsService Simple PositionsService which generates one position per [readingOrder] resource.
func (PerResourcePositionsService) Close ¶
func (s PerResourcePositionsService) Close()
func (PerResourcePositionsService) Links ¶
func (s PerResourcePositionsService) Links() manifest.LinkList
func (PerResourcePositionsService) Positions ¶
func (s PerResourcePositionsService) Positions(ctx context.Context) []manifest.Locator
func (PerResourcePositionsService) PositionsByReadingOrder ¶
func (s PerResourcePositionsService) PositionsByReadingOrder(ctx context.Context) [][]manifest.Locator
type PositionsService ¶
type PositionsService interface {
Service
PositionsByReadingOrder(ctx context.Context) [][]manifest.Locator // Returns the list of all the positions in the publication, grouped by the resource reading order index.
Positions(ctx context.Context) []manifest.Locator // Returns the list of all the positions in the publication. (flattening of PositionsByReadingOrder)
}
PositionsService implements Service Provides a list of discrete locations in the publication, no matter what the original format is.
type Publication ¶
type Publication struct {
Manifest manifest.Manifest // The manifest holding the publication metadata extracted from the publication file.
Fetcher fetcher.Fetcher // The underlying fetcher used to read publication resources.
// contains filtered or unexported fields
}
The Publication shared model is the entrypoint for all the metadata and services related to a Readium publication.
func New ¶
func New(m manifest.Manifest, f fetcher.Fetcher, b *ServicesBuilder) *Publication
func (Publication) BaseURL ¶
func (p Publication) BaseURL() url.URL
The URL where this publication is served, computed from the [Link] with `self` relation.
func (Publication) Close ¶
func (p Publication) Close()
Free up resources associated with the publication
func (Publication) ConformsTo ¶
func (p Publication) ConformsTo(profile manifest.Profile) bool
Returns whether this publication conforms to the given Readium Web Publication Profile.
func (Publication) FindService ¶
func (p Publication) FindService(serviceName ServiceName) Service
Find a service in the publication by its name.
func (Publication) JSONManifest ¶
func (p Publication) JSONManifest() (string, error)
Returns the RWPM JSON representation for this Publication's manifest, as a string.
func (Publication) LinkWithHref ¶
func (p Publication) LinkWithHref(href url.URL) *manifest.Link
Finds the first [Link] with the given href in the publication'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 (Publication) LinkWithRel ¶
func (p Publication) LinkWithRel(rel string) *manifest.Link
Finds the first [Link] having the given [rel] in the publications's links.
func (Publication) LinksWithRel ¶
func (p Publication) LinksWithRel(rel string) []manifest.Link
Finds all [Link]s having the given [rel] in the publications's links.
func (Publication) LocatorFromLink ¶
func (p Publication) LocatorFromLink(link manifest.Link) *manifest.Locator
Creates a new [Locator] object from a [Link] to a resource of this publication. Returns nil if the resource is not found in this publication.
func (*Publication) Positions ¶
func (p *Publication) Positions(ctx context.Context) []manifest.Locator
func (Publication) PositionsByReadingOrder ¶
func (p Publication) PositionsByReadingOrder(ctx context.Context) [][]manifest.Locator
func (Publication) PositionsFromManifest ¶
func (p Publication) PositionsFromManifest(ctx context.Context) []manifest.Locator
type Service ¶
type Service interface {
Links() manifest.LinkList // Links to be added to the publication
Get(ctx context.Context, link manifest.Link) (fetcher.Resource, bool) // A service can return a Resource that supplements, replaces or compensates for other links
Close() // Closes any opened file handles, removes temporary files, etc.
}
Base interface to be implemented by all publication services.
type ServiceFactory ¶
func DefaultContentServiceFactory ¶
func DefaultContentServiceFactory(resourceContentIteratorFactories []iterator.ResourceContentIteratorFactory) ServiceFactory
func HTMLGuidedNavigationServiceFactory ¶ added in v0.16.0
func HTMLGuidedNavigationServiceFactory(opts ...converter.Option) ServiceFactory
HTMLGuidedNavigationServiceFactory creates a service generating guided navigation documents from the (X)HTML documents of a publication's reading order and resources. It never touches SMIL media overlays (see the EPUB parser's media overlay service for those) and adds nothing to the manifest besides its own templated link when public. The options are passed to the HTML converter, e.g. converter.WithTextRefLocators. When the publication has no (X)HTML documents, no service is created.
func PerResourcePositionsServiceFactory ¶
func PerResourcePositionsServiceFactory(fallbackMediaType mediatype.MediaType) ServiceFactory
type ServiceName ¶ added in v0.11.0
type ServiceName string
const ( ContentProtectionService_Name ServiceName = "ContentProtectionService" CoverService_Name ServiceName = "CoverService" LocatorService_Name ServiceName = "LocatorService" PositionsService_Name ServiceName = "PositionsService" SearchService_Name ServiceName = "SearchService" ContentService_Name ServiceName = "ContentService" MediaOverlayService_Name ServiceName = "MediaOverlayService" )
type ServicesBuilder ¶
type ServicesBuilder struct {
// contains filtered or unexported fields
}
Builds a list of Service from a collection of service factories. Provides helpers to manipulate the list of services of a pub.Publication.
func NewServicesBuilder ¶
func NewServicesBuilder(fcs map[ServiceName]ServiceFactory) *ServicesBuilder
func (*ServicesBuilder) Build ¶
func (s *ServicesBuilder) Build(context Context) map[ServiceName]Service
Builds the actual list of publication services to use in a Publication.
func (*ServicesBuilder) Decorate ¶
func (s *ServicesBuilder) Decorate(name ServiceName, transform func(*ServiceFactory) ServiceFactory)
Replaces the service factory associated with the given service type with the result of [transform]
func (*ServicesBuilder) ExposeLinks ¶ added in v0.12.0
func (s *ServicesBuilder) ExposeLinks(name ServiceName)
func (*ServicesBuilder) Get ¶
func (s *ServicesBuilder) Get(name ServiceName) *ServiceFactory
Gets the publication service factory for the given service type.
func (*ServicesBuilder) HideLinks ¶ added in v0.12.0
func (s *ServicesBuilder) HideLinks(name ServiceName)
func (*ServicesBuilder) Remove ¶
func (s *ServicesBuilder) Remove(name ServiceName)
Removes the service factory producing the given kind of service, if any.
func (*ServicesBuilder) RemoveExcept ¶ added in v0.11.0
func (s *ServicesBuilder) RemoveExcept(name ...ServiceName)
Removes all service factories except the ones producing the given kinds of services, if any. If no services are given, all service factories are removed.
func (*ServicesBuilder) Services ¶ added in v0.12.0
func (s *ServicesBuilder) Services() []ServiceName
Gets the names of all services currently in the builder
func (*ServicesBuilder) Set ¶
func (s *ServicesBuilder) Set(name ServiceName, factory *ServiceFactory)
Sets the publication service factory for the given service type.