Cleanup
This commit is contained in:
parent
889397b9c5
commit
cd2e515141
@ -29,7 +29,9 @@ type Builder interface {
|
||||
// website until it is terminated.
|
||||
func DevServe(builder Builder, port int, sourceDir, targetDir, cacheDir string, watchDirs ...string) {
|
||||
dirs := append(watchDirs, sourceDir)
|
||||
build(dirs, func() { builder.Build(sourceDir, targetDir, cacheDir) })
|
||||
build(dirs, func() {
|
||||
builder.Build(sourceDir, targetDir, cacheDir)
|
||||
})
|
||||
|
||||
httpAddr := fmt.Sprintf(":%d", port)
|
||||
httpHandler := http.FileServer(http.Dir(targetDir))
|
||||
|
46
extension.go
46
extension.go
@ -2,29 +2,31 @@ package goldsmith
|
||||
|
||||
// Plugin contains the minimum set of methods required on plugins. Plugins can
|
||||
// also optionally implement Initializer, Processor, and Finalizer interfaces.
|
||||
type Plugin interface {
|
||||
Name() string
|
||||
}
|
||||
type (
|
||||
Plugin interface {
|
||||
Name() string
|
||||
}
|
||||
|
||||
// Initializer is used to optionally initialize a plugin and to specify a
|
||||
// filter to be used for determining which files will be processed.
|
||||
type Initializer interface {
|
||||
Initialize(context *Context) error
|
||||
}
|
||||
// Initializer is used to optionally initialize a plugin and to specify a
|
||||
// filter to be used for determining which files will be processed.
|
||||
Initializer interface {
|
||||
Initialize(context *Context) error
|
||||
}
|
||||
|
||||
// Processor allows for optional processing of files passing through a plugin.
|
||||
type Processor interface {
|
||||
Process(context *Context, file *File) error
|
||||
}
|
||||
// Processor allows for optional processing of files passing through a plugin.
|
||||
Processor interface {
|
||||
Process(context *Context, file *File) error
|
||||
}
|
||||
|
||||
// Finalizer allows for optional finalization of a plugin after all files
|
||||
// queued in the chain have passed through it.
|
||||
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.
|
||||
Finalizer interface {
|
||||
Finalize(context *Context) error
|
||||
}
|
||||
|
||||
// Filter is used to determine which files should continue in the chain.
|
||||
type Filter interface {
|
||||
Name() string
|
||||
Accept(file *File) bool
|
||||
}
|
||||
// Filter is used to determine which files should continue in the chain.
|
||||
Filter interface {
|
||||
Name() string
|
||||
Accept(file *File) bool
|
||||
}
|
||||
)
|
||||
|
26
file.go
26
file.go
@ -12,21 +12,21 @@ import (
|
||||
type (
|
||||
FileProp any
|
||||
FileProps map[string]FileProp
|
||||
|
||||
// File represents in-memory or on-disk files in a chain.
|
||||
File struct {
|
||||
relPath string
|
||||
props FileProps
|
||||
modTime time.Time
|
||||
size int64
|
||||
|
||||
dataPath string
|
||||
reader *bytes.Reader
|
||||
|
||||
index int
|
||||
}
|
||||
)
|
||||
|
||||
// File represents in-memory or on-disk files in a chain.
|
||||
type File struct {
|
||||
relPath string
|
||||
props FileProps
|
||||
modTime time.Time
|
||||
size int64
|
||||
|
||||
dataPath string
|
||||
reader *bytes.Reader
|
||||
|
||||
index int
|
||||
}
|
||||
|
||||
// Rename modifies the file path relative to the source directory.
|
||||
func (self *File) Rename(path string) error {
|
||||
if filepath.IsAbs(path) {
|
||||
|
@ -1,11 +1,13 @@
|
||||
package goldsmith
|
||||
|
||||
type filterEntry struct {
|
||||
filter Filter
|
||||
index int
|
||||
}
|
||||
type (
|
||||
filterEntry struct {
|
||||
filter Filter
|
||||
index int
|
||||
}
|
||||
|
||||
type filterStack []filterEntry
|
||||
filterStack []filterEntry
|
||||
)
|
||||
|
||||
func (self *filterStack) accept(file *File) bool {
|
||||
for _, entry := range *self {
|
||||
|
Loading…
Reference in New Issue
Block a user