eagle

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	Name  string `yaml:"name,omitempty" json:"name,omitempty"`
	URL   string `yaml:"url,omitempty" json:"url,omitempty"`
	Photo string `yaml:"photo,omitempty" json:"photo,omitempty"`
}

type Eagle

type Eagle struct {
	Notifications
	Config      *config.Config
	PublicDirCh chan string

	Miniflux *Miniflux
	Twitter  *Twitter
	// contains filtered or unexported fields
}

func NewEagle

func NewEagle(conf *config.Config) (*Eagle, error)

func (*Eagle) AutoLinkMentions

func (e *Eagle) AutoLinkMentions(entry *Entry)

AutoLinkMentions mentions replaces all Twitter and ActivityPub @mentions in a post by proper links. FIXME: do not check for mentions inside code blocks, only paragraphs.

func (*Eagle) Build

func (e *Eagle) Build(clean bool) error

func (*Eagle) DeleteEntry

func (e *Eagle) DeleteEntry(entry *Entry) error

func (*Eagle) GetAllEntries

func (e *Eagle) GetAllEntries() ([]*Entry, error)

func (*Eagle) GetEntry

func (e *Eagle) GetEntry(id string) (*Entry, error)

func (*Eagle) GetEntryData

func (e *Eagle) GetEntryData(entry *Entry) (*EntryData, error)

func (*Eagle) GetWebmentionTargets

func (e *Eagle) GetWebmentionTargets(entry *Entry) ([]string, []string, []string, error)

func (*Eagle) GetXRay

func (e *Eagle) GetXRay(url string) (*XRay, error)

func (*Eagle) MakeEntryBundle

func (e *Eagle) MakeEntryBundle(entry *Entry) error

func (*Eagle) ParseEntry

func (e *Eagle) ParseEntry(id, raw string) (*Entry, error)

func (*Eagle) Persist

func (e *Eagle) Persist(filename string, data []byte, message string) error

func (*Eagle) PersistJSON

func (e *Eagle) PersistJSON(filename string, data interface{}, msg string) error

func (*Eagle) ReadFile

func (e *Eagle) ReadFile(filename string) ([]byte, error)

func (*Eagle) ReadJSON

func (e *Eagle) ReadJSON(filename string, v interface{}) error

func (*Eagle) RebuildIndex

func (e *Eagle) RebuildIndex() error

func (*Eagle) ReceiveWebmentions

func (e *Eagle) ReceiveWebmentions(payload *WebmentionPayload) error

func (*Eagle) SaveEntry

func (e *Eagle) SaveEntry(entry *Entry) error

func (*Eagle) SaveEntryData

func (e *Eagle) SaveEntryData(entry *Entry, data *EntryData) error

func (*Eagle) Search

func (e *Eagle) Search(query *SearchQuery, page int) ([]*SearchEntry, error)

func (*Eagle) SendWebmentions

func (e *Eagle) SendWebmentions(entry *Entry) error

func (*Eagle) ShouldBuild

func (e *Eagle) ShouldBuild() (bool, error)

ShouldBuild indicates if the website should be built. This should only return true after initialization.

func (*Eagle) Sync

func (e *Eagle) Sync() ([]string, error)

func (*Eagle) TransformEntryData

func (e *Eagle) TransformEntryData(entry *Entry, t func(*EntryData) (*EntryData, error)) error

func (*Eagle) UpdateTargets

func (e *Eagle) UpdateTargets(entry *Entry) error

type Entry

type Entry struct {
	Path       string // The original path of the file. Might be empty.
	ID         string
	Permalink  string
	Content    string
	RawContent string
	Metadata   Metadata
}

func (*Entry) Date

func (e *Entry) Date() string

func (*Entry) Deleted

func (e *Entry) Deleted() bool

func (*Entry) Section

func (e *Entry) Section() string

func (*Entry) String

func (e *Entry) String() (string, error)

type EntryData

type EntryData struct {
	Targets     []string      `json:"targets"`
	Webmentions []*Webmention `json:"webmentions"`
}

type Feed

type Feed struct {
	Title    string `json:"title"`
	Site     string `json:"site"`
	Feed     string `json:"feed"`
	Category string `json:"category"`
}

type Media

type Media struct {
	*config.BunnyCDN
	// contains filtered or unexported fields
}

func (*Media) UploadMedia

func (m *Media) UploadMedia(filename string, data io.Reader) (string, error)

type MeiliSearch

type MeiliSearch struct {
	meilisearch.ClientInterface
}

func NewMeiliSearch

func NewMeiliSearch(conf *config.MeiliSearch) (*MeiliSearch, bool, error)

func (*MeiliSearch) Add

func (ms *MeiliSearch) Add(entries ...*Entry) error

func (*MeiliSearch) Remove

func (ms *MeiliSearch) Remove(entries ...*Entry) error

func (*MeiliSearch) ResetIndex

func (ms *MeiliSearch) ResetIndex() error

func (*MeiliSearch) Search

func (ms *MeiliSearch) Search(query *SearchQuery, page int) ([]*SearchEntry, error)
type Menu struct {
	Weight int    `yaml:"weight,omitempty"`
	Name   string `yaml:"name,omitempty"`
	Pre    string `yaml:"pre,omitempty"`
}

type Metadata

