article

package
v0.0.0-...-9431910 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package article includes common types and functions for the articles app and command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	// Id is the article identifier, used by the template
	// function reverse_article.
	Id string
	// Titles includes the current title and then all the previous ones.
	// The previous ones are kept for redirecting old URLs to the
	// new one.
	Titles []string
	// Slugs contains the current slug and all the previous ones (for
	// redirecting all URLs). If no slugs are present, the current title
	Slugs []string
	// is slugified.
	// The article synopsys shown in the articles list. Might be empty.
	Synopsis string
	// A list of times when the article was created.
	Updated []time.Time
	// The priority to sort articles in the index. Articles with the same
	// priority are sorted by title.
	Priority int
	// Text contains the article text, with any properties stripped.
	Text []byte
	// Properties contains unknown properties, to allow forward
	// compatibility. It might be nil.
	Properties map[string][]string
	// Filename indicates the base filename where this article was loaded
	// from, always using UNIX style directory separators. Note that it might be empty.
	Filename string
}

Article represents a loaded article.

func New

func New(r io.Reader) (*Article, error)

New returns a new Article by decoding it from the given io.Reader.

func Open

func Open(fs vfs.VFS, filename string) (*Article, error)

Open returns a new Article loading it from the given filename in the given fs.

func OpenFile

func OpenFile(filename string) (*Article, error)

OpenFile returns a new Article loading it from the file at the given path.

func (*Article) AllSlugs

func (a *Article) AllSlugs() []string

AllSlugs returns the current and all the previous article slugs, used for redirects.

func (*Article) Created

func (a *Article) Created() time.Time

Created returns the article creation time, or the zero time.Time if there are no recorded updates to the article.

func (*Article) LastUpdate

func (a *Article) LastUpdate() time.Time

LastUpdate returns the most recent update time, or the zero time.Time if there are no recorded updates to the article.

func (*Article) Set

func (a *Article) Set(key string, value string) error

Set sets a property in the article. For slice properties, it prepends the new value to the existing ones.

func (*Article) Slug

func (a *Article) Slug() string

Slug returns the current article slug.

func (*Article) Title

func (a *Article) Title() string

Title returns the current article title.

func (*Article) WriteTo

func (a *Article) WriteTo(w io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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