goldsmith: github.com/FooSoft/goldsmith Index | Files

package goldsmith

import "github.com/FooSoft/goldsmith"

Package goldsmith generates static websites.

Index

Package Files

cache.go context.go error.go file.go goldsmith.go interface.go loader.go

type Context Uses

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

Context corresponds to the current link in the chain and provides methods that enable plugins to inject new files into the chain.

func (*Context) CreateFileFromAsset Uses

func (*Context) CreateFileFromAsset(sourcePath, dataPath string) (*File, error)

CreateFileFromAsset creates a new file instance from the provided file path.

func (*Context) CreateFileFromData Uses

func (*Context) CreateFileFromData(sourcePath string, data []byte) *File

CreateFileFrom data creates a new file instance from the provided data buffer.

func (*Context) DispatchAndCacheFile Uses

func (context *Context) DispatchAndCacheFile(outputFile *File, inputFiles ...*File)

DispatchAndCacheFile caches the file data (excluding the metadata), taking dependencies on any input files that are needed to generate it, and then passes it to the next link in the chain.

func (*Context) DispatchFile Uses

func (context *Context) DispatchFile(file *File)

DispatchFile causes the file to get passed to the next link in the chain.

func (*Context) RetrieveCachedFile Uses

func (context *Context) RetrieveCachedFile(outputPath string, inputFiles ...*File) *File

RetrieveCachedFile looks up file data (excluding the metadata), given an output path and any input files that are needed to generate it. The function will return nil if the desired file is not found in the cache.

type Error Uses

type Error struct {
    Name string
    Path string
    Err  error
}

Error wraps the core error type to provide a plugin or filter name in addition to the file path that was being processed at the time.

func (Error) Error Uses

func (err Error) Error() string

Error returns a string representation of the error.

type File Uses

type File struct {
    Meta map[string]interface{}
    // contains filtered or unexported fields
}

File represents in-memory or on-disk files in a chain.

func (*File) Dir Uses

func (file *File) Dir() string

Dir returns the containing directory of the file.

func (*File) Ext Uses

func (file *File) Ext() string

Ext returns the extension of the file.

func (*File) ModTime Uses

func (file *File) ModTime() time.Time

ModTime returns the time of the file's last modification.

func (*File) Name Uses

func (file *File) Name() string

Name returns the base name of the file.

func (*File) Path Uses

func (file *File) Path() string

Path returns the file path relative to the source directory.

func (*File) Read Uses

func (file *File) Read(data []byte) (int, error)

Read reads file data into the provided buffer.

func (*File) Seek Uses

func (file *File) Seek(offset int64, whence int) (int64, error)

Seek updates the file pointer to the desired position.

func (*File) Size Uses

func (file *File) Size() int64

Size returns the file length in bytes.

func (*File) WriteTo Uses

func (file *File) WriteTo(writer io.Writer) (int64, error)

Write writes file data into the provided writer.

type FilesByPath Uses

type FilesByPath []*File

func (FilesByPath) Len Uses

func (file FilesByPath) Len() int

func (FilesByPath) Less Uses

func (file FilesByPath) Less(i, j int) bool

func (FilesByPath) Swap Uses

func (file FilesByPath) Swap(i, j int)

type Filter Uses

type Filter interface {
    Name() string
    Accept(file *File) (bool, error)
}

Filter is used to determine which files should continue in the chain.

type Finalizer Uses

type Finalizer interface {
    Finalize(context *Context) error
}

Finalizer allows for optional finalization of a plugin after all files queued in the chain have passed through it.

type Goldsmith Uses

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

Goldsmith chainable context.

func Begin Uses

func Begin(sourceDir string) *Goldsmith

Begin starts a chain, reading the files located in the source directory as input.

func (*Goldsmith) Cache Uses

func (goldsmith *Goldsmith) Cache(cacheDir string) *Goldsmith

Cache enables caching in cacheDir for the remainder of the chain.

func (*Goldsmith) Chain Uses

func (goldsmith *Goldsmith) Chain(plugin Plugin) *Goldsmith

Chain links a plugin instance into the chain.

func (*Goldsmith) Clean Uses

func (goldsmith *Goldsmith) Clean(clean bool) *Goldsmith

Clean enables or disables removal of leftover files in the target directory.

func (*Goldsmith) End Uses

func (goldsmith *Goldsmith) End(targetDir string) []error

End stops a chain, writing all recieved files to targetDir as output.

func (*Goldsmith) FilterPop Uses

func (goldsmith *Goldsmith) FilterPop() *Goldsmith

FilterPop pops a filter instance from the chain's filter stack.

func (*Goldsmith) FilterPush Uses

func (goldsmith *Goldsmith) FilterPush(filter Filter) *Goldsmith

FilterPush pushes a filter instance on the chain's filter stack.

type Initializer Uses

type Initializer interface {
    Initialize(context *Context) (Filter, error)
}

Initializer is used to optionally initialize a plugin and to specify a filter to be used for determining which files will be processed.

type Plugin Uses

type Plugin interface {
    Name() string
}

Plugin contains the minimum set of methods required on plugins. Plugins can also optionally implement Initializer, Processor, and Finalizer interfaces.

type Processor Uses

type Processor interface {
    Process(context *Context, file *File) error
}

Processor allows for optional processing of files passing through a plugin.

Package goldsmith imports 16 packages (graph) and is imported by 21 packages. Updated 2019-05-01. Refresh now. Tools for package owners.