opds

package
v0.0.0-...-60192f8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package opds provides types and functions to create OPDS content.

Index

Constants

View Source
const (
	// OPDSTypeNavigation is the link type for navigation.
	OPDSTypeNavigation = "application/atom+xml; profile=opds-catalog; kind=navigation"
	// OPDSTypeAcquisistion is the link type for acquisition.
	OPDSTypeAcquisistion = "application/atom+xml; profile=opds-catalog; kind=acquisition"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	Name string `xml:"name"`
	URI  string `xml:"uri"`
}

Author represent the feed author or the entry author.

type Category

type Category struct {
	Scheme string `xml:"scheme,attr"`
	Term   string `xml:"term,attr"`
	Label  string `xml:"label,attr"`
}

Category represent the book category with scheme and term to machine handling.

type Content

type Content struct {
	Content     string `xml:",cdata"`
	ContentType string `xml:"type,attr"`
}

Content content tag in an entry, the type will be html or text.

type Entry

type Entry struct {
	Title      string     `xml:"title"`
	ID         UUID       `xml:"id"`
	Identifier UUID       `xml:"dc:identifier"`
	Updated    Time       `xml:"updated"`
	Rights     string     `xml:"rights,omitempty"`
	Publisher  string     `xml:"dc:publisher,omitempty"`
	Author     []Author   `xml:"author,omitempty"`
	Language   string     `xml:"dc:language,omitempty"`
	Issued     *Time      `xml:"dc:issued,omitempty"`
	Published  *Time      `xml:"published,omitempty"`
	Category   []Category `xml:"category,omitempty"`
	Links      []Link     `xml:"link,omitempty"`
	Summary    *Content   `xml:"summary,omitempty"`
	Content    *Content   `xml:"content,omitempty"`
	Series     []Serie    `xml:"Series"`
}

Entry an atom entry in the feed.

func NewLinkEntry

func NewLinkEntry(title string, updated time.Time, href string) Entry

NewLinkEntry creates a navigation link.

type Feed

type Feed struct {
	XMLName      xml.Name `xml:"feed"`
	XMLns        string   `xml:"xmlns,attr"`
	XMLnsDC      string   `xml:"xmlns:dc,attr"`
	Lang         string   `xml:"xml:lang,attr"`
	ID           UUID     `xml:"id"`
	Title        string   `xml:"title"`
	Author       []Author `xml:"author,omitempty"`
	Updated      Time     `xml:"updated"`
	Entries      []Entry  `xml:"entry"`
	Links        []Link   `xml:"link"`
	TotalResults int      `xml:"totalResults,omitempty"`
	ItemsPerPage int      `xml:"itemsPerPage,omitempty"`
	FeedType     string   `xml:"-"`
}

Feed root element for acquisition or navigation feed.

func (*Feed) Encode

func (f *Feed) Encode(w io.Writer) (err error)

Encode encodes a feed on a writer.

type IndirectAcquisition

type IndirectAcquisition struct {
	TypeAcquisition     string                `xml:"type,attr"`
	IndirectAcquisition []IndirectAcquisition `xml:"indirectAcquisition"`
}

IndirectAcquisition represent the link mostly for buying or borrowing a book.

type Link struct {
	Rel                 string                `xml:"rel,attr"`
	Href                string                `xml:"href,attr"`
	TypeLink            string                `xml:"type,attr,omitempty"`
	Title               string                `xml:"title,attr,omitempty"`
	FacetGroup          string                `xml:"facetGroup,attr,omitempty"`
	Count               int                   `xml:"count,attr,omitempty"`
	IndirectAcquisition []IndirectAcquisition `xml:"indirectAcquisition,omitempty"`
}

Link link to different resources.

type Serie

type Serie struct {
	Name     string  `xml:"name,attr"`
	URL      string  `xml:"url,attr"`
	Position float32 `xml:"position,attr"`
}

Serie store serie information from schema.org.

type Time

type Time struct {
	time.Time
}

Time is wrapper around time.Time that can marshal into an RFC3339 format.

func AtomDate

func AtomDate(src time.Time) *Time

AtomDate returns a new Time instance.

func (Time) MarshalText

func (d Time) MarshalText() ([]byte, error)

MarshalText encodes the Time instance in RFC3339 format.

type UUID

type UUID struct {
	uuid.UUID
}

UUID is a wrapper around uuid.UUID that can be marshaled into a "urn:uuid" identifier.

func ID

func ID(src uuid.UUID) UUID

ID returns a new UUID instance.

func URLID

func URLID(src string) UUID

URLID returns a new UUID instance, based on a URL.

func (UUID) MarshalText

func (id UUID) MarshalText() ([]byte, error)

MarshalText encoded an UUID into a "urn:uuid" format.

Jump to

Keyboard shortcuts

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