session

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRightsTTL = 1 * time.Hour

By default, rights should be re-fetched every hour

View Source
const ReadingSessionDocumentService_Name pub.ServiceName = "ReadingSessionDocumentService"
View Source
const SchemeReadingSession = "session"

Variables

View Source
var ErrReadingSessionCancelled = errors.New("reading session has been cancelled")
View Source
var ErrReadingSessionExpired = errors.New("reading session has expired")
View Source
var ErrReadingSessionReturned = errors.New("reading session has been returned")
View Source
var ErrReadingSessionRevoked = errors.New("reading session has been revoked")

Functions

This section is empty.

Types

type Fetcher

type Fetcher interface {
	Fetch(ctx context.Context, url string) (*ReadingSessionDocument, error)
}

func NewHTTPFetcher

func NewHTTPFetcher(client *http.Client) Fetcher

type HTTPFetcher

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

func (*HTTPFetcher) Fetch

type ReadingSessionDocument

type ReadingSessionDocument struct {
	Links    manifest.LinkList       `json:"links"`
	Rights   *ReadingSessionRights   `json:"rights,omitempty"`
	Metadata *ReadingSessionMetadata `json:"metadata,omitempty"`
	// contains filtered or unexported fields
}

func (*ReadingSessionDocument) Enforce

func (d *ReadingSessionDocument) Enforce() (bool, error)

func (*ReadingSessionDocument) Injector

func (d *ReadingSessionDocument) Injector() func(builder *pub.Builder) error

Injector merges the reading session document metadata/links into the publication, and adds the rights as a service

func (*ReadingSessionDocument) Merge

Merge overwrites fields in the manifest with any metadata provided by the ReadingSessionDocument, and appends non-publication links to the manifest.

func (*ReadingSessionDocument) PublicationURL

func (d *ReadingSessionDocument) PublicationURL() (string, bool)

PublicationURL returns the href of the first link with rel "publication".

func (*ReadingSessionDocument) RightsService

func (d *ReadingSessionDocument) RightsService() RightsService

type ReadingSessionMetadata

type ReadingSessionMetadata struct {
	Identifier         string                          `json:"identifier,omitempty"`
	Title              *manifest.LocalizedString       `json:"title,omitempty"`
	Subtitle           *manifest.LocalizedString       `json:"subtitle,omitempty"`
	SortAs             *manifest.LocalizedString       `json:"sortAs,omitempty"`
	Type               string                          `json:"@type,omitempty"`
	ConformsTo         manifest.Profiles               `json:"conformsTo,omitempty"`
	Accessibility      *manifest.A11y                  `json:"accessibility,omitempty"`
	Modified           *time.Time                      `json:"modified,omitempty"`
	Published          *time.Time                      `json:"published,omitempty"`
	Languages          manifest.Strings                `json:"language,omitempty"`
	Subjects           []manifest.Subject              `json:"subject,omitempty"`
	Authors            manifest.Contributors           `json:"author,omitempty"`
	Translators        manifest.Contributors           `json:"translator,omitempty"`
	Editors            manifest.Contributors           `json:"editor,omitempty"`
	Artists            manifest.Contributors           `json:"artist,omitempty"`
	Illustrators       manifest.Contributors           `json:"illustrator,omitempty"`
	Letterers          manifest.Contributors           `json:"letterer,omitempty"`
	Pencilers          manifest.Contributors           `json:"penciler,omitempty"`
	Colorists          manifest.Contributors           `json:"colorist,omitempty"`
	Inkers             manifest.Contributors           `json:"inker,omitempty"`
	Narrators          manifest.Contributors           `json:"narrator,omitempty"`
	Contributors       manifest.Contributors           `json:"contributor,omitempty"`
	Publishers         manifest.Contributors           `json:"publisher,omitempty"`
	Imprints           manifest.Contributors           `json:"imprint,omitempty"`
	ReadingProgression manifest.ReadingProgression     `json:"readingProgression,omitempty"`
	Description        string                          `json:"description,omitempty"`
	Duration           *float64                        `json:"duration,omitempty"`
	NumberOfPages      *uint                           `json:"numberOfPages,omitempty"`
	BelongsTo          map[string]manifest.Collections `json:"belongsTo,omitempty"`
}

ReadingSessionMetadata contains optional metadata fields that can override those in a publication manifest. All fields are pointers or slices so that absent fields are distinguishable from zero values.

type ReadingSessionRights

type ReadingSessionRights struct {
	Status   ReadingSessionStatus `json:"status,omitempty"`
	Expires  *time.Time           `json:"expires,omitempty"`
	Copy     *bool                `json:"copy,omitempty"`
	Print    *bool                `json:"print,omitempty"`
	Devtools *bool                `json:"devtools,omitempty"`
	Devices  *uint16              `json:"devices,omitempty"` // Null means use default device count, 0 means no limit on devices
	TTL      *uint                `json:"ttl,omitempty"`     // Seconds until rights should be refreshed, null means use default TTL
	// contains filtered or unexported fields
}

func (*ReadingSessionRights) DeviceCount

func (r *ReadingSessionRights) DeviceCount(defaultDeviceCount uint16) uint16

func (*ReadingSessionRights) Empty

func (r *ReadingSessionRights) Empty() bool

Empty returns true if all fields in the rights object are zero values.

func (*ReadingSessionRights) Enforce

func (r *ReadingSessionRights) Enforce() (bool, error)

Enforce checks the reading session rights and returns an error if access has been denied. A boolean is also returned indicating whether the reading session should be refreshed (fetched again from source)

func (*ReadingSessionRights) UnmarshalJSON

func (r *ReadingSessionRights) UnmarshalJSON(data []byte) error

type ReadingSessionStatus

type ReadingSessionStatus string
const (
	ReadingSessionStatusReady     ReadingSessionStatus = "ready"
	ReadingSessionStatusActive    ReadingSessionStatus = "active"
	ReadingSessionStatusRevoked   ReadingSessionStatus = "revoked"
	ReadingSessionStatusReturned  ReadingSessionStatus = "returned"
	ReadingSessionStatusCancelled ReadingSessionStatus = "cancelled"
	ReadingSessionStatusExpired   ReadingSessionStatus = "expired"
)

type RightsService

type RightsService interface {
	Update(rights *ReadingSessionRights)
}

Jump to

Keyboard shortcuts

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