builder

package
v0.0.0-...-14122a6 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2016 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After

func After(fn Handler)

After add handler after building

func AssembleSource

func AssembleSource(ctx *Context)

AssembleSource assemble some extra data in Source, such as page nodes, i18n status. it need be used after posts and pages are loaded

func Before

func Before(fn Handler)

Before add handler before building

func Build

func Build(ctx *Context)

Build do a process with Context. the context should be prepared before building.

func CleanCopied

func CleanCopied(ctx *Context) error

CleanCopied clean old copied files

func Compile

func Compile(ctx *Context)

Compile compile source to static files

func Copy

func Copy(ctx *Context)

Copy copy assets to destination directory

func CopyMedia

func CopyMedia(ctx *Context) error

CopyMedia copy media files in source

func CopyMust

func CopyMust(ctx *Context) error

CopyMust copy files in source to destination

func CopyStatic

func CopyStatic(ctx *Context) error

CopyStatic copy static assets from theme to destination directory

func Counter

func Counter() int

Counter return the times of building process ran

func Read

func Read(ctx *Context)

Read do a process to read Source with Context. It does not build any thing, just read source data.

func ReadLang

func ReadLang(srcDir string) (map[string]*helper.I18n, error)

ReadLang read languages in srcDir

func ReadMeta

func ReadMeta(srcDir string) (*model.MetaAll, error)

ReadMeta read meta file in srcDir

func ReadPages

func ReadPages(srcDir string) ([]*model.Page, error)

ReadPages read pages files in srcDir/page

func ReadPosts

func ReadPosts(srcDir string) ([]*model.Post, error)

ReadPosts read posts files in srcDir/post

func ReadSource

func ReadSource(ctx *Context)

ReadSource read source with *Context. parse *Context.From and read data to *Context.Source

func ReadTheme

func ReadTheme(ctx *Context)

ReadTheme read *Theme to *Context

func Watch

func Watch(ctx *Context)

Watch watch changes

Types

type Builder

type Builder struct {
	IsBuilding bool
	IsWatching bool
	Counter    int
	// contains filtered or unexported fields
}

Builder is object of Builder handlers

type Context

type Context struct {

	// From is source origin
	From string
	// To is destination
	To string
	// Theme is theme origin
	ThemeName string
	// Err is error when context using
	Err error
	// Source is sources data
	Source *Source
	// Theme is theme object, use to render templates
	Theme *theme.Theme
	// Files is generated files in by this context
	Files *model.Files
	// Tree is url tree nodes by this context
	Tree   *model.Tree
	Copied *CopiedOpt
	// contains filtered or unexported fields
}

Context obtain context in once building process

func NewContext

func NewContext(cli *cli.Context, from, to, theme string) *Context

NewContext create new Context with from,to and theme args

func (*Context) Again

func (ctx *Context) Again()

Again reset some fields in context to rebuild

func (*Context) Cli

func (ctx *Context) Cli() *cli.Context

Cli get command line context in this building context

func (*Context) DstDir

func (ctx *Context) DstDir() string

DstDir get destination directory after build once

func (*Context) Duration

func (ctx *Context) Duration() float64

Duration return seconds after *Context created

func (*Context) IsValid

func (ctx *Context) IsValid() bool

IsValid check context requirement, there must have values in some fields

func (*Context) SrcDir

func (ctx *Context) SrcDir() string

SrcDir get src dir after build once

func (*Context) View

func (ctx *Context) View() map[string]interface{}

View get view data to template from Context

type CopiedOpt

type CopiedOpt struct {
	MustFiles       []string
	IgnoreDir       []string
	IgnoreFile      []string
	CleanIgnoreDir  []string
	CleanIgnoreFile []string
}

CopiedOpt set option when copying files to destination

type Handler

type Handler func(ctx *Context)

Handler define a step in building process

type Source

type Source struct {
	Meta      *model.Meta
	Nav       model.NavGroup
	Owner     *model.Author
	Authors   map[string]*model.Author
	Comment   *model.Comment
	Analytics *model.Analytics
	I18n      map[string]*helper.I18n

	Posts    model.Posts
	PostPage int
	Archive  []*model.Archive
	Pages    model.Pages
	Tags     map[string]*model.Tag
	// contains filtered or unexported fields
}

Source include all sources data

func NewSource

func NewSource(all *model.MetaAll) *Source

NewSource return new *Source from *MetaAll, it returns general *Source object without posts and pages, but meta, navigation, authors,comment and analytics are loaded.

Jump to

Keyboard shortcuts

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