type Metadata struct {
	DataID      string           `yaml:"dataId,omitempty"`
	Title       string           `yaml:"title,omitempty"`
	Description string           `yaml:"description,omitempty"`
	Tags        []string         `yaml:"tags,omitempty"`
	Date        time.Time        `yaml:"date,omitempty"`
	Lastmod     time.Time        `yaml:"lastmod,omitempty"`
	ExpiryDate  time.Time        `yaml:"expiryDate,omitempty"`
	Syndication []string         `yaml:"syndication,omitempty"`
	ReplyTo     *XRay            `yaml:"replyTo,omitempty"`
	URL         string           `yaml:"url,omitempty"`
	Aliases     []string         `yaml:"aliases,omitempty"`
	Emoji       string           `yaml:"emoji,omitempty"`
	Layout      string           `yaml:"layout,omitempty"`
	NoIndex     bool             `yaml:"noIndex,omitempty"`
	NoMentions  bool             `yaml:"noMentions,omitempty"`
	Math        bool             `yaml:"math,omitempty"`
	Mermaid     bool             `yaml:"mermaid,omitempty"`
	Pictures    []*Picture       `yaml:"pictures,omitempty"`
	Cover       *Picture         `yaml:"cover,omitempty"`
	Draft       bool             `yaml:"draft,omitempty"`
	Growth      string           `yaml:"growth,omitempty"`
	Menu        map[string]*Menu `yaml:"menu,omitempty"`
	Photo       []interface{}    `yaml:"photo,omitempty"`
	PhotoClass  string           `yaml:"photoClass,omitempty"`
}

type Miniflux

type Miniflux struct {
	*config.Miniflux
}

func (*Miniflux) Fetch

func (m *Miniflux) Fetch() ([]Feed, error)

type Notifications

type Notifications interface {
	// Notify should notify the administrator of a certain message.
	Notify(msg string)
	// NotifyError should notify the administrator of the error and log it.
	NotifyError(err error)
}

type Picture

type Picture struct {
	Title string `yaml:"title,omitempty"`
	Slug  string `yaml:"slug,omitempty"`
	Hide  bool   `yaml:"hide,omitempty"`
}

type SearchEntry

type SearchEntry struct {
	// SearchID is for Meilisearch. See searchKey.
	SearchID string `json:"idx" mapstructure:"idx"`

	ID        string   `json:"id" mapstructure:"id"`
	Permalink string   `json:"permalink" mapstructure:"permalink"`
	Title     string   `json:"title" mapstructure:"title"`
	Tags      []string `json:"tags" mapstructure:"tags"`
	Content   string   `json:"content" mapstructure:"content"`
	Section   string   `json:"section" mapstructure:"section"`
	Draft     bool     `json:"draft" mapstructure:"draft"`
	Deleted   bool     `json:"deleted" mapstructure:"deleted"`
	Date      string   `json:"date" mapstructure:"date"`
}

type SearchIndex

type SearchIndex interface {
	ResetIndex() error
	Add(entries ...*Entry) error
	Remove(entries ...*Entry) error
	Search(query *SearchQuery, page int) ([]*SearchEntry, error)
}

type SearchQuery

type SearchQuery struct {
	Query    string
	Sections []string // if empty, matches all sections
	ByDate   bool
	Draft    *bool
	Deleted  *bool
}

type Twitter

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

func NewTwitter

func NewTwitter(opts *config.Twitter) *Twitter

func (*Twitter) Syndicate

func (t *Twitter) Syndicate(entry *Entry) (string, error)

func (*Twitter) UserExists

func (t *Twitter) UserExists(user string) (bool, error)

type Webmention

type Webmention struct {
	XRay `yaml:",inline"`
	// Specifically for webmentions received from https://webmention.io
	// TODO: remove this and compare webmentions via URL.
	WmID    int  `yaml:"wm-id,omitempty" json:"wm-id,omitempty"`
	Private bool `json:"private,omitempty"`
}

type WebmentionContent

type WebmentionContent struct {
	Text string `json:"text"`
	HTML string `json:"html"`
}

type WebmentionPayload

type WebmentionPayload struct {
	Source  string `json:"source"`
	Secret  string `json:"secret"`
	Deleted bool   `json:"deleted"`
	Target  string `json:"target"`
	Post    struct {
		Type       string            `json:"type"`
		Author     Author            `json:"author"`
		URL        string            `json:"url"`
		Published  string            `json:"published"`
		WmReceived string            `json:"wm-received"`
		WmID       int               `json:"wm-id"`
		Content    WebmentionContent `json:"content"`
		MentionOf  string            `json:"mention-of"`
		WmProperty string            `json:"wm-property"`
		WmSource   string            `json:"wm-source"`
		WmPrivate  bool              `json:"wm-private"`
	} `json:"post"`
}

type XRay

type XRay struct {
	Type    string    `yaml:"type,omitempty" json:"type,omitempty"`
	URL     string    `yaml:"url,omitempty" json:"url,omitempty"`
	Name    string    `yaml:"name,omitempty" json:"name,omitempty"`
	Content string    `yaml:"content,omitempty" json:"content,omitempty"`
	Date    time.Time `yaml:"date,omitempty" json:"date,omitempty"`
	Author  *Author   `yaml:"author,omitempty" json:"author,omitempty"`
}

XRay is an xray of an external post. This is the format used to store Webmentions and ReplyTo context.

Jump to

Keyboard shortcuts

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