feed

package
v0.0.0-...-0cb40df Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SESSION_NAME = "session"
)

Variables

This section is empty.

Functions

func ApiRouter

func ApiRouter() http.Handler

func DbCreateItem

func DbCreateItem(item *Item) error

func DbCreateSource

func DbCreateSource(source *Source) error

func DbDeleteItem

func DbDeleteItem(item *Item) error

func DbDeleteItemsBySource

func DbDeleteItemsBySource(sourceID int64) (int64, error)

func DbDeleteSource

func DbDeleteSource(id int64) error

func DbUpdateItem

func DbUpdateItem(item *Item) error

func DbUpdateSource

func DbUpdateSource(source *Source) error

func DbUpsertSourceItem

func DbUpsertSourceItem(item *Item) (int64, error)

func ErrInvalidRequest

func ErrInvalidRequest(err error) render.Renderer

func ErrRender

func ErrRender(err error) render.Renderer

func FeedSourceCtx

func FeedSourceCtx(next http.Handler) http.Handler

func FlashMiddleware

func FlashMiddleware(next http.Handler) http.Handler

func NewFeedSourceListResponse

func NewFeedSourceListResponse(sources []*Source) []render.Renderer

func SetupDb

func SetupDb(config *Config)

func SetupHandler

func SetupHandler(c *Config) *chi.Mux

Types

type ChannelConfig

type ChannelConfig struct {
	Title          string `yaml:"title"`
	Description    string `yaml:"description"`
	Category       string `yaml:"category"`
	Link           string `yaml:"link"`
	Author         string `yaml:"author"`
	Copyright      string `yaml:"copyright"`
	Email          string `yaml:"email"`
	Language       string `yaml:"language"`
	PermaLink      string `yaml:"permalink"`
	FeedLink       string `yaml:"feedlink"`
	Explicit       string `yaml:"explicit"`
	CoverURL       string `yaml:"cover-url"`
	TrackingPrefix string `yaml:"tracking-prefix"`
}

ChannelConfig represents program configuration

type Config

type Config struct {
	Channel  ChannelConfig  `yaml:"channel"`
	Database DatabaseConfig `yaml:"database"`
	Server   ServerConfig   `yaml:"server"`
	Fetcher  FetcherConfig  `yaml:"fetcher"`
}

Config stores all configuration

type CustomFeed

type CustomFeed struct {
	Title       string
	Description string
	Permalink   string
	CoverURL    string
	Language    string
	Date        time.Time
	Entries     []Item
	Author      string
}

CustomFeed represents template variables used for rendering RSS feed

type DatabaseConfig

type DatabaseConfig struct {
	Driver   string
	Filename string
}

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"status"`          // user-level status message
	AppCode    int64  `json:"code,omitempty"`  // application-specific error code
	ErrorText  string `json:"error,omitempty"` // application-level error message, for debugging
}

ErrResponse renderer type for handling all sorts of errors.

In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

type FeedSourceResponse

type FeedSourceResponse struct {
	*Source
}

func NewFeedSourceResponse

func NewFeedSourceResponse(source *Source) *FeedSourceResponse

func (*FeedSourceResponse) Render

type Fetcher

type Fetcher struct {
	Config *Config
}

func NewFetcher

func NewFetcher(config *Config) *Fetcher

func SetupFetcher

func SetupFetcher(c *Config) *Fetcher

func (Fetcher) Start

func (f Fetcher) Start()

func (Fetcher) UpdateFeed

func (f Fetcher) UpdateFeed(source *Source) error

type FetcherConfig

type FetcherConfig struct {
	Interval time.Duration `yaml:"interval"`
}

type Item

type Item struct {
	ID           int64     `json:"id"`
	FeedID       int64     `json:"feedId"`
	GUID         string    `xorm:" varchar(200) not null" json:"guid"`
	Title        string    `xorm:" varchar(200) null" json:"title"`
	Description  string    `json:"description"`
	PubDate      time.Time `json:"pubdate"`
	Raw          string    `json:"raw"`
	EnclosureUrl string    `xorm:" varchar(200) null" json:"enclosureUrl"`
	Entry        string    `json:"entry"`
}

Item represents an item in a feed

func ApplyEnclosurePrefix

func ApplyEnclosurePrefix(items []Item, prefix string) ([]Item, error)

apply prefix to enclosure url

func DbGetItemsForCustomFeed

func DbGetItemsForCustomFeed(offset int, limit int) ([]Item, error)

func DbGetSourceItems

func DbGetSourceItems(sourceID int64, offset int, limit int) ([]Item, error)

type ServerConfig

type ServerConfig struct {
	SessionKey string `yaml:"session-key"`
	Username   string `yaml:"username"`
	Password   string `yaml:"password"`
}

type Source

type Source struct {
	ID   int64  `json:"id"`
	URL  string `xorm:" varchar(200) not null" json:"url"`
	Slug string `xorm:" varchar(200) not null" json:"slug"`
	Name string `xorm:" varchar(200) not null" json:"name"`
}

func DbGetSource

func DbGetSource(id int64) (Source, error)

func DbListSource

func DbListSource() []Source

type SourceRequest

type SourceRequest struct {
	Slug string
	Name string
	URL  string
}

type SqlStorage

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

func SetupSqlStorage

func SetupSqlStorage(config *Config) *SqlStorage

func (*SqlStorage) CreateItem

func (s *SqlStorage) CreateItem(item *Item) error

func (*SqlStorage) CreateSource

func (s *SqlStorage) CreateSource(source *Source) error

func (*SqlStorage) DeleteItem

func (s *SqlStorage) DeleteItem(item *Item) error

func (*SqlStorage) DeleteItemsBySource

func (s *SqlStorage) DeleteItemsBySource(sourceID int64) (int64, error)

func (*SqlStorage) DeleteSource

func (s *SqlStorage) DeleteSource(id int64) error

func (*SqlStorage) GetItemsForCustomFeed

func (s *SqlStorage) GetItemsForCustomFeed(offset int, limit int) ([]Item, error)

func (*SqlStorage) GetSource

func (s *SqlStorage) GetSource(id int64) (Source, error)

func (*SqlStorage) GetSourceItems

func (s *SqlStorage) GetSourceItems(sourceID int64, offset int, limit int) ([]Item, error)

func (*SqlStorage) ListSource

func (s *SqlStorage) ListSource() []Source

func (*SqlStorage) UpdateItem

func (s *SqlStorage) UpdateItem(item *Item) error

func (*SqlStorage) UpdateSource

func (s *SqlStorage) UpdateSource(source *Source) error

func (*SqlStorage) UpsertSourceItem

func (s *SqlStorage) UpsertSourceItem(item *Item) (int64, error)

type Storage

type Storage interface {
	GetSource(id int64) (Source, error)
	ListSource() []Source
	CreateSource(source *Source) error
	UpdateSource(source *Source) error
	DeleteSource(id int64) error
	CreateItem(item *Item) error
	UpdateItem(item *Item) error
	DeleteItem(item *Item) error
	GetSourceItems(sourceID int64, offset int, limit int) ([]Item, error)
	UpsertSourceItem(item *Item) (int64, error)
	DeleteItemsBySource(sourceID int64) (int64, error)
	GetItemsForCustomFeed(offset int, limit int) ([]Item, error)
}

Jump to

Keyboard shortcuts

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