Documentation ¶
Index ¶
- Constants
- Variables
- func Capitalize(s string) string
- func Contains(needle, value string) bool
- func CopyFile(srcPath, dstPath string) (n int64, err error)
- func Cut(begin, end, value string) (string, error)
- func Excerpt(text string, maxWords int) string
- func HasChanged(name string, value interface{}) bool
- func Hash(value string) string
- func IsDir(path string) (bool, error)
- func Markdown(source string) string
- func NonEmptySplit(s string, sep string) []string
- func Replace(old, new, value string) string
- func ReplaceN(old, new string, n int, value string) string
- func SliceStringIndexOf(haystack []string, needle string) int
- func Split(sep, value string) []string
- func StripHTML(value string) string
- func StripNewlines(value 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
- func Watch(s *Site)
- func Watcher(config *SiteConfig) (chan 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) Is(path string) bool
- func (page *Page) Next() *Page
- func (page *Page) OutputPath() string
- func (page *Page) Peek()
- func (page *Page) Prev() *Page
- func (page *Page) Process() *Page
- 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()
- func (pages PageSlice) Slice(from int, to int) PageSlice
- func (pages PageSlice) Sort()
- func (pages PageSlice) Swap(i, j int)
- func (pages PageSlice) WithTag(tag string) *PageSlice
- type Processor
- type ProcessorMap
- type Rule
- type RuleMap
- type Site
- func (site *Site) AddPage(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
- func (site *Site) ProcessAll()
- func (s *Site) ProcessCommand(page *Page, cmd *Command, pre bool) error
- 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.3"
)
Variables ¶
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 = `` /* 398-byte string literal not displayed */
var ExampleFeed = `` /* 1187-byte string literal not displayed */
var ExampleIndex = `` /* 183-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](http://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, "replace": Replace, "replacen": ReplaceN, "split": Split, "contains": Contains, "markdown": Markdown, "excerpt": Excerpt, }
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 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 Versionize ¶
func Watcher ¶
func Watcher(config *SiteConfig) (chan string, error)
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 ¶
func (page *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 right now.
func (*Page) SetContent ¶
func (*Page) SetWasRead ¶
will be 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
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 { SiteConfig Template *template.Template ChangedAt time.Time Pages PageSlice ForceRefresh bool Processors map[string]Processor }
func NewSite ¶
func NewSite(config *SiteConfig, procs ProcessorMap) *Site
func (*Site) PageBySomePath ¶
func (*Site) ProcessAll ¶
func (site *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