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 ¶
- type BelongsTo
- type Collection
- type Contributor
- type Facet
- type Feed
- func (feed *Feed) AddFacet(link Link, group string)
- func (feed *Feed) AddLink(href string, rel string, typeLink string, templated bool)
- func (feed *Feed) AddNavigation(title string, href string, rel string, typeLink string)
- func (feed *Feed) AddNavigationInGroup(link Link, collLink Link)
- func (feed *Feed) AddPagination(numberItems int, itemsPerPage int, currentPage int, nextLink string, ...)
- func (feed *Feed) AddPublicationInGroup(publication Publication, collLink Link)
- func (feed *Feed) UnmarshalJSON(data []byte) error
- type Group
- type IndirectAcquisition
- type Link
- type Metadata
- type MultiLanguage
- type Price
- type Properties
- type Publication
- func (publication *Publication) AddAuthor(name string, identifier string, sortAs string, href string, typeLink string)
- func (publication *Publication) AddImage(href string, typeImage string, height int, width int)
- func (publication *Publication) AddLink(href string, typeLink string, rel string, title string)
- func (publication *Publication) AddPublisher(name string, href string, typeLink string)
- func (publication *Publication) AddSerie(name string, position float32, href string, typeLink string)
- type PublicationMetadata
- type StringOrArray
- type Subject
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 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"` }
Feed is a collection as defined in Readium Web Publication Manifest
func ParseBuffer ¶
ParseBuffer parse opds2 feed from a buffer of byte usually get from a file or url
func (*Feed) AddNavigation ¶
AddNavigation add navigation element in feed
func (*Feed) AddNavigationInGroup ¶
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 ¶
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"` }
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 ¶
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 ¶
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 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) AddLink ¶
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
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