Documentation
¶
Index ¶
- Variables
- func CompileAll() error
- func FileChanged(srcPath string, ev *fsnotify.FileEvent) error
- func FindPaths(mf MatchFunc) ([]string, error)
- func RemoveAllOld() error
- type Compiler
- type HtmlTemplatesCompilerType
- func (c *HtmlTemplatesCompilerType) Compile(srcPath string) error
- func (c *HtmlTemplatesCompilerType) CompileAll(srcPaths []string) error
- func (c *HtmlTemplatesCompilerType) CompileMatchFunc() MatchFunc
- func (c *HtmlTemplatesCompilerType) FileChanged(srcPath string, ev *fsnotify.FileEvent) error
- func (c *HtmlTemplatesCompilerType) Init()
- func (c *HtmlTemplatesCompilerType) PostLayoutMatchFunc() MatchFunc
- func (c *HtmlTemplatesCompilerType) RemoveOld() error
- func (c *HtmlTemplatesCompilerType) RenderPost(post *Post, destPath string) error
- func (c *HtmlTemplatesCompilerType) WatchMatchFunc() MatchFunc
- type Initer
- type JadeCompilerType
- func (j *JadeCompilerType) Compile(srcPath string) error
- func (j *JadeCompilerType) CompileAll(srcPaths []string) error
- func (*JadeCompilerType) CompileMatchFunc() MatchFunc
- func (j *JadeCompilerType) FileChanged(srcPath string, ev *fsnotify.FileEvent) error
- func (c *JadeCompilerType) PostLayoutMatchFunc() MatchFunc
- func (j *JadeCompilerType) RemoveOld() error
- func (c *JadeCompilerType) RenderPost(post *Post, destPath string) error
- func (*JadeCompilerType) WatchMatchFunc() MatchFunc
- type MatchFunc
- type Post
- type PostLayoutCompiler
- type PostsByDate
- type PostsCompilerType
- func (p *PostsCompilerType) Compile(srcPath string) error
- func (p *PostsCompilerType) CompileAll(srcPaths []string) error
- func (p *PostsCompilerType) CompileMatchFunc() MatchFunc
- func (p *PostsCompilerType) FileChanged(srcPath string, ev *fsnotify.FileEvent) error
- func (p *PostsCompilerType) Init()
- func (p *PostsCompilerType) RemoveOld() error
- func (p *PostsCompilerType) WatchMatchFunc() MatchFunc
- type SassCompilerType
- func (s *SassCompilerType) Compile(srcPath string) error
- func (s *SassCompilerType) CompileAll(srcPaths []string) error
- func (s *SassCompilerType) CompileMatchFunc() MatchFunc
- func (s *SassCompilerType) FileChanged(srcPath string, ev *fsnotify.FileEvent) error
- func (s *SassCompilerType) RemoveOld() error
- func (s *SassCompilerType) WatchMatchFunc() MatchFunc
Constants ¶
This section is empty.
Variables ¶
var CompilerPaths = map[Compiler][]string{}
CompilerPaths is a map of Compiler to the matched paths for that Compiler
var Compilers = []Compiler{ &PostsCompiler, &SassCompiler, &HtmlTemplatesCompiler, &JadeCompiler, }
Compilers is a slice of all known Compilers. NOTE: it is important that PostsCompiler is the first item in the slice, because some other compilers rely on the existence of a list of parsed Post objects. For example, AceCompiler relies on the Posts function returning the correct results inside of ace templates.
var HtmlTemplatesCompiler = HtmlTemplatesCompilerType{}
HtmlTemplatesCompiler is an instatiation of HtmlTemplatesCompilerType
var JadeCompiler = JadeCompilerType{}
JadeCompiler is an instatiation of JadeCompilerType
var PostLayoutCompilers []PostLayoutCompiler
var PostsCompiler = PostsCompilerType{ // contains filtered or unexported fields }
PostCompiler is an instatiation of PostCompilerType
var SassCompiler = SassCompilerType{}
SassCompiler is an instatiation of SassCompilerType
var UnmatchedPaths = []string{}
UnmatchedPaths is a slice of paths which do not match any compiler
Functions ¶
func CompileAll ¶
func CompileAll() error
CompileAll compiles all files in config.SourceDir by delegating each path to it's corresponding Compiler. If a path in config.SourceDir does not match any Compiler, it will be copied to config.DestDir directly.
func FileChanged ¶
FileChanged delegates file changes to the appropriate compiler. If srcPath does not match any Compiler, it will be copied to config.DestDir directly.
func FindPaths ¶
FindPaths iterates recursively through config.SourceDir and returns all the matched paths using mf as a MatchFunc.
func RemoveAllOld ¶
func RemoveAllOld() error
RemoveAllOld removes all the files from config.DestDir
Types ¶
type Compiler ¶
type Compiler interface { // CompileMatchFunc returns a MatchFunc which will be applied // to every path in config.SourceDir to determine which paths // a Compiler is responsible for compiling. CompileMatchFunc() MatchFunc // Compile compiles a source file identified by srcPath. // srcPath will be some path that matches according to the // MatchFunc for the Compiler. Compile(srcPath string) error // CompileAll compiles all the files found in each path. // srcPaths will be all paths that match according to // the MatchFunc for the Compiler. CompileAll(srcPaths []string) error // RemoveAllOld removes all files which this compiler has created // in config.DestDir. A Compiler is responsible for keeping track // of the files it has created and removing them when this method // is called. RemoveOld() error // WatchMatchFunc returns a MatchFunc which will be applied // to every path in config.SourceDir to determine which paths // a Compiler is responsible for watching. Note that the files // that are watched may not be the same as those that are compiled. // E.g, files that start with an underscore are typically not compiled, // but may be imported or used by other files that are compiled, and // therefore should be watched. WatchMatchFunc() MatchFunc // FileChanged is triggered whenever a relevant file is changed. // Typically, the Compiler should recompile certain files. // srcPath will be some path that matches according to WatchMatchFunc, // and ev is the FileEvent associated with the change. FileChanged(srcPath string, ev *fsnotify.FileEvent) error }
Compiler is capable of compiling a certain type of file. It also is responsible for watching for changes to certain types of files.
type HtmlTemplatesCompilerType ¶
type HtmlTemplatesCompilerType struct {
// contains filtered or unexported fields
}
HtmlTemplatesCompilerType represents a type capable of compiling go html template files.
func (*HtmlTemplatesCompilerType) Compile ¶
func (c *HtmlTemplatesCompilerType) Compile(srcPath string) error
Compile compiles the file at srcPath. The caller will only call this function for files which belong to HtmlTemplatesCompiler according to the MatchFunc. Behavior for any other file is undefined. Compile will output the compiled result to the appropriate location in config.DestDir.
func (*HtmlTemplatesCompilerType) CompileAll ¶
func (c *HtmlTemplatesCompilerType) CompileAll(srcPaths []string) error
CompileAll compiles zero or more files identified by srcPaths. It works simply by calling Compile for each path. The caller is responsible for only passing in files that belong to HtmlTemplatesCompiler according to the MatchFunc. Behavior for any other file is undefined.
func (*HtmlTemplatesCompilerType) CompileMatchFunc ¶
func (c *HtmlTemplatesCompilerType) CompileMatchFunc() MatchFunc
CompileMatchFunc returns a MatchFunc which will return true for any files which match a given pattern. In this case, the pattern is any file that ends in ".tmpl", excluding hidden and ignored files and directories.
func (*HtmlTemplatesCompilerType) FileChanged ¶
func (c *HtmlTemplatesCompilerType) FileChanged(srcPath string, ev *fsnotify.FileEvent) error
func (*HtmlTemplatesCompilerType) Init ¶
func (c *HtmlTemplatesCompilerType) Init()
Init should be called before any other methods. In this case, Init finds and loads the layout templates in config.LayoutsDir
func (*HtmlTemplatesCompilerType) PostLayoutMatchFunc ¶
func (c *HtmlTemplatesCompilerType) PostLayoutMatchFunc() MatchFunc
func (*HtmlTemplatesCompilerType) RemoveOld ¶
func (c *HtmlTemplatesCompilerType) RemoveOld() error
func (*HtmlTemplatesCompilerType) RenderPost ¶
func (c *HtmlTemplatesCompilerType) RenderPost(post *Post, destPath string) error
func (*HtmlTemplatesCompilerType) WatchMatchFunc ¶
func (c *HtmlTemplatesCompilerType) WatchMatchFunc() MatchFunc
WatchMatchFunc returns a MatchFunc which will return true for any files which match a given pattern. In this case, the pattern is any file that ends in ".tmpl", excluding hidden files and directories, but including those that start with an underscore, since they may be imported in other files.
type Initer ¶
type Initer interface { // Init allows a Compiler or Watcher to do any necessary // setup before other methods are called. (e.g. set the // result of PathMatch based on some config variable). The // Init method is not required, but it will be called if // it exists. Init() }
Initer is an interface satisfied by any Compiler which needs to do something before Compile or CompileAll are called.
type JadeCompilerType ¶
type JadeCompilerType struct {
// contains filtered or unexported fields
}
JadeCompilerType represents a type capable of compiling jade files.
func (*JadeCompilerType) Compile ¶
func (j *JadeCompilerType) Compile(srcPath string) error
Compile compiles the file at srcPath. The caller will only call this function for files which belong to JadeCompiler according to the MatchFunc. Behavior for any other file is undefined. Compile will output the compiled result to the appropriate location in config.DestDir.
func (*JadeCompilerType) CompileAll ¶
func (j *JadeCompilerType) CompileAll(srcPaths []string) error
CompileAll compiles zero or more files identified by srcPaths. It works simply by calling Compile for each path. The caller is responsible for only passing in files that belong to JadeCompiler according to the MatchFunc. Behavior for any other file is undefined.
func (*JadeCompilerType) CompileMatchFunc ¶
func (*JadeCompilerType) CompileMatchFunc() MatchFunc
CompileMatchFunc returns a MatchFunc which will return true for any files which match a given pattern. In this case, the pattern is any file that ends in ".jade", excluding hidden and ignored files and directories.
func (*JadeCompilerType) FileChanged ¶
func (j *JadeCompilerType) FileChanged(srcPath string, ev *fsnotify.FileEvent) error
func (*JadeCompilerType) PostLayoutMatchFunc ¶
func (c *JadeCompilerType) PostLayoutMatchFunc() MatchFunc
func (*JadeCompilerType) RemoveOld ¶
func (j *JadeCompilerType) RemoveOld() error
func (*JadeCompilerType) RenderPost ¶
func (c *JadeCompilerType) RenderPost(post *Post, destPath string) error
func (*JadeCompilerType) WatchMatchFunc ¶
func (*JadeCompilerType) WatchMatchFunc() MatchFunc
WatchMatchFunc returns a MatchFunc which will return true for any files which match a given pattern. In this case, the pattern is any file that ends in ".jade", excluding hidden files and directories, but including those that start with an underscore, since they may be imported in other files.
type MatchFunc ¶
MatchFunc represents a function which should return true iff path matches some pattern. Compilers and Watchers return a MatchFunc to specify which paths they are concerned with.
type Post ¶
type Post struct { Title string `toml:"title"` Author string `toml:"author"` Description string `toml:"description"` Date time.Time `toml:"date"` // the url for the post, not including protocol or domain name (useful for creating links) Url template.URL `toml:"-"` // the html content for the post (parsed from markdown source) Content template.HTML `toml:"-"` // the layout tmpl file to be used for the post LayoutName string `toml:"layout"` // the layout template compiler (e.g. go html template or jade) that the post will be rendered into LayoutCompiler PostLayoutCompiler // contains filtered or unexported fields }
Post is an in-memory representation of the metadata for a given post. Much of this data comes from the toml frontmatter.
type PostLayoutCompiler ¶
type PostsByDate ¶
type PostsByDate []*Post
The PostsByDate type is used only for sorting
func (PostsByDate) Len ¶
func (p PostsByDate) Len() int
func (PostsByDate) Less ¶
func (p PostsByDate) Less(i, j int) bool
func (PostsByDate) Swap ¶
func (p PostsByDate) Swap(i, j int)
type PostsCompilerType ¶
type PostsCompilerType struct {
// contains filtered or unexported fields
}
PostsCompilerType represents a type capable of compiling post files.
func (*PostsCompilerType) Compile ¶
func (p *PostsCompilerType) Compile(srcPath string) error
Compile compiles the file at srcPath. The caller will only call this function for files which belong to PostsCompiler according to the MatchFunc. Behavior for any other file is undefined. Compile will output the compiled result to the appropriate location in config.DestDir.
func (*PostsCompilerType) CompileAll ¶
func (p *PostsCompilerType) CompileAll(srcPaths []string) error
CompileAll compiles zero or more files identified by srcPaths. It works simply by calling Compile for each path. The caller is responsible for only passing in files that belong to AceCompiler according to the MatchFunc. Behavior for any other file is undefined.
func (*PostsCompilerType) CompileMatchFunc ¶
func (p *PostsCompilerType) CompileMatchFunc() MatchFunc
CompileMatchFunc returns a MatchFunc which will return true for any files which match a given pattern. In this case, the pattern is any file that is inside config.PostsDir and ends in ".md", excluding hidden files and directories (which start with a ".") but not those which start with an underscore.
func (*PostsCompilerType) FileChanged ¶
func (p *PostsCompilerType) FileChanged(srcPath string, ev *fsnotify.FileEvent) error
func (*PostsCompilerType) Init ¶
func (p *PostsCompilerType) Init()
Init should be called before any other methods. In this case, Init sets up the pathMatch variable based on config.SourceDir and config.PostsDir and adds the Posts helper function to FuncMap.
func (*PostsCompilerType) RemoveOld ¶
func (p *PostsCompilerType) RemoveOld() error
func (*PostsCompilerType) WatchMatchFunc ¶
func (p *PostsCompilerType) WatchMatchFunc() MatchFunc
WatchMatchFunc returns a MatchFunc which will return true for any files which match a given pattern. In this case, the pattern is the same as it is for CompileMatchFunc.
type SassCompilerType ¶
type SassCompilerType struct {
// contains filtered or unexported fields
}
SassCompilerType represents a type capable of compiling sass files.
func (*SassCompilerType) Compile ¶
func (s *SassCompilerType) Compile(srcPath string) error
Compile compiles the file at srcPath. The caller will only call this function for files which belong to SassCompiler according to the MatchFunc. Behavior for any other file is undefined. Compile will output the compiled result to the appropriate location in config.DestDir.
func (*SassCompilerType) CompileAll ¶
func (s *SassCompilerType) CompileAll(srcPaths []string) error
CompileAll compiles zero or more files identified by srcPaths. It works simply by calling Compile for each path. The caller is responsible for only passing in files that belong to SassCompiler according to the MatchFunc. Behavior for any other file is undefined.
func (*SassCompilerType) CompileMatchFunc ¶
func (s *SassCompilerType) CompileMatchFunc() MatchFunc
CompileMatchFunc returns a MatchFunc which will return true for any files which match a given pattern. In this case, the pattern is any file that ends in ".scss", excluding hidden and ignored files and directories.
func (*SassCompilerType) FileChanged ¶
func (s *SassCompilerType) FileChanged(srcPath string, ev *fsnotify.FileEvent) error
func (*SassCompilerType) RemoveOld ¶
func (s *SassCompilerType) RemoveOld() error
func (*SassCompilerType) WatchMatchFunc ¶
func (s *SassCompilerType) WatchMatchFunc() MatchFunc
WatchMatchFunc returns a MatchFunc which will return true for any files which match a given pattern. In this case, the pattern is any file that ends in ".scss", excluding hidden files and directories, but including those that start with an underscore, since they may be imported in other files.