core

package
v0.0.0-...-9a36425 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SpecialSection  = "posts"
	SpecialTaxonomy = "categories"
)
View Source
const (
	ContentDirectory string = "content"
	DataDirectory    string = "data"

	RedirectsFile = "redirects"
	GoneFile      = "gone"
)

Variables

This section is empty.

Functions

func NewPostID

func NewPostID(slug string, t time.Time) string

Types

type BunnyCDN

type BunnyCDN struct {
	Zone string
	Key  string
	Base string
}

type Comments

type Comments struct {
	Redirect string
}

type Config

type Config struct {
	ServerConfig
	Site SiteConfig
}

func ParseConfig

func ParseConfig() (*Config, error)

ParseConfig parses the configuration from the default files and paths.

type Core

type Core struct {
	BuildHook func(string) // called when the build directory has changed
	// contains filtered or unexported fields
}

func NewCore

func NewCore(cfg *Config) (*Core, error)

func (*Core) AddOrUpdateWebmention

func (co *Core) AddOrUpdateWebmention(id string, mention *Mention, sourceOrURL string) error

func (*Core) BaseURL

func (co *Core) BaseURL() *url.URL

BaseURL returns a clone of the base URL.

func (*Core) Build

func (co *Core) Build(cleanBuildDirectory bool) error

func (*Core) DeleteWebmention

func (co *Core) DeleteWebmention(id, sourceOrURL string) error

func (*Core) GetEntries

func (co *Core) GetEntries(includeList bool) (Entries, error)

func (*Core) GetEntry

func (co *Core) GetEntry(id string) (*Entry, error)
func (co *Core) GetEntryFromPermalink(permalink string) (*Entry, error)
func (co *Core) GetEntryLinks(permalink string, withSyndications bool) ([]string, error)

GetEntryLinks gets the links found in the HTML rendered version of the entry. This uses the latest available build to check for the links. Entry must have .h-entry and .e-content classes.

func (*Core) GetGone

func (co *Core) GetGone() (map[string]bool, error)

func (*Core) GetRedirects

func (co *Core) GetRedirects(ignoreMalformed bool) (map[string]string, error)

func (*Core) IsLinkValid

func (co *Core) IsLinkValid(permalink string) (bool, error)

IsLinkValid checks if the given link exists in the built version of the website.

func (*Core) MkdirAll

func (co *Core) MkdirAll(filename string) error

func (*Core) NewBlankEntry

func (co *Core) NewBlankEntry(id string) *Entry

func (*Core) ReadDir

func (co *Core) ReadDir(filename string) ([]os.FileInfo, error)

func (*Core) ReadFile

func (co *Core) ReadFile(filename string) ([]byte, error)

func (*Core) ReadJSON

func (co *Core) ReadJSON(filename string, v interface{}) error

func (*Core) RemoveAll

func (co *Core) RemoveAll(path string) error

func (*Core) SaveEntry

func (co *Core) SaveEntry(e *Entry) error

func (*Core) SendWebmentions

func (co *Core) SendWebmentions(permalink string, otherTargets ...string) error

func (*Core) ShouldBuild

func (co *Core) ShouldBuild() (bool, error)

ShouldBuild returns true if the website has to be built. This should only return true after initialization.

func (*Core) Stat

func (co *Core) Stat(filename string) (os.FileInfo, error)

func (*Core) Sync

func (co *Core) Sync() ([]string, error)

func (*Core) UpdateSidecar

func (f *Core) UpdateSidecar(entry *Entry, t func(*Sidecar) (*Sidecar, error)) error

func (*Core) WriteFile

func (co *Core) WriteFile(filename string, data []byte, message string) error

func (*Core) WriteFiles

func (co *Core) WriteFiles(filesAndData map[string][]byte, message string) error

func (*Core) WriteJSON

func (co *Core) WriteJSON(filename string, data interface{}, message string) error

type Entries

type Entries []*Entry

type Entry

type Entry struct {
	FrontMatter
	ID           string
	IsList       bool
	Permalink    string
	RelPermalink string
	Content      string
}

func (*Entry) Deleted

func (e *Entry) Deleted() bool

func (*Entry) String

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

func (*Entry) Summary

func (e *Entry) Summary() string

func (*Entry) Taxonomy

func (e *Entry) Taxonomy(taxonomy string) []string

func (*Entry) TextContent

func (e *Entry) TextContent() string

type FrontMatter

type FrontMatter struct {
	Title         string         `yaml:"title,omitempty"`
	Description   string         `yaml:"description,omitempty"`
	Draft         bool           `yaml:"draft,omitempty"`
	Date          time.Time      `yaml:"date,omitempty"`
	Lastmod       time.Time      `yaml:"lastmod,omitempty"`
	ExpiryDate    time.Time      `yaml:"expiryDate,omitempty"`
	NoIndex       bool           `yaml:"noIndex,omitempty"`
	NoWebmentions bool           `yaml:"noWebmentions,omitempty"`
	Other         map[string]any `yaml:",inline"`
}

type ImgProxy

type ImgProxy struct {
	Directory string
	Endpoint  string
}

type Login

type Login struct {
	Username string
	Password string
}

type MeiliSearch

type MeiliSearch struct {
	Endpoint   string
	Key        string
	Taxonomies []string
}

type Mention

type Mention struct {
	xray.Post
	Source string `json:"source,omitempty"`

	ID      string `json:"-"`
	EntryID string `json:"-"`
}

func (*Mention) IsInteraction

func (m *Mention) IsInteraction() bool

type Micropub

type Micropub struct {
	ChannelsTaxonomy   string
	CategoriesTaxonomy string
	Properties         []string
	PostTypes          []micropub.PostType
}

type Notifications

type Notifications struct {
	Telegram *Telegram
}

type Notifier

type Notifier interface {
	Info(msg string)
	Error(err error)
}

type ServerConfig

type ServerConfig struct {
	Development     bool
	SourceDirectory string
	PublicDirectory string
	DataDirectory   string
	Port            int
	BaseURL         string // NOTE: maybe use the one from [SiteConfig].
	TokensSecret    string
	WebhookSecret   string
	Tor             bool

	Login         Login
	Comments      Comments
	Webmentions   Webmentions
	Micropub      *Micropub
	Notifications Notifications
	BunnyCDN      *BunnyCDN
	MeiliSearch   *MeiliSearch
	ImgProxy      *ImgProxy
	Plugins       map[string]map[string]interface{}
}

func (*ServerConfig) AbsoluteURL

func (c *ServerConfig) AbsoluteURL(refStr string) string

func (*ServerConfig) ID

func (c *ServerConfig) ID() string

type Sidecar

type Sidecar struct {
	Context      *xray.Post `json:"context,omitempty"`
	Replies      []*Mention `json:"replies,omitempty"`
	Interactions []*Mention `json:"interactions,omitempty"`
}

func (*Sidecar) Empty

func (s *Sidecar) Empty() bool

type SiteConfig

type SiteConfig struct {
	Paginate   int
	Taxonomies map[string]string
	Params     struct {
		Author struct {
			Name   string
			Email  string
			Photo  string
			Handle string
		}
	}
}

type Telegram

type Telegram struct {
	Token  string
	ChatID int64
}

type Webmentions

type Webmentions struct {
	Secret string
}

Jump to

Keyboard shortcuts

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