content

package
v0.0.0-...-95c851e Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSort sortingField = iota
	SortByID
	SortByDate
)
View Source
const (
	AscendingOrder sortingOrder = iota
	DescendingOrder
)

Variables

View Source
var (
	// ReadOnly sets the query for read articles.
	ReadOnly = QueryOpt{func(o *QueryOptions) {
		o.ReadOnly = true
	}}

	// UnreadOnly sets the query for unread articles.
	UnreadOnly = QueryOpt{func(o *QueryOptions) {
		o.UnreadOnly = true
	}}

	// UnreadFirst sets the query to return unread articles first.
	UnreadFirst = QueryOpt{func(o *QueryOptions) {
		o.UnreadFirst = true
	}}

	// FavoriteOnly sets the query for favorite articles.
	FavoriteOnly = QueryOpt{func(o *QueryOptions) {
		o.FavoriteOnly = true
	}}

	// UntaggedOnly sets the query for untagged articles.
	UntaggedOnly = QueryOpt{func(o *QueryOptions) {
		o.UntaggedOnly = true
	}}

	// IncludeScores sets the query to return articles' score information.
	IncludeScores = QueryOpt{func(o *QueryOptions) {
		o.IncludeScores = true
	}}

	// HighScoredFirst sets the query to return articles with high scores first.
	HighScoredFirst = QueryOpt{func(o *QueryOptions) {
		o.HighScoredFirst = true
	}}
)
View Source
var (
	ErrNoContent = errors.New("No content")
)

Functions

func IsNoContent

func IsNoContent(err error) bool

func IsValidationError

func IsValidationError(err error) bool

func NewValidationError

func NewValidationError(err error) error

Types

type Article

type Article struct {
	ID     ArticleID      `json:"id"`
	Guid   sql.NullString `json:"-"`
	FeedID FeedID         `db:"feed_id" json:"feedID"`

	Title       string    `json:"title"`
	Description string    `json:"description"`
	Link        string    `json:"link"`
	Date        time.Time `json:"date"`

	Read          bool   `json:"read"`
	Favorite      bool   `json:"favorite"`
	Score         int64  `json:"score,omitempty"`
	Thumbnail     string `json:"thumbnail,omitempty"`
	ThumbnailLink string `db:"thumbnail_link" json:"thumbnailLink,omitempty"`

	IsNew bool `json:"-"`

	Hit struct {
		Fragments map[string][]string `json:"fragments,omitempty"`
	} `json:"hits"`
}

func (Article) String

func (a Article) String() string

func (Article) Validate

func (a Article) Validate() error

type ArticleExtract

type ArticleExtract struct {
	ArticleID ArticleID
	Title     string
	Content   string
	TopImage  string `db:"top_image"`
	Language  string
}

type ArticleID

type ArticleID int64

func (*ArticleID) Scan

func (id *ArticleID) Scan(src interface{}) error

func (ArticleID) Value

func (id ArticleID) Value() (driver.Value, error)

type Extract

type Extract struct {
	ArticleID ArticleID `db:"article_id"`
	Title     string
	Content   string
	TopImage  string `db:"top_image"`
	Language  string
}

func (Extract) String

func (e Extract) String() string

func (Extract) Validate

func (e Extract) Validate() error

type Feed

type Feed struct {
	ID             FeedID          `json:"id"`
	Title          string          `json:"title"`
	Description    string          `json:"description"`
	Link           string          `json:"link"`
	SiteLink       string          `db:"site_link" json:"-"`
	HubLink        string          `db:"hub_link" json:"-"`
	UpdateError    string          `db:"update_error" json:"updateError"`
	SubscribeError string          `db:"subscribe_error" json:"subscribeError"`
	TTL            time.Duration   `json:"-"`
	SkipHours      map[int]bool    `json:"-"`
	SkipDays       map[string]bool `json:"-"`
	// contains filtered or unexported fields
}

func (*Feed) AddUpdateError

func (f *Feed) AddUpdateError(err string)

func (Feed) ParsedArticles

func (f Feed) ParsedArticles() (a []Article)

func (*Feed) Refresh

func (f *Feed) Refresh(pf parser.Feed)

func (Feed) String

func (f Feed) String() string

func (Feed) Validate

func (f Feed) Validate() error

type FeedID

type FeedID int64

func (*FeedID) Scan

func (id *FeedID) Scan(src interface{}) error

func (FeedID) Value

func (id FeedID) Value() (driver.Value, error)

type Filter

type Filter struct {
	TagID        TagID    `json:"tagID"`
	FeedIDs      []FeedID `json:"feedIDs"`
	InverseFeeds bool     `json:"inverseFeeds"`
	URLTerm      string   `json:"urlTerm"`
	TitleTerm    string   `json:"titleTerm"`
	InverseURL   bool     `json:"inverseURL"`
	InverseTitle bool     `json:"inverseTitle"`
}

func GetUserFilters

func GetUserFilters(u User) []Filter

func (Filter) Valid

func (f Filter) Valid() bool

type Login

type Login string

Login is the user login name.

func (*Login) Scan

func (val *Login) Scan(src interface{}) error

func (Login) Value

