diff --git a/cache.go b/cache.go index aa9050e..79a5f49 100644 --- a/cache.go +++ b/cache.go @@ -15,7 +15,7 @@ type cache struct { baseDir string } -func (self *cache) retrieveFile(context *Context, outputPath string, inputFiles []File) (File, error) { +func (self *cache) retrieveFile(context *contextImpl, outputPath string, inputFiles []File) (File, error) { cachePath, err := self.buildCachePath(context, outputPath, inputFiles) if err != nil { return nil, err @@ -33,7 +33,7 @@ func (self *cache) retrieveFile(context *Context, outputPath string, inputFiles return outputFile, nil } -func (self *cache) storeFile(context *Context, outputFile File, inputFiles []File) error { +func (self *cache) storeFile(context *contextImpl, outputFile File, inputFiles []File) error { cachePath, err := self.buildCachePath(context, outputFile.Path(), inputFiles) if err != nil { return err @@ -69,7 +69,7 @@ func (self *cache) storeFile(context *Context, outputFile File, inputFiles []Fil return nil } -func (self *cache) buildCachePath(context *Context, outputPath string, inputFiles []File) (string, error) { +func (self *cache) buildCachePath(context *contextImpl, outputPath string, inputFiles []File) (string, error) { hasher := crc32.NewIEEE() hasher.Write([]byte(outputPath)) diff --git a/context.go b/context.go index dc4d339..297f884 100644 --- a/context.go +++ b/context.go @@ -13,7 +13,34 @@ import ( // Context corresponds to the current link in the chain and provides methods // that enable plugins to inject new files into the chain. -type Context struct { +type Context interface { + // CreateFileFrom data creates a new file instance from the provided data buffer. + CreateFileFromReader(sourcePath string, reader io.Reader) (File, error) + + // CreateFileFromAsset creates a new file instance from the provided file path. + CreateFileFromAsset(sourcePath, dataPath string) (File, error) + + // DispatchFile causes the file to get passed to the next link in the chain. + DispatchFile(file 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. + DispatchAndCacheFile(outputFile File, inputFiles ...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. + RetrieveCachedFile(outputPath string, inputFiles ...File) File + + // Specify internal filter(s) that exclude files from being processed. + Filter(filters ...Filter) Context + + // Specify the maximum number of threads used for processing. + Threads(threads int) Context +} + +type contextImpl struct { goldsmith *Goldsmith plugin Plugin @@ -29,7 +56,7 @@ type Context struct { } // CreateFileFrom data creates a new file instance from the provided data buffer. -func (self *Context) CreateFileFromReader(sourcePath string, reader io.Reader) (File, error) { +func (self *contextImpl) CreateFileFromReader(sourcePath string, reader io.Reader) (File, error) { data, err := io.ReadAll(reader) if err != nil { return nil, err @@ -50,7 +77,7 @@ func (self *Context) CreateFileFromReader(sourcePath string, reader io.Reader) ( } // CreateFileFromAsset creates a new file instance from the provided file path. -func (self *Context) CreateFileFromAsset(sourcePath, dataPath string) (File, error) { +func (self *contextImpl) CreateFileFromAsset(sourcePath, dataPath string) (File, error) { if filepath.IsAbs(sourcePath) { return nil, errors.New("source paths must be relative") } @@ -82,14 +109,14 @@ func (self *Context) CreateFileFromAsset(sourcePath, dataPath string) (File, err } // DispatchFile causes the file to get passed to the next link in the chain. -func (self *Context) DispatchFile(file File) { +func (self *contextImpl) DispatchFile(file File) { self.filesOut <- 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 (self *Context) DispatchAndCacheFile(outputFile File, inputFiles ...File) { +func (self *contextImpl) DispatchAndCacheFile(outputFile File, inputFiles ...File) { if self.goldsmith.cache != nil { self.goldsmith.cache.storeFile(self, outputFile, inputFiles) } @@ -100,7 +127,7 @@ func (self *Context) DispatchAndCacheFile(outputFile File, inputFiles ...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. -func (self *Context) RetrieveCachedFile(outputPath string, inputFiles ...File) File { +func (self *contextImpl) RetrieveCachedFile(outputPath string, inputFiles ...File) File { var outputFile File if self.goldsmith.cache != nil { outputFile, _ = self.goldsmith.cache.retrieveFile(self, outputPath, inputFiles) @@ -110,7 +137,7 @@ func (self *Context) RetrieveCachedFile(outputPath string, inputFiles ...File) F } // Specify internal filter(s) that exclude files from being processed. -func (self *Context) Filter(filters ...Filter) *Context { +func (self *contextImpl) Filter(filters ...Filter) Context { for _, filter := range filters { self.filtersInt.push(filter, self.index) } @@ -119,12 +146,12 @@ func (self *Context) Filter(filters ...Filter) *Context { } // Specify the maximum number of threads used for processing. -func (self *Context) Threads(threads int) *Context { +func (self *contextImpl) Threads(threads int) Context { self.threads = threads return self } -func (self *Context) step() { +func (self *contextImpl) step() { defer close(self.filesOut) if initializer, ok := self.plugin.(Initializer); ok { diff --git a/extension.go b/extension.go index 91e184c..7bf9413 100644 --- a/extension.go +++ b/extension.go @@ -9,18 +9,18 @@ type Plugin interface { // 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 + Initialize(context Context) error } // Processor allows for optional processing of files passing through a plugin. type Processor interface { - Process(context *Context, file File) error + 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 + Finalize(context Context) error } // Filter is used to determine which files should continue in the chain. diff --git a/file_exporter.go b/file_exporter.go index 9a5139a..72a1a41 100644 --- a/file_exporter.go +++ b/file_exporter.go @@ -16,13 +16,13 @@ func (*fileExporter) Name() string { return "exporter" } -func (self *fileExporter) Initialize(context *Context) error { +func (self *fileExporter) Initialize(context Context) error { self.tokens = make(map[string]bool) context.Threads(1) return nil } -func (self *fileExporter) Process(context *Context, file File) error { +func (self *fileExporter) Process(context Context, file File) error { slicePath := func(path string) string { if filepath.IsAbs(path) { var err error @@ -64,7 +64,7 @@ func (self *fileExporter) Process(context *Context, file File) error { return nil } -func (self *fileExporter) Finalize(context *Context) error { +func (self *fileExporter) Finalize(context Context) error { if !self.clean { return nil } diff --git a/file_importer.go b/file_importer.go index 9c4864f..7b216f8 100644 --- a/file_importer.go +++ b/file_importer.go @@ -13,7 +13,7 @@ func (*fileImporter) Name() string { return "importer" } -func (self *fileImporter) Initialize(context *Context) error { +func (self *fileImporter) Initialize(context Context) error { return filepath.Walk(self.sourceDir, func(path string, info os.FileInfo, err error) error { if info.IsDir() { return nil diff --git a/goldsmith.go b/goldsmith.go index 9748423..01246fa 100644 --- a/goldsmith.go +++ b/goldsmith.go @@ -8,7 +8,7 @@ import ( // Goldsmith chainable context. type Goldsmith struct { - contexts []*Context + contexts []*contextImpl cache *cache filters filterStack @@ -40,7 +40,7 @@ func (self *Goldsmith) Clean(clean bool) *Goldsmith { // Chain links a plugin instance into the chain. func (self *Goldsmith) Chain(plugin Plugin) *Goldsmith { - context := &Context{ + context := &contextImpl{ goldsmith: self, plugin: plugin, filtersExt: append(filterStack(nil), self.filters...), diff --git a/plugins/absolute/absolute.go b/plugins/absolute/absolute.go index e6c1d74..26a6391 100644 --- a/plugins/absolute/absolute.go +++ b/plugins/absolute/absolute.go @@ -45,12 +45,12 @@ func (*Absolute) Name() string { return "absolute" } -func (*Absolute) Initialize(context *goldsmith.Context) error { +func (*Absolute) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.html", "**/*.htm")) return nil } -func (self *Absolute) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Absolute) Process(context goldsmith.Context, inputFile goldsmith.File) error { if outputFile := context.RetrieveCachedFile(inputFile.Path(), inputFile); outputFile != nil { outputFile.CopyProps(inputFile) context.DispatchFile(outputFile) diff --git a/plugins/breadcrumbs/breadcrumbs.go b/plugins/breadcrumbs/breadcrumbs.go index 5218f62..7b62934 100644 --- a/plugins/breadcrumbs/breadcrumbs.go +++ b/plugins/breadcrumbs/breadcrumbs.go @@ -70,12 +70,12 @@ func (*Breadcrumbs) Name() string { return "breadcrumbs" } -func (*Breadcrumbs) Initialize(context *goldsmith.Context) error { +func (*Breadcrumbs) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.html", "**/*.htm")) return nil } -func (self *Breadcrumbs) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Breadcrumbs) Process(context goldsmith.Context, inputFile goldsmith.File) error { var parentNameStr string if parentName, ok := inputFile.Prop(self.parentKey); ok { parentNameStr, _ = parentName.(string) @@ -103,7 +103,7 @@ func (self *Breadcrumbs) Process(context *goldsmith.Context, inputFile goldsmith return nil } -func (self *Breadcrumbs) Finalize(context *goldsmith.Context) error { +func (self *Breadcrumbs) Finalize(context goldsmith.Context) error { for _, node := range self.allNodes { if len(node.parentName) == 0 { continue diff --git a/plugins/collection/collection.go b/plugins/collection/collection.go index 731215f..8a9224d 100644 --- a/plugins/collection/collection.go +++ b/plugins/collection/collection.go @@ -61,12 +61,12 @@ func (*Collection) Name() string { return "collection" } -func (*Collection) Initialize(context *goldsmith.Context) error { +func (*Collection) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.html", "**/*.htm")) return nil } -func (self *Collection) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Collection) Process(context goldsmith.Context, inputFile goldsmith.File) error { self.mutex.Lock() defer func() { inputFile.SetProp(self.groupsKey, self.groups) @@ -96,7 +96,7 @@ func (self *Collection) Process(context *goldsmith.Context, inputFile goldsmith. return nil } -func (self *Collection) Finalize(context *goldsmith.Context) error { +func (self *Collection) Finalize(context goldsmith.Context) error { for _, files := range self.groups { fg := &fileSorter{files, self.comparer} sort.Sort(fg) diff --git a/plugins/document/document.go b/plugins/document/document.go index 5a1b458..19eebc5 100644 --- a/plugins/document/document.go +++ b/plugins/document/document.go @@ -32,12 +32,12 @@ func (*Document) Name() string { return "document" } -func (*Document) Initialize(context *goldsmith.Context) error { +func (*Document) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.html", "**/*.htm")) return nil } -func (self *Document) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Document) Process(context goldsmith.Context, inputFile goldsmith.File) error { doc, err := goquery.NewDocumentFromReader(inputFile) if err != nil { return err @@ -61,7 +61,7 @@ func (self *Document) Process(context *goldsmith.Context, inputFile goldsmith.Fi return nil } -func (self *Document) Finalize(context *goldsmith.Context) error { +func (self *Document) Finalize(context goldsmith.Context) error { for _, file := range self.files { context.DispatchFile(file) } diff --git a/plugins/forward/forward.go b/plugins/forward/forward.go index c5d2afc..ecacc5c 100644 --- a/plugins/forward/forward.go +++ b/plugins/forward/forward.go @@ -53,7 +53,7 @@ func (*Forward) Name() string { return "forward" } -func (self *Forward) Initialize(context *goldsmith.Context) error { +func (self *Forward) Initialize(context goldsmith.Context) error { for sourcePath, targetPath := range self.pathMap { sourceFile, err := context.CreateFileFromReader(sourcePath, bytes.NewReader(nil)) if err != nil { diff --git a/plugins/frontmatter/frontmatter.go b/plugins/frontmatter/frontmatter.go index 31769a6..53ca2eb 100644 --- a/plugins/frontmatter/frontmatter.go +++ b/plugins/frontmatter/frontmatter.go @@ -66,12 +66,12 @@ func (*FrontMatter) Name() string { return "frontmatter" } -func (*FrontMatter) Initialize(context *goldsmith.Context) error { +func (*FrontMatter) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.md", "**/*.markdown", "**/*.rst", "**/*.txt", "**/*.html", "**/*.htm")) return nil } -func (*FrontMatter) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (*FrontMatter) Process(context goldsmith.Context, inputFile goldsmith.File) error { meta, body, err := parse(inputFile) if err != nil { return err diff --git a/plugins/index/index.go b/plugins/index/index.go index 8c453b3..4d7bcdc 100644 --- a/plugins/index/index.go +++ b/plugins/index/index.go @@ -60,7 +60,7 @@ func (*Index) Name() string { return "index" } -func (self *Index) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Index) Process(context goldsmith.Context, inputFile goldsmith.File) error { self.mutex.Lock() defer self.mutex.Unlock() @@ -105,7 +105,7 @@ func (self *Index) Process(context *goldsmith.Context, inputFile goldsmith.File) return nil } -func (self *Index) Finalize(context *goldsmith.Context) error { +func (self *Index) Finalize(context goldsmith.Context) error { for name, list := range self.dirLists { sort.Sort(list.entries) diff --git a/plugins/layout/layout.go b/plugins/layout/layout.go index 0125080..241c75f 100644 --- a/plugins/layout/layout.go +++ b/plugins/layout/layout.go @@ -64,13 +64,13 @@ func (*Layout) Name() string { return "layout" } -func (self *Layout) Initialize(context *goldsmith.Context) error { +func (self *Layout) Initialize(context goldsmith.Context) error { self.template = template.New("").Funcs(self.helpers) context.Filter(wildcard.New("**/*.html", "**/*.htm", "**/*.tmpl", "**/*.gohtml")) return nil } -func (self *Layout) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Layout) Process(context goldsmith.Context, inputFile goldsmith.File) error { self.mutex.Lock() defer self.mutex.Unlock() @@ -94,7 +94,7 @@ func (self *Layout) Process(context *goldsmith.Context, inputFile goldsmith.File return nil } -func (self *Layout) Finalize(context *goldsmith.Context) error { +func (self *Layout) Finalize(context goldsmith.Context) error { for _, templateFile := range self.templateFiles { var buff bytes.Buffer if _, err := templateFile.WriteTo(&buff); err != nil { diff --git a/plugins/livejs/livejs.go b/plugins/livejs/livejs.go index 782a481..b626e51 100644 --- a/plugins/livejs/livejs.go +++ b/plugins/livejs/livejs.go @@ -31,13 +31,13 @@ func (*LiveJs) Name() string { return "livejs" } -func (self *LiveJs) Initialize(context *goldsmith.Context) error { +func (self *LiveJs) Initialize(context goldsmith.Context) error { self.html = fmt.Sprintf("\n\n\n\n", livejs) context.Filter(wildcard.New("**/*.html", "**/*.htm")) return nil } -func (self *LiveJs) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *LiveJs) Process(context goldsmith.Context, inputFile goldsmith.File) error { if outputFile := context.RetrieveCachedFile(inputFile.Path(), inputFile); outputFile != nil { outputFile.CopyProps(inputFile) context.DispatchFile(outputFile) diff --git a/plugins/markdown/markdown.go b/plugins/markdown/markdown.go index 80dc529..263b567 100644 --- a/plugins/markdown/markdown.go +++ b/plugins/markdown/markdown.go @@ -42,12 +42,12 @@ func (*Markdown) Name() string { return "markdown" } -func (self *Markdown) Initialize(context *goldsmith.Context) error { +func (self *Markdown) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.md", "**/*.markdown")) return nil } -func (self *Markdown) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Markdown) Process(context goldsmith.Context, inputFile goldsmith.File) error { outputPath := strings.TrimSuffix(inputFile.Path(), path.Ext(inputFile.Path())) + ".html" if outputFile := context.RetrieveCachedFile(outputPath, inputFile); outputFile != nil { outputFile.CopyProps(inputFile) diff --git a/plugins/minify/minify.go b/plugins/minify/minify.go index 97e0d8c..e9652b2 100644 --- a/plugins/minify/minify.go +++ b/plugins/minify/minify.go @@ -32,12 +32,12 @@ func (*Minify) Name() string { return "minify" } -func (*Minify) Initialize(context *goldsmith.Context) error { +func (*Minify) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.css", "**/*.html", "**/*.htm", "**/*.js", "**/*.svg", "**/*.json", "**/*.xml")) return nil } -func (*Minify) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (*Minify) Process(context goldsmith.Context, inputFile goldsmith.File) error { if outputFile := context.RetrieveCachedFile(inputFile.Path(), inputFile); outputFile != nil { outputFile.CopyProps(inputFile) context.DispatchFile(outputFile) diff --git a/plugins/pager/pager.go b/plugins/pager/pager.go index b7f22fb..9f596e8 100644 --- a/plugins/pager/pager.go +++ b/plugins/pager/pager.go @@ -109,12 +109,12 @@ func (*Pager) Name() string { return "pager" } -func (*Pager) Initialize(context *goldsmith.Context) error { +func (*Pager) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.html", "**/*.htm")) return nil } -func (self *Pager) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Pager) Process(context goldsmith.Context, inputFile goldsmith.File) error { self.mutex.Lock() defer self.mutex.Unlock() @@ -200,7 +200,7 @@ func (self *Pager) Process(context *goldsmith.Context, inputFile goldsmith.File) return nil } -func (self *Pager) Finalize(ctx *goldsmith.Context) error { +func (self *Pager) Finalize(ctx goldsmith.Context) error { for _, f := range self.files { ctx.DispatchFile(f) } diff --git a/plugins/rule/rule.go b/plugins/rule/rule.go index ef8cf3c..2c1a846 100644 --- a/plugins/rule/rule.go +++ b/plugins/rule/rule.go @@ -128,7 +128,7 @@ func (*Rule) Name() string { return "rule" } -func (self *Rule) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Rule) Process(context goldsmith.Context, inputFile goldsmith.File) error { if inputFile.Name() == self.filename { ruleSet, err := newRuleSet(inputFile) if err != nil { @@ -147,7 +147,7 @@ func (self *Rule) Process(context *goldsmith.Context, inputFile goldsmith.File) return nil } -func (self *Rule) Finalize(context *goldsmith.Context) error { +func (self *Rule) Finalize(context goldsmith.Context) error { for _, inputFile := range self.inputFiles { var block bool for _, ruleSet := range self.ruleSets { diff --git a/plugins/summary/summary.go b/plugins/summary/summary.go index 7fe74ca..a8a6410 100644 --- a/plugins/summary/summary.go +++ b/plugins/summary/summary.go @@ -57,12 +57,12 @@ func (*Summary) Name() string { return "summary" } -func (*Summary) Initialize(context *goldsmith.Context) error { +func (*Summary) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.html", "**/*.htm")) return nil } -func (self *Summary) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Summary) Process(context goldsmith.Context, inputFile goldsmith.File) error { doc, err := goquery.NewDocumentFromReader(inputFile) if err != nil { return err diff --git a/plugins/syndicate/syndicate.go b/plugins/syndicate/syndicate.go index 83f3720..b23a2fc 100644 --- a/plugins/syndicate/syndicate.go +++ b/plugins/syndicate/syndicate.go @@ -120,7 +120,7 @@ func (self *Syndicate) WithFeed(name string, config FeedConfig) *Syndicate { return self } -func (self *Syndicate) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Syndicate) Process(context goldsmith.Context, inputFile goldsmith.File) error { defer context.DispatchFile(inputFile) getString := func(key string) string { @@ -214,7 +214,7 @@ func (self *Syndicate) Process(context *goldsmith.Context, inputFile goldsmith.F return nil } -func (self *feed) output(context *goldsmith.Context) error { +func (self *feed) output(context goldsmith.Context) error { feed := feeds.Feed{ Title: self.config.Title, Link: &feeds.Link{Href: self.config.Url}, @@ -310,7 +310,7 @@ func (self *feed) output(context *goldsmith.Context) error { return nil } -func (self *Syndicate) Finalize(context *goldsmith.Context) error { +func (self *Syndicate) Finalize(context goldsmith.Context) error { for _, feed := range self.feeds { feed.output(context) } diff --git a/plugins/syntax/syntax.go b/plugins/syntax/syntax.go index 32d35e3..465be14 100644 --- a/plugins/syntax/syntax.go +++ b/plugins/syntax/syntax.go @@ -69,12 +69,12 @@ func (*Syntax) Name() string { return "syntax" } -func (*Syntax) Initialize(context *goldsmith.Context) error { +func (*Syntax) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.html", "**/*.htm")) return nil } -func (self *Syntax) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Syntax) Process(context goldsmith.Context, inputFile goldsmith.File) error { if outputFile := context.RetrieveCachedFile(inputFile.Path(), inputFile); outputFile != nil { outputFile.CopyProps(inputFile) context.DispatchFile(outputFile) diff --git a/plugins/tags/tags.go b/plugins/tags/tags.go index a7e1826..efa6844 100644 --- a/plugins/tags/tags.go +++ b/plugins/tags/tags.go @@ -93,12 +93,12 @@ func (*Tags) Name() string { return "tags" } -func (*Tags) Initialize(context *goldsmith.Context) error { +func (*Tags) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.html", "**/*.htm")) return nil } -func (self *Tags) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Tags) Process(context goldsmith.Context, inputFile goldsmith.File) error { tagState := &TagState{ TagsByName: &self.infoByName, TagsByCount: &self.infoByCount, @@ -158,7 +158,7 @@ func (self *Tags) Process(context *goldsmith.Context, inputFile goldsmith.File) return nil } -func (self *Tags) Finalize(context *goldsmith.Context) error { +func (self *Tags) Finalize(context goldsmith.Context) error { for _, info := range self.info { sort.Sort(info.TaggedFiles) @@ -185,7 +185,7 @@ func (self *Tags) Finalize(context *goldsmith.Context) error { return nil } -func (self *Tags) buildPages(context *goldsmith.Context) ([]goldsmith.File, error) { +func (self *Tags) buildPages(context goldsmith.Context) ([]goldsmith.File, error) { var files []goldsmith.File for tag, info := range self.info { var err error diff --git a/plugins/thumbnail/thumbnail.go b/plugins/thumbnail/thumbnail.go index d749721..5992386 100644 --- a/plugins/thumbnail/thumbnail.go +++ b/plugins/thumbnail/thumbnail.go @@ -76,12 +76,12 @@ func (*Thumbnail) Name() string { return "thumbnail" } -func (*Thumbnail) Initialize(context *goldsmith.Context) error { +func (*Thumbnail) Initialize(context goldsmith.Context) error { context.Filter(wildcard.New("**/*.jpg", "**/*.jpeg", "**/*.gif", "**/*.png")) return nil } -func (self *Thumbnail) Process(context *goldsmith.Context, inputFile goldsmith.File) error { +func (self *Thumbnail) Process(context goldsmith.Context, inputFile goldsmith.File) error { defer context.DispatchFile(inputFile) thumbPath := self.namer(inputFile.Path(), self.size) @@ -104,7 +104,7 @@ func (self *Thumbnail) Process(context *goldsmith.Context, inputFile goldsmith.F return nil } -func (self *Thumbnail) thumbnail(context *goldsmith.Context, inputFile goldsmith.File, thumbPath string) (goldsmith.File, error) { +func (self *Thumbnail) thumbnail(context goldsmith.Context, inputFile goldsmith.File, thumbPath string) (goldsmith.File, error) { var thumbFormat imaging.Format switch strings.ToLower(filepath.Ext(thumbPath)) { case ".jpg", ".jpeg":