opds2

package
v0.0.0-...-9c163cf Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2017 License: BSD-3-Clause Imports: 7 Imported by: 3

Documentation

Overview

Package opds2 provide parsing and generation method for an OPDS2 feed https://github.com/opds-community/opds-revision/blob/master/opds-2.0.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BelongsTo

type BelongsTo struct {
	Series     []Collection `json:"series,omitempty"`
	Collection []Collection `json:"collection,omitempty"`
}

BelongsTo is a list of collections/series that a publication belongs to

type Collection

type Collection struct {
	Name       string  `json:"name"`
	SortAs     string  `json:"sort_as,omitempty"`
	Identifier string  `json:"identifier,omitempty"`
	Position   float32 `json:"position,omitempty"`
	Links      []Link  `json:"links,omitempty"`
}

Collection construct used for collection/serie metadata

type Contributor

type Contributor struct {
	Name       MultiLanguage `json:"name,omitempty"`
	SortAs     string        `json:"sort_as,omitempty"`
	Identifier string        `json:"identifier,omitempty"`
	Role       string        `json:"role,omitempty"`
	Links      []Link        `json:"links,omitempty"`
}

Contributor construct used internally for all contributors

type Facet

type Facet struct {
	Metadata Metadata `json:"metadata"`
	Links    []Link   `json:"links"`
}

Facet is a collection that contains a facet group

type Feed

type Feed struct {
	Context      []string      `json:"@context,omitempty"`
	Metadata     Metadata      `json:"metadata"`
	Links        []Link        `json:"links"`
	Facets       []Facet       `json:"facets,omitempty"`
	Groups       []Group       `json:"groups,omitempty"`
	Publications []Publication `json:"publications,omitempty"`
	Navigation   []Link        `json:"navigation,omitempty"`
}

Feed is a collection as defined in Readium Web Publication Manifest

func New

func New(title string) Feed

New create a new feed structure

func ParseBuffer

func ParseBuffer(buff []byte) (*Feed, error)

ParseBuffer parse opds2 feed from a buffer of byte usually get from a file or url

func ParseFile

func ParseFile(filePath string) (*Feed, error)

ParseFile parse opds2 from a file on filesystem

func ParseURL

func ParseURL(url string) (*Feed, error)

ParseURL parse the opds2 feed from an url

func (*Feed) AddFacet

func (feed *Feed) AddFacet(link Link, group string)

AddFacet add link to facet handler multiple add

func (feed *Feed) AddLink(href string, rel string, typeLink string, templated bool)

AddLink add a new link in feed information at minimum the self link

func (*Feed) AddNavigation

func (feed *Feed) AddNavigation(title string, href string, rel string, typeLink string)

AddNavigation add navigation element in feed

func (*Feed) AddNavigationInGroup

func (feed *Feed) AddNavigationInGroup(link Link, collLink Link)

AddNavigationInGroup add a navigation link to Group

func (*Feed) AddPagination

func (feed *Feed) AddPagination(numberItems int, itemsPerPage int, currentPage int, nextLink string, prevLink string, firstLink string, lastLink string)

AddPagination add pagination and link information in feed

func (*Feed) AddPublicationInGroup

func (feed *Feed) AddPublicationInGroup(publication Publication, collLink Link)

AddPublicationInGroup smart adding of publication in Group

func (*Feed) UnmarshalJSON

func (feed *Feed) UnmarshalJSON(data []byte) error

UnmarshalJSON make all unmarshalling by hand to handle all case

type Group

type Group struct {
	Metadata     Metadata      `json:"metadata"`
	Links        []Link        `json:"links,omitempty"`
	Publications []Publication `json:"publications,omitempty"`
	Navigation   []Link        `json:"navigation,omitempty"`
}

Group is a group collection that must contain publications

type IndirectAcquisition

type IndirectAcquisition struct {
	TypeAcquisition string                `json:"type"`
	Child           []IndirectAcquisition `json:"child,omitempty"`
}

IndirectAcquisition store

type Link struct {
	Href       string        `json:"href"`
	TypeLink   string        `json:"type,omitempty"`
	Rel        StringOrArray `json:"rel,omitempty"`
	Height     int           `json:"height,omitempty"`
	Width      int           `json:"width,omitempty"`
	Title      string        `json:"title,omitempty"`
	Properties *Properties   `json:"properties,omitempty"`
	Duration   string        `json:"duration,omitempty"`
	Templated  bool          `json:"templated,omitempty"`
	Children   []Link        `json:"children,omitempty"`
	Bitrate    int           `json:"bitrate,omitempty"`
}

Link object used in collections and links

