domain

package
v0.0.0-...-1fec9c6 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Layout1   = Layout{1, 2, 6, 200, 32}
	Layout2   = Layout{2, 2, 6, 500, 32}
	Layout3   = Layout{3, 2, 6, 2250, 32}
	Layout4   = Layout{4, 4, 4, 2800, 45}
	Layout5   = Layout{5, 4, 4, 4000, 45}
	Layout6   = Layout{6, 6, 2, 3300, 60}
	LayoutBar = Layout{0, 12, 0, 0, 0}
)

Functions

func AnalyticsMiddleware

func AnalyticsMiddleware(h http.HandlerFunc) (http.HandlerFunc, error)

func CompressContent

func CompressContent(article readability.Article) ([]byte, error)

func ConvertToReadabilityArticle

func ConvertToReadabilityArticle(jsonArticle JSONArticle) readability.Article

func DecompressContent

func DecompressContent(data []byte) (readability.Article, error)

func WithUser

func WithUser(ctx context.Context, u *User) context.Context

Types

type Article

type Article struct {
	ID                string
	Title             string
	Description       string
	CompressedContent []byte
	Content           readability.Article
	ImageURL          string
	Link              string
	Author            string
	SourceID          int64
	Source            Source
	Timestamp         time.Time
	TS                string
	LayoutID          int64
	Layout            Layout
	// contains filtered or unexported fields
}

func LayoutArticles

func LayoutArticles(aa []Article) []Article

func (*Article) RawHTML

func (a *Article) RawHTML() template.HTML

func (*Article) SetHTMLContent

func (article *Article) SetHTMLContent(body string) []byte

func (*Article) Size

func (a *Article) Size() int

func (*Article) Trim

func (a *Article) Trim(size int)

type Cache

type Cache interface {
	Get(url string) (string, string, bool, error)
	Set(url, text, image string) error
	GetImage(url string) *image.Image
	SetImage(url string, i *image.Image)
}
var C Cache = &memoryCache{m: make(map[string][2]string)}

type Edition

type Edition struct {
	ID         string
	Name       string
	Sources    []Source
	Articles   []Article
	Categories []string
	Date       string

	StartTime time.Time
	EndTime   time.Time
	Created   time.Time

	Metadata map[string]string

	Article Article

	DisableCache bool
	// contains filtered or unexported fields
}

func NewEdition

func NewEdition(ctx context.Context, now time.Time) (*Edition, error)

type Element

type Element struct {
	Type  string
	Value string
}

type HTTPPublisher

type HTTPPublisher struct {
	ArticleURL string
	SourceURL  string
}

func (*HTTPPublisher) Publish

func (p *HTTPPublisher) Publish(ctx context.Context, topic string, payload interface{}) error

type Homepage

type Homepage struct {
	Title      string
	Date       string
	Categories []string
	Sources    []Source
	Articles   []Article
}

type JSONArticle

type JSONArticle struct {
	Title         string
	Byline        string
	Content       string
	TextContent   string
	Length        int
	Excerpt       string
	SiteName      string
	Image         string
	Favicon       string
	Language      string
	PublishedTime *time.Time
	ModifiedTime  *time.Time
}

func ConvertToJSONArticle

func ConvertToJSONArticle(article readability.Article) JSONArticle

type Layout

type Layout struct {
	Size        int
	Width       int
	TitleSize   int
	MaxChars    int
	MaxElements int
}

type PubSubMessage

type PubSubMessage struct {
	Message      pubsub.Message `json:"message"`
	Subscription string         `json:"subscription"`
}

PubSubMessage is the payload of a Pub/Sub event.

type PubSubPublisher

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

func (*PubSubPublisher) Publish

func (p *PubSubPublisher) Publish(ctx context.Context, topic string, payload interface{}) error

type Publisher

type Publisher interface {
	Publish(ctx context.Context, topic string, payload interface{}) error
}

func NewPubSubPublisher

func NewPubSubPublisher(ctx context.Context) (Publisher, error)

type Source

type Source struct {
	ID            string
	OwnerID       string
	Name          string
	URL           string
	FeedURL       string
	Categories    []string
	DisableFetch  bool
	LastFetchTime time.Time
	LayoutID      string
}

func GetSources

func GetSources() []Source

type User

type User struct {
	ID           string
	Name         string
	Created      time.Time
	PasswordHash []byte `json:"-"`
	IsAdmin      bool
}

func NewUser

func NewUser(ctx context.Context, name, password string, isAdmin bool) *User

func UserFromContext

func UserFromContext(ctx context.Context) *User

func (*User) Session

func (u *User) Session() (string, error)

func (*User) ValidatePassword

func (u *User) ValidatePassword(password string) bool

Jump to

Keyboard shortcuts

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