pub

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentProtectionService_Name = "ContentProtectionService"
	CoverService_Name             = "CoverService"
	LocatorService_Name           = "LocatorService"
	PositionsService_Name         = "PositionsService"
	SearchService_Name            = "SearchService"
	ContentService_Name           = "ContentService"
	GuidedNavigationService_Name  = "GuidedNavigationService"
)

Variables

View Source
var ContentLink = manifest.Link{
	Href:      manifest.MustNewHREFFromString("~readium/content.json", false),
	MediaType: &mediatype.ReadiumContentDocument,
}
View Source
var GuidedNavigationLink = manifest.Link{
	Href:      manifest.MustNewHREFFromString("~readium/guided-navigation.json{?ref}", true),
	MediaType: &mediatype.ReadiumGuidedNavigationDocument,
}
View Source
var PositionsLink = manifest.Link{
	Href:      manifest.MustNewHREFFromString("~readium/positions.json", false),
	MediaType: &mediatype.ReadiumPositionList,
}

Functions

func GetForContentService

func GetForContentService(service ContentService, link manifest.Link) (fetcher.Resource, bool)

func GetForGuidedNavigationService added in v0.5.0

func GetForGuidedNavigationService(service GuidedNavigationService, link manifest.Link) (fetcher.Resource, bool)

func GetForPositionsService

func GetForPositionsService(service PositionsService, link manifest.Link) (fetcher.Resource, bool)

Types

type Builder

type Builder struct {
	Manifest        manifest.Manifest
	Fetcher         fetcher.Fetcher
	ServicesBuilder ServicesBuilder
}

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 Context

type Context struct {
	Manifest manifest.Manifest
	Fetcher  fetcher.Fetcher
}

Container for the context from which a service is created.

func NewContext

func NewContext(manifest manifest.Manifest, fetcher fetcher.Fetcher) Context

type DefaultContentService

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

Implements ContentService

func (DefaultContentService) Close

func (s DefaultContentService) Close()

func (DefaultContentService) Content

func (DefaultContentService) Get

type GuidedNavigationService added in v0.5.0

type GuidedNavigationService interface {
	Service
	GuideForResource(href string) (*manifest.GuidedNavigationDocument, error)
	HasGuideForResource(href string) bool
}

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

func (PerResourcePositionsService) Positions

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 (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

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 (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

type ServiceFactory func(context Context) Service

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.

Jump to

Keyboard shortcuts

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