README

go-barefeed GoDoc builds.sr.ht status

An implementation of the barefeed message format for Go.

Contributing

Send patches to ~chrisppy/beagles-devel@lists.sr.ht

License

MIT

Documentation

Overview

Package barefeed is an implementation of the barefeed message format for Go.

https://git.sr.ht/~chrisppy/go-barefeed

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entries

type Entries []Entry

Entries are a slice of Entry

func (Entries) Len

func (e Entries) Len() int

Len is the length of the slice

func (Entries) Less

func (e Entries) Less(i, j int) bool

Less is how to compare the two Entry

func (Entries) Swap

func (e Entries) Swap(i, j int)

Swap is how to swap the two Entry

type Entry

type Entry interface {
	bare.Union
}

Entry type contains elements from RSS Item & Atom Entry

type EntryV1

type EntryV1 struct {
	FeedPath  string    `bare:"feedPath"`
	ID        string    `bare:"id"`
	Title     Text      `bare:"title"`
	Content   Text      `bare:"content"`
	Published Timestamp `bare:"published"`
	Updated   Timestamp `bare:"updated"`
	Authors   Persons   `bare:"authors"`
	Links     Links     `bare:"links"`
}

EntryV1 type contains elements from RSS Item & Atom Entry

func (EntryV1) IsUnion

func (t EntryV1) IsUnion()

IsUnion function is necessary to make the type compatible with the Union interface

type Feed

type Feed interface {
	bare.Union
}

Feed type contains elements from RSS Channel & Atom Feed

type FeedType

type FeedType uint

FeedType is an enumerated type for Feed

const (
	// RSS denotes the feed as RSS
	RSS FeedType = iota
	// ATOM denotes the feed as ATOM
	ATOM
)

func ToFeedType

func ToFeedType(t string) FeedType

ToFeedType converts a string to the enumerated value. RSS is default.

func (FeedType) String

func (t FeedType) String() string

String converts the enumerated value to a string. "RSS" is default.

type FeedV1

type FeedV1 struct {
	Path        string    `bare:"path"`
	ID          string    `bare:"id"`
	FeedType    FeedType  `bare:"feedType"`
	Title       Text      `bare:"title"`
	Updated     Timestamp `bare:"updated"`
	Authors     Persons   `bare:"authors"`
	Links       Links     `bare:"links"`
	Entries     []string  `bare:"entries"`
	Generator   *string   `bare:"generator"`
	Description *Text     `bare:"description"`
}

FeedV1 type contains elements from RSS Channel & Atom Feed

func (FeedV1) IsUnion

func (t FeedV1) IsUnion()

IsUnion function is necessary to make the type compatible with the Union interface

type Feeds

type Feeds []Feed

Feeds are a slice of Feed

func (Feeds) Len

func (f Feeds) Len() int

Len is the length of the slice

func (Feeds) Less

func (f Feeds) Less(i, j int) bool

Less is how to compare the two Feed

func (Feeds) Swap

func (f Feeds) Swap(i, j int)

Swap is how to swap the two Feed

type Link struct {
	URL      string `bare:"url"`
	LinkType string `bare:"linkType"`
	Rel      string `bare:"rel"`
	Length   int    `bare:"length"`
}

Link contains info needed for any link

type Links []Link

Links is a slice of Link

type Message

type Message struct {
	Generator string               `bare:"generator"`
	Created   Timestamp            `bare:"created"`
	Feeds     map[string]Feed      `bare:"feeds"`
	Entries   map[string]Entry     `bare:"entries"`
	Unread    map[string]int64     `bare:"unread"`
	Favorite  map[string]Timestamp `bare:"favorite"`
}

Message is the first version of the spec

func FromFile

func FromFile(path string) (*Message, error)

FromFile will read barefeed from a file

func FromReader

func FromReader(reader io.Reader) (*Message, error)

FromReader will read barefeed from a Reader

func (Message) Bytes

func (t Message) Bytes() ([]byte, error)

Bytes will return the barefeed as a slice of bytes

func (Message) WriteFile

func (t Message) WriteFile(path string) error

WriteFile will write barefeed to a file at the designated path

type Person

type Person struct {
	Name  string  `bare:"name"`
	Email *string `bare:"email"`
	URI   *string `bare:"uri"`
}

Person contains info needed for authors

type Persons

type Persons []Person

Persons is a slice of Person

type Text

type Text struct {
	Value    string   `bare:"value"`
	TextType TextType `bare:"textType"`
}

Text contains info needed for any text

type TextType

type TextType uint

TextType is an enumerated type for Text

const (
	// TEXT denotes the text as plain text
	TEXT TextType = iota
	// HTML denotes the text as entity escaped html
	HTML
	// XHTML denotes the text as inline xhtml, wrapped in a div element
	XHTML
)

func ToTextType

func ToTextType(t string) TextType

ToTextType converts a string to the enumerated value. TEXT is default.

func (TextType) String

func (t TextType) String() string

String converts the enumerated value to a string. "TEXT" is default.

type Timestamp

type Timestamp int64

Timestamp type to hold the UTC Unix value of time

func ToTimestamp

func ToTimestamp(t time.Time) Timestamp

ToTimestamp will convert the time to timestamp

func (Timestamp) Time

func (t Timestamp) Time() time.Time

Time will convert the timestamp to time