type Metadata

type Metadata struct {
	RDFType       string     `json:"@type,omitempty"`
	Title         string     `json:"title"`
	NumberOfItems int        `json:"numberOfItems,omitempty"`
	ItemsPerPage  int        `json:"itemsPerPage,omitempty"`
	CurrentPage   int        `json:"currentPage,omitempty"`
	Modified      *time.Time `json:"modified,omitempty"`
}

Metadata has a limited subset of metadata compared to a publication

type MultiLanguage

type MultiLanguage struct {
	SingleString string
	MultiString  map[string]string
}

MultiLanguage store the a basic string when we only have one lang Store in a hash by language for multiple string representation

func (MultiLanguage) MarshalJSON

func (m MultiLanguage) MarshalJSON() ([]byte, error)

MarshalJSON overwrite json marshalling for MultiLanguage when we have an entry in the Multi fields we use it otherwise we use the single string

func (MultiLanguage) String

func (m MultiLanguage) String() string

type Price

type Price struct {
	Currency string  `json:"currency"`
	Value    float64 `json:"value"`
}

Price price information

type Properties

type Properties struct {
	NumberOfItems       int                   `json:"numberOfItems,omitempty"`
	Price               *Price                `json:"price,omitempty"`
	IndirectAcquisition []IndirectAcquisition `json:"indirectAcquisition,omitempty"`
}

Properties object use to link properties Use also in Rendition for fxl

type Publication

type Publication struct {
	Metadata PublicationMetadata `json:"metadata"`
	Links    []Link              `json:"links"`
	Images   []Link              `json:"images"`
}

Publication is a collection for a given publication

func (*Publication) AddAuthor

func (publication *Publication) AddAuthor(name string, identifier string, sortAs string, href string, typeLink string)

AddAuthor add author to publication with all parameters mostly optional

func (*Publication) AddImage

func (publication *Publication) AddImage(href string, typeImage string, height int, width int)

AddImage add a image link to Publication

func (publication *Publication) AddLink(href string, typeLink string, rel string, title string)

AddLink add a new link to the publication

func (*Publication) AddPublisher

func (publication *Publication) AddPublisher(name string, href string, typeLink string)

AddPublisher add publisher to publication

func (*Publication) AddSerie

func (publication *Publication) AddSerie(name string, position float32, href string, typeLink string)

AddSerie add serie to publication

type PublicationMetadata

type PublicationMetadata struct {
	RDFType         string        `json:"@type,omitempty"` //Defaults to schema.org for EBook
	Title           MultiLanguage `json:"title"`
	Identifier      string        `json:"identifier"`
	Author          []Contributor `json:"author,omitempty"`
	Translator      []Contributor `json:"translator,omitempty"`
	Editor          []Contributor `json:"editor,omitempty"`
	Artist          []Contributor `json:"artist,omitempty"`
	Illustrator     []Contributor `json:"illustrator,omitempty"`
	Letterer        []Contributor `json:"letterer,omitempty"`
	Penciler        []Contributor `json:"penciler,omitempty"`
	Colorist        []Contributor `json:"colorist,omitempty"`
	Inker           []Contributor `json:"inker,omitempty"`
	Narrator        []Contributor `json:"narrator,omitempty"`
	Contributor     []Contributor `json:"contributor,omitempty"`
	Publisher       []Contributor `json:"publisher,omitempty"`
	Imprint         []Contributor `json:"imprint,omitempty"`
	Language        StringOrArray `json:"language,omitempty"`
	Modified        *time.Time    `json:"modified,omitempty"`
	PublicationDate *time.Time    `json:"published,omitempty"`
	Description     string        `json:"description,omitempty"`
	Source          string        `json:"source,omitempty"`
	Rights          string        `json:"rights,omitempty"`
	Subject         []Subject     `json:"subject,omitempty"`
	BelongsTo       *BelongsTo    `json:"belongs_to,omitempty"`
	Duration        int           `json:"duration,omitempty"`
}

PublicationMetadata for the default context in WebPub

type StringOrArray

type StringOrArray []string

StringOrArray is a array of string redifine for overriding json marshalling and unmarshalling

func (StringOrArray) MarshalJSON

func (r StringOrArray) MarshalJSON() ([]byte, error)

MarshalJSON overwrite json marshalling for handling string or array

type Subject

type Subject struct {
	Name   string `json:"name"`
	SortAs string `json:"sort_as,omitempty"`
	Scheme string `json:"scheme,omitempty"`
	Code   string `json:"code,omitempty"`
}

Subject as based on EPUB 3.1 and WebPub

Jump to

Keyboard shortcuts

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