feeds

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBFeedSchema = `` /* 579-byte string literal not displayed */

	DBFeedFormatsSchema = `CREATE TABLE IF NOT EXISTS feed_formats (
		id INTEGER PRIMARY KEY,
		format_name TEXT NOT NULL UNIQUE
	)`
)
View Source
const (
	QDeleteFeedById = `DELETE FROM feeds WHERE feed_id = ?`
	QGetFeed        = `SELECT * FROM feeds WHERE feed_id = ?`
	QGetFeedByName  = `SELECT * FROM feeds WHERE name = ?`
	QGetFeedByURL   = `SELECT * FROM feeds WHERE url = ?`
	QListFeeds      = `` /* 462-byte string literal not displayed */

)
View Source
const (
	MsgOK = "OK"
)

Variables

View Source
var (
	ErrDoesNotExist  = errors.New("does not exist")
	ErrAlreadyExists = errors.New("already exists")
)
View Source
var DB = db.DB

sqlite> SELECT feeds.name, url, feed_formats.name AS format_name from feeds JOIN feed_formats ON feeds.format = feed_formats.id;

View Source
var (
	ErrNotInt = "expected int"
)
View Source
var FeedFormats = map[FeedFormat]string{
	FormatRSS:       "RSS",
	FormatHTML:      "HTML",
	FormatJSON:      "JSON",
	FormatTweet:     "TWEET",
	FormatRFC:       "RFC",
	FormatGHRelease: "GithubRelease",
}

Functions

func DeleteById

func DeleteById(id int) error

Types

type Feed

type Feed struct {
	FeedID       int64            `json:"id" db:"feed_id"`
	Name         string           `json:"name" db:"name"`
	Section      string           `json:"section,omitempty"`
	Categories   types.StringList `json:"categories,omitempty"`
	Description  string           `json:"description"`
	Url          string           `json:"url"`
	Format       FeedFormat       `json:"-"`
	FormatString string           `json:"format" db:"format_name"`
	LastRefresh  time.Time        `db:"last_refresh" json:"last_refresh"` // timestamp time.Unix()
	Created      time.Time        `json:"created"`
	DisplayName  string           `db:"display_name"`
	Publications string           `json:"-"`

	// This feed's posts should also be exported individually
	ExportPosts bool `json:"export_posts" db:"export_posts"`

	// Time in seconds between each polling job on the news feed
	Interval float64 `json:"refresh_interval"`

	Serial bool `json:"serial" db:"serial_run"` // Jobs for this feed should run in series

	// Items which only contain summaries and redirect to external content
	// like publications and newsletters
	UseExternalLink bool `json:"use_external_link" db:"use_external_link"`
}

func GetById

func GetById(id int64) (*Feed, error)

func GetByName

func GetByName(name string) (*Feed, error)

func GetByURL

func GetByURL(url string) (*Feed, error)

func ListFeeds

func ListFeeds() ([]*Feed, error)

func (*Feed) ShouldRefresh

func (feed *Feed) ShouldRefresh() (float64, bool)

Returns true if the feed should be refreshed

func (*Feed) UpdateRefreshTime

func (f *Feed) UpdateRefreshTime(time time.Time) error

func (*Feed) Write

func (f *Feed) Write() error

type FeedCtrl

type FeedCtrl struct{}

func (FeedCtrl) Create

func (ctrl FeedCtrl) Create(c *gin.Context)

func (FeedCtrl) Delete

func (ctrl FeedCtrl) Delete(c *gin.Context)

func (FeedCtrl) List

func (ctrl FeedCtrl) List(c *gin.Context)

type FeedForm

type FeedForm struct {
	Name       string     `form:"name" binding:"required"`
	Url        string     `form:"url" binding:"required"`
	Format     FeedFormat `form:"format"`
	Categories []string   `form:"categories"`
	Section    string     `form:"section"`
}

type FeedFormat

type FeedFormat int
const (
	FormatRSS FeedFormat = iota
	FormatHTML
	FormatJSON
	FormatTweet
	FormatRFC
	FormatGHRelease
)

Feed Formats

Jump to

Keyboard shortcuts

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