barefeed

package module
Version: v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 8 Imported by: 0

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 added in v0.2.0

type Entries []Entry

Entries are a slice of Entry

func (Entries) Len added in v0.2.0

func (e Entries) Len() int

Len is the length of the slice

func (Entries) Less added in v0.2.0

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

Less is how to compare the two Entry

func (Entries) Swap added in v0.2.0

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

Swap is how to swap the two Entry

type Entry added in v0.2.0

type Entry interface {
	bare.Union
}

Entry type contains elements from RSS Item & Atom Entry

type EntryV1 added in v0.2.0

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 added in v0.2.0

func (t EntryV1) IsUnion()

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

type Feed added in v0.2.0

type Feed interface {
	bare.Union
}

Feed type contains elements from RSS Channel & Atom Feed

type FeedType added in v0.3.0

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 added in v0.3.0

func ToFeedType(t string) FeedType

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

func (FeedType) String added in v0.3.0

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 added in v0.2.0

func (t FeedV1) IsUnion()

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

type Feeds added in v0.2.0

type Feeds []Feed

Feeds are a slice of Feed

func (Feeds) Len added in v0.2.0

func (f Feeds) Len() int

Len is the length of the slice

func (Feeds) Less added in v0.2.0

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

Less is how to compare the two Feed

func (Feeds) Swap added in v0.2.0

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 FromBytes

func FromBytes(b []byte) (*Message, error)

FromBytes will read barefeed from bytes

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 added in v0.2.0

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

Bytes will return the barefeed as a slice of bytes

func (Message) WriteFile added in v0.2.0

func (t Message) WriteFile(path string) error

WriteFile will write barefeed to a file at the designated path

type Person added in v0.2.0

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

Person contains info needed for authors

type Persons added in v0.2.0

type Persons []Person

Persons is a slice of Person

type Text added in v0.2.0

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

Text contains info needed for any text

type TextType added in v0.3.0

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 added in v0.3.0

func ToTextType(t string) TextType

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

func (TextType) String added in v0.3.0

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

Jump to

Keyboard shortcuts

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