Documentation ¶
Index ¶
- Constants
- Variables
- func Absurl(prefix, path string) (string, error)
- func Base(value string) string
- func Capitalize(s string) string
- func Chroma(htmlsource string, style string) string
- func Contains(needle, value string) bool
- func CopyFile(srcPath, dstPath string) (n int64, err error)
- func Count(text string) int
- func Cut(begin, end, value string) (string, error)
- func Dir(value string) string
- func Ends(needle, value string) bool
- func Even(value int) bool
- func Excerpt(text string, maxWords int) string
- func Exec(cmd string, arg ...string) (string, error)
- func ExecText(cmd string, arg ...string) (string, error)
- func HasChanged(name string, value interface{}) bool
- func Hash(value string) string
- func IsDir(path string) (bool, error)
- func Markdown(source string, args []string) string
- func Matches(pattern, value string) (bool, error)
- func NonEmptySplit(s string, sep string) []string
- func Odd(value int) bool
- func ReFind(pattern, value string) (string, error)
- func ReadingTime(text string) int
- func Replace(old, new, value string) string
- func ReplaceN(old, new string, n int, value string) string
- func ReplaceRe(pattern, repl, value string) (string, error)
- func SliceStringIndexOf(haystack []string, needle string) int
- func Some(strs ...interface{}) string
- func Split(sep, value string) []string
- func Starts(needle, value string) bool
- func StripHTML(value string) string
- func StripNewlines(value string) string
- func TemplateMarkdown(strs ...string) string
- func TrimSplitN(s string, sep string, n int) []string
- func Truncate(length int, value string) string
- func Versionize(current *Page, value string) (string, error)
- func WriteExample(dir string) error
- func WriteFile(dir string, fn string, content string) error
- type Command
- type CommandList
- type Page
- func (page *Page) Changed() bool
- func (page *Page) Content() string
- func (page *Page) FullPath() string
- func (page *Page) Has(field, value string) bool
- func (page *Page) Is(path string) bool
- func (page *Page) Name() string
- func (page *Page) Next() *Page
- func (page *Page) OutputPath() string
- func (page *Page) Peek() error
- func (page *Page) Prev() *Page
- func (page *Page) Process() (*Page, error)
- func (page *Page) Raw() string
- func (page *Page) Rel(path string) string
- func (page *Page) Render() (n int64, err error)
- func (page *Page) SetContent(content string)
- func (page *Page) SetState(state int)
- func (page *Page) SetWasRead(wasread bool)
- func (page *Page) Url() string
- func (page *Page) UrlMatches(regex string) bool
- func (page *Page) UrlTo(other *Page) string
- func (page *Page) WasRead() bool
- func (page *Page) WriteTo(writer io.Writer) (n int64, err error)
- type PageHeader
- type PageSlice
- func (pages PageSlice) ByPath(s string) *Page
- func (pages PageSlice) BySource(s string) *Page
- func (pages PageSlice) Children(root string) *PageSlice
- func (pages PageSlice) First() *Page
- func (pages PageSlice) Get(i int) *Page
- func (pages PageSlice) GlobSource(pattern string) *PageSlice
- func (pages PageSlice) HasPage(check func(page *Page) bool) bool
- func (pages PageSlice) Last() *Page
- func (pages PageSlice) Len() int
- func (pages PageSlice) Less(i, j int) bool
- func (pages PageSlice) Next(cur *Page) *Page
- func (pages PageSlice) Prev(cur *Page) *Page
- func (pages PageSlice) Reverse() *PageSlice
- func (pages PageSlice) Slice(from int, to int) PageSlice
- func (pages PageSlice) Sort()
- func (pages PageSlice) Swap(i, j int)
- func (pages PageSlice) Where(field, value string) *PageSlice
- func (pages PageSlice) WhereNot(field, value string) *PageSlice
- func (pages PageSlice) WithTag(tag string) *PageSlice
- type Processor
- type ProcessorMap
- type Rule
- type RuleMap
- type Site
- func (site *Site) AddPages(path string)
- func (site *Site) Collect()
- func (site *Site) FindDeps()
- func (site *Site) Lookup(path string) *Page
- func (site *Site) PageBySomePath(s string) *Page
- func (site *Site) Process() (int, error)
- func (site *Site) ProcessAll() error
- func (s *Site) ProcessCommand(page *Page, cmd *Command, pre bool) error
- func (site *Site) Reconfig()
- func (site *Site) Render()
- func (site *Site) Summary()
- type SiteConfig
Constants ¶
const ( StateUnknown = iota StateChanged StateUnchanged StateIgnored )
const ( // Preprocessor is a processor which will be executed during initialization // stage Pre = 1 << iota Hidden Post )
const VERSION = "2.36"
Current gostatic version
Variables ¶
var ( Code = regexp.MustCompile(`(?s)<pre><code[^>]*>.+?</code></pre>`) LangRe = regexp.MustCompile(`<code class="language-([^"]+)">`) )
var DATEFORMATS = []string{ time.RFC3339, time.RFC3339Nano, "2006-01-02T15:04:05Z-07:00", "2006-01-02T15:04:05Z", "2006-01-02 15:04:05 -0700", "2006-01-02 15:04:05 -07", "2006-01-02 15:04:05", "2006-01-02 15:04", "2006-01-02 15", "2006-01-02", "06-01-02", }
var (
DEBUG bool = false
)
var ExampleConfig = `` /* 399-byte string literal not displayed */
var ExampleFeed = `` /* 1187-byte string literal not displayed */
var ExampleIndex = `` /* 196-byte string literal not displayed */
var ExampleMakefile = `
GS ?= gostatic
compile:
$(GS) config
w:
$(GS) -w config
`
var ExamplePost = `
title: First Post
date: 2012-12-12
tags: blog
----
My first post with [gostatic](https://github.com/piranha/gostatic).
`
var ExampleStyle = `
/* put your style rules here */
`
var ExampleTemplate = `` /* 1291-byte string literal not displayed */
var FalsyValues = map[string]bool{ "false": true, "False": true, "FALSE": true, "f": true, }
var TemplateFuncMap = template.FuncMap{ "changed": HasChanged, "cut": Cut, "hash": Hash, "version": Versionize, "truncate": Truncate, "strip_html": StripHTML, "strip_newlines": StripNewlines, "trim": strings.TrimSpace, "replace": Replace, "replacen": ReplaceN, "replacere": ReplaceRe, "split": Split, "contains": Contains, "starts": Starts, "ends": Ends, "matches": Matches, "refind": ReFind, "markdown": TemplateMarkdown, "exec": Exec, "exectext": ExecText, "excerpt": Excerpt, "even": Even, "odd": Odd, "count": Count, "reading_time": ReadingTime, "some": Some, "dir": Dir, "base": Base, "absurl": Absurl, "abcsort": AbcSort, }
TemplateFuncMap contains the mapping of function names and their corresponding Go functions, to be used within templates.
var VarRe = regexp.MustCompile(`\$\(([^\)]+)\)`)
Functions ¶
func Capitalize ¶
func Excerpt ¶
Excerpt takes an input string (for example, text from a blog post), and truncates it to the amount of words given in maxWords. For instance, given the text:
"The quick brown fox jumps, over the lazy dog."
and the given maxWords of 0, 1, 3, 4, and 6, 999, it will return in order:
"" // an empty string "The [...]" "The quick brown [...]" "The quick brown fox [...]" "The quick brown fox jumps, over the lazy dog."
func HasChanged ¶
func NonEmptySplit ¶
func ReadingTime ¶
func Replace ¶
Replace replaces `old' with `new' in the given value string and returns it. There is no limit on the amount of replacements.
func ReplaceN ¶
ReplaceN replaces the `old' string with the `new' string in the given value, n times. If n < 0, there is no limit on the number of replacements.
func SliceStringIndexOf ¶
func StripNewlines ¶
StripNewlines removes all \r and \n characters from the value string, and returns it as such.
func TemplateMarkdown ¶
func WriteExample ¶
Types ¶
type Command ¶
type Command string
Command is a command belonging to a Rule. For example, `markdown', `directorify'.
type Page ¶
type Page struct { PageHeader Site *Site `json:"-"` Rule *Rule Pattern string Deps PageSlice `json:"-"` Source string Path string ModTime time.Time // contains filtered or unexported fields }
func (*Page) OutputPath ¶
func (*Page) Peek ¶
Peek is used to run those processors which should be done before others can find out about us. Two actual examples include 'config' and 'rename' processors.
func (*Page) SetContent ¶
func (*Page) SetWasRead ¶
SetWasRead is used for dynamically created pages
func (*Page) UrlMatches ¶
type PageHeader ¶
type PageHeader struct { Title string Tags []string Date time.Time Hide bool Other map[string]string }
func NewPageHeader ¶
func NewPageHeader() *PageHeader
func ParseHeader ¶
func ParseHeader(source string) *PageHeader
func ParseYamlHeader ¶
func ParseYamlHeader(source string) *PageHeader
type ProcessorMap ¶
func (ProcessorMap) ProcessorSummary ¶
func (pm ProcessorMap) ProcessorSummary()
type Rule ¶
type Rule struct { Deps []string Commands CommandList }
Rule is a collection of a slice of dependencies, with a slice of commands in the form of a CommandList.
func (*Rule) ParseCommand ¶
func (rule *Rule) ParseCommand(cfg *SiteConfig, line string)
type Site ¶
type Site struct { ConfigPath string SiteConfig Template *template.Template ChangedAt time.Time Pages PageSlice ForceRefresh bool Processors map[string]Processor // contains filtered or unexported fields }
func (*Site) PageBySomePath ¶
func (*Site) ProcessAll ¶
func (*Site) ProcessCommand ¶
type SiteConfig ¶
type SiteConfig struct { Templates []string Base string Source string Output string Rules RuleMap Other map[string]string // contains filtered or unexported fields }
SiteConfig contains the data for a complete parsed site configuration file.
func NewSiteConfig ¶
func NewSiteConfig(path string) (*SiteConfig, error)
NewSiteConfig parses the given `path' file to a *SiteConfig. Will return a nil pointer plus the non-nil error if the parsing has failed.
func (*SiteConfig) ParseRule ¶
func (cfg *SiteConfig) ParseRule(line string) *Rule
func (*SiteConfig) ParseVariable ¶
func (cfg *SiteConfig) ParseVariable(base string, line string)
func (*SiteConfig) SubVars ¶
func (cfg *SiteConfig) SubVars(s string) string