Documentation ¶
Index ¶
- Constants
- Variables
- func GetForContentService(service ContentService, link manifest.Link) (fetcher.Resource, bool)
- func GetForGuidedNavigationService(service GuidedNavigationService, link manifest.Link) (fetcher.Resource, bool)
- func GetForPositionsService(service PositionsService, link manifest.Link) (fetcher.Resource, bool)
- type Builder
- type ContentService
- type Context
- type DefaultContentService
- type GuidedNavigationService
- type PerResourcePositionsService
- func (s PerResourcePositionsService) Close()
- func (s PerResourcePositionsService) Get(link manifest.Link) (fetcher.Resource, bool)
- func (s PerResourcePositionsService) Links() manifest.LinkList
- func (s PerResourcePositionsService) Positions() []manifest.Locator
- func (s PerResourcePositionsService) PositionsByReadingOrder() [][]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 string) Service
- func (p Publication) FindServices(serviceName string) []Service
- func (p Publication) Get(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() []manifest.Locator
- func (p Publication) PositionsByReadingOrder() [][]manifest.Locator
- func (p Publication) PositionsFromManifest() []manifest.Locator
- type Service
- type ServiceFactory
- type ServicesBuilder
- func (s *ServicesBuilder) Build(context Context) map[string]Service
- func (s *ServicesBuilder) Decorate(name string, transform func(*ServiceFactory) ServiceFactory)
- func (s *ServicesBuilder) Get(name string) *ServiceFactory
- func (s *ServicesBuilder) Remove(name string, factory *ServiceFactory)
- func (s *ServicesBuilder) Set(name string, factory *ServiceFactory)
Constants ¶
const ( ContentProtectionService_Name = "ContentProtectionService" CoverService_Name = "CoverService" LocatorService_Name = "LocatorService" PositionsService_Name = "PositionsService" SearchService_Name = "SearchService" ContentService_Name = "ContentService" )
Variables ¶
var ContentLink = manifest.Link{ Href: manifest.MustNewHREFFromString("~readium/content.json", false), MediaType: &mediatype.ReadiumContentDocument, }
manifest.MustNewHREFFromString("~readium/guided-navigation.json{?ref}", true), MediaType: &mediatype.ReadiumGuidedNavigationDocument, }Href:
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 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 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() []manifest.Locator
func (PerResourcePositionsService) PositionsByReadingOrder ¶
func (s PerResourcePositionsService) PositionsByReadingOrder() [][]manifest.Locator
type PositionsService ¶
type PositionsService interface { Service PositionsByReadingOrder() [][]manifest.Locator // Returns the list of all the positions in the publication, grouped by the resource reading order index. Positions() []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 string) Service
func (Publication) FindServices ¶
func (p Publication) FindServices(serviceName string) []Service
func (Publication) Get ¶
func (p Publication) Get(link manifest.Link) fetcher.Resource
Returns the resource targeted by the given non-templated [link].
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() []manifest.Locator
func (Publication) PositionsByReadingOrder ¶
func (p Publication) PositionsByReadingOrder() [][]manifest.Locator
func (Publication) PositionsFromManifest ¶
func (p Publication) PositionsFromManifest() []manifest.Locator
type Service ¶
type Service interface { Links() manifest.LinkList // Links to be added to the publication Get(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 PerResourcePositionsServiceFactory ¶
func PerResourcePositionsServiceFactory(fallbackMediaType mediatype.MediaType) ServiceFactory
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[string]ServiceFactory) *ServicesBuilder
func (*ServicesBuilder) Build ¶
func (s *ServicesBuilder) Build(context Context) map[string]Service
Builds the actual list of publication services to use in a Publication.
func (*ServicesBuilder) Decorate ¶
func (s *ServicesBuilder) Decorate(name string, transform func(*ServiceFactory) ServiceFactory)
Replaces the service factory associated with the given service type with the result of [transform]
func (*ServicesBuilder) Get ¶
func (s *ServicesBuilder) Get(name string) *ServiceFactory
Gets the publication service factory for the given service type.
func (*ServicesBuilder) Remove ¶
func (s *ServicesBuilder) Remove(name string, factory *ServiceFactory)
Removes the service factory producing the given kind of service, if any.
func (*ServicesBuilder) Set ¶
func (s *ServicesBuilder) Set(name string, factory *ServiceFactory)
Sets the publication service factory for the given service type.