site

package
v0.0.0-...-96c5686 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SITE_EWNL  = SiteID("ewnl")
	SITE_VKVNL = SiteID("vkvnl")
)
View Source
const (
	KIND_NOTE    = Kind("note")
	KIND_STORY   = Kind("story")
	KIND_ARTICLE = Kind("article")
	KIND_INVALID = Kind("")
)
View Source
const (
	LANGUAGE_EN      = Language("en")
	LANGUAGE_NL      = Language("nl")
	LANGUAGE_INVALID = Language("")
)

Variables

View Source
var (
	SITE_CONFIG_EWNL = &SiteConfig{
		ID:            SITE_EWNL,
		BaseURL:       "https://erikwinter.nl",
		PathsWithKind: true,
		TemplateConfigs: []*TemplateConfig{
			{
				Name:          "home",
				TemplateNames: []string{"list", "head", "menu"},
				TemplateExt:   "gohtml",
				Render:        renderEWNLHome,
			},
			{
				Name:          "listings",
				TemplateNames: []string{"list", "head", "menu"},
				TemplateExt:   "gohtml",
				Render:        renderEWNLListings,
			},
			{
				Name:          "archive",
				TemplateNames: []string{"archive", "head", "menu"},
				TemplateExt:   "gohtml",
				Render:        renderEWNLArchive,
			},
			{
				Name:          "static",
				TemplateNames: []string{"static", "head", "menu"},
				TemplateExt:   "gohtml",
				Render:        renderEWNLStaticPages,
			},
			{
				Name:          "posts",
				TemplateNames: []string{"post", "head", "menu"},
				TemplateExt:   "gohtml",
				Render:        renderEWNLPosts,
			},
			{
				Name:          "rss",
				TemplateNames: []string{"rss"},
				TemplateExt:   "goxml",
				Render:        renderEWNLRSS,
			},
		},
		KindMap: map[adoc.Kind]Kind{
			adoc.KIND_NOTE:     KIND_NOTE,
			adoc.KIND_VKV:      KIND_STORY,
			adoc.KIND_ESSAY:    KIND_ARTICLE,
			adoc.KIND_TUTORIAL: KIND_ARTICLE,
			adoc.KIND_ARTICLE:  KIND_ARTICLE,
		},
	}

	SITE_CONFIG_VKVNL = &SiteConfig{
		ID:            SITE_VKVNL,
		BaseURL:       "https://vrijkorteverhalen.nl",
		PathsWithKind: false,
		TemplateConfigs: []*TemplateConfig{
			{
				Name:          "post",
				TemplateNames: []string{"post"},
				TemplateExt:   "gohtml",
				Render:        renderVKVNLPosts,
			},
			{
				Name:          "rss",
				TemplateNames: []string{"rss"},
				TemplateExt:   "goxml",
				Render:        renderVKVNLRSS,
			},
		},
		KindMap: map[adoc.Kind]Kind{
			adoc.KIND_VKV: KIND_STORY,
		},
	}
)
View Source
var (
	ErrInvalidPost = errors.New("invalid post")
)
View Source
var (
	ErrUnknownSiteID = errors.New("unknown site id")
)

Functions

func FormatBlock

func FormatBlock(block adoc.BlockElement) string

func FormatDate

func FormatDate(date time.Time, language Language, format DateFormat) string

func FormatInline

func FormatInline(src adoc.InlineElement) string

func TruncateOnSpace

func TruncateOnSpace(text string, maxChars int) string

Types

type DateFormat

type DateFormat int
const (
	DATE_SHORT DateFormat = iota
	DATE_LONG
	DATE_FORMAL //Sat, 12 Sep 2020 12:32:00 +0200
)

type HTMLPost

type HTMLPost struct {
	Slug      string
	Title     string
	DateLong  string
	DateShort string
	Content   string
}

type HTMLSummary

type HTMLSummary struct {
	Link      string
	Title     string
	Language  Language
	DateShort string
	DateLong  string
	Summary   string
}

type Kind

type Kind string

type Language

type Language string

func NewLanguage

func NewLanguage(ln adoc.Language) Language

type Post

type Post struct {
	Date     time.Time
	Kind     Kind
	Language Language
	Tags     []Tag
	// contains filtered or unexported fields
}

func NewPost

func NewPost(config *SiteConfig, doc *adoc.ADoc) *Post
func (p *Post) FullLink() string

func (*Post) HTMLPost

func (p *Post) HTMLPost() *HTMLPost

func (*Post) HTMLSummary

func (p *Post) HTMLSummary() *HTMLSummary
func (p *Post) Link() string

func (Post) Slug

func (p Post) Slug() string

func (*Post) XMLPost

func (p *Post) XMLPost() *XMLPost

func (*Post) Year

func (p *Post) Year() string

type Posts

type Posts []*Post

func (Posts) Len

func (p Posts) Len() int

func (Posts) Less

func (p Posts) Less(i, j int) bool

func (Posts) Limit

func (p Posts) Limit(limit int) Posts

func (Posts) RemoveKind

func (p Posts) RemoveKind(kind Kind) Posts

func (Posts) SelectKind

func (p Posts) SelectKind(wanted Kind) Posts

func (Posts) SelectTag

func (p Posts) SelectTag(wanted Tag) Posts

func (Posts) SelectYear

func (p Posts) SelectYear(year string) Posts

func (Posts) Sort

func (p Posts) Sort() Posts

Sort sorts on reverse chronological order

func (Posts) Swap

func (p Posts) Swap(i, j int)

func (Posts) TagList

func (p Posts) TagList() []string

func (Posts) YearList

func (p Posts) YearList() []string

type Site

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

func New

func New(config *SiteConfig, resourcesPath string) (*Site, error)

func (*Site) AddFilePost

func (s *Site) AddFilePost(fPath string) error

func (*Site) AddStaticPage

func (s *Site) AddStaticPage(staticPath string)

func (*Site) RenderHTML

func (s *Site) RenderHTML(targetPath string) error

type SiteConfig

type SiteConfig struct {
	ID              SiteID
	BaseURL         string
	PathsWithKind   bool
	TemplateConfigs []*TemplateConfig
	StaticPages     []*StaticPage
	KindMap         map[adoc.Kind]Kind
}

func NewSiteConfig

func NewSiteConfig(id SiteID) (*SiteConfig, error)

func (*SiteConfig) MapKind

func (sc *SiteConfig) MapKind(docKind adoc.Kind) Kind

func (*SiteConfig) ParseTemplates

func (sc *SiteConfig) ParseTemplates(tplPath string) error

type SiteID

type SiteID string

type StaticPage

type StaticPage struct {
	Name string
	Path string
}

type Tag

type Tag string

type TemplateConfig

type TemplateConfig struct {
	Name          string
	TemplateNames []string
	TemplateExt   string
	Template      *template.Template
	Render        func(targetPath string, tpl *template.Template, posts Posts, staticPages []*StaticPage) error
}

type XMLPost

type XMLPost struct {
	Link       string
	Title      string
	DateFormal string
	Content    string
}

Jump to

Keyboard shortcuts

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