func (val Login) Value() (driver.Value, error)

type ProfileData

type ProfileData map[string]interface{}

func (*ProfileData) Scan

func (val *ProfileData) Scan(src interface{}) error

func (*ProfileData) UnmarshalJSON

func (p *ProfileData) UnmarshalJSON(b []byte) error

func (ProfileData) Value

func (val ProfileData) Value() (driver.Value, error)

type QueryOpt

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

QueryOpt is a single query option.

func FeedIDs

func FeedIDs(ids []FeedID) QueryOpt

FeedIDS limits the query to the specified feed ids.

func Filters

func Filters(filters []Filter) QueryOpt

Filters ads configurable filters to limit the query result.

func IDRange

func IDRange(after, before ArticleID) QueryOpt

IDRange sets the valid article ids between the two provided.

func IDs

func IDs(ids []ArticleID) QueryOpt

IDS limits the query to the specified article ids.

func Paging

func Paging(limit, offset int) QueryOpt

Paging sets the article query paging optons.

func ScoreRange

func ScoreRange(after, before int64) QueryOpt

ScoreRange sets the minimum and maximum scores of returned articles.

func Sorting

func Sorting(field sortingField, order sortingOrder) QueryOpt

Sorting sets the query result sorting.

func TimeRange

func TimeRange(after, before time.Time) QueryOpt

TimeRange sets the minimum and maximum times of returned articles.

type QueryOptions

type QueryOptions struct {
	Limit           int
	Offset          int
	ReadOnly        bool
	UnreadOnly      bool
	UnreadFirst     bool
	FavoriteOnly    bool
	UntaggedOnly    bool
	IncludeScores   bool
	HighScoredFirst bool
	BeforeID        ArticleID
	AfterID         ArticleID
	BeforeDate      time.Time
	AfterDate       time.Time
	BeforeScore     int64
	AfterScore      int64
	IDs             []ArticleID
	FeedIDs         []FeedID
	Filters         []Filter

	SortField sortingField
	SortOrder sortingOrder
}

QueryOptions is the full range of options for querying articles.

func (*QueryOptions) Apply

func (o *QueryOptions) Apply(opts []QueryOpt)

Apply applies the settings from the passed opts to the QueryOptions

type Scores

type Scores struct {
	ArticleID ArticleID `db:"article_id"`
	Score     int64
	Score1    int64
	Score2    int64
	Score3    int64
	Score4    int64
	Score5    int64
}

Scores contains the calculated popularity score of an article.

func (Scores) Calculate

func (s Scores) Calculate() int64

Calculate returns the overall score of the article.

func (Scores) String

func (s Scores) String() string

func (Scores) Validate

func (s Scores) Validate() error

Validate validates the score data.

type Subscription

type Subscription struct {
	FeedID              FeedID    `db:"feed_id"`
	Link                string    `db:"link"`
	LeaseDuration       int64     `db:"lease_duration"`
	VerificationTime    time.Time `db:"verification_time"`
	SubscriptionFailure bool      `db:"subscription_failure"`
}

func (Subscription) String

func (s Subscription) String() string

func (Subscription) Validate

func (s Subscription) Validate() error

type Tag

type Tag struct {
	ID    TagID    `json:"id"`
	Value TagValue `json:"value"`
}

func (Tag) String

func (t Tag) String() string

func (Tag) Validate

func (t Tag) Validate() error

type TagID

type TagID int64

func (*TagID) Scan

func (id *TagID) Scan(src interface{}) error

func (TagID) Value

func (id TagID) Value() (driver.Value, error)

type TagValue

type TagValue string

func (*TagValue) Scan

func (val *TagValue) Scan(src interface{}) error

func (TagValue) Value

func (val TagValue) Value() (driver.Value, error)

type Thumbnail

type Thumbnail struct {
	ArticleID ArticleID `db:"article_id"`
	Thumbnail string
	Link      string
	Processed bool
}

func (Thumbnail) String

func (t Thumbnail) String() string

func (Thumbnail) Validate

func (t Thumbnail) Validate() error

type User

type User struct {
	Login     Login  `json:"login"`
	FirstName string `db:"first_name" json:"firstName"`
	LastName  string `db:"last_name" json:"lastName"`
	Email     string `json:"email"`
	HashType  string `db:"hash_type" json:"-"`
	Admin     bool   `json:"admin"`
	Active    bool   `json:"active"`
	Salt      []byte `json:"-"`
	Hash      []byte `json:"-"`
	MD5API    []byte `db:"md5_api" json:"-"` // "md5(user:pass)"

	ProfileData ProfileData `db:"profile_data" json:"profileData"`
}

User represents a readeef user.

func (User) Authenticate

func (u User) Authenticate(password string, secret []byte) (bool, error)

func (*User) Password

func (u *User) Password(password string, secret []byte) error

func (User) String

func (u User) String() string

func (User) Validate

func (u User) Validate() error

Validate checks whether all required fields have been provided.

type ValidationError

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

Directories

Path Synopsis
mock_repo
Package mock_repo is a generated GoMock package.
Package mock_repo is a generated GoMock package.
sql

Jump to

Keyboard shortcuts

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