Back to godoc.org
github.com/FooSoft/goldsmith

Package goldsmith

v0.0.0-...-9aba24e
Latest Go to latest

The latest major version is .

Published: Aug 13, 2020 | License: MIT | Module: github.com/FooSoft/goldsmith

Overview

Package goldsmith generates static websites.

Index

type Context

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

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

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

func (*Context) CreateFileFromData

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

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

func (*Context) DispatchAndCacheFile

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

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

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

func (*Context) RetrieveCachedFile

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 File

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

func (file *File) Dir() string

Dir returns the containing directory of the file.

func (*File) Ext

func (file *File) Ext() string

Ext returns the extension of the file.

func (*File) GoString

func (file *File) GoString() string

Returns value for string formatting.

func (*File) ModTime

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

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

func (*File) Name

func (file *File) Name() string

Name returns the base name of the file.

func (*File) Path

func (file *File) Path() string

Path returns the file path relative to the source directory.

func (*File) Read

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

Read reads file data into the provided buffer.

func (*File) Rename

func (file *File) Rename(path string)

Rename modifies the file path relative to the source directory.

func (*File) Seek

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

Seek updates the file pointer to the desired position.

func (*File) Size

func (file *File) Size() int64

Size returns the file length in bytes.

func (*File) WriteTo

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

Write writes file data into the provided writer.

type FilesByPath

type FilesByPath []*File

func (FilesByPath) Len

func (file FilesByPath) Len() int

func (FilesByPath) Less

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

func (FilesByPath) Swap

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

type Filter

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

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

type Finalizer

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

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

Goldsmith chainable context.

func Begin

func Begin(sourceDir string) *Goldsmith

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

func (*Goldsmith) Cache

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

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

func (*Goldsmith) Chain

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

Chain links a plugin instance into the chain.

func (*Goldsmith) Clean

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

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

func (*Goldsmith) End

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

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

func (*Goldsmith) FilterPop

func (goldsmith *Goldsmith) FilterPop() *Goldsmith

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

func (*Goldsmith) FilterPush

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

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

type Initializer

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

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

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

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier