opds

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package opds provides structures to represent valid OPDS feeds According to https://specs.opds.io/opds-1.2

Index

Constants

View Source
const (
	// NavigationLink points to a navigation feed: https://specs.opds.io/opds-1.2#22-navigation-feeds
	NavigationLink = "application/atom+xml;profile=opds-catalog;kind=navigation"
	// AcquisitionLink points to an acquisition feed: https://specs.opds.io/opds-1.2#23-acquisition-feeds
	AcquisitionLink = "application/atom+xml;profile=opds-catalog;kind=acquisition"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	XMLName xml.Name `xml:"author"`
	Name    string   `xml:"name"`
	URI     string   `xml:"uri,omitempty"`
}

Author of a resource

type Content

type Content struct {
	XMLName xml.Name `xml:"content"`
	Content string   `xml:",cdata"`
	Type    string   `xml:"type,attr"`
}

Content of an entry

type Entry

type Entry struct {
	XMLName xml.Name  `xml:"entry"`
	ID      string    `xml:"id"`
	Title   string    `xml:"title"`
	Links   []*Link   `xml:",omitempty"`
	Updated time.Time `xml:"updated"`
	Content *Content  `xml:",omitempty"`
	Summary string    `xml:"summary,omitempty"`
	Authors []*Author `xml:",omitempty"`
}

Entry represents an entry of an OPDS feed

type Feed

type Feed struct {
	XMLName       xml.Name  `xml:"feed"`
	Xmlns         string    `xml:"xmlns,attr"`
	Xmlnsdc       string    `xml:"xmlns:dc,attr,omitempty"`
	Xmlnbookshelf string    `xml:"xmlns:opds,attr,omitempty"`
	Title         string    `xml:"title"`
	ID            string    `xml:"id"`
	Updated       time.Time `xml:"updated"`
	Links         []*Link   `xml:"links,omitempty"`
	Author        *Author   `xml:"author,omitempty"`
	Entries       []*Entry  `xml:",omitempty"`
}

Feed represents an OPDS feed, use a FeedBuilder to properly create namespaced feed

type FeedBuilder

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

FeedBuilder allow to build a Feed while enforcing few invariants

func NewFeedBuilder

func NewFeedBuilder() *FeedBuilder

NewFeedBuilder creates a FeedBuilder ready to use

func (*FeedBuilder) Build

func (builder *FeedBuilder) Build() *Feed

Build will return the feed as configured by the FeedBuilder

func (*FeedBuilder) WithAuthor

func (builder *FeedBuilder) WithAuthor(author *Author) *FeedBuilder

WithAuthor sets the feed's author

func (*FeedBuilder) WithEntries

func (builder *FeedBuilder) WithEntries(entries []*Entry) *FeedBuilder

WithEntries adds entries to the feed

func (*FeedBuilder) WithID

func (builder *FeedBuilder) WithID(id string) *FeedBuilder

WithID sets the feed's ID

func (builder *FeedBuilder) WithLinks(links []*Link) *FeedBuilder

WithLinks adds links to the feed

func (*FeedBuilder) WithTitle

func (builder *FeedBuilder) WithTitle(title string) *FeedBuilder

WithTitle sets the feed's title

func (*FeedBuilder) WithType

func (builder *FeedBuilder) WithType(kind FeedType) *FeedBuilder

WithType sets the feed's type, and may update the XML namespace accordingly

func (*FeedBuilder) WithUpdated

func (builder *FeedBuilder) WithUpdated(updated time.Time) *FeedBuilder

WithUpdated sets the feed's updated date

type FeedType

type FeedType string

FeedType denotes the OPDS type, being either a navigation or acquisition feed See https://specs.opds.io/opds-1.2#2-opds-catalog-feed-documents

const (
	// Navigation feed: https://specs.opds.io/opds-1.2#22-navigation-feeds
	Navigation FeedType = "navigation"
	// Acquisition feed: https://specs.opds.io/opds-1.2#23-acquisition-feeds
	Acquisition = "acquisition"
)
type Link struct {
	XMLName xml.Name `xml:"link"`
	Rel     string   `xml:"rel,attr,omitempty"`
	Href    string   `xml:"href,attr"`
	Type    string   `xml:"type,attr,omitempty"`
}

Link points to resources such as feed or entry

Jump to

Keyboard shortcuts

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