provider

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AtomName is the name of the Atom provider.
	AtomName = "atom"
)
View Source
const (
	// GiteaName is the name of the Atom provider.
	GiteaName = "gitea"
)
View Source
const (
	// RDFName is the name of the Atom provider.
	RDFName = "rdf"
)
View Source
const (
	// RSSName is the name of the Atom provider.
	RSSName = "rss"
)

Variables

This section is empty.

Functions

func Download

func Download(url string) ([]byte, error)

Download fetches the content of an URI and returns with a parsed []mode.Entry.

func XMLFeedTypeOf

func XMLFeedTypeOf(content []byte) (string, error)

XMLFeedTypeOf tries to make a decision what type of provider we should use based on the content. If it's not an XML or it's an unknown type, then returns with error.

Types

type Atom

type Atom struct{}

Atom provider.

func (Atom) Name

func (a Atom) Name() string

Name returns with the name of the provider.

func (*Atom) Parse

func (a *Atom) Parse(body []byte) []*Entry

Parse tries to parse all entries from an Atom []byte content.

type Entry

type Entry struct {
	ID      string
	Title   string
	Link    string
	Content string
	Image   string
}

Entry is a proxy struct to pass entry data around.

func (Entry) ToModel

func (e Entry) ToModel() *model.Entry

ToModel returns with the model representation of an entry.

type Gitea added in v1.2.0

type Gitea struct{}

Gitea provider.

func (Gitea) Name added in v1.2.0

func (a Gitea) Name() string

Name returns with the name of the provider.

func (*Gitea) Parse added in v1.2.0

func (a *Gitea) Parse(body []byte) []*Entry

Parse tries to parse all entries from an Gitea []byte content.

type Interface

type Interface interface {
	Name() string
	Parse(body []byte) (entries []*Entry)
}

Interface is a common interface for providers like RSS.

func NewProviderByName

func NewProviderByName(name string) Interface

NewProviderByName creates a new Provider based on its name.

type RDF

type RDF struct{}

RDF provider.

func (RDF) Name

func (a RDF) Name() string

Name returns with the name of the provider.

func (*RDF) Parse

func (a *RDF) Parse(body []byte) []*Entry

Parse tries to parse all entries from an RDF []byte content.

type RSS

type RSS struct{}

RSS provider.

func (RSS) Name

func (a RSS) Name() string

Name returns with the name of the provider.

func (*RSS) Parse

func (a *RSS) Parse(body []byte) []*Entry

Parse tries to parse all entries from an RSS []byte content.

type UnknownXMLFeedTypeError added in v1.2.4

type UnknownXMLFeedTypeError struct {
	Type string
}

UnknownXMLFeedTypeError occurs when downloader meets with an unknown feed format.

func (UnknownXMLFeedTypeError) Error added in v1.2.4

func (e UnknownXMLFeedTypeError) Error() string

type XMLHeader

type XMLHeader struct {
	XMLName xml.Name
	XMLNS   string `xml:"xmlns,attr"`
}

XMLHeader is the wrapper object to determine what type of feed we have.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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