repo_name
stringclasses
2 values
pr_number
int64
2.62k
123k
pr_title
stringlengths
8
193
pr_description
stringlengths
0
27.9k
author
stringlengths
3
23
date_created
unknown
date_merged
unknown
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
query
stringlengths
21
28k
filepath
stringlengths
7
174
before_content
stringlengths
0
554M
after_content
stringlengths
0
554M
label
int64
-1
1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./markup/asciidocext/asciidocext_config/config.go
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package asciidoc_config holds asciidoc related configuration. package asciidocext_config var ( // Default holds Hugo's default asciidoc configuration. Default = Config{ Backend: "html5", Extensions: []string{}, Attributes: map[string]string{}, NoHeaderOrFooter: true, SafeMode: "unsafe", SectionNumbers: false, Verbose: false, Trace: false, FailureLevel: "fatal", WorkingFolderCurrent: false, PreserveTOC: false, } // CliDefault holds Asciidoctor CLI defaults (see https://asciidoctor.org/docs/user-manual/) CliDefault = Config{ Backend: "html5", SafeMode: "unsafe", FailureLevel: "fatal", } AllowedExtensions = map[string]bool{ "asciidoctor-html5s": true, "asciidoctor-bibtex": true, "asciidoctor-diagram": true, "asciidoctor-interdoc-reftext": true, "asciidoctor-katex": true, "asciidoctor-latex": true, "asciidoctor-mathematical": true, "asciidoctor-question": true, "asciidoctor-rouge": true, } AllowedSafeMode = map[string]bool{ "unsafe": true, "safe": true, "server": true, "secure": true, } AllowedFailureLevel = map[string]bool{ "fatal": true, "warn": true, } AllowedBackend = map[string]bool{ "html5": true, "html5s": true, "xhtml5": true, "docbook5": true, "docbook45": true, "manpage": true, } DisallowedAttributes = map[string]bool{ "outdir": true, } ) // Config configures asciidoc. type Config struct { Backend string Extensions []string Attributes map[string]string NoHeaderOrFooter bool SafeMode string SectionNumbers bool Verbose bool Trace bool FailureLevel string WorkingFolderCurrent bool PreserveTOC bool }
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package asciidoc_config holds asciidoc related configuration. package asciidocext_config var ( // Default holds Hugo's default asciidoc configuration. Default = Config{ Backend: "html5", Extensions: []string{}, Attributes: map[string]string{}, NoHeaderOrFooter: true, SafeMode: "unsafe", SectionNumbers: false, Verbose: false, Trace: false, FailureLevel: "fatal", WorkingFolderCurrent: false, PreserveTOC: false, } // CliDefault holds Asciidoctor CLI defaults (see https://asciidoctor.org/docs/user-manual/) CliDefault = Config{ Backend: "html5", SafeMode: "unsafe", FailureLevel: "fatal", } AllowedExtensions = map[string]bool{ "asciidoctor-html5s": true, "asciidoctor-bibtex": true, "asciidoctor-diagram": true, "asciidoctor-interdoc-reftext": true, "asciidoctor-katex": true, "asciidoctor-latex": true, "asciidoctor-mathematical": true, "asciidoctor-question": true, "asciidoctor-rouge": true, } AllowedSafeMode = map[string]bool{ "unsafe": true, "safe": true, "server": true, "secure": true, } AllowedFailureLevel = map[string]bool{ "fatal": true, "warn": true, } AllowedBackend = map[string]bool{ "html5": true, "html5s": true, "xhtml5": true, "docbook5": true, "docbook45": true, "manpage": true, } DisallowedAttributes = map[string]bool{ "outdir": true, } ) // Config configures asciidoc. type Config struct { Backend string Extensions []string Attributes map[string]string NoHeaderOrFooter bool SafeMode string SectionNumbers bool Verbose bool Trace bool FailureLevel string WorkingFolderCurrent bool PreserveTOC bool }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./tpl/debug/debug.go
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package debug provides template functions to help debugging templates. package debug import ( "github.com/sanity-io/litter" "github.com/gohugoio/hugo/deps" ) // New returns a new instance of the debug-namespaced template functions. func New(d *deps.Deps) *Namespace { return &Namespace{} } // Namespace provides template functions for the "debug" namespace. type Namespace struct { } // Dump returns a object dump of val as a string. // Note that not every value passed to Dump will print so nicely, but // we'll improve on that. We recommend using the "go" Chroma lexer to format the output // nicely. // Also note that the output from Dump may change from Hugo version to the next, // so don't depend on a specific output. func (ns *Namespace) Dump(val interface{}) string { return litter.Sdump(val) }
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package debug provides template functions to help debugging templates. package debug import ( "github.com/sanity-io/litter" "github.com/gohugoio/hugo/deps" ) // New returns a new instance of the debug-namespaced template functions. func New(d *deps.Deps) *Namespace { return &Namespace{} } // Namespace provides template functions for the "debug" namespace. type Namespace struct { } // Dump returns a object dump of val as a string. // Note that not every value passed to Dump will print so nicely, but // we'll improve on that. We recommend using the "go" Chroma lexer to format the output // nicely. // Also note that the output from Dump may change from Hugo version to the next, // so don't depend on a specific output. func (ns *Namespace) Dump(val interface{}) string { return litter.Sdump(val) }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./common/text/transform.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package text import ( "sync" "unicode" "golang.org/x/text/runes" "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" ) var accentTransformerPool = &sync.Pool{ New: func() interface{} { return transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC) }, } // RemoveAccents removes all accents from b. func RemoveAccents(b []byte) []byte { t := accentTransformerPool.Get().(transform.Transformer) b, _, _ = transform.Bytes(t, b) t.Reset() accentTransformerPool.Put(t) return b } // RemoveAccentsString removes all accents from s. func RemoveAccentsString(s string) string { t := accentTransformerPool.Get().(transform.Transformer) s, _, _ = transform.String(t, s) t.Reset() accentTransformerPool.Put(t) return s }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package text import ( "sync" "unicode" "golang.org/x/text/runes" "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" ) var accentTransformerPool = &sync.Pool{ New: func() interface{} { return transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC) }, } // RemoveAccents removes all accents from b. func RemoveAccents(b []byte) []byte { t := accentTransformerPool.Get().(transform.Transformer) b, _, _ = transform.Bytes(t, b) t.Reset() accentTransformerPool.Put(t) return b } // RemoveAccentsString removes all accents from s. func RemoveAccentsString(s string) string { t := accentTransformerPool.Get().(transform.Transformer) s, _, _ = transform.String(t, s) t.Reset() accentTransformerPool.Put(t) return s }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./hugofs/language_composite_fs.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugofs import ( "os" "path" "github.com/spf13/afero" ) var ( _ afero.Fs = (*languageCompositeFs)(nil) _ afero.Lstater = (*languageCompositeFs)(nil) ) type languageCompositeFs struct { *afero.CopyOnWriteFs } // NewLanguageCompositeFs creates a composite and language aware filesystem. // This is a hybrid filesystem. To get a specific file in Open, Stat etc., use the full filename // to the target filesystem. This information is available in Readdir, Stat etc. via the // special LanguageFileInfo FileInfo implementation. func NewLanguageCompositeFs(base, overlay afero.Fs) afero.Fs { return &languageCompositeFs{afero.NewCopyOnWriteFs(base, overlay).(*afero.CopyOnWriteFs)} } // Open takes the full path to the file in the target filesystem. If it is a directory, it gets merged // using the language as a weight. func (fs *languageCompositeFs) Open(name string) (afero.File, error) { f, err := fs.CopyOnWriteFs.Open(name) if err != nil { return nil, err } fu, ok := f.(*afero.UnionFile) if ok { // This is a directory: Merge it. fu.Merger = LanguageDirsMerger } return f, nil } // LanguageDirsMerger implements the afero.DirsMerger interface, which is used // to merge two directories. var LanguageDirsMerger = func(lofi, bofi []os.FileInfo) ([]os.FileInfo, error) { m := make(map[string]FileMetaInfo) getKey := func(fim FileMetaInfo) string { return path.Join(fim.Meta().Lang(), fim.Name()) } for _, fi := range lofi { fim := fi.(FileMetaInfo) m[getKey(fim)] = fim } for _, fi := range bofi { fim := fi.(FileMetaInfo) key := getKey(fim) _, found := m[key] if !found { m[key] = fim } } merged := make([]os.FileInfo, len(m)) i := 0 for _, v := range m { merged[i] = v i++ } return merged, nil }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugofs import ( "os" "path" "github.com/spf13/afero" ) var ( _ afero.Fs = (*languageCompositeFs)(nil) _ afero.Lstater = (*languageCompositeFs)(nil) ) type languageCompositeFs struct { *afero.CopyOnWriteFs } // NewLanguageCompositeFs creates a composite and language aware filesystem. // This is a hybrid filesystem. To get a specific file in Open, Stat etc., use the full filename // to the target filesystem. This information is available in Readdir, Stat etc. via the // special LanguageFileInfo FileInfo implementation. func NewLanguageCompositeFs(base, overlay afero.Fs) afero.Fs { return &languageCompositeFs{afero.NewCopyOnWriteFs(base, overlay).(*afero.CopyOnWriteFs)} } // Open takes the full path to the file in the target filesystem. If it is a directory, it gets merged // using the language as a weight. func (fs *languageCompositeFs) Open(name string) (afero.File, error) { f, err := fs.CopyOnWriteFs.Open(name) if err != nil { return nil, err } fu, ok := f.(*afero.UnionFile) if ok { // This is a directory: Merge it. fu.Merger = LanguageDirsMerger } return f, nil } // LanguageDirsMerger implements the afero.DirsMerger interface, which is used // to merge two directories. var LanguageDirsMerger = func(lofi, bofi []os.FileInfo) ([]os.FileInfo, error) { m := make(map[string]FileMetaInfo) getKey := func(fim FileMetaInfo) string { return path.Join(fim.Meta().Lang(), fim.Name()) } for _, fi := range lofi { fim := fi.(FileMetaInfo) m[getKey(fim)] = fim } for _, fi := range bofi { fim := fi.(FileMetaInfo) key := getKey(fim) _, found := m[key] if !found { m[key] = fim } } merged := make([]os.FileInfo, len(m)) i := 0 for _, v := range m { merged[i] = v i++ } return merged, nil }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./docs/content/en/news/0.72.0-relnotes/index.md
--- date: 2020-05-31 title: URL rewrites in dev server description: "Hugo 0.72.0 comes with dev server redirects and URL rewrites, Goldmark typography extension fixes, Scratch.Values." categories: ["Releases"] --- This is a rather small release, its probably main motivation being the fixes in Goldmark's [Typographer extension](https://github.com/gohugoio/hugo/commit/432885c499849efb29d3e50196f377fe0e908333). This release also adds [redirect and URL rewrite support](https://gohugo.io/getting-started/configuration/#configure-server) to the development server, with mostly Netlify-compatible configuration syntax. This is especially useful if you're building a [SPA](https://en.wikipedia.org/wiki/Single-page_application) with client-side routing. This release represents **13 contributions by 3 contributors** to the main Hugo code base. Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs), which has received **9 contributions by 6 contributors**. A special thanks to [@faraixyz](https://github.com/faraixyz), [@bep](https://github.com/bep), [@coliff](https://github.com/coliff), and [@Leon0824](https://github.com/Leon0824) for their work on the documentation site. Hugo now has: * 44383+ [stars](https://github.com/gohugoio/hugo/stargazers) * 437+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors) * 327+ [themes](http://themes.gohugo.io/) ## Enhancements ### Other * Add Scratch.Values [2919a6a5](https://github.com/gohugoio/hugo/commit/2919a6a503f7b369154d6eb787023a1fe58a9ad4) [@bep](https://github.com/bep) [#7335](https://github.com/gohugoio/hugo/issues/7335) * Update Goldmark to improve Typographer [432885c4](https://github.com/gohugoio/hugo/commit/432885c499849efb29d3e50196f377fe0e908333) [@bep](https://github.com/bep) [#7289](https://github.com/gohugoio/hugo/issues/7289) * Add redirect support to the server [6a3e8974](https://github.com/gohugoio/hugo/commit/6a3e89743ccad58097a6dd203a63448946a2304d) [@bep](https://github.com/bep) [#7323](https://github.com/gohugoio/hugo/issues/7323) ## Fixes ### Other * Fix tag collector for nested table elements [c950c86b](https://github.com/gohugoio/hugo/commit/c950c86b4e5fb93f787ec78ca823bded9ef9fa3a) [@bep](https://github.com/bep) [#7318](https://github.com/gohugoio/hugo/issues/7318) * Fix build error: my previous commits did not fix it [91520249](https://github.com/gohugoio/hugo/commit/915202494b140882d594e0542153531f6afada02) [@anthonyfok](https://github.com/anthonyfok)
--- date: 2020-05-31 title: URL rewrites in dev server description: "Hugo 0.72.0 comes with dev server redirects and URL rewrites, Goldmark typography extension fixes, Scratch.Values." categories: ["Releases"] --- This is a rather small release, its probably main motivation being the fixes in Goldmark's [Typographer extension](https://github.com/gohugoio/hugo/commit/432885c499849efb29d3e50196f377fe0e908333). This release also adds [redirect and URL rewrite support](https://gohugo.io/getting-started/configuration/#configure-server) to the development server, with mostly Netlify-compatible configuration syntax. This is especially useful if you're building a [SPA](https://en.wikipedia.org/wiki/Single-page_application) with client-side routing. This release represents **13 contributions by 3 contributors** to the main Hugo code base. Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs), which has received **9 contributions by 6 contributors**. A special thanks to [@faraixyz](https://github.com/faraixyz), [@bep](https://github.com/bep), [@coliff](https://github.com/coliff), and [@Leon0824](https://github.com/Leon0824) for their work on the documentation site. Hugo now has: * 44383+ [stars](https://github.com/gohugoio/hugo/stargazers) * 437+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors) * 327+ [themes](http://themes.gohugo.io/) ## Enhancements ### Other * Add Scratch.Values [2919a6a5](https://github.com/gohugoio/hugo/commit/2919a6a503f7b369154d6eb787023a1fe58a9ad4) [@bep](https://github.com/bep) [#7335](https://github.com/gohugoio/hugo/issues/7335) * Update Goldmark to improve Typographer [432885c4](https://github.com/gohugoio/hugo/commit/432885c499849efb29d3e50196f377fe0e908333) [@bep](https://github.com/bep) [#7289](https://github.com/gohugoio/hugo/issues/7289) * Add redirect support to the server [6a3e8974](https://github.com/gohugoio/hugo/commit/6a3e89743ccad58097a6dd203a63448946a2304d) [@bep](https://github.com/bep) [#7323](https://github.com/gohugoio/hugo/issues/7323) ## Fixes ### Other * Fix tag collector for nested table elements [c950c86b](https://github.com/gohugoio/hugo/commit/c950c86b4e5fb93f787ec78ca823bded9ef9fa3a) [@bep](https://github.com/bep) [#7318](https://github.com/gohugoio/hugo/issues/7318) * Fix build error: my previous commits did not fix it [91520249](https://github.com/gohugoio/hugo/commit/915202494b140882d594e0542153531f6afada02) [@anthonyfok](https://github.com/anthonyfok)
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./docs/content/en/commands/hugo_mod_graph.md
--- date: 2020-09-13 title: "hugo mod graph" slug: hugo_mod_graph url: /commands/hugo_mod_graph/ --- ## hugo mod graph Print a module dependency graph. ### Synopsis Print a module dependency graph with information about module status (disabled, vendored). Note that for vendored modules, that is the version listed and not the one from go.mod. ``` hugo mod graph [flags] ``` ### Options ``` -h, --help help for graph ``` ### Options inherited from parent commands ``` --config string config file (default is path/config.yaml|json|toml) --configDir string config dir (default "config") --debug debug output -e, --environment string build environment --ignoreVendor ignores any _vendor directory --ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode -s, --source string filesystem path to read files relative from --themesDir string filesystem path to themes directory -v, --verbose verbose output --verboseLog verbose logging ``` ### SEE ALSO * [hugo mod](/commands/hugo_mod/) - Various Hugo Modules helpers. ###### Auto generated by spf13/cobra on 13-Sep-2020
--- date: 2020-09-13 title: "hugo mod graph" slug: hugo_mod_graph url: /commands/hugo_mod_graph/ --- ## hugo mod graph Print a module dependency graph. ### Synopsis Print a module dependency graph with information about module status (disabled, vendored). Note that for vendored modules, that is the version listed and not the one from go.mod. ``` hugo mod graph [flags] ``` ### Options ``` -h, --help help for graph ``` ### Options inherited from parent commands ``` --config string config file (default is path/config.yaml|json|toml) --configDir string config dir (default "config") --debug debug output -e, --environment string build environment --ignoreVendor ignores any _vendor directory --ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode -s, --source string filesystem path to read files relative from --themesDir string filesystem path to themes directory -v, --verbose verbose output --verboseLog verbose logging ``` ### SEE ALSO * [hugo mod](/commands/hugo_mod/) - Various Hugo Modules helpers. ###### Auto generated by spf13/cobra on 13-Sep-2020
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./hugolib/cascade_test.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "bytes" "fmt" "path" "strings" "testing" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/parser" "github.com/gohugoio/hugo/parser/metadecoders" ) func BenchmarkCascade(b *testing.B) { allLangs := []string{"en", "nn", "nb", "sv", "ab", "aa", "af", "sq", "kw", "da"} for i := 1; i <= len(allLangs); i += 2 { langs := allLangs[0:i] b.Run(fmt.Sprintf("langs-%d", len(langs)), func(b *testing.B) { c := qt.New(b) b.StopTimer() builders := make([]*sitesBuilder, b.N) for i := 0; i < b.N; i++ { builders[i] = newCascadeTestBuilder(b, langs) } b.StartTimer() for i := 0; i < b.N; i++ { builder := builders[i] err := builder.BuildE(BuildCfg{}) c.Assert(err, qt.IsNil) first := builder.H.Sites[0] c.Assert(first, qt.Not(qt.IsNil)) } }) } } func TestCascade(t *testing.T) { allLangs := []string{"en", "nn", "nb", "sv"} langs := allLangs[:3] t.Run(fmt.Sprintf("langs-%d", len(langs)), func(t *testing.T) { b := newCascadeTestBuilder(t, langs) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` 12|term|categories/cool/_index.md|Cascade Category|cat.png|categories|HTML-| 12|term|categories/catsect1|catsect1|cat.png|categories|HTML-| 12|term|categories/funny|funny|cat.png|categories|HTML-| 12|taxonomy|categories/_index.md|My Categories|cat.png|categories|HTML-| 32|term|categories/sad/_index.md|Cascade Category|sad.png|categories|HTML-| 42|term|tags/blue|blue|home.png|tags|HTML-| 42|taxonomy|tags|Cascade Home|home.png|tags|HTML-| 42|section|sectnocontent|Cascade Home|home.png|sectnocontent|HTML-| 42|section|sect3|Cascade Home|home.png|sect3|HTML-| 42|page|bundle1/index.md|Cascade Home|home.png|page|HTML-| 42|page|p2.md|Cascade Home|home.png|page|HTML-| 42|page|sect2/p2.md|Cascade Home|home.png|sect2|HTML-| 42|page|sect3/nofrontmatter.md|Cascade Home|home.png|sect3|HTML-| 42|page|sect3/p1.md|Cascade Home|home.png|sect3|HTML-| 42|page|sectnocontent/p1.md|Cascade Home|home.png|sectnocontent|HTML-| 42|section|sectnofrontmatter/_index.md|Cascade Home|home.png|sectnofrontmatter|HTML-| 42|term|tags/green|green|home.png|tags|HTML-| 42|home|_index.md|Home|home.png|page|HTML-| 42|page|p1.md|p1|home.png|page|HTML-| 42|section|sect1/_index.md|Sect1|sect1.png|stype|HTML-| 42|section|sect1/s1_2/_index.md|Sect1_2|sect1.png|stype|HTML-| 42|page|sect1/s1_2/p1.md|Sect1_2_p1|sect1.png|stype|HTML-| 42|page|sect1/s1_2/p2.md|Sect1_2_p2|sect1.png|stype|HTML-| 42|section|sect2/_index.md|Sect2|home.png|sect2|HTML-| 42|page|sect2/p1.md|Sect2_p1|home.png|sect2|HTML-| 52|page|sect4/p1.md|Cascade Home|home.png|sect4|RSS-| 52|section|sect4/_index.md|Sect4|home.png|sect4|RSS-| `) // Check that type set in cascade gets the correct layout. b.AssertFileContent("public/sect1/index.html", `stype list: Sect1`) b.AssertFileContent("public/sect1/s1_2/p2/index.html", `stype single: Sect1_2_p2`) // Check output formats set in cascade b.AssertFileContent("public/sect4/index.xml", `<link>https://example.org/sect4/index.xml</link>`) b.AssertFileContent("public/sect4/p1/index.xml", `<link>https://example.org/sect4/p1/index.xml</link>`) b.C.Assert(b.CheckExists("public/sect2/index.xml"), qt.Equals, false) // Check cascade into bundled page b.AssertFileContent("public/bundle1/index.html", `Resources: bp1.md|home.png|`) }) } func TestCascadeEdit(t *testing.T) { p1Content := `--- title: P1 --- ` indexContentNoCascade := ` --- title: Home --- ` indexContentCascade := ` --- title: Section cascade: banner: post.jpg layout: postlayout type: posttype --- ` layout := `Banner: {{ .Params.banner }}|Layout: {{ .Layout }}|Type: {{ .Type }}|Content: {{ .Content }}` newSite := func(t *testing.T, cascade bool) *sitesBuilder { b := newTestSitesBuilder(t).Running() b.WithTemplates("_default/single.html", layout) b.WithTemplates("_default/list.html", layout) if cascade { b.WithContent("post/_index.md", indexContentCascade) } else { b.WithContent("post/_index.md", indexContentNoCascade) } b.WithContent("post/dir/p1.md", p1Content) return b } t.Run("Edit descendant", func(t *testing.T) { t.Parallel() b := newSite(t, true) b.Build(BuildCfg{}) assert := func() { b.Helper() b.AssertFileContent("public/post/dir/p1/index.html", `Banner: post.jpg|`, `Layout: postlayout`, `Type: posttype`, ) } assert() b.EditFiles("content/post/dir/p1.md", p1Content+"\ncontent edit") b.Build(BuildCfg{}) assert() b.AssertFileContent("public/post/dir/p1/index.html", `content edit Banner: post.jpg`, ) }) t.Run("Edit ancestor", func(t *testing.T) { t.Parallel() b := newSite(t, true) b.Build(BuildCfg{}) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: post.jpg|Layout: postlayout|Type: posttype|Content:`) b.EditFiles("content/post/_index.md", strings.Replace(indexContentCascade, "post.jpg", "edit.jpg", 1)) b.Build(BuildCfg{}) b.AssertFileContent("public/post/index.html", `Banner: edit.jpg|Layout: postlayout|Type: posttype|`) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: edit.jpg|Layout: postlayout|Type: posttype|`) }) t.Run("Edit ancestor, add cascade", func(t *testing.T) { t.Parallel() b := newSite(t, true) b.Build(BuildCfg{}) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: post.jpg`) b.EditFiles("content/post/_index.md", indexContentCascade) b.Build(BuildCfg{}) b.AssertFileContent("public/post/index.html", `Banner: post.jpg|Layout: postlayout|Type: posttype|`) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: post.jpg|Layout: postlayout|`) }) t.Run("Edit ancestor, remove cascade", func(t *testing.T) { t.Parallel() b := newSite(t, false) b.Build(BuildCfg{}) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: |Layout: |`) b.EditFiles("content/post/_index.md", indexContentNoCascade) b.Build(BuildCfg{}) b.AssertFileContent("public/post/index.html", `Banner: |Layout: |Type: post|`) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: |Layout: |`) }) t.Run("Edit ancestor, content only", func(t *testing.T) { t.Parallel() b := newSite(t, true) b.Build(BuildCfg{}) b.EditFiles("content/post/_index.md", indexContentCascade+"\ncontent edit") counters := &testCounters{} b.Build(BuildCfg{testCounters: counters}) // As we only changed the content, not the cascade front matter, // only the home page is re-rendered. b.Assert(int(counters.contentRenderCounter), qt.Equals, 1) b.AssertFileContent("public/post/index.html", `Banner: post.jpg|Layout: postlayout|Type: posttype|Content: <p>content edit</p>`) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: post.jpg|Layout: postlayout|`) }) } func newCascadeTestBuilder(t testing.TB, langs []string) *sitesBuilder { p := func(m map[string]interface{}) string { var yamlStr string if len(m) > 0 { var b bytes.Buffer parser.InterfaceToConfig(m, metadecoders.YAML, &b) yamlStr = b.String() } metaStr := "---\n" + yamlStr + "\n---" return metaStr } createLangConfig := func(lang string) string { const langEntry = ` [languages.%s] ` return fmt.Sprintf(langEntry, lang) } createMount := func(lang string) string { const mountsTempl = ` [[module.mounts]] source="content/%s" target="content" lang="%s" ` return fmt.Sprintf(mountsTempl, lang, lang) } config := ` baseURL = "https://example.org" defaultContentLanguage = "en" defaultContentLanguageInSubDir = false [languages]` for _, lang := range langs { config += createLangConfig(lang) } config += "\n\n[module]\n" for _, lang := range langs { config += createMount(lang) } b := newTestSitesBuilder(t).WithConfigFile("toml", config) createContentFiles := func(lang string) { withContent := func(filenameContent ...string) { for i := 0; i < len(filenameContent); i += 2 { b.WithContent(path.Join(lang, filenameContent[i]), filenameContent[i+1]) } } withContent( "_index.md", p(map[string]interface{}{ "title": "Home", "cascade": map[string]interface{}{ "title": "Cascade Home", "ICoN": "home.png", "outputs": []string{"HTML"}, "weight": 42, }, }), "p1.md", p(map[string]interface{}{ "title": "p1", }), "p2.md", p(map[string]interface{}{}), "sect1/_index.md", p(map[string]interface{}{ "title": "Sect1", "type": "stype", "cascade": map[string]interface{}{ "title": "Cascade Sect1", "icon": "sect1.png", "type": "stype", "categories": []string{"catsect1"}, }, }), "sect1/s1_2/_index.md", p(map[string]interface{}{ "title": "Sect1_2", }), "sect1/s1_2/p1.md", p(map[string]interface{}{ "title": "Sect1_2_p1", }), "sect1/s1_2/p2.md", p(map[string]interface{}{ "title": "Sect1_2_p2", }), "sect2/_index.md", p(map[string]interface{}{ "title": "Sect2", }), "sect2/p1.md", p(map[string]interface{}{ "title": "Sect2_p1", "categories": []string{"cool", "funny", "sad"}, "tags": []string{"blue", "green"}, }), "sect2/p2.md", p(map[string]interface{}{}), "sect3/p1.md", p(map[string]interface{}{}), // No front matter, see #6855 "sect3/nofrontmatter.md", `**Hello**`, "sectnocontent/p1.md", `**Hello**`, "sectnofrontmatter/_index.md", `**Hello**`, "sect4/_index.md", p(map[string]interface{}{ "title": "Sect4", "cascade": map[string]interface{}{ "weight": 52, "outputs": []string{"RSS"}, }, }), "sect4/p1.md", p(map[string]interface{}{}), "p2.md", p(map[string]interface{}{}), "bundle1/index.md", p(map[string]interface{}{}), "bundle1/bp1.md", p(map[string]interface{}{}), "categories/_index.md", p(map[string]interface{}{ "title": "My Categories", "cascade": map[string]interface{}{ "title": "Cascade Category", "icoN": "cat.png", "weight": 12, }, }), "categories/cool/_index.md", p(map[string]interface{}{}), "categories/sad/_index.md", p(map[string]interface{}{ "cascade": map[string]interface{}{ "icon": "sad.png", "weight": 32, }, }), ) } createContentFiles("en") b.WithTemplates("index.html", ` {{ range .Site.Pages }} {{- .Weight }}|{{ .Kind }}|{{ path.Join .Path }}|{{ .Title }}|{{ .Params.icon }}|{{ .Type }}|{{ range .OutputFormats }}{{ .Name }}-{{ end }}| {{ end }} `, "_default/single.html", "default single: {{ .Title }}|{{ .RelPermalink }}|{{ .Content }}|Resources: {{ range .Resources }}{{ .Name }}|{{ .Params.icon }}|{{ .Content }}{{ end }}", "_default/list.html", "default list: {{ .Title }}", "stype/single.html", "stype single: {{ .Title }}|{{ .RelPermalink }}|{{ .Content }}", "stype/list.html", "stype list: {{ .Title }}", ) return b } func TestCascadeTarget(t *testing.T) { t.Parallel() c := qt.New(t) newBuilder := func(c *qt.C) *sitesBuilder { b := newTestSitesBuilder(c) b.WithTemplates("index.html", ` {{ $p1 := site.GetPage "s1/p1" }} {{ $s1 := site.GetPage "s1" }} P1|p1:{{ $p1.Params.p1 }}|p2:{{ $p1.Params.p2 }}| S1|p1:{{ $s1.Params.p1 }}|p2:{{ $s1.Params.p2 }}| `) b.WithContent("s1/_index.md", "---\ntitle: s1 section\n---") b.WithContent("s1/p1/index.md", "---\ntitle: p1\n---") b.WithContent("s1/p2/index.md", "---\ntitle: p2\n---") b.WithContent("s2/p1/index.md", "---\ntitle: p1_2\n---") return b } c.Run("slice", func(c *qt.C) { b := newBuilder(c) b.WithContent("_index.md", `+++ title = "Home" [[cascade]] p1 = "p1" [[cascade]] p2 = "p2" +++ `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", "P1|p1:p1|p2:p2") }) c.Run("slice with _target", func(c *qt.C) { b := newBuilder(c) b.WithContent("_index.md", `+++ title = "Home" [[cascade]] p1 = "p1" [cascade._target] path="**p1**" [[cascade]] p2 = "p2" [cascade._target] kind="section" +++ `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` P1|p1:p1|p2:| S1|p1:|p2:p2| `) }) c.Run("slice with yaml _target", func(c *qt.C) { b := newBuilder(c) b.WithContent("_index.md", `--- title: "Home" cascade: - p1: p1 _target: path: "**p1**" - p2: p2 _target: kind: "section" --- `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` P1|p1:p1|p2:| S1|p1:|p2:p2| `) }) c.Run("slice with json _target", func(c *qt.C) { b := newBuilder(c) b.WithContent("_index.md", `{ "title": "Home", "cascade": [ { "p1": "p1", "_target": { "path": "**p1**" } },{ "p2": "p2", "_target": { "kind": "section" } } ] } `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` P1|p1:p1|p2:| S1|p1:|p2:p2| `) }) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "bytes" "fmt" "path" "strings" "testing" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/parser" "github.com/gohugoio/hugo/parser/metadecoders" ) func BenchmarkCascade(b *testing.B) { allLangs := []string{"en", "nn", "nb", "sv", "ab", "aa", "af", "sq", "kw", "da"} for i := 1; i <= len(allLangs); i += 2 { langs := allLangs[0:i] b.Run(fmt.Sprintf("langs-%d", len(langs)), func(b *testing.B) { c := qt.New(b) b.StopTimer() builders := make([]*sitesBuilder, b.N) for i := 0; i < b.N; i++ { builders[i] = newCascadeTestBuilder(b, langs) } b.StartTimer() for i := 0; i < b.N; i++ { builder := builders[i] err := builder.BuildE(BuildCfg{}) c.Assert(err, qt.IsNil) first := builder.H.Sites[0] c.Assert(first, qt.Not(qt.IsNil)) } }) } } func TestCascade(t *testing.T) { allLangs := []string{"en", "nn", "nb", "sv"} langs := allLangs[:3] t.Run(fmt.Sprintf("langs-%d", len(langs)), func(t *testing.T) { b := newCascadeTestBuilder(t, langs) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` 12|term|categories/cool/_index.md|Cascade Category|cat.png|categories|HTML-| 12|term|categories/catsect1|catsect1|cat.png|categories|HTML-| 12|term|categories/funny|funny|cat.png|categories|HTML-| 12|taxonomy|categories/_index.md|My Categories|cat.png|categories|HTML-| 32|term|categories/sad/_index.md|Cascade Category|sad.png|categories|HTML-| 42|term|tags/blue|blue|home.png|tags|HTML-| 42|taxonomy|tags|Cascade Home|home.png|tags|HTML-| 42|section|sectnocontent|Cascade Home|home.png|sectnocontent|HTML-| 42|section|sect3|Cascade Home|home.png|sect3|HTML-| 42|page|bundle1/index.md|Cascade Home|home.png|page|HTML-| 42|page|p2.md|Cascade Home|home.png|page|HTML-| 42|page|sect2/p2.md|Cascade Home|home.png|sect2|HTML-| 42|page|sect3/nofrontmatter.md|Cascade Home|home.png|sect3|HTML-| 42|page|sect3/p1.md|Cascade Home|home.png|sect3|HTML-| 42|page|sectnocontent/p1.md|Cascade Home|home.png|sectnocontent|HTML-| 42|section|sectnofrontmatter/_index.md|Cascade Home|home.png|sectnofrontmatter|HTML-| 42|term|tags/green|green|home.png|tags|HTML-| 42|home|_index.md|Home|home.png|page|HTML-| 42|page|p1.md|p1|home.png|page|HTML-| 42|section|sect1/_index.md|Sect1|sect1.png|stype|HTML-| 42|section|sect1/s1_2/_index.md|Sect1_2|sect1.png|stype|HTML-| 42|page|sect1/s1_2/p1.md|Sect1_2_p1|sect1.png|stype|HTML-| 42|page|sect1/s1_2/p2.md|Sect1_2_p2|sect1.png|stype|HTML-| 42|section|sect2/_index.md|Sect2|home.png|sect2|HTML-| 42|page|sect2/p1.md|Sect2_p1|home.png|sect2|HTML-| 52|page|sect4/p1.md|Cascade Home|home.png|sect4|RSS-| 52|section|sect4/_index.md|Sect4|home.png|sect4|RSS-| `) // Check that type set in cascade gets the correct layout. b.AssertFileContent("public/sect1/index.html", `stype list: Sect1`) b.AssertFileContent("public/sect1/s1_2/p2/index.html", `stype single: Sect1_2_p2`) // Check output formats set in cascade b.AssertFileContent("public/sect4/index.xml", `<link>https://example.org/sect4/index.xml</link>`) b.AssertFileContent("public/sect4/p1/index.xml", `<link>https://example.org/sect4/p1/index.xml</link>`) b.C.Assert(b.CheckExists("public/sect2/index.xml"), qt.Equals, false) // Check cascade into bundled page b.AssertFileContent("public/bundle1/index.html", `Resources: bp1.md|home.png|`) }) } func TestCascadeEdit(t *testing.T) { p1Content := `--- title: P1 --- ` indexContentNoCascade := ` --- title: Home --- ` indexContentCascade := ` --- title: Section cascade: banner: post.jpg layout: postlayout type: posttype --- ` layout := `Banner: {{ .Params.banner }}|Layout: {{ .Layout }}|Type: {{ .Type }}|Content: {{ .Content }}` newSite := func(t *testing.T, cascade bool) *sitesBuilder { b := newTestSitesBuilder(t).Running() b.WithTemplates("_default/single.html", layout) b.WithTemplates("_default/list.html", layout) if cascade { b.WithContent("post/_index.md", indexContentCascade) } else { b.WithContent("post/_index.md", indexContentNoCascade) } b.WithContent("post/dir/p1.md", p1Content) return b } t.Run("Edit descendant", func(t *testing.T) { t.Parallel() b := newSite(t, true) b.Build(BuildCfg{}) assert := func() { b.Helper() b.AssertFileContent("public/post/dir/p1/index.html", `Banner: post.jpg|`, `Layout: postlayout`, `Type: posttype`, ) } assert() b.EditFiles("content/post/dir/p1.md", p1Content+"\ncontent edit") b.Build(BuildCfg{}) assert() b.AssertFileContent("public/post/dir/p1/index.html", `content edit Banner: post.jpg`, ) }) t.Run("Edit ancestor", func(t *testing.T) { t.Parallel() b := newSite(t, true) b.Build(BuildCfg{}) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: post.jpg|Layout: postlayout|Type: posttype|Content:`) b.EditFiles("content/post/_index.md", strings.Replace(indexContentCascade, "post.jpg", "edit.jpg", 1)) b.Build(BuildCfg{}) b.AssertFileContent("public/post/index.html", `Banner: edit.jpg|Layout: postlayout|Type: posttype|`) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: edit.jpg|Layout: postlayout|Type: posttype|`) }) t.Run("Edit ancestor, add cascade", func(t *testing.T) { t.Parallel() b := newSite(t, true) b.Build(BuildCfg{}) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: post.jpg`) b.EditFiles("content/post/_index.md", indexContentCascade) b.Build(BuildCfg{}) b.AssertFileContent("public/post/index.html", `Banner: post.jpg|Layout: postlayout|Type: posttype|`) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: post.jpg|Layout: postlayout|`) }) t.Run("Edit ancestor, remove cascade", func(t *testing.T) { t.Parallel() b := newSite(t, false) b.Build(BuildCfg{}) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: |Layout: |`) b.EditFiles("content/post/_index.md", indexContentNoCascade) b.Build(BuildCfg{}) b.AssertFileContent("public/post/index.html", `Banner: |Layout: |Type: post|`) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: |Layout: |`) }) t.Run("Edit ancestor, content only", func(t *testing.T) { t.Parallel() b := newSite(t, true) b.Build(BuildCfg{}) b.EditFiles("content/post/_index.md", indexContentCascade+"\ncontent edit") counters := &testCounters{} b.Build(BuildCfg{testCounters: counters}) // As we only changed the content, not the cascade front matter, // only the home page is re-rendered. b.Assert(int(counters.contentRenderCounter), qt.Equals, 1) b.AssertFileContent("public/post/index.html", `Banner: post.jpg|Layout: postlayout|Type: posttype|Content: <p>content edit</p>`) b.AssertFileContent("public/post/dir/p1/index.html", `Banner: post.jpg|Layout: postlayout|`) }) } func newCascadeTestBuilder(t testing.TB, langs []string) *sitesBuilder { p := func(m map[string]interface{}) string { var yamlStr string if len(m) > 0 { var b bytes.Buffer parser.InterfaceToConfig(m, metadecoders.YAML, &b) yamlStr = b.String() } metaStr := "---\n" + yamlStr + "\n---" return metaStr } createLangConfig := func(lang string) string { const langEntry = ` [languages.%s] ` return fmt.Sprintf(langEntry, lang) } createMount := func(lang string) string { const mountsTempl = ` [[module.mounts]] source="content/%s" target="content" lang="%s" ` return fmt.Sprintf(mountsTempl, lang, lang) } config := ` baseURL = "https://example.org" defaultContentLanguage = "en" defaultContentLanguageInSubDir = false [languages]` for _, lang := range langs { config += createLangConfig(lang) } config += "\n\n[module]\n" for _, lang := range langs { config += createMount(lang) } b := newTestSitesBuilder(t).WithConfigFile("toml", config) createContentFiles := func(lang string) { withContent := func(filenameContent ...string) { for i := 0; i < len(filenameContent); i += 2 { b.WithContent(path.Join(lang, filenameContent[i]), filenameContent[i+1]) } } withContent( "_index.md", p(map[string]interface{}{ "title": "Home", "cascade": map[string]interface{}{ "title": "Cascade Home", "ICoN": "home.png", "outputs": []string{"HTML"}, "weight": 42, }, }), "p1.md", p(map[string]interface{}{ "title": "p1", }), "p2.md", p(map[string]interface{}{}), "sect1/_index.md", p(map[string]interface{}{ "title": "Sect1", "type": "stype", "cascade": map[string]interface{}{ "title": "Cascade Sect1", "icon": "sect1.png", "type": "stype", "categories": []string{"catsect1"}, }, }), "sect1/s1_2/_index.md", p(map[string]interface{}{ "title": "Sect1_2", }), "sect1/s1_2/p1.md", p(map[string]interface{}{ "title": "Sect1_2_p1", }), "sect1/s1_2/p2.md", p(map[string]interface{}{ "title": "Sect1_2_p2", }), "sect2/_index.md", p(map[string]interface{}{ "title": "Sect2", }), "sect2/p1.md", p(map[string]interface{}{ "title": "Sect2_p1", "categories": []string{"cool", "funny", "sad"}, "tags": []string{"blue", "green"}, }), "sect2/p2.md", p(map[string]interface{}{}), "sect3/p1.md", p(map[string]interface{}{}), // No front matter, see #6855 "sect3/nofrontmatter.md", `**Hello**`, "sectnocontent/p1.md", `**Hello**`, "sectnofrontmatter/_index.md", `**Hello**`, "sect4/_index.md", p(map[string]interface{}{ "title": "Sect4", "cascade": map[string]interface{}{ "weight": 52, "outputs": []string{"RSS"}, }, }), "sect4/p1.md", p(map[string]interface{}{}), "p2.md", p(map[string]interface{}{}), "bundle1/index.md", p(map[string]interface{}{}), "bundle1/bp1.md", p(map[string]interface{}{}), "categories/_index.md", p(map[string]interface{}{ "title": "My Categories", "cascade": map[string]interface{}{ "title": "Cascade Category", "icoN": "cat.png", "weight": 12, }, }), "categories/cool/_index.md", p(map[string]interface{}{}), "categories/sad/_index.md", p(map[string]interface{}{ "cascade": map[string]interface{}{ "icon": "sad.png", "weight": 32, }, }), ) } createContentFiles("en") b.WithTemplates("index.html", ` {{ range .Site.Pages }} {{- .Weight }}|{{ .Kind }}|{{ path.Join .Path }}|{{ .Title }}|{{ .Params.icon }}|{{ .Type }}|{{ range .OutputFormats }}{{ .Name }}-{{ end }}| {{ end }} `, "_default/single.html", "default single: {{ .Title }}|{{ .RelPermalink }}|{{ .Content }}|Resources: {{ range .Resources }}{{ .Name }}|{{ .Params.icon }}|{{ .Content }}{{ end }}", "_default/list.html", "default list: {{ .Title }}", "stype/single.html", "stype single: {{ .Title }}|{{ .RelPermalink }}|{{ .Content }}", "stype/list.html", "stype list: {{ .Title }}", ) return b } func TestCascadeTarget(t *testing.T) { t.Parallel() c := qt.New(t) newBuilder := func(c *qt.C) *sitesBuilder { b := newTestSitesBuilder(c) b.WithTemplates("index.html", ` {{ $p1 := site.GetPage "s1/p1" }} {{ $s1 := site.GetPage "s1" }} P1|p1:{{ $p1.Params.p1 }}|p2:{{ $p1.Params.p2 }}| S1|p1:{{ $s1.Params.p1 }}|p2:{{ $s1.Params.p2 }}| `) b.WithContent("s1/_index.md", "---\ntitle: s1 section\n---") b.WithContent("s1/p1/index.md", "---\ntitle: p1\n---") b.WithContent("s1/p2/index.md", "---\ntitle: p2\n---") b.WithContent("s2/p1/index.md", "---\ntitle: p1_2\n---") return b } c.Run("slice", func(c *qt.C) { b := newBuilder(c) b.WithContent("_index.md", `+++ title = "Home" [[cascade]] p1 = "p1" [[cascade]] p2 = "p2" +++ `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", "P1|p1:p1|p2:p2") }) c.Run("slice with _target", func(c *qt.C) { b := newBuilder(c) b.WithContent("_index.md", `+++ title = "Home" [[cascade]] p1 = "p1" [cascade._target] path="**p1**" [[cascade]] p2 = "p2" [cascade._target] kind="section" +++ `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` P1|p1:p1|p2:| S1|p1:|p2:p2| `) }) c.Run("slice with yaml _target", func(c *qt.C) { b := newBuilder(c) b.WithContent("_index.md", `--- title: "Home" cascade: - p1: p1 _target: path: "**p1**" - p2: p2 _target: kind: "section" --- `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` P1|p1:p1|p2:| S1|p1:|p2:p2| `) }) c.Run("slice with json _target", func(c *qt.C) { b := newBuilder(c) b.WithContent("_index.md", `{ "title": "Home", "cascade": [ { "p1": "p1", "_target": { "path": "**p1**" } },{ "p2": "p2", "_target": { "kind": "section" } } ] } `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` P1|p1:p1|p2:| S1|p1:|p2:p2| `) }) }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./resources/images/resampling.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package images import "math" // We moved from imaging to the gift package for image processing at some point. // That package had more, but also less resampling filters. So we add the missing // ones here. They are fairly exotic, but someone may use them, so keep them here // for now. // // The filters below are ported from https://github.com/disintegration/imaging/blob/9aab30e6aa535fe3337b489b76759ef97dfaf362/resize.go#L369 // MIT License. var ( // Hermite cubic spline filter (BC-spline; B=0; C=0). hermiteResampling = resamp{ name: "Hermite", support: 1.0, kernel: func(x float32) float32 { x = absf32(x) if x < 1.0 { return bcspline(x, 0.0, 0.0) } return 0 }, } // Mitchell-Netravali cubic filter (BC-spline; B=1/3; C=1/3). mitchellNetravaliResampling = resamp{ name: "MitchellNetravali", support: 2.0, kernel: func(x float32) float32 { x = absf32(x) if x < 2.0 { return bcspline(x, 1.0/3.0, 1.0/3.0) } return 0 }, } // Catmull-Rom - sharp cubic filter (BC-spline; B=0; C=0.5). catmullRomResampling = resamp{ name: "CatmullRomResampling", support: 2.0, kernel: func(x float32) float32 { x = absf32(x) if x < 2.0 { return bcspline(x, 0.0, 0.5) } return 0 }, } // BSpline is a smooth cubic filter (BC-spline; B=1; C=0). bSplineResampling = resamp{ name: "BSplineResampling", support: 2.0, kernel: func(x float32) float32 { x = absf32(x) if x < 2.0 { return bcspline(x, 1.0, 0.0) } return 0 }, } // Gaussian blurring filter. gaussianResampling = resamp{ name: "GaussianResampling", support: 2.0, kernel: func(x float32) float32 { x = absf32(x) if x < 2.0 { return float32(math.Exp(float64(-2 * x * x))) } return 0 }, } // Hann-windowed sinc filter (3 lobes). hannResampling = resamp{ name: "HannResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * float32(0.5+0.5*math.Cos(math.Pi*float64(x)/3.0)) } return 0 }, } hammingResampling = resamp{ name: "HammingResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * float32(0.54+0.46*math.Cos(math.Pi*float64(x)/3.0)) } return 0 }, } // Blackman-windowed sinc filter (3 lobes). blackmanResampling = resamp{ name: "BlackmanResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * float32(0.42-0.5*math.Cos(math.Pi*float64(x)/3.0+math.Pi)+0.08*math.Cos(2.0*math.Pi*float64(x)/3.0)) } return 0 }, } bartlettResampling = resamp{ name: "BartlettResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * (3.0 - x) / 3.0 } return 0 }, } // Welch-windowed sinc filter (parabolic window, 3 lobes). welchResampling = resamp{ name: "WelchResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * (1.0 - (x * x / 9.0)) } return 0 }, } // Cosine-windowed sinc filter (3 lobes). cosineResampling = resamp{ name: "CosineResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * float32(math.Cos((math.Pi/2.0)*(float64(x)/3.0))) } return 0 }, } ) // The following code is borrowed from https://raw.githubusercontent.com/disintegration/gift/master/resize.go // MIT licensed. type resamp struct { name string support float32 kernel func(float32) float32 } func (r resamp) String() string { return r.name } func (r resamp) Support() float32 { return r.support } func (r resamp) Kernel(x float32) float32 { return r.kernel(x) } func bcspline(x, b, c float32) float32 { if x < 0 { x = -x } if x < 1 { return ((12-9*b-6*c)*x*x*x + (-18+12*b+6*c)*x*x + (6 - 2*b)) / 6 } if x < 2 { return ((-b-6*c)*x*x*x + (6*b+30*c)*x*x + (-12*b-48*c)*x + (8*b + 24*c)) / 6 } return 0 } func absf32(x float32) float32 { if x < 0 { return -x } return x } func sinc(x float32) float32 { if x == 0 { return 1 } return float32(math.Sin(math.Pi*float64(x)) / (math.Pi * float64(x))) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package images import "math" // We moved from imaging to the gift package for image processing at some point. // That package had more, but also less resampling filters. So we add the missing // ones here. They are fairly exotic, but someone may use them, so keep them here // for now. // // The filters below are ported from https://github.com/disintegration/imaging/blob/9aab30e6aa535fe3337b489b76759ef97dfaf362/resize.go#L369 // MIT License. var ( // Hermite cubic spline filter (BC-spline; B=0; C=0). hermiteResampling = resamp{ name: "Hermite", support: 1.0, kernel: func(x float32) float32 { x = absf32(x) if x < 1.0 { return bcspline(x, 0.0, 0.0) } return 0 }, } // Mitchell-Netravali cubic filter (BC-spline; B=1/3; C=1/3). mitchellNetravaliResampling = resamp{ name: "MitchellNetravali", support: 2.0, kernel: func(x float32) float32 { x = absf32(x) if x < 2.0 { return bcspline(x, 1.0/3.0, 1.0/3.0) } return 0 }, } // Catmull-Rom - sharp cubic filter (BC-spline; B=0; C=0.5). catmullRomResampling = resamp{ name: "CatmullRomResampling", support: 2.0, kernel: func(x float32) float32 { x = absf32(x) if x < 2.0 { return bcspline(x, 0.0, 0.5) } return 0 }, } // BSpline is a smooth cubic filter (BC-spline; B=1; C=0). bSplineResampling = resamp{ name: "BSplineResampling", support: 2.0, kernel: func(x float32) float32 { x = absf32(x) if x < 2.0 { return bcspline(x, 1.0, 0.0) } return 0 }, } // Gaussian blurring filter. gaussianResampling = resamp{ name: "GaussianResampling", support: 2.0, kernel: func(x float32) float32 { x = absf32(x) if x < 2.0 { return float32(math.Exp(float64(-2 * x * x))) } return 0 }, } // Hann-windowed sinc filter (3 lobes). hannResampling = resamp{ name: "HannResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * float32(0.5+0.5*math.Cos(math.Pi*float64(x)/3.0)) } return 0 }, } hammingResampling = resamp{ name: "HammingResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * float32(0.54+0.46*math.Cos(math.Pi*float64(x)/3.0)) } return 0 }, } // Blackman-windowed sinc filter (3 lobes). blackmanResampling = resamp{ name: "BlackmanResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * float32(0.42-0.5*math.Cos(math.Pi*float64(x)/3.0+math.Pi)+0.08*math.Cos(2.0*math.Pi*float64(x)/3.0)) } return 0 }, } bartlettResampling = resamp{ name: "BartlettResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * (3.0 - x) / 3.0 } return 0 }, } // Welch-windowed sinc filter (parabolic window, 3 lobes). welchResampling = resamp{ name: "WelchResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * (1.0 - (x * x / 9.0)) } return 0 }, } // Cosine-windowed sinc filter (3 lobes). cosineResampling = resamp{ name: "CosineResampling", support: 3.0, kernel: func(x float32) float32 { x = absf32(x) if x < 3.0 { return sinc(x) * float32(math.Cos((math.Pi/2.0)*(float64(x)/3.0))) } return 0 }, } ) // The following code is borrowed from https://raw.githubusercontent.com/disintegration/gift/master/resize.go // MIT licensed. type resamp struct { name string support float32 kernel func(float32) float32 } func (r resamp) String() string { return r.name } func (r resamp) Support() float32 { return r.support } func (r resamp) Kernel(x float32) float32 { return r.kernel(x) } func bcspline(x, b, c float32) float32 { if x < 0 { x = -x } if x < 1 { return ((12-9*b-6*c)*x*x*x + (-18+12*b+6*c)*x*x + (6 - 2*b)) / 6 } if x < 2 { return ((-b-6*c)*x*x*x + (6*b+30*c)*x*x + (-12*b-48*c)*x + (8*b + 24*c)) / 6 } return 0 } func absf32(x float32) float32 { if x < 0 { return -x } return x } func sinc(x float32) float32 { if x == 0 { return 1 } return float32(math.Sin(math.Pi*float64(x)) / (math.Pi * float64(x))) }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./docs/content/en/functions/hugo.md
--- title: hugo linktitle: hugo description: The `hugo` function provides easy access to Hugo-related data. godocref: date: 2019-01-31 publishdate: 2019-01-31 lastmod: 2019-01-31 keywords: [] categories: [functions] menu: docs: parent: "functions" toc: signature: ["hugo"] workson: [] hugoversion: relatedfuncs: [] deprecated: false draft: false aliases: [] --- `hugo` returns an instance that contains the following functions: hugo.Generator : `<meta>` tag for the version of Hugo that generated the site. `hugo.Generator` outputs a *complete* HTML tag; e.g. `<meta name="generator" content="Hugo 0.63.2" />` hugo.Version : the current version of the Hugo binary you are using e.g. `0.63.2` `hugo` returns an instance that contains the following functions: hugo.Environment : the current running environment as defined through the `--environment` cli tag hugo.CommitHash : the git commit hash of the current Hugo binary e.g. `0e8bed9ccffba0df554728b46c5bbf6d78ae5247` hugo.BuildDate : the compile date of the current Hugo binary formatted with RFC 3339 e.g. `2002-10-02T10:00:00-05:00` hugo.IsProduction : returns true if `hugo.Environment` is set to the production environment {{% note "Use the Hugo Generator Tag" %}} We highly recommend using `hugo.Generator` in your website's `<head>`. `hugo.Generator` is included by default in all themes hosted on [themes.gohugo.io](https://themes.gohugo.io). The generator tag allows the Hugo team to track the usage and popularity of Hugo. {{% /note %}}
--- title: hugo linktitle: hugo description: The `hugo` function provides easy access to Hugo-related data. godocref: date: 2019-01-31 publishdate: 2019-01-31 lastmod: 2019-01-31 keywords: [] categories: [functions] menu: docs: parent: "functions" toc: signature: ["hugo"] workson: [] hugoversion: relatedfuncs: [] deprecated: false draft: false aliases: [] --- `hugo` returns an instance that contains the following functions: hugo.Generator : `<meta>` tag for the version of Hugo that generated the site. `hugo.Generator` outputs a *complete* HTML tag; e.g. `<meta name="generator" content="Hugo 0.63.2" />` hugo.Version : the current version of the Hugo binary you are using e.g. `0.63.2` `hugo` returns an instance that contains the following functions: hugo.Environment : the current running environment as defined through the `--environment` cli tag hugo.CommitHash : the git commit hash of the current Hugo binary e.g. `0e8bed9ccffba0df554728b46c5bbf6d78ae5247` hugo.BuildDate : the compile date of the current Hugo binary formatted with RFC 3339 e.g. `2002-10-02T10:00:00-05:00` hugo.IsProduction : returns true if `hugo.Environment` is set to the production environment {{% note "Use the Hugo Generator Tag" %}} We highly recommend using `hugo.Generator` in your website's `<head>`. `hugo.Generator` is included by default in all themes hosted on [themes.gohugo.io](https://themes.gohugo.io). The generator tag allows the Hugo team to track the usage and popularity of Hugo. {{% /note %}}
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./examples/multilingual/content/about.en.md
+++ title = "About" +++ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex deleniti ut tenetur amet accusantium dolores nam provident! Ipsum, dicta voluptatum quas architecto nostrum sapiente eos commodi numquam accusantium reprehenderit. Doloremque, veritatis qui impedit expedita quas distinctio temporibus repellendus dicta debitis iure molestias recusandae cum facere natus esse saepe inventore beatae ipsum soluta voluptas in quaerat nam culpa id autem! ## History Sequi eum impedit distinctio facilis repudiandae provident iure illo quia autem optio. Ea, facilis, possimus dolor nobis explicabo recusandae numquam ducimus minus eum totam odio architecto nesciunt accusamus expedita natus.
+++ title = "About" +++ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ex deleniti ut tenetur amet accusantium dolores nam provident! Ipsum, dicta voluptatum quas architecto nostrum sapiente eos commodi numquam accusantium reprehenderit. Doloremque, veritatis qui impedit expedita quas distinctio temporibus repellendus dicta debitis iure molestias recusandae cum facere natus esse saepe inventore beatae ipsum soluta voluptas in quaerat nam culpa id autem! ## History Sequi eum impedit distinctio facilis repudiandae provident iure illo quia autem optio. Ea, facilis, possimus dolor nobis explicabo recusandae numquam ducimus minus eum totam odio architecto nesciunt accusamus expedita natus.
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./hugolib/content_map_page.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "context" "fmt" "path" "path/filepath" "strings" "sync" "github.com/gohugoio/hugo/common/maps" "github.com/gohugoio/hugo/common/types" "github.com/gohugoio/hugo/resources" "github.com/gohugoio/hugo/common/hugio" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/hugofs/files" "github.com/gohugoio/hugo/parser/pageparser" "github.com/gohugoio/hugo/resources/page" "github.com/gohugoio/hugo/resources/resource" "github.com/spf13/cast" "github.com/gohugoio/hugo/common/para" "github.com/pkg/errors" ) func newPageMaps(h *HugoSites) *pageMaps { mps := make([]*pageMap, len(h.Sites)) for i, s := range h.Sites { mps[i] = s.pageMap } return &pageMaps{ workers: para.New(h.numWorkers), pmaps: mps, } } type pageMap struct { s *Site *contentMap } func (m *pageMap) Len() int { l := 0 for _, t := range m.contentMap.pageTrees { l += t.Len() } return l } func (m *pageMap) createMissingTaxonomyNodes() error { if m.cfg.taxonomyDisabled { return nil } m.taxonomyEntries.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) vi := n.viewInfo k := cleanSectionTreeKey(vi.name.plural + "/" + vi.termKey) if _, found := m.taxonomies.Get(k); !found { vic := &contentBundleViewInfo{ name: vi.name, termKey: vi.termKey, termOrigin: vi.termOrigin, } m.taxonomies.Insert(k, &contentNode{viewInfo: vic}) } return false }) return nil } func (m *pageMap) newPageFromContentNode(n *contentNode, parentBucket *pagesMapBucket, owner *pageState) (*pageState, error) { if n.fi == nil { panic("FileInfo must (currently) be set") } f, err := newFileInfo(m.s.SourceSpec, n.fi) if err != nil { return nil, err } meta := n.fi.Meta() content := func() (hugio.ReadSeekCloser, error) { return meta.Open() } bundled := owner != nil s := m.s sections := s.sectionsFromFile(f) kind := s.kindFromFileInfoOrSections(f, sections) if kind == page.KindTerm { s.PathSpec.MakePathsSanitized(sections) } metaProvider := &pageMeta{kind: kind, sections: sections, bundled: bundled, s: s, f: f} ps, err := newPageBase(metaProvider) if err != nil { return nil, err } if n.fi.Meta().GetBool(walkIsRootFileMetaKey) { // Make sure that the bundle/section we start walking from is always // rendered. // This is only relevant in server fast render mode. ps.forceRender = true } n.p = ps if ps.IsNode() { ps.bucket = newPageBucket(ps) } gi, err := s.h.gitInfoForPage(ps) if err != nil { return nil, errors.Wrap(err, "failed to load Git data") } ps.gitInfo = gi r, err := content() if err != nil { return nil, err } defer r.Close() parseResult, err := pageparser.Parse( r, pageparser.Config{EnableEmoji: s.siteCfg.enableEmoji}, ) if err != nil { return nil, err } ps.pageContent = pageContent{ source: rawPageContent{ parsed: parseResult, posMainContent: -1, posSummaryEnd: -1, posBodyStart: -1, }, } ps.shortcodeState = newShortcodeHandler(ps, ps.s, nil) if err := ps.mapContent(parentBucket, metaProvider); err != nil { return nil, ps.wrapError(err) } if err := metaProvider.applyDefaultValues(n); err != nil { return nil, err } ps.init.Add(func() (interface{}, error) { pp, err := newPagePaths(s, ps, metaProvider) if err != nil { return nil, err } outputFormatsForPage := ps.m.outputFormats() // Prepare output formats for all sites. // We do this even if this page does not get rendered on // its own. It may be referenced via .Site.GetPage and // it will then need an output format. ps.pageOutputs = make([]*pageOutput, len(ps.s.h.renderFormats)) created := make(map[string]*pageOutput) shouldRenderPage := !ps.m.noRender() for i, f := range ps.s.h.renderFormats { if po, found := created[f.Name]; found { ps.pageOutputs[i] = po continue } render := shouldRenderPage if render { _, render = outputFormatsForPage.GetByName(f.Name) } po := newPageOutput(ps, pp, f, render) // Create a content provider for the first, // we may be able to reuse it. if i == 0 { contentProvider, err := newPageContentOutput(ps, po) if err != nil { return nil, err } po.initContentProvider(contentProvider) } ps.pageOutputs[i] = po created[f.Name] = po } if err := ps.initCommonProviders(pp); err != nil { return nil, err } return nil, nil }) ps.parent = owner return ps, nil } func (m *pageMap) newResource(fim hugofs.FileMetaInfo, owner *pageState) (resource.Resource, error) { if owner == nil { panic("owner is nil") } // TODO(bep) consolidate with multihost logic + clean up outputFormats := owner.m.outputFormats() seen := make(map[string]bool) var targetBasePaths []string // Make sure bundled resources are published to all of the output formats' // sub paths. for _, f := range outputFormats { p := f.Path if seen[p] { continue } seen[p] = true targetBasePaths = append(targetBasePaths, p) } meta := fim.Meta() r := func() (hugio.ReadSeekCloser, error) { return meta.Open() } target := strings.TrimPrefix(meta.Path(), owner.File().Dir()) return owner.s.ResourceSpec.New( resources.ResourceSourceDescriptor{ TargetPaths: owner.getTargetPaths, OpenReadSeekCloser: r, FileInfo: fim, RelTargetFilename: target, TargetBasePaths: targetBasePaths, LazyPublish: !owner.m.buildConfig.PublishResources, }) } func (m *pageMap) createSiteTaxonomies() error { m.s.taxonomies = make(TaxonomyList) var walkErr error m.taxonomies.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) t := n.viewInfo viewName := t.name if t.termKey == "" { m.s.taxonomies[viewName.plural] = make(Taxonomy) } else { taxonomy := m.s.taxonomies[viewName.plural] if taxonomy == nil { walkErr = errors.Errorf("missing taxonomy: %s", viewName.plural) return true } m.taxonomyEntries.WalkPrefix(s, func(ss string, v interface{}) bool { b2 := v.(*contentNode) info := b2.viewInfo taxonomy.add(info.termKey, page.NewWeightedPage(info.weight, info.ref.p, n.p)) return false }) } return false }) for _, taxonomy := range m.s.taxonomies { for _, v := range taxonomy { v.Sort() } } return walkErr } func (m *pageMap) createListAllPages() page.Pages { pages := make(page.Pages, 0) m.contentMap.pageTrees.Walk(func(s string, n *contentNode) bool { if n.p == nil { panic(fmt.Sprintf("BUG: page not set for %q", s)) } if contentTreeNoListAlwaysFilter(s, n) { return false } pages = append(pages, n.p) return false }) page.SortByDefault(pages) return pages } func (m *pageMap) assemblePages() error { m.taxonomyEntries.DeletePrefix("/") if err := m.assembleSections(); err != nil { return err } var err error if err != nil { return err } m.pages.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) var shouldBuild bool defer func() { // Make sure we always rebuild the view cache. if shouldBuild && err == nil && n.p != nil { m.attachPageToViews(s, n) } }() if n.p != nil { // A rebuild shouldBuild = true return false } var parent *contentNode var parentBucket *pagesMapBucket _, parent = m.getSection(s) if parent == nil { panic(fmt.Sprintf("BUG: parent not set for %q", s)) } parentBucket = parent.p.bucket n.p, err = m.newPageFromContentNode(n, parentBucket, nil) if err != nil { return true } shouldBuild = !(n.p.Kind() == page.KindPage && m.cfg.pageDisabled) && m.s.shouldBuild(n.p) if !shouldBuild { m.deletePage(s) return false } n.p.treeRef = &contentTreeRef{ m: m, t: m.pages, n: n, key: s, } if err = m.assembleResources(s, n.p, parentBucket); err != nil { return true } return false }) m.deleteOrphanSections() return err } func (m *pageMap) assembleResources(s string, p *pageState, parentBucket *pagesMapBucket) error { var err error m.resources.WalkPrefix(s, func(s string, v interface{}) bool { n := v.(*contentNode) meta := n.fi.Meta() classifier := meta.Classifier() var r resource.Resource switch classifier { case files.ContentClassContent: var rp *pageState rp, err = m.newPageFromContentNode(n, parentBucket, p) if err != nil { return true } rp.m.resourcePath = filepath.ToSlash(strings.TrimPrefix(rp.Path(), p.File().Dir())) r = rp case files.ContentClassFile: r, err = m.newResource(n.fi, p) if err != nil { return true } default: panic(fmt.Sprintf("invalid classifier: %q", classifier)) } p.resources = append(p.resources, r) return false }) return err } func (m *pageMap) assembleSections() error { var sectionsToDelete []string var err error m.sections.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) var shouldBuild bool defer func() { // Make sure we always rebuild the view cache. if shouldBuild && err == nil && n.p != nil { m.attachPageToViews(s, n) if n.p.IsHome() { m.s.home = n.p } } }() sections := m.splitKey(s) if n.p != nil { if n.p.IsHome() { m.s.home = n.p } shouldBuild = true return false } var parent *contentNode var parentBucket *pagesMapBucket if s != "/" { _, parent = m.getSection(s) if parent == nil || parent.p == nil { panic(fmt.Sprintf("BUG: parent not set for %q", s)) } } if parent != nil { parentBucket = parent.p.bucket } kind := page.KindSection if s == "/" { kind = page.KindHome } if n.fi != nil { n.p, err = m.newPageFromContentNode(n, parentBucket, nil) if err != nil { return true } } else { n.p = m.s.newPage(n, parentBucket, kind, "", sections...) } shouldBuild = m.s.shouldBuild(n.p) if !shouldBuild { sectionsToDelete = append(sectionsToDelete, s) return false } n.p.treeRef = &contentTreeRef{ m: m, t: m.sections, n: n, key: s, } if err = m.assembleResources(s+cmLeafSeparator, n.p, parentBucket); err != nil { return true } return false }) for _, s := range sectionsToDelete { m.deleteSectionByPath(s) } return err } func (m *pageMap) assembleTaxonomies() error { var taxonomiesToDelete []string var err error m.taxonomies.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) if n.p != nil { return false } kind := n.viewInfo.kind() sections := n.viewInfo.sections() _, parent := m.getTaxonomyParent(s) if parent == nil || parent.p == nil { panic(fmt.Sprintf("BUG: parent not set for %q", s)) } parentBucket := parent.p.bucket if n.fi != nil { n.p, err = m.newPageFromContentNode(n, parent.p.bucket, nil) if err != nil { return true } } else { title := "" if kind == page.KindTerm { title = n.viewInfo.term() } n.p = m.s.newPage(n, parent.p.bucket, kind, title, sections...) } if !m.s.shouldBuild(n.p) { taxonomiesToDelete = append(taxonomiesToDelete, s) return false } n.p.treeRef = &contentTreeRef{ m: m, t: m.taxonomies, n: n, key: s, } if err = m.assembleResources(s+cmLeafSeparator, n.p, parentBucket); err != nil { return true } return false }) for _, s := range taxonomiesToDelete { m.deleteTaxonomy(s) } return err } func (m *pageMap) attachPageToViews(s string, b *contentNode) { if m.cfg.taxonomyDisabled { return } for _, viewName := range m.cfg.taxonomyConfig { vals := types.ToStringSlicePreserveString(getParam(b.p, viewName.plural, false)) if vals == nil { continue } w := getParamToLower(b.p, viewName.plural+"_weight") weight, err := cast.ToIntE(w) if err != nil { m.s.Log.Errorf("Unable to convert taxonomy weight %#v to int for %q", w, b.p.Path()) // weight will equal zero, so let the flow continue } for i, v := range vals { termKey := m.s.getTaxonomyKey(v) bv := &contentNode{ viewInfo: &contentBundleViewInfo{ ordinal: i, name: viewName, termKey: termKey, termOrigin: v, weight: weight, ref: b, }, } var key string if strings.HasSuffix(s, "/") { key = cleanSectionTreeKey(path.Join(viewName.plural, termKey, s)) } else { key = cleanTreeKey(path.Join(viewName.plural, termKey, s)) } m.taxonomyEntries.Insert(key, bv) } } } type pageMapQuery struct { Prefix string Filter contentTreeNodeCallback } func (m *pageMap) collectPages(query pageMapQuery, fn func(c *contentNode)) error { if query.Filter == nil { query.Filter = contentTreeNoListAlwaysFilter } m.pages.WalkQuery(query, func(s string, n *contentNode) bool { fn(n) return false }) return nil } func (m *pageMap) collectPagesAndSections(query pageMapQuery, fn func(c *contentNode)) error { if err := m.collectSections(query, fn); err != nil { return err } query.Prefix = query.Prefix + cmBranchSeparator if err := m.collectPages(query, fn); err != nil { return err } return nil } func (m *pageMap) collectSections(query pageMapQuery, fn func(c *contentNode)) error { level := strings.Count(query.Prefix, "/") return m.collectSectionsFn(query, func(s string, c *contentNode) bool { if strings.Count(s, "/") != level+1 { return false } fn(c) return false }) } func (m *pageMap) collectSectionsFn(query pageMapQuery, fn func(s string, c *contentNode) bool) error { if !strings.HasSuffix(query.Prefix, "/") { query.Prefix += "/" } m.sections.WalkQuery(query, func(s string, n *contentNode) bool { return fn(s, n) }) return nil } func (m *pageMap) collectSectionsRecursiveIncludingSelf(query pageMapQuery, fn func(c *contentNode)) error { return m.collectSectionsFn(query, func(s string, c *contentNode) bool { fn(c) return false }) } func (m *pageMap) collectTaxonomies(prefix string, fn func(c *contentNode)) error { m.taxonomies.WalkQuery(pageMapQuery{Prefix: prefix}, func(s string, n *contentNode) bool { fn(n) return false }) return nil } // withEveryBundlePage applies fn to every Page, including those bundled inside // leaf bundles. func (m *pageMap) withEveryBundlePage(fn func(p *pageState) bool) { m.bundleTrees.Walk(func(s string, n *contentNode) bool { if n.p != nil { return fn(n.p) } return false }) } type pageMaps struct { workers *para.Workers pmaps []*pageMap } // deleteSection deletes the entire section from s. func (m *pageMaps) deleteSection(s string) { m.withMaps(func(pm *pageMap) error { pm.deleteSectionByPath(s) return nil }) } func (m *pageMaps) AssemblePages() error { return m.withMaps(func(pm *pageMap) error { if err := pm.CreateMissingNodes(); err != nil { return err } if err := pm.assemblePages(); err != nil { return err } if err := pm.createMissingTaxonomyNodes(); err != nil { return err } // Handle any new sections created in the step above. if err := pm.assembleSections(); err != nil { return err } if pm.s.home == nil { // Home is disabled, everything is. pm.bundleTrees.DeletePrefix("") return nil } if err := pm.assembleTaxonomies(); err != nil { return err } if err := pm.createSiteTaxonomies(); err != nil { return err } sw := &sectionWalker{m: pm.contentMap} a := sw.applyAggregates() _, mainSectionsSet := pm.s.s.Info.Params()["mainsections"] if !mainSectionsSet && a.mainSection != "" { mainSections := []string{strings.TrimRight(a.mainSection, "/")} pm.s.s.Info.Params()["mainSections"] = mainSections pm.s.s.Info.Params()["mainsections"] = mainSections } pm.s.lastmod = a.datesAll.Lastmod() if resource.IsZeroDates(pm.s.home) { pm.s.home.m.Dates = a.datesAll } return nil }) } func (m *pageMaps) walkBundles(fn func(n *contentNode) bool) { _ = m.withMaps(func(pm *pageMap) error { pm.bundleTrees.Walk(func(s string, n *contentNode) bool { return fn(n) }) return nil }) } func (m *pageMaps) walkBranchesPrefix(prefix string, fn func(s string, n *contentNode) bool) { _ = m.withMaps(func(pm *pageMap) error { pm.branchTrees.WalkPrefix(prefix, func(s string, n *contentNode) bool { return fn(s, n) }) return nil }) } func (m *pageMaps) withMaps(fn func(pm *pageMap) error) error { g, _ := m.workers.Start(context.Background()) for _, pm := range m.pmaps { pm := pm g.Run(func() error { return fn(pm) }) } return g.Wait() } type pagesMapBucket struct { // Cascading front matter. cascade map[page.PageMatcher]maps.Params owner *pageState // The branch node *pagesMapBucketPages } type pagesMapBucketPages struct { pagesInit sync.Once pages page.Pages pagesAndSectionsInit sync.Once pagesAndSections page.Pages sectionsInit sync.Once sections page.Pages } func (b *pagesMapBucket) getPages() page.Pages { b.pagesInit.Do(func() { b.pages = b.owner.treeRef.getPages() page.SortByDefault(b.pages) }) return b.pages } func (b *pagesMapBucket) getPagesRecursive() page.Pages { pages := b.owner.treeRef.getPagesRecursive() page.SortByDefault(pages) return pages } func (b *pagesMapBucket) getPagesAndSections() page.Pages { b.pagesAndSectionsInit.Do(func() { b.pagesAndSections = b.owner.treeRef.getPagesAndSections() }) return b.pagesAndSections } func (b *pagesMapBucket) getSections() page.Pages { b.sectionsInit.Do(func() { if b.owner.treeRef == nil { return } b.sections = b.owner.treeRef.getSections() }) return b.sections } func (b *pagesMapBucket) getTaxonomies() page.Pages { b.sectionsInit.Do(func() { var pas page.Pages ref := b.owner.treeRef ref.m.collectTaxonomies(ref.key, func(c *contentNode) { pas = append(pas, c.p) }) page.SortByDefault(pas) b.sections = pas }) return b.sections } func (b *pagesMapBucket) getTaxonomyEntries() page.Pages { var pas page.Pages ref := b.owner.treeRef viewInfo := ref.n.viewInfo prefix := strings.ToLower("/" + viewInfo.name.plural + "/" + viewInfo.termKey + "/") ref.m.taxonomyEntries.WalkPrefix(prefix, func(s string, v interface{}) bool { n := v.(*contentNode) pas = append(pas, n.viewInfo.ref.p) return false }) page.SortByDefault(pas) return pas } type sectionAggregate struct { datesAll resource.Dates datesSection resource.Dates pageCount int mainSection string mainSectionPageCount int } type sectionAggregateHandler struct { sectionAggregate sectionPageCount int // Section b *contentNode s string } func (h *sectionAggregateHandler) String() string { return fmt.Sprintf("%s/%s - %d - %s", h.sectionAggregate.datesAll, h.sectionAggregate.datesSection, h.sectionPageCount, h.s) } func (h *sectionAggregateHandler) isRootSection() bool { return h.s != "/" && strings.Count(h.s, "/") == 2 } func (h *sectionAggregateHandler) handleNested(v sectionWalkHandler) error { nested := v.(*sectionAggregateHandler) h.sectionPageCount += nested.pageCount h.pageCount += h.sectionPageCount h.datesAll.UpdateDateAndLastmodIfAfter(nested.datesAll) h.datesSection.UpdateDateAndLastmodIfAfter(nested.datesAll) return nil } func (h *sectionAggregateHandler) handlePage(s string, n *contentNode) error { h.sectionPageCount++ var d resource.Dated if n.p != nil { d = n.p } else if n.viewInfo != nil && n.viewInfo.ref != nil { d = n.viewInfo.ref.p } else { return nil } h.datesAll.UpdateDateAndLastmodIfAfter(d) h.datesSection.UpdateDateAndLastmodIfAfter(d) return nil } func (h *sectionAggregateHandler) handleSectionPost() error { if h.sectionPageCount > h.mainSectionPageCount && h.isRootSection() { h.mainSectionPageCount = h.sectionPageCount h.mainSection = strings.TrimPrefix(h.s, "/") } if resource.IsZeroDates(h.b.p) { h.b.p.m.Dates = h.datesSection } h.datesSection = resource.Dates{} return nil } func (h *sectionAggregateHandler) handleSectionPre(s string, b *contentNode) error { h.s = s h.b = b h.sectionPageCount = 0 h.datesAll.UpdateDateAndLastmodIfAfter(b.p) return nil } type sectionWalkHandler interface { handleNested(v sectionWalkHandler) error handlePage(s string, b *contentNode) error handleSectionPost() error handleSectionPre(s string, b *contentNode) error } type sectionWalker struct { err error m *contentMap } func (w *sectionWalker) applyAggregates() *sectionAggregateHandler { return w.walkLevel("/", func() sectionWalkHandler { return &sectionAggregateHandler{} }).(*sectionAggregateHandler) } func (w *sectionWalker) walkLevel(prefix string, createVisitor func() sectionWalkHandler) sectionWalkHandler { level := strings.Count(prefix, "/") visitor := createVisitor() w.m.taxonomies.WalkBelow(prefix, func(s string, v interface{}) bool { currentLevel := strings.Count(s, "/") if currentLevel > level+1 { return false } n := v.(*contentNode) if w.err = visitor.handleSectionPre(s, n); w.err != nil { return true } if currentLevel == 2 { nested := w.walkLevel(s, createVisitor) if w.err = visitor.handleNested(nested); w.err != nil { return true } } else { w.m.taxonomyEntries.WalkPrefix(s, func(ss string, v interface{}) bool { n := v.(*contentNode) w.err = visitor.handlePage(ss, n) return w.err != nil }) } w.err = visitor.handleSectionPost() return w.err != nil }) w.m.sections.WalkBelow(prefix, func(s string, v interface{}) bool { currentLevel := strings.Count(s, "/") if currentLevel > level+1 { return false } n := v.(*contentNode) if w.err = visitor.handleSectionPre(s, n); w.err != nil { return true } w.m.pages.WalkPrefix(s+cmBranchSeparator, func(s string, v interface{}) bool { w.err = visitor.handlePage(s, v.(*contentNode)) return w.err != nil }) if w.err != nil { return true } nested := w.walkLevel(s, createVisitor) if w.err = visitor.handleNested(nested); w.err != nil { return true } w.err = visitor.handleSectionPost() return w.err != nil }) return visitor } type viewName struct { singular string // e.g. "category" plural string // e.g. "categories" } func (v viewName) IsZero() bool { return v.singular == "" }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "context" "fmt" "path" "path/filepath" "strings" "sync" "github.com/gohugoio/hugo/common/maps" "github.com/gohugoio/hugo/common/types" "github.com/gohugoio/hugo/resources" "github.com/gohugoio/hugo/common/hugio" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/hugofs/files" "github.com/gohugoio/hugo/parser/pageparser" "github.com/gohugoio/hugo/resources/page" "github.com/gohugoio/hugo/resources/resource" "github.com/spf13/cast" "github.com/gohugoio/hugo/common/para" "github.com/pkg/errors" ) func newPageMaps(h *HugoSites) *pageMaps { mps := make([]*pageMap, len(h.Sites)) for i, s := range h.Sites { mps[i] = s.pageMap } return &pageMaps{ workers: para.New(h.numWorkers), pmaps: mps, } } type pageMap struct { s *Site *contentMap } func (m *pageMap) Len() int { l := 0 for _, t := range m.contentMap.pageTrees { l += t.Len() } return l } func (m *pageMap) createMissingTaxonomyNodes() error { if m.cfg.taxonomyDisabled { return nil } m.taxonomyEntries.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) vi := n.viewInfo k := cleanSectionTreeKey(vi.name.plural + "/" + vi.termKey) if _, found := m.taxonomies.Get(k); !found { vic := &contentBundleViewInfo{ name: vi.name, termKey: vi.termKey, termOrigin: vi.termOrigin, } m.taxonomies.Insert(k, &contentNode{viewInfo: vic}) } return false }) return nil } func (m *pageMap) newPageFromContentNode(n *contentNode, parentBucket *pagesMapBucket, owner *pageState) (*pageState, error) { if n.fi == nil { panic("FileInfo must (currently) be set") } f, err := newFileInfo(m.s.SourceSpec, n.fi) if err != nil { return nil, err } meta := n.fi.Meta() content := func() (hugio.ReadSeekCloser, error) { return meta.Open() } bundled := owner != nil s := m.s sections := s.sectionsFromFile(f) kind := s.kindFromFileInfoOrSections(f, sections) if kind == page.KindTerm { s.PathSpec.MakePathsSanitized(sections) } metaProvider := &pageMeta{kind: kind, sections: sections, bundled: bundled, s: s, f: f} ps, err := newPageBase(metaProvider) if err != nil { return nil, err } if n.fi.Meta().GetBool(walkIsRootFileMetaKey) { // Make sure that the bundle/section we start walking from is always // rendered. // This is only relevant in server fast render mode. ps.forceRender = true } n.p = ps if ps.IsNode() { ps.bucket = newPageBucket(ps) } gi, err := s.h.gitInfoForPage(ps) if err != nil { return nil, errors.Wrap(err, "failed to load Git data") } ps.gitInfo = gi r, err := content() if err != nil { return nil, err } defer r.Close() parseResult, err := pageparser.Parse( r, pageparser.Config{EnableEmoji: s.siteCfg.enableEmoji}, ) if err != nil { return nil, err } ps.pageContent = pageContent{ source: rawPageContent{ parsed: parseResult, posMainContent: -1, posSummaryEnd: -1, posBodyStart: -1, }, } ps.shortcodeState = newShortcodeHandler(ps, ps.s, nil) if err := ps.mapContent(parentBucket, metaProvider); err != nil { return nil, ps.wrapError(err) } if err := metaProvider.applyDefaultValues(n); err != nil { return nil, err } ps.init.Add(func() (interface{}, error) { pp, err := newPagePaths(s, ps, metaProvider) if err != nil { return nil, err } outputFormatsForPage := ps.m.outputFormats() // Prepare output formats for all sites. // We do this even if this page does not get rendered on // its own. It may be referenced via .Site.GetPage and // it will then need an output format. ps.pageOutputs = make([]*pageOutput, len(ps.s.h.renderFormats)) created := make(map[string]*pageOutput) shouldRenderPage := !ps.m.noRender() for i, f := range ps.s.h.renderFormats { if po, found := created[f.Name]; found { ps.pageOutputs[i] = po continue } render := shouldRenderPage if render { _, render = outputFormatsForPage.GetByName(f.Name) } po := newPageOutput(ps, pp, f, render) // Create a content provider for the first, // we may be able to reuse it. if i == 0 { contentProvider, err := newPageContentOutput(ps, po) if err != nil { return nil, err } po.initContentProvider(contentProvider) } ps.pageOutputs[i] = po created[f.Name] = po } if err := ps.initCommonProviders(pp); err != nil { return nil, err } return nil, nil }) ps.parent = owner return ps, nil } func (m *pageMap) newResource(fim hugofs.FileMetaInfo, owner *pageState) (resource.Resource, error) { if owner == nil { panic("owner is nil") } // TODO(bep) consolidate with multihost logic + clean up outputFormats := owner.m.outputFormats() seen := make(map[string]bool) var targetBasePaths []string // Make sure bundled resources are published to all of the output formats' // sub paths. for _, f := range outputFormats { p := f.Path if seen[p] { continue } seen[p] = true targetBasePaths = append(targetBasePaths, p) } meta := fim.Meta() r := func() (hugio.ReadSeekCloser, error) { return meta.Open() } target := strings.TrimPrefix(meta.Path(), owner.File().Dir()) return owner.s.ResourceSpec.New( resources.ResourceSourceDescriptor{ TargetPaths: owner.getTargetPaths, OpenReadSeekCloser: r, FileInfo: fim, RelTargetFilename: target, TargetBasePaths: targetBasePaths, LazyPublish: !owner.m.buildConfig.PublishResources, }) } func (m *pageMap) createSiteTaxonomies() error { m.s.taxonomies = make(TaxonomyList) var walkErr error m.taxonomies.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) t := n.viewInfo viewName := t.name if t.termKey == "" { m.s.taxonomies[viewName.plural] = make(Taxonomy) } else { taxonomy := m.s.taxonomies[viewName.plural] if taxonomy == nil { walkErr = errors.Errorf("missing taxonomy: %s", viewName.plural) return true } m.taxonomyEntries.WalkPrefix(s, func(ss string, v interface{}) bool { b2 := v.(*contentNode) info := b2.viewInfo taxonomy.add(info.termKey, page.NewWeightedPage(info.weight, info.ref.p, n.p)) return false }) } return false }) for _, taxonomy := range m.s.taxonomies { for _, v := range taxonomy { v.Sort() } } return walkErr } func (m *pageMap) createListAllPages() page.Pages { pages := make(page.Pages, 0) m.contentMap.pageTrees.Walk(func(s string, n *contentNode) bool { if n.p == nil { panic(fmt.Sprintf("BUG: page not set for %q", s)) } if contentTreeNoListAlwaysFilter(s, n) { return false } pages = append(pages, n.p) return false }) page.SortByDefault(pages) return pages } func (m *pageMap) assemblePages() error { m.taxonomyEntries.DeletePrefix("/") if err := m.assembleSections(); err != nil { return err } var err error if err != nil { return err } m.pages.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) var shouldBuild bool defer func() { // Make sure we always rebuild the view cache. if shouldBuild && err == nil && n.p != nil { m.attachPageToViews(s, n) } }() if n.p != nil { // A rebuild shouldBuild = true return false } var parent *contentNode var parentBucket *pagesMapBucket _, parent = m.getSection(s) if parent == nil { panic(fmt.Sprintf("BUG: parent not set for %q", s)) } parentBucket = parent.p.bucket n.p, err = m.newPageFromContentNode(n, parentBucket, nil) if err != nil { return true } shouldBuild = !(n.p.Kind() == page.KindPage && m.cfg.pageDisabled) && m.s.shouldBuild(n.p) if !shouldBuild { m.deletePage(s) return false } n.p.treeRef = &contentTreeRef{ m: m, t: m.pages, n: n, key: s, } if err = m.assembleResources(s, n.p, parentBucket); err != nil { return true } return false }) m.deleteOrphanSections() return err } func (m *pageMap) assembleResources(s string, p *pageState, parentBucket *pagesMapBucket) error { var err error m.resources.WalkPrefix(s, func(s string, v interface{}) bool { n := v.(*contentNode) meta := n.fi.Meta() classifier := meta.Classifier() var r resource.Resource switch classifier { case files.ContentClassContent: var rp *pageState rp, err = m.newPageFromContentNode(n, parentBucket, p) if err != nil { return true } rp.m.resourcePath = filepath.ToSlash(strings.TrimPrefix(rp.Path(), p.File().Dir())) r = rp case files.ContentClassFile: r, err = m.newResource(n.fi, p) if err != nil { return true } default: panic(fmt.Sprintf("invalid classifier: %q", classifier)) } p.resources = append(p.resources, r) return false }) return err } func (m *pageMap) assembleSections() error { var sectionsToDelete []string var err error m.sections.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) var shouldBuild bool defer func() { // Make sure we always rebuild the view cache. if shouldBuild && err == nil && n.p != nil { m.attachPageToViews(s, n) if n.p.IsHome() { m.s.home = n.p } } }() sections := m.splitKey(s) if n.p != nil { if n.p.IsHome() { m.s.home = n.p } shouldBuild = true return false } var parent *contentNode var parentBucket *pagesMapBucket if s != "/" { _, parent = m.getSection(s) if parent == nil || parent.p == nil { panic(fmt.Sprintf("BUG: parent not set for %q", s)) } } if parent != nil { parentBucket = parent.p.bucket } kind := page.KindSection if s == "/" { kind = page.KindHome } if n.fi != nil { n.p, err = m.newPageFromContentNode(n, parentBucket, nil) if err != nil { return true } } else { n.p = m.s.newPage(n, parentBucket, kind, "", sections...) } shouldBuild = m.s.shouldBuild(n.p) if !shouldBuild { sectionsToDelete = append(sectionsToDelete, s) return false } n.p.treeRef = &contentTreeRef{ m: m, t: m.sections, n: n, key: s, } if err = m.assembleResources(s+cmLeafSeparator, n.p, parentBucket); err != nil { return true } return false }) for _, s := range sectionsToDelete { m.deleteSectionByPath(s) } return err } func (m *pageMap) assembleTaxonomies() error { var taxonomiesToDelete []string var err error m.taxonomies.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) if n.p != nil { return false } kind := n.viewInfo.kind() sections := n.viewInfo.sections() _, parent := m.getTaxonomyParent(s) if parent == nil || parent.p == nil { panic(fmt.Sprintf("BUG: parent not set for %q", s)) } parentBucket := parent.p.bucket if n.fi != nil { n.p, err = m.newPageFromContentNode(n, parent.p.bucket, nil) if err != nil { return true } } else { title := "" if kind == page.KindTerm { title = n.viewInfo.term() } n.p = m.s.newPage(n, parent.p.bucket, kind, title, sections...) } if !m.s.shouldBuild(n.p) { taxonomiesToDelete = append(taxonomiesToDelete, s) return false } n.p.treeRef = &contentTreeRef{ m: m, t: m.taxonomies, n: n, key: s, } if err = m.assembleResources(s+cmLeafSeparator, n.p, parentBucket); err != nil { return true } return false }) for _, s := range taxonomiesToDelete { m.deleteTaxonomy(s) } return err } func (m *pageMap) attachPageToViews(s string, b *contentNode) { if m.cfg.taxonomyDisabled { return } for _, viewName := range m.cfg.taxonomyConfig { vals := types.ToStringSlicePreserveString(getParam(b.p, viewName.plural, false)) if vals == nil { continue } w := getParamToLower(b.p, viewName.plural+"_weight") weight, err := cast.ToIntE(w) if err != nil { m.s.Log.Errorf("Unable to convert taxonomy weight %#v to int for %q", w, b.p.Path()) // weight will equal zero, so let the flow continue } for i, v := range vals { termKey := m.s.getTaxonomyKey(v) bv := &contentNode{ viewInfo: &contentBundleViewInfo{ ordinal: i, name: viewName, termKey: termKey, termOrigin: v, weight: weight, ref: b, }, } var key string if strings.HasSuffix(s, "/") { key = cleanSectionTreeKey(path.Join(viewName.plural, termKey, s)) } else { key = cleanTreeKey(path.Join(viewName.plural, termKey, s)) } m.taxonomyEntries.Insert(key, bv) } } } type pageMapQuery struct { Prefix string Filter contentTreeNodeCallback } func (m *pageMap) collectPages(query pageMapQuery, fn func(c *contentNode)) error { if query.Filter == nil { query.Filter = contentTreeNoListAlwaysFilter } m.pages.WalkQuery(query, func(s string, n *contentNode) bool { fn(n) return false }) return nil } func (m *pageMap) collectPagesAndSections(query pageMapQuery, fn func(c *contentNode)) error { if err := m.collectSections(query, fn); err != nil { return err } query.Prefix = query.Prefix + cmBranchSeparator if err := m.collectPages(query, fn); err != nil { return err } return nil } func (m *pageMap) collectSections(query pageMapQuery, fn func(c *contentNode)) error { level := strings.Count(query.Prefix, "/") return m.collectSectionsFn(query, func(s string, c *contentNode) bool { if strings.Count(s, "/") != level+1 { return false } fn(c) return false }) } func (m *pageMap) collectSectionsFn(query pageMapQuery, fn func(s string, c *contentNode) bool) error { if !strings.HasSuffix(query.Prefix, "/") { query.Prefix += "/" } m.sections.WalkQuery(query, func(s string, n *contentNode) bool { return fn(s, n) }) return nil } func (m *pageMap) collectSectionsRecursiveIncludingSelf(query pageMapQuery, fn func(c *contentNode)) error { return m.collectSectionsFn(query, func(s string, c *contentNode) bool { fn(c) return false }) } func (m *pageMap) collectTaxonomies(prefix string, fn func(c *contentNode)) error { m.taxonomies.WalkQuery(pageMapQuery{Prefix: prefix}, func(s string, n *contentNode) bool { fn(n) return false }) return nil } // withEveryBundlePage applies fn to every Page, including those bundled inside // leaf bundles. func (m *pageMap) withEveryBundlePage(fn func(p *pageState) bool) { m.bundleTrees.Walk(func(s string, n *contentNode) bool { if n.p != nil { return fn(n.p) } return false }) } type pageMaps struct { workers *para.Workers pmaps []*pageMap } // deleteSection deletes the entire section from s. func (m *pageMaps) deleteSection(s string) { m.withMaps(func(pm *pageMap) error { pm.deleteSectionByPath(s) return nil }) } func (m *pageMaps) AssemblePages() error { return m.withMaps(func(pm *pageMap) error { if err := pm.CreateMissingNodes(); err != nil { return err } if err := pm.assemblePages(); err != nil { return err } if err := pm.createMissingTaxonomyNodes(); err != nil { return err } // Handle any new sections created in the step above. if err := pm.assembleSections(); err != nil { return err } if pm.s.home == nil { // Home is disabled, everything is. pm.bundleTrees.DeletePrefix("") return nil } if err := pm.assembleTaxonomies(); err != nil { return err } if err := pm.createSiteTaxonomies(); err != nil { return err } sw := &sectionWalker{m: pm.contentMap} a := sw.applyAggregates() _, mainSectionsSet := pm.s.s.Info.Params()["mainsections"] if !mainSectionsSet && a.mainSection != "" { mainSections := []string{strings.TrimRight(a.mainSection, "/")} pm.s.s.Info.Params()["mainSections"] = mainSections pm.s.s.Info.Params()["mainsections"] = mainSections } pm.s.lastmod = a.datesAll.Lastmod() if resource.IsZeroDates(pm.s.home) { pm.s.home.m.Dates = a.datesAll } return nil }) } func (m *pageMaps) walkBundles(fn func(n *contentNode) bool) { _ = m.withMaps(func(pm *pageMap) error { pm.bundleTrees.Walk(func(s string, n *contentNode) bool { return fn(n) }) return nil }) } func (m *pageMaps) walkBranchesPrefix(prefix string, fn func(s string, n *contentNode) bool) { _ = m.withMaps(func(pm *pageMap) error { pm.branchTrees.WalkPrefix(prefix, func(s string, n *contentNode) bool { return fn(s, n) }) return nil }) } func (m *pageMaps) withMaps(fn func(pm *pageMap) error) error { g, _ := m.workers.Start(context.Background()) for _, pm := range m.pmaps { pm := pm g.Run(func() error { return fn(pm) }) } return g.Wait() } type pagesMapBucket struct { // Cascading front matter. cascade map[page.PageMatcher]maps.Params owner *pageState // The branch node *pagesMapBucketPages } type pagesMapBucketPages struct { pagesInit sync.Once pages page.Pages pagesAndSectionsInit sync.Once pagesAndSections page.Pages sectionsInit sync.Once sections page.Pages } func (b *pagesMapBucket) getPages() page.Pages { b.pagesInit.Do(func() { b.pages = b.owner.treeRef.getPages() page.SortByDefault(b.pages) }) return b.pages } func (b *pagesMapBucket) getPagesRecursive() page.Pages { pages := b.owner.treeRef.getPagesRecursive() page.SortByDefault(pages) return pages } func (b *pagesMapBucket) getPagesAndSections() page.Pages { b.pagesAndSectionsInit.Do(func() { b.pagesAndSections = b.owner.treeRef.getPagesAndSections() }) return b.pagesAndSections } func (b *pagesMapBucket) getSections() page.Pages { b.sectionsInit.Do(func() { if b.owner.treeRef == nil { return } b.sections = b.owner.treeRef.getSections() }) return b.sections } func (b *pagesMapBucket) getTaxonomies() page.Pages { b.sectionsInit.Do(func() { var pas page.Pages ref := b.owner.treeRef ref.m.collectTaxonomies(ref.key, func(c *contentNode) { pas = append(pas, c.p) }) page.SortByDefault(pas) b.sections = pas }) return b.sections } func (b *pagesMapBucket) getTaxonomyEntries() page.Pages { var pas page.Pages ref := b.owner.treeRef viewInfo := ref.n.viewInfo prefix := strings.ToLower("/" + viewInfo.name.plural + "/" + viewInfo.termKey + "/") ref.m.taxonomyEntries.WalkPrefix(prefix, func(s string, v interface{}) bool { n := v.(*contentNode) pas = append(pas, n.viewInfo.ref.p) return false }) page.SortByDefault(pas) return pas } type sectionAggregate struct { datesAll resource.Dates datesSection resource.Dates pageCount int mainSection string mainSectionPageCount int } type sectionAggregateHandler struct { sectionAggregate sectionPageCount int // Section b *contentNode s string } func (h *sectionAggregateHandler) String() string { return fmt.Sprintf("%s/%s - %d - %s", h.sectionAggregate.datesAll, h.sectionAggregate.datesSection, h.sectionPageCount, h.s) } func (h *sectionAggregateHandler) isRootSection() bool { return h.s != "/" && strings.Count(h.s, "/") == 2 } func (h *sectionAggregateHandler) handleNested(v sectionWalkHandler) error { nested := v.(*sectionAggregateHandler) h.sectionPageCount += nested.pageCount h.pageCount += h.sectionPageCount h.datesAll.UpdateDateAndLastmodIfAfter(nested.datesAll) h.datesSection.UpdateDateAndLastmodIfAfter(nested.datesAll) return nil } func (h *sectionAggregateHandler) handlePage(s string, n *contentNode) error { h.sectionPageCount++ var d resource.Dated if n.p != nil { d = n.p } else if n.viewInfo != nil && n.viewInfo.ref != nil { d = n.viewInfo.ref.p } else { return nil } h.datesAll.UpdateDateAndLastmodIfAfter(d) h.datesSection.UpdateDateAndLastmodIfAfter(d) return nil } func (h *sectionAggregateHandler) handleSectionPost() error { if h.sectionPageCount > h.mainSectionPageCount && h.isRootSection() { h.mainSectionPageCount = h.sectionPageCount h.mainSection = strings.TrimPrefix(h.s, "/") } if resource.IsZeroDates(h.b.p) { h.b.p.m.Dates = h.datesSection } h.datesSection = resource.Dates{} return nil } func (h *sectionAggregateHandler) handleSectionPre(s string, b *contentNode) error { h.s = s h.b = b h.sectionPageCount = 0 h.datesAll.UpdateDateAndLastmodIfAfter(b.p) return nil } type sectionWalkHandler interface { handleNested(v sectionWalkHandler) error handlePage(s string, b *contentNode) error handleSectionPost() error handleSectionPre(s string, b *contentNode) error } type sectionWalker struct { err error m *contentMap } func (w *sectionWalker) applyAggregates() *sectionAggregateHandler { return w.walkLevel("/", func() sectionWalkHandler { return &sectionAggregateHandler{} }).(*sectionAggregateHandler) } func (w *sectionWalker) walkLevel(prefix string, createVisitor func() sectionWalkHandler) sectionWalkHandler { level := strings.Count(prefix, "/") visitor := createVisitor() w.m.taxonomies.WalkBelow(prefix, func(s string, v interface{}) bool { currentLevel := strings.Count(s, "/") if currentLevel > level+1 { return false } n := v.(*contentNode) if w.err = visitor.handleSectionPre(s, n); w.err != nil { return true } if currentLevel == 2 { nested := w.walkLevel(s, createVisitor) if w.err = visitor.handleNested(nested); w.err != nil { return true } } else { w.m.taxonomyEntries.WalkPrefix(s, func(ss string, v interface{}) bool { n := v.(*contentNode) w.err = visitor.handlePage(ss, n) return w.err != nil }) } w.err = visitor.handleSectionPost() return w.err != nil }) w.m.sections.WalkBelow(prefix, func(s string, v interface{}) bool { currentLevel := strings.Count(s, "/") if currentLevel > level+1 { return false } n := v.(*contentNode) if w.err = visitor.handleSectionPre(s, n); w.err != nil { return true } w.m.pages.WalkPrefix(s+cmBranchSeparator, func(s string, v interface{}) bool { w.err = visitor.handlePage(s, v.(*contentNode)) return w.err != nil }) if w.err != nil { return true } nested := w.walkLevel(s, createVisitor) if w.err = visitor.handleNested(nested); w.err != nil { return true } w.err = visitor.handleSectionPost() return w.err != nil }) return visitor } type viewName struct { singular string // e.g. "category" plural string // e.g. "categories" } func (v viewName) IsZero() bool { return v.singular == "" }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./tpl/tplimpl/template_funcs_test.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package tplimpl import ( "bytes" "fmt" "path/filepath" "reflect" "testing" "time" "github.com/gohugoio/hugo/modules" "github.com/gohugoio/hugo/resources/page" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/common/hugo" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/langs" "github.com/gohugoio/hugo/langs/i18n" "github.com/gohugoio/hugo/tpl" "github.com/gohugoio/hugo/tpl/internal" "github.com/gohugoio/hugo/tpl/partials" "github.com/spf13/afero" "github.com/spf13/viper" ) var logger = loggers.NewErrorLogger() func newTestConfig() config.Provider { v := viper.New() v.Set("contentDir", "content") v.Set("dataDir", "data") v.Set("i18nDir", "i18n") v.Set("layoutDir", "layouts") v.Set("archetypeDir", "archetypes") v.Set("assetDir", "assets") v.Set("resourceDir", "resources") v.Set("publishDir", "public") langs.LoadLanguageSettings(v, nil) mod, err := modules.CreateProjectModule(v) if err != nil { panic(err) } v.Set("allModules", modules.Modules{mod}) return v } func newDepsConfig(cfg config.Provider) deps.DepsCfg { l := langs.NewLanguage("en", cfg) return deps.DepsCfg{ Language: l, Site: page.NewDummyHugoSite(cfg), Cfg: cfg, Fs: hugofs.NewMem(l), Logger: logger, TemplateProvider: DefaultTemplateProvider, TranslationProvider: i18n.NewTranslationProvider(), } } func TestTemplateFuncsExamples(t *testing.T) { t.Parallel() c := qt.New(t) workingDir := "/home/hugo" v := newTestConfig() v.Set("workingDir", workingDir) v.Set("multilingual", true) v.Set("contentDir", "content") v.Set("assetDir", "assets") v.Set("baseURL", "http://mysite.com/hugo/") v.Set("CurrentContentLanguage", langs.NewLanguage("en", v)) fs := hugofs.NewMem(v) afero.WriteFile(fs.Source, filepath.Join(workingDir, "files", "README.txt"), []byte("Hugo Rocks!"), 0755) depsCfg := newDepsConfig(v) depsCfg.Fs = fs d, err := deps.New(depsCfg) defer d.Close() c.Assert(err, qt.IsNil) var data struct { Title string Section string Hugo map[string]interface{} Params map[string]interface{} } data.Title = "**BatMan**" data.Section = "blog" data.Params = map[string]interface{}{"langCode": "en"} data.Hugo = map[string]interface{}{"Version": hugo.MustParseVersion("0.36.1").Version()} for _, nsf := range internal.TemplateFuncsNamespaceRegistry { ns := nsf(d) for _, mm := range ns.MethodMappings { for i, example := range mm.Examples { in, expected := example[0], example[1] d.WithTemplate = func(templ tpl.TemplateManager) error { c.Assert(templ.AddTemplate("test", in), qt.IsNil) c.Assert(templ.AddTemplate("partials/header.html", "<title>Hugo Rocks!</title>"), qt.IsNil) return nil } c.Assert(d.LoadResources(), qt.IsNil) var b bytes.Buffer templ, _ := d.Tmpl().Lookup("test") c.Assert(d.Tmpl().Execute(templ, &b, &data), qt.IsNil) if b.String() != expected { t.Fatalf("%s[%d]: got %q expected %q", ns.Name, i, b.String(), expected) } } } } } // TODO(bep) it would be dandy to put this one into the partials package, but // we have some package cycle issues to solve first. func TestPartialCached(t *testing.T) { t.Parallel() c := qt.New(t) partial := `Now: {{ now.UnixNano }}` name := "testing" var data struct { } v := newTestConfig() config := newDepsConfig(v) config.WithTemplate = func(templ tpl.TemplateManager) error { err := templ.AddTemplate("partials/"+name, partial) if err != nil { return err } return nil } de, err := deps.New(config) c.Assert(err, qt.IsNil) defer de.Close() c.Assert(de.LoadResources(), qt.IsNil) ns := partials.New(de) res1, err := ns.IncludeCached(name, &data) c.Assert(err, qt.IsNil) for j := 0; j < 10; j++ { time.Sleep(2 * time.Nanosecond) res2, err := ns.IncludeCached(name, &data) c.Assert(err, qt.IsNil) if !reflect.DeepEqual(res1, res2) { t.Fatalf("cache mismatch") } res3, err := ns.IncludeCached(name, &data, fmt.Sprintf("variant%d", j)) c.Assert(err, qt.IsNil) if reflect.DeepEqual(res1, res3) { t.Fatalf("cache mismatch") } } } func BenchmarkPartial(b *testing.B) { doBenchmarkPartial(b, func(ns *partials.Namespace) error { _, err := ns.Include("bench1") return err }) } func BenchmarkPartialCached(b *testing.B) { doBenchmarkPartial(b, func(ns *partials.Namespace) error { _, err := ns.IncludeCached("bench1", nil) return err }) } func doBenchmarkPartial(b *testing.B, f func(ns *partials.Namespace) error) { c := qt.New(b) config := newDepsConfig(viper.New()) config.WithTemplate = func(templ tpl.TemplateManager) error { err := templ.AddTemplate("partials/bench1", `{{ shuffle (seq 1 10) }}`) if err != nil { return err } return nil } de, err := deps.New(config) c.Assert(err, qt.IsNil) defer de.Close() c.Assert(de.LoadResources(), qt.IsNil) ns := partials.New(de) b.ResetTimer() b.RunParallel(func(pb *testing.PB) { for pb.Next() { if err := f(ns); err != nil { b.Fatalf("error executing template: %s", err) } } }) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package tplimpl import ( "bytes" "fmt" "path/filepath" "reflect" "testing" "time" "github.com/gohugoio/hugo/modules" "github.com/gohugoio/hugo/resources/page" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/common/hugo" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/langs" "github.com/gohugoio/hugo/langs/i18n" "github.com/gohugoio/hugo/tpl" "github.com/gohugoio/hugo/tpl/internal" "github.com/gohugoio/hugo/tpl/partials" "github.com/spf13/afero" "github.com/spf13/viper" ) var logger = loggers.NewErrorLogger() func newTestConfig() config.Provider { v := viper.New() v.Set("contentDir", "content") v.Set("dataDir", "data") v.Set("i18nDir", "i18n") v.Set("layoutDir", "layouts") v.Set("archetypeDir", "archetypes") v.Set("assetDir", "assets") v.Set("resourceDir", "resources") v.Set("publishDir", "public") langs.LoadLanguageSettings(v, nil) mod, err := modules.CreateProjectModule(v) if err != nil { panic(err) } v.Set("allModules", modules.Modules{mod}) return v } func newDepsConfig(cfg config.Provider) deps.DepsCfg { l := langs.NewLanguage("en", cfg) return deps.DepsCfg{ Language: l, Site: page.NewDummyHugoSite(cfg), Cfg: cfg, Fs: hugofs.NewMem(l), Logger: logger, TemplateProvider: DefaultTemplateProvider, TranslationProvider: i18n.NewTranslationProvider(), } } func TestTemplateFuncsExamples(t *testing.T) { t.Parallel() c := qt.New(t) workingDir := "/home/hugo" v := newTestConfig() v.Set("workingDir", workingDir) v.Set("multilingual", true) v.Set("contentDir", "content") v.Set("assetDir", "assets") v.Set("baseURL", "http://mysite.com/hugo/") v.Set("CurrentContentLanguage", langs.NewLanguage("en", v)) fs := hugofs.NewMem(v) afero.WriteFile(fs.Source, filepath.Join(workingDir, "files", "README.txt"), []byte("Hugo Rocks!"), 0755) depsCfg := newDepsConfig(v) depsCfg.Fs = fs d, err := deps.New(depsCfg) defer d.Close() c.Assert(err, qt.IsNil) var data struct { Title string Section string Hugo map[string]interface{} Params map[string]interface{} } data.Title = "**BatMan**" data.Section = "blog" data.Params = map[string]interface{}{"langCode": "en"} data.Hugo = map[string]interface{}{"Version": hugo.MustParseVersion("0.36.1").Version()} for _, nsf := range internal.TemplateFuncsNamespaceRegistry { ns := nsf(d) for _, mm := range ns.MethodMappings { for i, example := range mm.Examples { in, expected := example[0], example[1] d.WithTemplate = func(templ tpl.TemplateManager) error { c.Assert(templ.AddTemplate("test", in), qt.IsNil) c.Assert(templ.AddTemplate("partials/header.html", "<title>Hugo Rocks!</title>"), qt.IsNil) return nil } c.Assert(d.LoadResources(), qt.IsNil) var b bytes.Buffer templ, _ := d.Tmpl().Lookup("test") c.Assert(d.Tmpl().Execute(templ, &b, &data), qt.IsNil) if b.String() != expected { t.Fatalf("%s[%d]: got %q expected %q", ns.Name, i, b.String(), expected) } } } } } // TODO(bep) it would be dandy to put this one into the partials package, but // we have some package cycle issues to solve first. func TestPartialCached(t *testing.T) { t.Parallel() c := qt.New(t) partial := `Now: {{ now.UnixNano }}` name := "testing" var data struct { } v := newTestConfig() config := newDepsConfig(v) config.WithTemplate = func(templ tpl.TemplateManager) error { err := templ.AddTemplate("partials/"+name, partial) if err != nil { return err } return nil } de, err := deps.New(config) c.Assert(err, qt.IsNil) defer de.Close() c.Assert(de.LoadResources(), qt.IsNil) ns := partials.New(de) res1, err := ns.IncludeCached(name, &data) c.Assert(err, qt.IsNil) for j := 0; j < 10; j++ { time.Sleep(2 * time.Nanosecond) res2, err := ns.IncludeCached(name, &data) c.Assert(err, qt.IsNil) if !reflect.DeepEqual(res1, res2) { t.Fatalf("cache mismatch") } res3, err := ns.IncludeCached(name, &data, fmt.Sprintf("variant%d", j)) c.Assert(err, qt.IsNil) if reflect.DeepEqual(res1, res3) { t.Fatalf("cache mismatch") } } } func BenchmarkPartial(b *testing.B) { doBenchmarkPartial(b, func(ns *partials.Namespace) error { _, err := ns.Include("bench1") return err }) } func BenchmarkPartialCached(b *testing.B) { doBenchmarkPartial(b, func(ns *partials.Namespace) error { _, err := ns.IncludeCached("bench1", nil) return err }) } func doBenchmarkPartial(b *testing.B, f func(ns *partials.Namespace) error) { c := qt.New(b) config := newDepsConfig(viper.New()) config.WithTemplate = func(templ tpl.TemplateManager) error { err := templ.AddTemplate("partials/bench1", `{{ shuffle (seq 1 10) }}`) if err != nil { return err } return nil } de, err := deps.New(config) c.Assert(err, qt.IsNil) defer de.Close() c.Assert(de.LoadResources(), qt.IsNil) ns := partials.New(de) b.ResetTimer() b.RunParallel(func(pb *testing.PB) { for pb.Next() { if err := f(ns); err != nil { b.Fatalf("error executing template: %s", err) } } }) }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./tpl/internal/templatefuncRegistry_test.go
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package internal import ( "runtime" "testing" qt "github.com/frankban/quicktest" ) type Test struct { } func (t *Test) MyTestMethod() string { return "abcde" } func TestMethodToName(t *testing.T) { c := qt.New(t) test := &Test{} if runtime.Compiler == "gccgo" { c.Assert(methodToName(test.MyTestMethod), qt.Contains, "thunk") } else { c.Assert(methodToName(test.MyTestMethod), qt.Equals, "MyTestMethod") } }
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package internal import ( "runtime" "testing" qt "github.com/frankban/quicktest" ) type Test struct { } func (t *Test) MyTestMethod() string { return "abcde" } func TestMethodToName(t *testing.T) { c := qt.New(t) test := &Test{} if runtime.Compiler == "gccgo" { c.Assert(methodToName(test.MyTestMethod), qt.Contains, "thunk") } else { c.Assert(methodToName(test.MyTestMethod), qt.Equals, "MyTestMethod") } }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./deps/deps_test.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package deps import ( "testing" qt "github.com/frankban/quicktest" ) func TestBuildFlags(t *testing.T) { c := qt.New(t) var bf BuildState bf.Incr() bf.Incr() bf.Incr() c.Assert(bf.Incr(), qt.Equals, 4) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package deps import ( "testing" qt "github.com/frankban/quicktest" ) func TestBuildFlags(t *testing.T) { c := qt.New(t) var bf BuildState bf.Incr() bf.Incr() bf.Incr() c.Assert(bf.Incr(), qt.Equals, 4) }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./README.md
<img src="https://raw.githubusercontent.com/gohugoio/gohugoioTheme/master/static/images/hugo-logo-wide.svg?sanitize=true" alt="Hugo" width="565"> A Fast and Flexible Static Site Generator built with love by [bep](https://github.com/bep), [spf13](http://spf13.com/) and [friends](https://github.com/gohugoio/hugo/graphs/contributors) in [Go][]. [Website](https://gohugo.io) | [Forum](https://discourse.gohugo.io) | [Documentation](https://gohugo.io/getting-started/) | [Installation Guide](https://gohugo.io/getting-started/installing/) | [Contribution Guide](CONTRIBUTING.md) | [Twitter](https://twitter.com/gohugoio) [![GoDoc](https://godoc.org/github.com/gohugoio/hugo?status.svg)](https://godoc.org/github.com/gohugoio/hugo) [![Tests on Linux, MacOS and Windows](https://github.com/gohugoio/hugo/workflows/Test/badge.svg)](https://github.com/gohugoio/hugo/actions?query=workflow%3ATest) [![Go Report Card](https://goreportcard.com/badge/github.com/gohugoio/hugo)](https://goreportcard.com/report/github.com/gohugoio/hugo) ## Overview Hugo is a static HTML and CSS website generator written in [Go][]. It is optimized for speed, ease of use, and configurability. Hugo takes a directory with content and templates and renders them into a full HTML website. Hugo relies on Markdown files with front matter for metadata, and you can run Hugo from any directory. This works well for shared hosts and other systems where you don’t have a privileged account. Hugo renders a typical website of moderate size in a fraction of a second. A good rule of thumb is that each piece of content renders in around 1 millisecond. Hugo is designed to work well for any kind of website including blogs, tumbles, and docs. #### Supported Architectures Currently, we provide pre-built Hugo binaries for Windows, Linux, FreeBSD, NetBSD, DragonFly BSD, Open BSD, macOS (Darwin), and [Android](https://gist.github.com/bep/a0d8a26cf6b4f8bc992729b8e50b480b) for x64, i386 and ARM architectures. Hugo may also be compiled from source wherever the Go compiler tool chain can run, e.g. for other operating systems including Plan 9 and Solaris. **Complete documentation is available at [Hugo Documentation](https://gohugo.io/getting-started/).** ## Choose How to Install If you want to use Hugo as your site generator, simply install the Hugo binaries. The Hugo binaries have no external dependencies. To contribute to the Hugo source code or documentation, you should [fork the Hugo GitHub project](https://github.com/gohugoio/hugo#fork-destination-box) and clone it to your local machine. Finally, you can install the Hugo source code with `go`, build the binaries yourself, and run Hugo that way. Building the binaries is an easy task for an experienced `go` getter. ### Install Hugo as Your Site Generator (Binary Install) Use the [installation instructions in the Hugo documentation](https://gohugo.io/getting-started/installing/). ### Build and Install the Binaries from Source (Advanced Install) #### Prerequisite Tools * [Git](https://git-scm.com/) * [Go (we test it with the last 2 major versions)](https://golang.org/dl/) #### Fetch from GitHub Since Hugo 0.48, Hugo uses the Go Modules support built into Go 1.11 to build. The easiest is to clone Hugo in a directory outside of `GOPATH`, as in the following example: ```bash mkdir $HOME/src cd $HOME/src git clone https://github.com/gohugoio/hugo.git cd hugo go install ``` **If you are a Windows user, substitute the `$HOME` environment variable above with `%USERPROFILE%`.** If you want to compile with Sass/SCSS support use `--tags extended` and make sure `CGO_ENABLED=1` is set in your go environment. If you don't want to have CGO enabled, you may use the following command to temporarily enable CGO only for hugo compilation: ```bash CGO_ENABLED=1 go install --tags extended ``` ## The Hugo Documentation The Hugo documentation now lives in its own repository, see https://github.com/gohugoio/hugoDocs. But we do keep a version of that documentation as a `git subtree` in this repository. To build the sub folder `/docs` as a Hugo site, you need to clone this repo: ```bash git clone [email protected]:gohugoio/hugo.git ``` ## Contributing to Hugo For a complete guide to contributing to Hugo, see the [Contribution Guide](CONTRIBUTING.md). We welcome contributions to Hugo of any kind including documentation, themes, organization, tutorials, blog posts, bug reports, issues, feature requests, feature implementations, pull requests, answering questions on the forum, helping to manage issues, etc. The Hugo community and maintainers are [very active](https://github.com/gohugoio/hugo/pulse/monthly) and helpful, and the project benefits greatly from this activity. ### Asking Support Questions We have an active [discussion forum](https://discourse.gohugo.io) where users and developers can ask questions. Please don't use the GitHub issue tracker to ask questions. ### Reporting Issues If you believe you have found a defect in Hugo or its documentation, use the GitHub issue tracker to report the problem to the Hugo maintainers. If you're not sure if it's a bug or not, start by asking in the [discussion forum](https://discourse.gohugo.io). When reporting the issue, please provide the version of Hugo in use (`hugo version`). ### Submitting Patches The Hugo project welcomes all contributors and contributions regardless of skill or experience level. If you are interested in helping with the project, we will help you with your contribution. Hugo is a very active project with many contributions happening daily. We want to create the best possible product for our users and the best contribution experience for our developers, we have a set of guidelines which ensure that all contributions are acceptable. The guidelines are not intended as a filter or barrier to participation. If you are unfamiliar with the contribution process, the Hugo team will help you and teach you how to bring your contribution in accordance with the guidelines. For a complete guide to contributing code to Hugo, see the [Contribution Guide](CONTRIBUTING.md). [![Analytics](https://ga-beacon.appspot.com/UA-7131036-6/hugo/readme)](https://github.com/igrigorik/ga-beacon) [Go]: https://golang.org/ [Hugo Documentation]: https://gohugo.io/overview/introduction/ ## Dependencies Hugo stands on the shoulder of many great open source libraries, in lexical order: | Dependency | License | | :------------- | :------------- | | [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) | MIT License | | [github.com/armon/go-radix](https://github.com/armon/go-radix) | MIT License | | [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) | Apache License 2.0 | | [github.com/bep/debounce](https://github.com/bep/debounce) | MIT License | | [github.com/bep/gitmap](https://github.com/bep/gitmap) | MIT License | | [github.com/bep/golibsass](https://github.com/bep/golibsass) | MIT License | | [github.com/bep/tmc](https://github.com/bep/tmc) | MIT License | | [github.com/BurntSushi/locker](https://github.com/BurntSushi/locker) | The Unlicense | | [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml) | MIT License | | [github.com/cpuguy83/go-md2man](https://github.com/cpuguy83/go-md2man) | MIT License | | [github.com/danwakefield/fnmatch](https://github.com/danwakefield/fnmatch) | BSD 2-Clause "Simplified" License | | [github.com/disintegration/gift](https://github.com/disintegration/gift) | MIT License | | [github.com/dustin/go-humanize](https://github.com/dustin/go-humanize) | MIT License | | [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) | BSD 3-Clause "New" or "Revised" License | | [github.com/gobwas/glob](https://github.com/gobwas/glob) | MIT License | | [github.com/gorilla/websocket](https://github.com/gorilla/websocket) | BSD 2-Clause "Simplified" License | | [github.com/hashicorp/golang-lru](https://github.com/hashicorp/golang-lru) | Mozilla Public License 2.0 | | [github.com/hashicorp/hcl](https://github.com/hashicorp/hcl) | Mozilla Public License 2.0 | | [github.com/jdkato/prose](https://github.com/jdkato/prose) | MIT License | | [github.com/kr/pretty](https://github.com/kr/pretty) | MIT License | | [github.com/kyokomi/emoji](https://github.com/kyokomi/emoji) | MIT License | | [github.com/magiconair/properties](https://github.com/magiconair/properties) | BSD 2-Clause "Simplified" License | | [github.com/markbates/inflect](https://github.com/markbates/inflect) | MIT License | | [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) | MIT License | | [github.com/mattn/go-runewidth](https://github.com/mattn/go-runewidth) | MIT License | | [github.com/miekg/mmark](https://github.com/miekg/mmark) | Simplified BSD License | | [github.com/mitchellh/hashstructure](https://github.com/mitchellh/hashstructure) | MIT License | | [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) | MIT License | | [github.com/muesli/smartcrop](https://github.com/muesli/smartcrop) | MIT License | | [github.com/nicksnyder/go-i18n](https://github.com/nicksnyder/go-i18n) | MIT License | | [github.com/niklasfasching/go-org](https://github.com/niklasfasching/go-org) | MIT License | | [github.com/olekukonko/tablewriter](https://github.com/olekukonko/tablewriter) | MIT License | | [github.com/pelletier/go-toml](https://github.com/pelletier/go-toml) | MIT License | | [github.com/pkg/errors](https://github.com/pkg/errors) | BSD 2-Clause "Simplified" License | | [github.com/PuerkitoBio/purell](https://github.com/PuerkitoBio/purell) | BSD 3-Clause "New" or "Revised" License | | [github.com/PuerkitoBio/urlesc](https://github.com/PuerkitoBio/urlesc) | BSD 3-Clause "New" or "Revised" License | | [github.com/rogpeppe/go-internal](https://github.com/rogpeppe/go-internal) | BSD 3-Clause "New" or "Revised" License | | [github.com/russross/blackfriday](https://github.com/russross/blackfriday) | Simplified BSD License | | [github.com/rwcarlsen/goexif](https://github.com/rwcarlsen/goexif) | BSD 2-Clause "Simplified" License | | [github.com/spf13/afero](https://github.com/spf13/afero) | Apache License 2.0 | | [github.com/spf13/cast](https://github.com/spf13/cast) | MIT License | | [github.com/spf13/cobra](https://github.com/spf13/cobra) | Apache License 2.0 | | [github.com/spf13/fsync](https://github.com/spf13/fsync) | MIT License | | [github.com/spf13/jwalterweatherman](https://github.com/spf13/jwalterweatherman) | MIT License | | [github.com/spf13/pflag](https://github.com/spf13/pflag) | BSD 3-Clause "New" or "Revised" License | | [github.com/spf13/viper](https://github.com/spf13/viper) | MIT License | | [github.com/tdewolff/minify](https://github.com/tdewolff/minify) | MIT License | | [github.com/tdewolff/parse](https://github.com/tdewolff/parse) | MIT License | | [github.com/yuin/goldmark](https://github.com/yuin/goldmark) | MIT License | | [github.com/yuin/goldmark-highlighting](https://github.com/yuin/goldmark-highlighting) | MIT License | | [go.opencensus.io](https://go.opencensus.io) | Apache License 2.0 | | [go.uber.org/atomic](https://go.uber.org/atomic) | MIT License | | [gocloud.dev](https://gocloud.dev) | Apache License 2.0 | | [golang.org/x/image](https://golang.org/x/image) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/net](https://golang.org/x/net) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/oauth2](https://golang.org/x/oauth2) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/sync](https://golang.org/x/sync) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/sys](https://golang.org/x/sys) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/text](https://golang.org/x/text) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/xerrors](https://golang.org/x/xerrors) | BSD 3-Clause "New" or "Revised" License | | [google.golang.org/api](https://google.golang.org/api) | BSD 3-Clause "New" or "Revised" License | | [google.golang.org/genproto](https://google.golang.org/genproto) | Apache License 2.0 | | [gopkg.in/ini.v1](https://gopkg.in/ini.v1) | Apache License 2.0 | | [gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) | Apache License 2.0 |
<img src="https://raw.githubusercontent.com/gohugoio/gohugoioTheme/master/static/images/hugo-logo-wide.svg?sanitize=true" alt="Hugo" width="565"> A Fast and Flexible Static Site Generator built with love by [bep](https://github.com/bep), [spf13](http://spf13.com/) and [friends](https://github.com/gohugoio/hugo/graphs/contributors) in [Go][]. [Website](https://gohugo.io) | [Forum](https://discourse.gohugo.io) | [Documentation](https://gohugo.io/getting-started/) | [Installation Guide](https://gohugo.io/getting-started/installing/) | [Contribution Guide](CONTRIBUTING.md) | [Twitter](https://twitter.com/gohugoio) [![GoDoc](https://godoc.org/github.com/gohugoio/hugo?status.svg)](https://godoc.org/github.com/gohugoio/hugo) [![Tests on Linux, MacOS and Windows](https://github.com/gohugoio/hugo/workflows/Test/badge.svg)](https://github.com/gohugoio/hugo/actions?query=workflow%3ATest) [![Go Report Card](https://goreportcard.com/badge/github.com/gohugoio/hugo)](https://goreportcard.com/report/github.com/gohugoio/hugo) ## Overview Hugo is a static HTML and CSS website generator written in [Go][]. It is optimized for speed, ease of use, and configurability. Hugo takes a directory with content and templates and renders them into a full HTML website. Hugo relies on Markdown files with front matter for metadata, and you can run Hugo from any directory. This works well for shared hosts and other systems where you don’t have a privileged account. Hugo renders a typical website of moderate size in a fraction of a second. A good rule of thumb is that each piece of content renders in around 1 millisecond. Hugo is designed to work well for any kind of website including blogs, tumbles, and docs. #### Supported Architectures Currently, we provide pre-built Hugo binaries for Windows, Linux, FreeBSD, NetBSD, DragonFly BSD, Open BSD, macOS (Darwin), and [Android](https://gist.github.com/bep/a0d8a26cf6b4f8bc992729b8e50b480b) for x64, i386 and ARM architectures. Hugo may also be compiled from source wherever the Go compiler tool chain can run, e.g. for other operating systems including Plan 9 and Solaris. **Complete documentation is available at [Hugo Documentation](https://gohugo.io/getting-started/).** ## Choose How to Install If you want to use Hugo as your site generator, simply install the Hugo binaries. The Hugo binaries have no external dependencies. To contribute to the Hugo source code or documentation, you should [fork the Hugo GitHub project](https://github.com/gohugoio/hugo#fork-destination-box) and clone it to your local machine. Finally, you can install the Hugo source code with `go`, build the binaries yourself, and run Hugo that way. Building the binaries is an easy task for an experienced `go` getter. ### Install Hugo as Your Site Generator (Binary Install) Use the [installation instructions in the Hugo documentation](https://gohugo.io/getting-started/installing/). ### Build and Install the Binaries from Source (Advanced Install) #### Prerequisite Tools * [Git](https://git-scm.com/) * [Go (we test it with the last 2 major versions)](https://golang.org/dl/) #### Fetch from GitHub Since Hugo 0.48, Hugo uses the Go Modules support built into Go 1.11 to build. The easiest is to clone Hugo in a directory outside of `GOPATH`, as in the following example: ```bash mkdir $HOME/src cd $HOME/src git clone https://github.com/gohugoio/hugo.git cd hugo go install ``` **If you are a Windows user, substitute the `$HOME` environment variable above with `%USERPROFILE%`.** If you want to compile with Sass/SCSS support use `--tags extended` and make sure `CGO_ENABLED=1` is set in your go environment. If you don't want to have CGO enabled, you may use the following command to temporarily enable CGO only for hugo compilation: ```bash CGO_ENABLED=1 go install --tags extended ``` ## The Hugo Documentation The Hugo documentation now lives in its own repository, see https://github.com/gohugoio/hugoDocs. But we do keep a version of that documentation as a `git subtree` in this repository. To build the sub folder `/docs` as a Hugo site, you need to clone this repo: ```bash git clone [email protected]:gohugoio/hugo.git ``` ## Contributing to Hugo For a complete guide to contributing to Hugo, see the [Contribution Guide](CONTRIBUTING.md). We welcome contributions to Hugo of any kind including documentation, themes, organization, tutorials, blog posts, bug reports, issues, feature requests, feature implementations, pull requests, answering questions on the forum, helping to manage issues, etc. The Hugo community and maintainers are [very active](https://github.com/gohugoio/hugo/pulse/monthly) and helpful, and the project benefits greatly from this activity. ### Asking Support Questions We have an active [discussion forum](https://discourse.gohugo.io) where users and developers can ask questions. Please don't use the GitHub issue tracker to ask questions. ### Reporting Issues If you believe you have found a defect in Hugo or its documentation, use the GitHub issue tracker to report the problem to the Hugo maintainers. If you're not sure if it's a bug or not, start by asking in the [discussion forum](https://discourse.gohugo.io). When reporting the issue, please provide the version of Hugo in use (`hugo version`). ### Submitting Patches The Hugo project welcomes all contributors and contributions regardless of skill or experience level. If you are interested in helping with the project, we will help you with your contribution. Hugo is a very active project with many contributions happening daily. We want to create the best possible product for our users and the best contribution experience for our developers, we have a set of guidelines which ensure that all contributions are acceptable. The guidelines are not intended as a filter or barrier to participation. If you are unfamiliar with the contribution process, the Hugo team will help you and teach you how to bring your contribution in accordance with the guidelines. For a complete guide to contributing code to Hugo, see the [Contribution Guide](CONTRIBUTING.md). [![Analytics](https://ga-beacon.appspot.com/UA-7131036-6/hugo/readme)](https://github.com/igrigorik/ga-beacon) [Go]: https://golang.org/ [Hugo Documentation]: https://gohugo.io/overview/introduction/ ## Dependencies Hugo stands on the shoulder of many great open source libraries, in lexical order: | Dependency | License | | :------------- | :------------- | | [github.com/alecthomas/chroma](https://github.com/alecthomas/chroma) | MIT License | | [github.com/armon/go-radix](https://github.com/armon/go-radix) | MIT License | | [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) | Apache License 2.0 | | [github.com/bep/debounce](https://github.com/bep/debounce) | MIT License | | [github.com/bep/gitmap](https://github.com/bep/gitmap) | MIT License | | [github.com/bep/golibsass](https://github.com/bep/golibsass) | MIT License | | [github.com/bep/tmc](https://github.com/bep/tmc) | MIT License | | [github.com/BurntSushi/locker](https://github.com/BurntSushi/locker) | The Unlicense | | [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml) | MIT License | | [github.com/cpuguy83/go-md2man](https://github.com/cpuguy83/go-md2man) | MIT License | | [github.com/danwakefield/fnmatch](https://github.com/danwakefield/fnmatch) | BSD 2-Clause "Simplified" License | | [github.com/disintegration/gift](https://github.com/disintegration/gift) | MIT License | | [github.com/dustin/go-humanize](https://github.com/dustin/go-humanize) | MIT License | | [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) | BSD 3-Clause "New" or "Revised" License | | [github.com/gobwas/glob](https://github.com/gobwas/glob) | MIT License | | [github.com/gorilla/websocket](https://github.com/gorilla/websocket) | BSD 2-Clause "Simplified" License | | [github.com/hashicorp/golang-lru](https://github.com/hashicorp/golang-lru) | Mozilla Public License 2.0 | | [github.com/hashicorp/hcl](https://github.com/hashicorp/hcl) | Mozilla Public License 2.0 | | [github.com/jdkato/prose](https://github.com/jdkato/prose) | MIT License | | [github.com/kr/pretty](https://github.com/kr/pretty) | MIT License | | [github.com/kyokomi/emoji](https://github.com/kyokomi/emoji) | MIT License | | [github.com/magiconair/properties](https://github.com/magiconair/properties) | BSD 2-Clause "Simplified" License | | [github.com/markbates/inflect](https://github.com/markbates/inflect) | MIT License | | [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) | MIT License | | [github.com/mattn/go-runewidth](https://github.com/mattn/go-runewidth) | MIT License | | [github.com/miekg/mmark](https://github.com/miekg/mmark) | Simplified BSD License | | [github.com/mitchellh/hashstructure](https://github.com/mitchellh/hashstructure) | MIT License | | [github.com/mitchellh/mapstructure](https://github.com/mitchellh/mapstructure) | MIT License | | [github.com/muesli/smartcrop](https://github.com/muesli/smartcrop) | MIT License | | [github.com/nicksnyder/go-i18n](https://github.com/nicksnyder/go-i18n) | MIT License | | [github.com/niklasfasching/go-org](https://github.com/niklasfasching/go-org) | MIT License | | [github.com/olekukonko/tablewriter](https://github.com/olekukonko/tablewriter) | MIT License | | [github.com/pelletier/go-toml](https://github.com/pelletier/go-toml) | MIT License | | [github.com/pkg/errors](https://github.com/pkg/errors) | BSD 2-Clause "Simplified" License | | [github.com/PuerkitoBio/purell](https://github.com/PuerkitoBio/purell) | BSD 3-Clause "New" or "Revised" License | | [github.com/PuerkitoBio/urlesc](https://github.com/PuerkitoBio/urlesc) | BSD 3-Clause "New" or "Revised" License | | [github.com/rogpeppe/go-internal](https://github.com/rogpeppe/go-internal) | BSD 3-Clause "New" or "Revised" License | | [github.com/russross/blackfriday](https://github.com/russross/blackfriday) | Simplified BSD License | | [github.com/rwcarlsen/goexif](https://github.com/rwcarlsen/goexif) | BSD 2-Clause "Simplified" License | | [github.com/spf13/afero](https://github.com/spf13/afero) | Apache License 2.0 | | [github.com/spf13/cast](https://github.com/spf13/cast) | MIT License | | [github.com/spf13/cobra](https://github.com/spf13/cobra) | Apache License 2.0 | | [github.com/spf13/fsync](https://github.com/spf13/fsync) | MIT License | | [github.com/spf13/jwalterweatherman](https://github.com/spf13/jwalterweatherman) | MIT License | | [github.com/spf13/pflag](https://github.com/spf13/pflag) | BSD 3-Clause "New" or "Revised" License | | [github.com/spf13/viper](https://github.com/spf13/viper) | MIT License | | [github.com/tdewolff/minify](https://github.com/tdewolff/minify) | MIT License | | [github.com/tdewolff/parse](https://github.com/tdewolff/parse) | MIT License | | [github.com/yuin/goldmark](https://github.com/yuin/goldmark) | MIT License | | [github.com/yuin/goldmark-highlighting](https://github.com/yuin/goldmark-highlighting) | MIT License | | [go.opencensus.io](https://go.opencensus.io) | Apache License 2.0 | | [go.uber.org/atomic](https://go.uber.org/atomic) | MIT License | | [gocloud.dev](https://gocloud.dev) | Apache License 2.0 | | [golang.org/x/image](https://golang.org/x/image) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/net](https://golang.org/x/net) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/oauth2](https://golang.org/x/oauth2) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/sync](https://golang.org/x/sync) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/sys](https://golang.org/x/sys) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/text](https://golang.org/x/text) | BSD 3-Clause "New" or "Revised" License | | [golang.org/x/xerrors](https://golang.org/x/xerrors) | BSD 3-Clause "New" or "Revised" License | | [google.golang.org/api](https://google.golang.org/api) | BSD 3-Clause "New" or "Revised" License | | [google.golang.org/genproto](https://google.golang.org/genproto) | Apache License 2.0 | | [gopkg.in/ini.v1](https://gopkg.in/ini.v1) | Apache License 2.0 | | [gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) | Apache License 2.0 |
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./helpers/testhelpers_test.go
package helpers import ( "github.com/gohugoio/hugo/common/loggers" "github.com/spf13/afero" "github.com/spf13/viper" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/langs" "github.com/gohugoio/hugo/modules" ) func newTestPathSpec(fs *hugofs.Fs, v *viper.Viper) *PathSpec { l := langs.NewDefaultLanguage(v) ps, _ := NewPathSpec(fs, l, nil) return ps } func newTestDefaultPathSpec(configKeyValues ...interface{}) *PathSpec { v := viper.New() fs := hugofs.NewMem(v) cfg := newTestCfgFor(fs) for i := 0; i < len(configKeyValues); i += 2 { cfg.Set(configKeyValues[i].(string), configKeyValues[i+1]) } return newTestPathSpec(fs, cfg) } func newTestCfgFor(fs *hugofs.Fs) *viper.Viper { v := newTestCfg() v.SetFs(fs.Source) return v } func newTestCfg() *viper.Viper { v := viper.New() v.Set("contentDir", "content") v.Set("dataDir", "data") v.Set("i18nDir", "i18n") v.Set("layoutDir", "layouts") v.Set("assetDir", "assets") v.Set("resourceDir", "resources") v.Set("publishDir", "public") v.Set("archetypeDir", "archetypes") langs.LoadLanguageSettings(v, nil) langs.LoadLanguageSettings(v, nil) mod, err := modules.CreateProjectModule(v) if err != nil { panic(err) } v.Set("allModules", modules.Modules{mod}) return v } func newTestContentSpec() *ContentSpec { v := viper.New() spec, err := NewContentSpec(v, loggers.NewErrorLogger(), afero.NewMemMapFs()) if err != nil { panic(err) } return spec }
package helpers import ( "github.com/gohugoio/hugo/common/loggers" "github.com/spf13/afero" "github.com/spf13/viper" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/langs" "github.com/gohugoio/hugo/modules" ) func newTestPathSpec(fs *hugofs.Fs, v *viper.Viper) *PathSpec { l := langs.NewDefaultLanguage(v) ps, _ := NewPathSpec(fs, l, nil) return ps } func newTestDefaultPathSpec(configKeyValues ...interface{}) *PathSpec { v := viper.New() fs := hugofs.NewMem(v) cfg := newTestCfgFor(fs) for i := 0; i < len(configKeyValues); i += 2 { cfg.Set(configKeyValues[i].(string), configKeyValues[i+1]) } return newTestPathSpec(fs, cfg) } func newTestCfgFor(fs *hugofs.Fs) *viper.Viper { v := newTestCfg() v.SetFs(fs.Source) return v } func newTestCfg() *viper.Viper { v := viper.New() v.Set("contentDir", "content") v.Set("dataDir", "data") v.Set("i18nDir", "i18n") v.Set("layoutDir", "layouts") v.Set("assetDir", "assets") v.Set("resourceDir", "resources") v.Set("publishDir", "public") v.Set("archetypeDir", "archetypes") langs.LoadLanguageSettings(v, nil) langs.LoadLanguageSettings(v, nil) mod, err := modules.CreateProjectModule(v) if err != nil { panic(err) } v.Set("allModules", modules.Modules{mod}) return v } func newTestContentSpec() *ContentSpec { v := viper.New() spec, err := NewContentSpec(v, loggers.NewErrorLogger(), afero.NewMemMapFs()) if err != nil { panic(err) } return spec }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./resources/page/pagemeta/pagemeta.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package pagemeta import ( "github.com/mitchellh/mapstructure" ) type URLPath struct { URL string Permalink string Slug string Section string } const ( Never = "never" Always = "always" ListLocally = "local" Link = "link" ) var defaultBuildConfig = BuildConfig{ List: Always, Render: Always, PublishResources: true, set: true, } // BuildConfig holds configuration options about how to handle a Page in Hugo's // build process. type BuildConfig struct { // Whether to add it to any of the page collections. // Note that the page can always be found with .Site.GetPage. // Valid values: never, always, local. // Setting it to 'local' means they will be available via the local // page collections, e.g. $section.Pages. // Note: before 0.57.2 this was a bool, so we accept those too. List string // Whether to render it. // Valid values: never, always, link. // The value link means it will not be rendered, but it will get a RelPermalink/Permalink. // Note that before 0.76.0 this was a bool, so we accept those too. Render string // Whether to publish its resources. These will still be published on demand, // but enabling this can be useful if the originals (e.g. images) are // never used. PublishResources bool set bool // BuildCfg is non-zero if this is set to true. } // Disable sets all options to their off value. func (b *BuildConfig) Disable() { b.List = Never b.Render = Never b.PublishResources = false b.set = true } func (b BuildConfig) IsZero() bool { return !b.set } func DecodeBuildConfig(m interface{}) (BuildConfig, error) { b := defaultBuildConfig if m == nil { return b, nil } err := mapstructure.WeakDecode(m, &b) // In 0.67.1 we changed the list attribute from a bool to a string (enum). // Bool values will become 0 or 1. switch b.List { case "0": b.List = Never case "1": b.List = Always case Always, Never, ListLocally: default: b.List = Always } // In 0.76.0 we changed the Render from bool to a string. switch b.Render { case "0": b.Render = Never case "1": b.Render = Always case Always, Never, Link: default: b.Render = Always } return b, err }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package pagemeta import ( "github.com/mitchellh/mapstructure" ) type URLPath struct { URL string Permalink string Slug string Section string } const ( Never = "never" Always = "always" ListLocally = "local" Link = "link" ) var defaultBuildConfig = BuildConfig{ List: Always, Render: Always, PublishResources: true, set: true, } // BuildConfig holds configuration options about how to handle a Page in Hugo's // build process. type BuildConfig struct { // Whether to add it to any of the page collections. // Note that the page can always be found with .Site.GetPage. // Valid values: never, always, local. // Setting it to 'local' means they will be available via the local // page collections, e.g. $section.Pages. // Note: before 0.57.2 this was a bool, so we accept those too. List string // Whether to render it. // Valid values: never, always, link. // The value link means it will not be rendered, but it will get a RelPermalink/Permalink. // Note that before 0.76.0 this was a bool, so we accept those too. Render string // Whether to publish its resources. These will still be published on demand, // but enabling this can be useful if the originals (e.g. images) are // never used. PublishResources bool set bool // BuildCfg is non-zero if this is set to true. } // Disable sets all options to their off value. func (b *BuildConfig) Disable() { b.List = Never b.Render = Never b.PublishResources = false b.set = true } func (b BuildConfig) IsZero() bool { return !b.set } func DecodeBuildConfig(m interface{}) (BuildConfig, error) { b := defaultBuildConfig if m == nil { return b, nil } err := mapstructure.WeakDecode(m, &b) // In 0.67.1 we changed the list attribute from a bool to a string (enum). // Bool values will become 0 or 1. switch b.List { case "0": b.List = Never case "1": b.List = Always case Always, Never, ListLocally: default: b.List = Always } // In 0.76.0 we changed the Render from bool to a string. switch b.Render { case "0": b.Render = Never case "1": b.Render = Always case Always, Never, Link: default: b.Render = Always } return b, err }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./docshelper/docs.go
// Copyright 2017-present The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package docshelper provides some helpers for the Hugo documentation, and // is of limited interest for the general Hugo user. package docshelper type ( DocProviderFunc = func() DocProvider DocProvider map[string]map[string]interface{} ) var docProviderFuncs []DocProviderFunc func AddDocProviderFunc(fn DocProviderFunc) { docProviderFuncs = append(docProviderFuncs, fn) } func GetDocProvider() DocProvider { provider := make(DocProvider) for _, fn := range docProviderFuncs { p := fn() for k, v := range p { if prev, found := provider[k]; !found { provider[k] = v } else { merge(prev, v) } } } return provider } // Shallow merge func merge(dst, src map[string]interface{}) { for k, v := range src { dst[k] = v } }
// Copyright 2017-present The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package docshelper provides some helpers for the Hugo documentation, and // is of limited interest for the general Hugo user. package docshelper type ( DocProviderFunc = func() DocProvider DocProvider map[string]map[string]interface{} ) var docProviderFuncs []DocProviderFunc func AddDocProviderFunc(fn DocProviderFunc) { docProviderFuncs = append(docProviderFuncs, fn) } func GetDocProvider() DocProvider { provider := make(DocProvider) for _, fn := range docProviderFuncs { p := fn() for k, v := range p { if prev, found := provider[k]; !found { provider[k] = v } else { merge(prev, v) } } } return provider } // Shallow merge func merge(dst, src map[string]interface{}) { for k, v := range src { dst[k] = v } }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./hugolib/testdata/redis.cn.md
--- title: The Little Redis Book cn --- \thispagestyle{empty} \changepage{}{}{}{-0.5cm}{}{2cm}{}{}{} ![The Little Redis Book cn, By Karl Seguin, Translate By Jason Lai](title.png)\ \clearpage \changepage{}{}{}{0.5cm}{}{-2cm}{}{}{} ## 关于此书 ### 许可证 《The Little Redis Book》是经由Attribution-NonCommercial 3.0 Unported license许可的,你不需要为此书付钱。 你可以自由地对此书进行复制,分发,修改或者展示等操作。当然,你必须知道且认可这本书的作者是Karl Seguin,译者是赖立维,而且不应该将此书用于商业用途。 关于这个**许可证**的*详细描述*在这里: <http://creativecommons.org/licenses/by-nc/3.0/legalcode> ### 关于作者 作者Karl Seguin是一名在多项技术领域浸淫多年的开发者。他是开源软件计划的活跃贡献者,同时也是一名技术作者以及业余演讲者。他写过若干关于Radis的文章以及一些工具。在他的一个面向业余游戏开发者的免费服务里,Redis为其中的评级和统计功能提供了支持:[mogade.com](http://mogade.com/)。 Karl之前还写了[《The Little MongoDB Book》](http://openmymind.net/2011/3/28/The-Little-MongoDB-Book/),这是一本免费且受好评,关于MongoDB的书。 他的博客是<http://openmymind.net>,你也可以关注他的Twitter帐号,via [@karlseguin](http://twitter.com/karlseguin)。 ### 关于译者 译者 赖立维 是一名长在天朝的普通程序员,对许多技术都有浓厚的兴趣,是开源软件的支持者,Emacs的轻度使用者。 虽然译者已经很认真地对待这次翻译,但是限于水平有限,肯定会有不少错漏,如果发现该书的翻译有什么需要修改,可以通过他的邮箱与他联系。他的邮箱是<[email protected]>。 ### 致谢 必须特别感谢[Perry Neal](https://twitter.com/perryneal)一直以来的指导,我的眼界、触觉以及激情都来源于你。你为我提供了无价的帮助,感谢你。 ### 最新版本 此书的最新有效资源在: <https://github.com/karlseguin/the-little-redis-book> 中文版是英文版的一个分支,最新的中文版本在: <https://github.com/JasonLai256/the-little-redis-book> \clearpage ## 简介 最近几年来,关于持久化和数据查询的相关技术,其需求已经增长到了让人惊讶的程度。可以断言,关系型数据库再也不是放之四海皆准。换一句话说,围绕数据的解决方案不可能再只有唯一一种。 对于我来说,在众多新出现的解决方案和工具里,最让人兴奋的,无疑是Redis。为什么?首先是因为其让人不可思议的容易学习,只需要简短的几个小时学习时间,就能对Redis有个大概的认识。还有,Redis在处理一组特定的问题集的同时能保持相当的通用性。更准确地说就是,Redis不会尝试去解决关于数据的所有事情。在你足够了解Redis后,事情就会变得越来越清晰,什么是可行的,什么是不应该由Redis来处理的。作为一名开发人员,如此的经验当是相当的美妙。 当你能仅使用Redis去构建一个完整系统时,我想大多数人将会发现,Redis能使得他们的许多数据方案变得更为通用,不论是一个传统的关系型数据库,一个面向文档的系统,或是其它更多的东西。这是一种用来实现某些特定特性的解决方法。就类似于一个索引引擎,你不会在Lucene上构建整个程序,但当你需要足够好的搜索,为什么不使用它呢?这对你和你的用户都有好处。当然,关于Redis和索引引擎之间相似性的讨论到此为止。 本书的目的是向读者传授掌握Redis所需要的基本知识。我们将会注重于学习Redis的5种数据结构,并研究各种数据建模方法。我们还会接触到一些主要的管理细节和调试技巧。 ## 入门 每个人的学习方式都不一样,有的人喜欢亲自实践学习,有的喜欢观看教学视频,还有的喜欢通过阅读来学习。对于Redis,没有什么比亲自实践学习来得效果更好的了。Redis的安装非常简单。而且通过随之安装的一个简单的命令解析程序,就能处理我们想做的一切事情。让我们先花几分钟的时间把Redis安装到我们的机器上。 ### Windows平台 Redis并没有官方支持Windows平台,但还是可供选择。你不会想在这里配置实际的生产环境,不过在我过往的开发经历里并没有感到有什么限制。 首先进入<https://github.com/dmajkic/redis/downloads>,然后下载最新的版本(应该会在列表的最上方)。 获取zip文件,然后根据你的系统架构,打开`64bit`或`32bit`文件夹。 ### *nix和MacOSX平台 对于*nix和MacOSX平台的用户,从源文件来安装是你的最佳选择。通过最新的版本号来选择,有效地址于<http://redis.io/download>。在编写此书的时候,最新的版本是2.4.6,我们可以运行下面的命令来安装该版本: wget http://redis.googlecode.com/files/redis-2.4.6.tar.gz tar xzf redis-2.4.6.tar.gz cd redis-2.4.6 make (当然,Redis同样可以通过套件管理程序来安装。例如,使用Homebrew的MaxOSX用户可以只键入`brew install redis`即可。) 如果你是通过源文件来安装,二进制可执行文件会被放置在`src`目录里。通过运行`cd src`可跳转到`src`目录。 ### 运行和连接Redis 如果一切都工作正常,那Redis的二进制文件应该已经可以曼妙地跳跃于你的指尖之下。Redis只有少量的可执行文件,我们将着重于Redis的服务器和命令行界面(一个类DOS的客户端)。首先,让我们来运行服务器。在Windows平台,双击`redis-server`,在*nix/MacOSX平台则运行`./redis-server`. 如果你仔细看了启动信息,你会看到一个警告,指没能找到`redis.conf`文件。Redis将会采用内置的默认设置,这对于我们将要做的已经足够了。 然后,通过双击`redis-cli`(Windows平台)或者运行`./redis-cli`(*nix/MacOSX平台),启动Redis的控制台。控制台将会通过默认的端口(6379)来连接本地运行的服务器。 可以在命令行界面键入`info`命令来查看一切是不是都运行正常。你会很乐意看到这么一大组关键字-值(key-value)对的显示,这为我们查看服务器的状态提供了大量有效信息。 如果在上面的启动步骤里遇到什么问题,我建议你到[Redis的官方支持组](https://groups.google.com/forum/#!forum/redis-db)里获取帮助。 ## 驱动Redis 很快你就会发现,Redis的API就如一组定义明确的函数那般容易理解。Redis具有让人难以置信的简单性,其操作过程也同样如此。这意味着,无论你是使用命令行程序,或是使用你喜欢的语言来驱动,整体的感觉都不会相差多少。因此,相对于命令行程序,如果你更愿意通过一种编程语言去驱动Redis,你不会感觉到有任何适应的问题。如果真想如此,可以到Redis的[客户端推荐页面](http://redis.io/clients)下载适合的Redis载体。 \clearpage ## 第1章 - 基础知识 是什么使Redis显得这么特别?Redis具体能解决什么类型的问题?要实际应用Redis,开发者必须储备什么知识?在我们能回答这么一些问题之前,我们需要明白Redis到底是什么。 Redis通常被人们认为是一种持久化的存储器关键字-值型存储(in-memory persistent key-value store)。我认为这种对Redis的描述并不太准确。Redis的确是将所有的数据存放于存储器(更多是是按位存储),而且也确实通过将数据写入磁盘来实现持久化,但是Redis的实际意义比单纯的关键字-值型存储要来得深远。纠正脑海里的这种误解观点非常关键,否则你对于Redis之道以及其应用的洞察力就会变得越发狭义。 事实是,Redis引入了5种不同的数据结构,只有一个是典型的关键字-值型结构。理解Redis的关键就在于搞清楚这5种数据结构,其工作的原理都是如何,有什么关联方法以及你能怎样应用这些数据结构去构建模型。首先,让我们来弄明白这些数据结构的实际意义。 应用上面提及的数据结构概念到我们熟悉的关系型数据库里,我们可以认为其引入了一个单独的数据结构——表格。表格既复杂又灵活,基于表格的存储和管理,没有多少东西是你不能进行建模的。然而,这种通用性并不是没有缺点。具体来说就是,事情并不是总能达到假设中的简单或者快速。相对于这种普遍适用(one-size-fits-all)的结构体系,我们可以使用更为专门化的结构体系。当然,因此可能有些事情我们会完成不了(至少,达不到很好的程度)。但话说回来,这样做就能确定我们可以获得想象中的简单性和速度吗? 针对特定类型的问题使用特定的数据结构?我们不就是这样进行编程的吗?你不会使用一个散列表去存储每份数据,也不会使用一个标量变量去存储。对我来说,这正是Redis的做法。如果你需要处理标量、列表、散列或者集合,为什么不直接就用标量、列表、散列和集合去存储他们?为什么不是直接调用`exists(key)`去检测一个已存在的值,而是要调用其他比O(1)(常量时间查找,不会因为待处理元素的增长而变慢)慢的操作? ### 数据库(Databases) 与你熟悉的关系型数据库一致,Redis有着相同的数据库基本概念,即一个数据库包含一组数据。典型的数据库应用案例是,将一个程序的所有数据组织起来,使之与另一个程序的数据保持独立。 在Redis里,数据库简单的使用一个数字编号来进行辨认,默认数据库的数字编号是`0`。如果你想切换到一个不同的数据库,你可以使用`select`命令来实现。在命令行界面里键入`select 1`,Redis应该会回复一条`OK`的信息,然后命令行界面里的提示符会变成类似`redis 127.0.0.1:6379[1]>`这样。如果你想切换回默认数据库,只要在命令行界面键入`select 0`即可。 ### 命令、关键字和值(Commands, Keys and Values) Redis不仅仅是一种简单的关键字-值型存储,从其核心概念来看,Redis的5种数据结构中的每一个都至少有一个关键字和一个值。在转入其它关于Redis的有用信息之前,我们必须理解关键字和值的概念。 关键字(Keys)是用来标识数据块。我们将会很常跟关键字打交道,不过在现在,明白关键字就是类似于`users:leto`这样的表述就足够了。一般都能很好地理解到,这样关键字包含的信息是一个名为`leto`的用户。这个关键字里的冒号没有任何特殊含义,对于Redis而言,使用分隔符来组织关键字是很常见的方法。 值(Values)是关联于关键字的实际值,可以是任何东西。有时候你会存储字符串,有时候是整数,还有时候你会存储序列化对象(使用JSON、XML或其他格式)。在大多数情况下,Redis会把值看做是一个字节序列,而不会关注它们实质上是什么。要注意,不同的Redis载体处理序列化会有所不同(一些会让你自己决定)。因此,在这本书里,我们将仅讨论字符串、整数和JSON。 现在让我们活动一下手指吧。在命令行界面键入下面的命令: set users:leto "{name: leto, planet: dune, likes: [spice]}" 这就是Redis命令的基本构成。首先我们要有一个确定的命令,在上面的语句里就是`set`。然后就是相应的参数,`set`命令接受两个参数,包括要设置的关键字,以及相应要设置的值。很多的情况是,命令接受一个关键字(当这种情况出现,其经常是第一个参数)。你能想到如何去获取这个值吗?我想你会说(当然一时拿不准也没什么): get users:leto 关键字和值的是Redis的基本概念,而`get`和`set`命令是对此最简单的使用。你可以创建更多的用户,去尝试不同类型的关键字以及不同的值,看看一些不同的组合。 ### 查询(Querying) 随着学习的持续深入,两件事情将变得清晰起来。对于Redis而言,关键字就是一切,而值是没有任何意义。更通俗来看就是,Redis不允许你通过值来进行查询。回到上面的例子,我们就不能查询生活在`dune`行星上的用户。 对许多人来说,这会引起一些担忧。在我们生活的世界里,数据查询是如此的灵活和强大,而Redis的方式看起来是这么的原始和不高效。不要让这些扰乱你太久。要记住,Redis不是一种普遍使用(one-size-fits-all)的解决方案,确实存在这么一些事情是不应该由Redis来解决的(因为其查询的限制)。事实上,在考虑了这些情况后,你会找到新的方法去构建你的数据。 很快,我们就能看到更多实际的用例。很重要的一点是,我们要明白关于Redis的这些基本事实。这能帮助我们弄清楚为什么值可以是任何东西,因为Redis从来不需要去读取或理解它们。而且,这也可以帮助我们理清思路,然后去思考如何在这个新世界里建立模型。 ### 存储器和持久化(Memory and Persistence) 我们之前提及过,Redis是一种持久化的存储器内存储(in-memory persistent store)。对于持久化,默认情况下,Redis会根据已变更的关键字数量来进行判断,然后在磁盘里创建数据库的快照(snapshot)。你可以对此进行设置,如果X个关键字已变更,那么每隔Y秒存储数据库一次。默认情况下,如果1000个或更多的关键字已变更,Redis会每隔60秒存储数据库;而如果9个或更少的关键字已变更,Redis会每隔15分钟存储数据库。 除了创建磁盘快照外,Redis可以在附加模式下运行。任何时候,如果有一个关键字变更,一个单一附加(append-only)的文件会在磁盘里进行更新。在一些情况里,虽然硬件或软件可能发生错误,但用那60秒有效数据存储去换取更好性能是可以接受的。而在另一些情况里,这种损失就难以让人接受,Redis为你提供了选择。在第5章里,我们将会看到第三种选择,其将持久化任务减荷到一个从属数据库里。 至于存储器,Redis会将所有数据都保留在存储器中。显而易见,运行Redis具有不低的成本:因为RAM仍然是最昂贵的服务器硬件部件。 我很清楚有一些开发者对即使是一点点的数据空间都是那么的敏感。一本《威廉·莎士比亚全集》需要近5.5MB的存储空间。对于缩放的需求,其它的解决方案趋向于IO-bound或者CPU-bound。这些限制(RAM或者IO)将会需要你去理解更多机器实际依赖的数据类型,以及应该如何去进行存储和查询。除非你是存储大容量的多媒体文件到Redis中,否则存储器内存储应该不会是一个问题。如果这对于一个程序是个问题,你就很可能不会用IO-bound的解决方案。 Redis有虚拟存储器的支持。然而,这个功能已经被认为是失败的了(通过Redis的开发者),而且它的使用已经被废弃了。 (从另一个角度来看,一本5.5MB的《威廉·莎士比亚全集》可以通过压缩减小到近2MB。当然,Redis不会自动对值进行压缩,但是因为其将所有值都看作是字节,没有什么限制让你不能对数据进行压缩/解压,通过牺牲处理时间来换取存储空间。) ### 整体来看(Putting It Together) 我们已经接触了好几个高层次的主题。在继续深入Redis之前,我想做的最后一件事情是将这些主题整合起来。这些主题包括,查询的限制,数据结构以及Redis在存储器内存储数据的方法。 当你将这3个主题整合起来,你最终会得出一个绝妙的结论:速度。一些人可能会想,当然Redis会很快速,要知道所以的东西都在存储器里。但这仅仅是其中的一部分,让Redis闪耀的真正原因是其不同于其它解决方案的特殊数据结构。 能有多快速?这依赖于很多东西,包括你正在使用着哪个命令,数据的类型等等。但Redis的性能测试是趋向于数万或数十万次操作**每秒**。你可以通过运行`redis-benchmark`(就在`redis-server`和`redis-cli`的同一个文件夹里)来进行测试。 我曾经试过将一组使用传统模型的代码转向使用Redis。在传统模型里,运行一个我写的载入测试,需要超过5分钟的时间来完成。而在Redis里,只需要150毫秒就完成了。你不会总能得到这么好的收获,但希望这能让你对我们所谈的东西有更清晰的理解。 理解Redis的这个特性很重要,因为这将影响到你如何去与Redis进行交互。拥有SQL背景的程序员通常会致力于让数据库的数据往返次数减至最小。这对于任何系统都是个好建议,包括Redis。然而,考虑到我们是在处理比较简单的数据结构,有时候我们还是需要与Redis服务器频繁交互,以达到我们的目的。刚开始的时候,可能会对这种数据访问模式感到不太自然。实际上,相对于我们通过Redis获得的高性能而言,这仅仅是微不足道的损失。 ### 小结 虽然我们只接触和摆弄了Redis的冰山一角,但我们讨论的主题已然覆盖了很大范围内的东西。如果觉得有些事情还是不太清楚(例如查询),不用为此而担心,在下一章我们将会继续深入探讨,希望你的问题都能得到解答。 这一章的要点包括: * 关键字(Keys)是用于标识一段数据的一个字符串 * 值(Values)是一段任意的字节序列,Redis不会关注它们实质上是什么 * Redis展示了(也实现了)5种专门的数据结构 * 上面的几点使得Redis快速而且容易使用,但要知道Redis并不适用于所有的应用场景 \clearpage ## 第2章 - 数据结构 现在开始将探究Redis的5种数据结构,我们会解释每种数据结构都是什么,包含了什么有效的方法(Method),以及你能用这些数据结构处理哪些类型的特性和数据。 目前为止,我们所知道的Redis构成仅包括命令、关键字和值,还没有接触到关于数据结构的具体概念。当我们使用`set`命令时,Redis是怎么知道我们是在使用哪个数据结构?其解决方法是,每个命令都相对应于一种特定的数据结构。例如,当你使用`set`命令,你就是将值存储到一个字符串数据结构里。而当你使用`hset`命令,你就是将值存储到一个散列数据结构里。考虑到Redis的关键字集很小,这样的机制具有相当的可管理性。 **[Redis的网站](http://redis.io/commands)里有着非常优秀的参考文档,没有任何理由去重造轮子。但为了搞清楚这些数据结构的作用,我们将会覆盖那些必须知道的重要命令。** 没有什么事情比高兴的玩和试验有趣的东西来得更重要的了。在任何时候,你都能通过键入`flushdb`命令将你数据库里的所有值清除掉,因此,不要再那么害羞了,去尝试做些疯狂的事情吧! ### 字符串(Strings) 在Redis里,字符串是最基本的数据结构。当你在思索着关键字-值对时,你就是在思索着字符串数据结构。不要被名字给搞混了,如之前说过的,你的值可以是任何东西。我更喜欢将他们称作“标量”(Scalars),但也许只有我才这样想。 我们已经看到了一个常见的字符串使用案例,即通过关键字存储对象的实例。有时候,你会频繁地用到这类操作: set users:leto "{name: leto, planet: dune, likes: [spice]}" 除了这些外,Redis还有一些常用的操作。例如,`strlen <key>`能用来获取一个关键字对应值的长度;`getrange <key> <start> <end>`将返回指定范围内的关键字对应值;`append <key> <value>`会将value附加到已存在的关键字对应值中(如果该关键字并不存在,则会创建一个新的关键字-值对)。不要犹豫,去试试看这些命令吧。下面是我得到的: > strlen users:leto (integer) 42 > getrange users:leto 27 40 "likes: [spice]" > append users:leto " OVER 9000!!" (integer) 54 现在你可能会想,这很好,但似乎没有什么意义。你不能有效地提取出一段范围内的JSON文件,或者为其附加一些值。你是对的,这里的经验是,一些命令,尤其是关于字符串数据结构的,只有在给定了明确的数据类型后,才会有实际意义。 之前我们知道了,Redis不会去关注你的值是什么东西。通常情况下,这没有错。然而,一些字符串命令是专门为一些类型或值的结构而设计的。作为一个有些含糊的用例,我们可以看到,对于一些自定义的空间效率很高的(space-efficient)串行化对象,`append`和`getrange`命令将会很有用。对于一个更为具体的用例,我们可以再看一下`incr`、`incrby`、`decr`和`decrby`命令。这些命令会增长或者缩减一个字符串数据结构的值: > incr stats:page:about (integer) 1 > incr stats:page:about (integer) 2 > incrby ratings:video:12333 5 (integer) 5 > incrby ratings:video:12333 3 (integer) 8 由此你可以想象到,Redis的字符串数据结构能很好地用于分析用途。你还可以去尝试增长`users:leto`(一个不是整数的值),然后看看会发生什么(应该会得到一个错误)。 更为进阶的用例是`setbit`和`getbit`命令。“今天我们有多少个独立用户访问”是个在Web应用里常见的问题,有一篇[精彩的博文](http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/),在里面可以看到Spool是如何使用这两个命令有效地解决此问题。对于1.28亿个用户,一部笔记本电脑在不到50毫秒的时间里就给出了答复,而且只用了16MB的存储空间。 最重要的事情不是在于你是否明白位图(Bitmaps)的工作原理,或者Spool是如何去使用这些命令,而是应该要清楚Redis的字符串数据结构比你当初所想的要有用许多。然而,最常见的应用案例还是上面我们给出的:存储对象(简单或复杂)和计数。同时,由于通过关键字来获取一个值是如此之快,字符串数据结构很常被用来缓存数据。 ### 散列(Hashes) 我们已经知道把Redis称为一种关键字-值型存储是不太准确的,散列数据结构是一个很好的例证。你会看到,在很多方面里,散列数据结构很像字符串数据结构。两者显著的区别在于,散列数据结构提供了一个额外的间接层:一个域(Field)。因此,散列数据结构中的`set`和`get`是: hset users:goku powerlevel 9000 hget users:goku powerlevel 相关的操作还包括在同一时间设置多个域、同一时间获取多个域、获取所有的域和值、列出所有的域或者删除指定的一个域: hmset users:goku race saiyan age 737 hmget users:goku race powerlevel hgetall users:goku hkeys users:goku hdel users:goku age 如你所见,散列数据结构比普通的字符串数据结构具有更多的可操作性。我们可以使用一个散列数据结构去获得更精确的描述,是存储一个用户,而不是一个序列化对象。从而得到的好处是能够提取、更新和删除具体的数据片段,而不必去获取或写入整个值。 对于散列数据结构,可以从一个经过明确定义的对象的角度来考虑,例如一个用户,关键之处在于要理解他们是如何工作的。从性能上的原因来看,这是正确的,更具粒度化的控制可能会相当有用。在下一章我们将会看到,如何用散列数据结构去组织你的数据,使查询变得更为实效。在我看来,这是散列真正耀眼的地方。 ### 列表(Lists) 对于一个给定的关键字,列表数据结构让你可以存储和处理一组值。你可以添加一个值到列表里、获取列表的第一个值或最后一个值以及用给定的索引来处理值。列表数据结构维护了值的顺序,提供了基于索引的高效操作。为了跟踪在网站里注册的最新用户,我们可以维护一个`newusers`的列表: lpush newusers goku ltrim newusers 0 50 **(译注:`ltrim`命令的具体构成是`LTRIM Key start stop`。要理解`ltrim`命令,首先要明白Key所存储的值是一个列表,理论上列表可以存放任意个值。对于指定的列表,根据所提供的两个范围参数start和stop,`ltrim`命令会将指定范围外的值都删除掉,只留下范围内的值。)** 首先,我们将一个新用户推入到列表的前端,然后对列表进行调整,使得该列表只包含50个最近被推入的用户。这是一种常见的模式。`ltrim`是一个具有O(N)时间复杂度的操作,N是被删除的值的数量。从上面的例子来看,我们总是在插入了一个用户后再进行列表调整,实际上,其将具有O(1)的时间复杂度(因为N将永远等于1)的常数性能。 这是我们第一次看到一个关键字的对应值索引另一个值。如果我们想要获取最近的10个用户的详细资料,我们可以运行下面的组合操作: keys = redis.lrange('newusers', 0, 10) redis.mget(*keys.map {|u| "users:#{u}"}) 我们之前谈论过关于多次往返数据的模式,上面的两行Ruby代码为我们进行了很好的演示。 当然,对于存储和索引关键字的功能,并不是只有列表数据结构这种方式。值可以是任意的东西,你可以使用列表数据结构去存储日志,也可以用来跟踪用户浏览网站时的路径。如果你过往曾构建过游戏,你可能会使用列表数据结构去跟踪用户的排队活动。 ### 集合 集合数据结构常常被用来存储只能唯一存在的值,并提供了许多的基于集合的操作,例如并集。集合数据结构没有对值进行排序,但是其提供了高效的基于值的操作。使用集合数据结构的典型用例是朋友名单的实现: sadd friends:leto ghanima paul chani jessica sadd friends:duncan paul jessica alia 不管一个用户有多少个朋友,我们都能高效地(O(1)时间复杂度)识别出用户X是不是用户Y的朋友: sismember friends:leto jessica sismember friends:leto vladimir 而且,我们可以查看两个或更多的人是不是有共同的朋友: sinter friends:leto friends:duncan 甚至可以在一个新的关键字里存储结果: sinterstore friends:leto_duncan friends:leto friends:duncan 有时候需要对值的属性进行标记和跟踪处理,但不能通过简单的复制操作完成,集合数据结构是解决此类问题的最好方法之一。当然,对于那些需要运用集合操作的地方(例如交集和并集),集合数据结构就是最好的选择。 ### 分类集合(Sorted Sets) 最后也是最强大的数据结构是分类集合数据结构。如果说散列数据结构类似于字符串数据结构,主要区分是域(field)的概念;那么分类集合数据结构就类似于集合数据结构,主要区分是标记(score)的概念。标记提供了排序(sorting)和秩划分(ranking)的功能。如果我们想要一个秩分类的朋友名单,可以这样做: zadd friends:duncan 70 ghanima 95 paul 95 chani 75 jessica 1 vladimir 对于`duncan`的朋友,要怎样计算出标记(score)为90或更高的人数? zcount friends:duncan 90 100 如何获取`chani`在名单里的秩(rank)? zrevrank friends:duncan chani **(译注:`zrank`命令的具体构成是`ZRANK Key menber`,要知道Key存储的Sorted Set默认是根据Score对各个menber进行升序的排列,该命令就是用来获取menber在该排列里的次序,这就是所谓的秩。)** 我们使用了`zrevrank`命令而不是`zrank`命令,这是因为Redis的默认排序是从低到高,但是在这个例子里我们的秩划分是从高到低。对于分类集合数据结构,最常见的应用案例是用来实现排行榜系统。事实上,对于一些基于整数排序,且能以标记(score)来进行有效操作的东西,使用分类集合数据结构来处理应该都是不错的选择。 ### 小结 对于Redis的5种数据结构,我们进行了高层次的概述。一件有趣的事情是,相对于最初构建时的想法,你经常能用Redis创造出一些更具实效的事情。对于字符串数据结构和分类集合数据结构的使用,很有可能存在一些构建方法是还没有人想到的。当你理解了那些常用的应用案例后,你将发现Redis对于许多类型的问题,都是很理想的选择。还有,不要因为Redis展示了5种数据结构和相应的各种方法,就认为你必须要把所有的东西都用上。只使用一些命令去构建一个特性是很常见的。 \clearpage ## 第3章 - 使用数据结构 在上一章里,我们谈论了Redis的5种数据结构,对于一些可能的用途也给出了用例。现在是时候来看看一些更高级,但依然很常见的主题和设计模式。 ### 大O表示法(Big O Notation) 在本书中,我们之前就已经看到过大O表示法,包括O(1)和O(N)的表示。大O表示法的惯常用途是,描述一些用于处理一定数量元素的行为的综合表现。在Redis里,对于一个要处理一定数量元素的命令,大O表示法让我们能了解该命令的大概运行速度。 在Redis的文档里,每一个命令的时间复杂度都用大O表示法进行了描述,还能知道各命令的具体性能会受什么因素影响。让我们来看看一些用例。 常数时间复杂度O(1)被认为是最快速的,无论我们是在处理5个元素还是5百万个元素,最终都能得到相同的性能。对于`sismember`命令,其作用是告诉我们一个值是否属于一个集合,时间复杂度为O(1)。`sismember`命令很强大,很大部分的原因是其高效的性能特征。许多Redis命令都具有O(1)的时间复杂度。 对数时间复杂度O(log(N))被认为是第二快速的,其通过使需扫描的区间不断皱缩来快速完成处理。使用这种“分而治之”的方式,大量的元素能在几个迭代过程里被快速分解完整。`zadd`命令的时间复杂度就是O(log(N)),其中N是在分类集合中的元素数量。 再下来就是线性时间复杂度O(N),在一个表格的非索引列里进行查找就需要O(N)次操作。`ltrim`命令具有O(N)的时间复杂度,但是,在`ltrim`命令里,N不是列表所拥有的元素数量,而是被删除的元素数量。从一个具有百万元素的列表里用`ltrim`命令删除1个元素,要比从一个具有一千个元素的列表里用`ltrim`命令删除10个元素来的快速(实际上,两者很可能会是一样快,因为两个时间都非常的小)。 根据给定的最小和最大的值的标记,`zremrangebyscore`命令会在一个分类集合里进行删除元素操作,其时间复杂度是O(log(N)+M)。这看起来似乎有点儿杂乱,通过阅读文档可以知道,这里的N指的是在分类集合里的总元素数量,而M则是被删除的元素数量。可以看出,对于性能而言,被删除的元素数量很可能会比分类集合里的总元素数量更为重要。 **(译注:`zremrangebyscore`命令的具体构成是`ZREMRANGEBYSCORE Key max mix`。)** 对于`sort`命令,其时间复杂度为O(N+M*log(M)),我们将会在下一章谈论更多的相关细节。从`sort`命令的性能特征来看,可以说这是Redis里最复杂的一个命令。 还存在其他的时间复杂度描述,包括O(N^2)和O(C^N)。随着N的增大,其性能将急速下降。在Redis里,没有任何一个命令具有这些类型的时间复杂度。 值得指出的一点是,在Redis里,当我们发现一些操作具有O(N)的时间复杂度时,我们可能可以找到更为好的方法去处理。 **(译注:对于Big O Notation,相信大家都非常的熟悉,虽然原文仅仅是对该表示法进行简单的介绍,但限于个人的算法知识和文笔水平实在有限,此小节的翻译让我头痛颇久,最终成果也确实难以让人满意,望见谅。)** ### 仿多关键字查询(Pseudo Multi Key Queries) 时常,你会想通过不同的关键字去查询相同的值。例如,你会想通过电子邮件(当用户开始登录时)去获取用户的具体信息,或者通过用户id(在用户登录后)去获取。有一种很不实效的解决方法,其将用户对象分别放置到两个字符串值里去: set users:[email protected] "{id: 9001, email: '[email protected]', ...}" set users:9001 "{id: 9001, email: '[email protected]', ...}" 这种方法很糟糕,如此不但会产生两倍数量的内存,而且这将会成为数据管理的恶梦。 如果Redis允许你将一个关键字链接到另一个的话,可能情况会好很多,可惜Redis并没有提供这样的功能(而且很可能永远都不会提供)。Redis发展到现在,其开发的首要目的是要保持代码和API的整洁简单,关键字链接功能的内部实现并不符合这个前提(对于关键字,我们还有很多相关方法没有谈论到)。其实,Redis已经提供了解决的方法:散列。 使用散列数据结构,我们可以摆脱重复的缠绕: set users:9001 "{id: 9001, email: [email protected], ...}" hset users:lookup:email [email protected] 9001 我们所做的是,使用域来作为一个二级索引,然后去引用单个用户对象。要通过id来获取用户信息,我们可以使用一个普通的`get`命令: get users:9001 而如果想通过电子邮箱来获取用户信息,我们可以使用`hget`命令再配合使用`get`命令(Ruby代码): id = redis.hget('users:lookup:email', '[email protected]') user = redis.get("users:#{id}") 你很可能将会经常使用这类用法。在我看来,这就是散列真正耀眼的地方。在你了解这类用法之前,这可能不是一个明显的用例。 ### 引用和索引(References and Indexes) 我们已经看过几个关于值引用的用例,包括介绍列表数据结构时的用例,以及在上面使用散列数据结构来使查询更灵活一些。进行归纳后会发现,对于那些值与值间的索引和引用,我们都必须手动的去管理。诚实来讲,这确实会让人有点沮丧,尤其是当你想到那些引用相关的操作,如管理、更新和删除等,都必须手动的进行时。在Redis里,这个问题还没有很好的解决方法。 我们已经看到,集合数据结构很常被用来实现这类索引: sadd friends:leto ghanima paul chani jessica 这个集合里的每一个成员都是一个Redis字符串数据结构的引用,而每一个引用的值则包含着用户对象的具体信息。那么如果`chani`改变了她的名字,或者删除了她的帐号,应该如何处理?从整个朋友圈的关系结构来看可能会更好理解,我们知道,`chani`也有她的朋友: sadd friends_of:chani leto paul 如果你有什么待处理情况像上面那样,那在维护成本之外,还会有对于额外索引值的处理和存储空间的成本。这可能会令你感到有点退缩。在下一小节里,我们将会谈论减少使用额外数据交互的性能成本的一些方法(在第1章我们粗略地讨论了下)。 如果你确实在担忧着这些情况,其实,关系型数据库也有同样的开销。索引需要一定的存储空间,必须通过扫描或查找,然后才能找到相应的记录。其开销也是存在的,当然他们对此做了很多的优化工作,使之变得更为有效。 再次说明,需要在Redis里手动地管理引用确实是颇为棘手。但是,对于你关心的那些问题,包括性能或存储空间等,应该在经过测试后,才会有真正的理解。我想你会发现这不会是一个大问题。 ### 数据交互和流水线(Round Trips and Pipelining) 我们已经提到过,与服务器频繁交互是Redis的一种常见模式。这类情况可能很常出现,为了使我们能获益更多,值得仔细去看看我们能利用哪些特性。 许多命令能接受一个或更多的参数,也有一种关联命令(sister-command)可以接受多个参数。例如早前我们看到过`mget`命令,接受多个关键字,然后返回值: keys = redis.lrange('newusers', 0, 10) redis.mget(*keys.map {|u| "users:#{u}"}) 或者是`sadd`命令,能添加一个或多个成员到集合里: sadd friends:vladimir piter sadd friends:paul jessica leto "leto II" chani Redis还支持流水线功能。通常情况下,当一个客户端发送请求到Redis后,在发送下一个请求之前必须等待Redis的答复。使用流水线功能,你可以发送多个请求,而不需要等待Redis响应。这不但减少了网络开销,还能获得性能上的显著提高。 值得一提的是,Redis会使用存储器去排列命令,因此批量执行命令是一个好主意。至于具体要多大的批量,将取决于你要使用什么命令(更明确来说,该参数有多大)。另一方面来看,如果你要执行的命令需要差不多50个字符的关键字,你大概可以对此进行数千或数万的批量操作。 对于不同的Redis载体,在流水线里运行命令的方式会有所差异。在Ruby里,你传递一个代码块到`pipelined`方法: redis.pipelined do 9001.times do redis.incr('powerlevel') end end 正如你可能猜想到的,流水线功能可以实际地加速一连串命令的处理。 ### 事务(Transactions) 每一个Redis命令都具有原子性,包括那些一次处理多项事情的命令。此外,对于使用多个命令,Redis支持事务功能。 你可能不知道,但Redis实际上是单线程运行的,这就是为什么每一个Redis命令都能够保证具有原子性。当一个命令在执行时,没有其他命令会运行(我们会在往后的章节里简略谈论一下Scaling)。在你考虑到一些命令去做多项事情时,这会特别的有用。例如: `incr`命令实际上就是一个`get`命令然后紧随一个`set`命令。 `getset`命令设置一个新的值然后返回原始值。 `setnx`命令首先测试关键字是否存在,只有当关键字不存在时才设置值 虽然这些都很有用,但在实际开发时,往往会需要运行具有原子性的一组命令。若要这样做,首先要执行`multi`命令,紧随其后的是所有你想要执行的命令(作为事务的一部分),最后执行`exec`命令去实际执行命令,或者使用`discard`命令放弃执行命令。Redis的事务功能保证了什么? * 事务中的命令将会按顺序地被执行 * 事务中的命令将会如单个原子操作般被执行(没有其它的客户端命令会在中途被执行) * 事务中的命令要么全部被执行,要么不会执行 你可以(也应该)在命令行界面对事务功能进行一下测试。还有一点要注意到,没有什么理由不能结合流水线功能和事务功能。 multi hincrby groups:1percent balance -9000000000 hincrby groups:99percent balance 9000000000 exec 最后,Redis能让你指定一个关键字(或多个关键字),当关键字有改变时,可以查看或者有条件地应用一个事务。这是用于当你需要获取值,且待运行的命令基于那些值时,所有都在一个事务里。对于上面展示的代码,我们不能去实现自己的`incr`命令,因为一旦`exec`命令被调用,他们会全部被执行在一块。我们不能这么做: redis.multi() current = redis.get('powerlevel') redis.set('powerlevel', current + 1) redis.exec() **(译注:虽然Redis是单线程运行的,但是我们可以同时运行多个Redis客户端进程,常见的并发问题还是会出现。像上面的代码,在`get`运行之后,`set`运行之前,`powerlevel`的值可能会被另一个Redis客户端给改变,从而造成错误。)** 这些不是Redis的事务功能的工作。但是,如果我们增加一个`watch`到`powerlevel`,我们可以这样做: redis.watch('powerlevel') current = redis.get('powerlevel') redis.multi() redis.set('powerlevel', current + 1) redis.exec() 在我们调用`watch`后,如果另一个客户端改变了`powerlevel`的值,我们的事务将会运行失败。如果没有客户端改变`powerlevel`的值,那么事务会继续工作。我们可以在一个循环里运行这些代码,直到其能正常工作。 ### 关键字反模式(Keys Anti-Pattern) 在下一章中,我们将会谈论那些没有确切关联到数据结构的命令,其中的一些是管理或调试工具。然而有一个命令我想特别地在这里进行谈论:`keys`命令。这个命令需要一个模式,然后查找所有匹配的关键字。这个命令看起来很适合一些任务,但这不应该用在实际的产品代码里。为什么?因为这个命令通过线性扫描所有的关键字来进行匹配。或者,简单地说,这个命令太慢了。 人们会如此去使用这个命令?一般会用来构建一个本地的Bug追踪服务。每一个帐号都有一个`id`,你可能会通过一个看起来像`bug:account_id:bug_id`的关键字,把每一个Bug存储到一个字符串数据结构值中去。如果你在任何时候需要查询一个帐号的Bug(显示它们,或者当用户删除了帐号时删除掉这些Bugs),你可能会尝试去使用`keys`命令: keys bug:1233:* 更好的解决方法应该使用一个散列数据结构,就像我们可以使用散列数据结构来提供一种方法去展示二级索引,因此我们可以使用域来组织数据: hset bugs:1233 1 "{id:1, account: 1233, subject: '...'}" hset bugs:1233 2 "{id:2, account: 1233, subject: '...'}" 从一个帐号里获取所有的Bug标识,可以简单地调用`hkeys bugs:1233`。去删除一个指定的Bug,可以调用`hdel bugs:1233 2`。如果要删除了一个帐号,可以通过`del bugs:1233`把关键字删除掉。 ### 小结 结合这一章以及前一章,希望能让你得到一些洞察力,了解如何使用Redis去支持(Power)实际项目。还有其他的模式可以让你去构建各种类型的东西,但真正的关键是要理解基本的数据结构。你将能领悟到,这些数据结构是如何能够实现你最初视角之外的东西。 \clearpage ## 第4章 超越数据结构 5种数据结构组成了Redis的基础,其他没有关联特定数据结构的命令也有很多。我们已经看过一些这样的命令:`info`, `select`, `flushdb`, `multi`, `exec`, `discard`, `watch`和`keys `。这一章将看看其他的一些重要命令。 ### 使用期限(Expiration) Redis允许你标记一个关键字的使用期限。你可以给予一个Unix时间戳形式(自1970年1月1日起)的绝对时间,或者一个基于秒的存活时间。这是一个基于关键字的命令,因此其不在乎关键字表示的是哪种类型的数据结构。 expire pages:about 30 expireat pages:about 1356933600 第一个命令将会在30秒后删除掉关键字(包括其关联的值)。第二个命令则会在2012年12月31日上午12点删除掉关键字。 这让Redis能成为一个理想的缓冲引擎。通过`ttl`命令,你可以知道一个关键字还能够存活多久。而通过`persist`命令,你可以把一个关键字的使用期限删除掉。 ttl pages:about persist pages:about 最后,有个特殊的字符串命令,`setex`命令让你可以在一个单独的原子命令里设置一个字符串值,同时里指定一个生存期(这比任何事情都要方便)。 setex pages:about 30 '<h1>about us</h1>....' ### 发布和订阅(Publication and Subscriptions) Redis的列表数据结构有`blpop`和`brpop`命令,能从列表里返回且删除第一个(或最后一个)元素,或者被堵塞,直到有一个元素可供操作。这可以用来实现一个简单的队列。 **(译注:对于`blpop`和`brpop`命令,如果列表里没有关键字可供操作,连接将被堵塞,直到有另外的Redis客户端使用`lpush`或`rpush`命令推入关键字为止。)** 此外,Redis对于消息发布和频道订阅有着一流的支持。你可以打开第二个`redis-cli`窗口,去尝试一下这些功能。在第一个窗口里订阅一个频道(我们会称它为`warnings`): subscribe warnings 其将会答复你订阅的信息。现在,在另一个窗口,发布一条消息到`warnings`频道: publish warnings "it's over 9000!" 如果你回到第一个窗口,你应该已经接收到`warnings`频道发来的消息。 你可以订阅多个频道(`subscribe channel1 channel2 ...`),订阅一组基于模式的频道(`psubscribe warnings:*`),以及使用`unsubscribe`和`punsubscribe`命令停止监听一个或多个频道,或一个频道模式。 最后,可以注意到`publish`命令的返回值是1,这指出了接收到消息的客户端数量。 ### 监控和延迟日志(Monitor and Slow Log) `monitor`命令可以让你查看Redis正在做什么。这是一个优秀的调试工具,能让你了解你的程序如何与Redis进行交互。在两个`redis-cli`窗口中选一个(如果其中一个还处于订阅状态,你可以使用`unsubscribe`命令退订,或者直接关掉窗口再重新打开一个新窗口)键入`monitor`命令。在另一个窗口,执行任何其他类型的命令(例如`get`或`set`命令)。在第一个窗口里,你应该可以看到这些命令,包括他们的参数。 在实际生产环境里,你应该谨慎运行`monitor`命令,这真的仅仅就是一个很有用的调试和开发工具。除此之外,没有更多要说的了。 随同`monitor`命令一起,Redis拥有一个`slowlog`命令,这是一个优秀的性能剖析工具。其会记录执行时间超过一定数量**微秒**的命令。在下一章节,我们会简略地涉及如何配置Redis,现在你可以按下面的输入配置Redis去记录所有的命令: config set slowlog-log-slower-than 0 然后,执行一些命令。最后,你可以检索到所有日志,或者检索最近的那些日志: slowlog get slowlog get 10 通过键入`slowlog len`,你可以获取延迟日志里的日志数量。 对于每个被你键入的命令,你应该查看4个参数: * 一个自动递增的id * 一个Unix时间戳,表示命令开始运行的时间 * 一个微妙级的时间,显示命令运行的总时间 * 该命令以及所带参数 延迟日志保存在存储器中,因此在生产环境中运行(即使有一个低阀值)也应该不是一个问题。默认情况下,它将会追踪最近的1024个日志。 ### 排序(Sort) `sort`命令是Redis最强大的命令之一。它让你可以在一个列表、集合或者分类集合里对值进行排序(分类集合是通过标记来进行排序,而不是集合里的成员)。下面是一个`sort`命令的简单用例: rpush users:leto:guesses 5 9 10 2 4 10 19 2 sort users:leto:guesses 这将返回进行升序排序后的值。这里有一个更高级的例子: sadd friends:ghanima leto paul chani jessica alia duncan sort friends:ghanima limit 0 3 desc alpha 上面的命令向我们展示了,如何对已排序的记录进行分页(通过`limit`),如何返回降序排序的结果(通过`desc`),以及如何用字典序排序代替数值序排序(通过`alpha`)。 `sort`命令的真正力量是其基于引用对象来进行排序的能力。早先的时候,我们说明了列表、集合和分类集合很常被用于引用其他的Redis对象,`sort`命令能够解引用这些关系,而且通过潜在值来进行排序。例如,假设我们有一个Bug追踪器能让用户看到各类已存在问题。我们可能使用一个集合数据结构去追踪正在被监视的问题: sadd watch:leto 12339 1382 338 9338 你可能会有强烈的感觉,想要通过id来排序这些问题(默认的排序就是这样的),但是,我们更可能是通过问题的严重性来对这些问题进行排序。为此,我们要告诉Redis将使用什么模式来进行排序。首先,为了可以看到一个有意义的结果,让我们添加多一点数据: set severity:12339 3 set severity:1382 2 set severity:338 5 set severity:9338 4 要通过问题的严重性来降序排序这些Bug,你可以这样做: sort watch:leto by severity:* desc Redis将会用存储在列表(集合或分类集合)中的值去替代模式中的`*`(通过`by`)。这会创建出关键字名字,Redis将通过查询其实际值来排序。 在Redis里,虽然你可以有成千上万个关键字,类似上面展示的关系还是会引起一些混乱。幸好,`sort`命令也可以工作在散列数据结构及其相关域里。相对于拥有大量的高层次关键字,你可以利用散列: hset bug:12339 severity 3 hset bug:12339 priority 1 hset bug:12339 details "{id: 12339, ....}" hset bug:1382 severity 2 hset bug:1382 priority 2 hset bug:1382 details "{id: 1382, ....}" hset bug:338 severity 5 hset bug:338 priority 3 hset bug:338 details "{id: 338, ....}" hset bug:9338 severity 4 hset bug:9338 priority 2 hset bug:9338 details "{id: 9338, ....}" 所有的事情不仅变得更为容易管理,而且我们能通过`severity`或`priority`来进行排序,还可以告诉`sort`命令具体要检索出哪一个域的数据: sort watch:leto by bug:*->priority get bug:*->details 相同的值替代出现了,但Redis还能识别`->`符号,用它来查看散列中指定的域。里面还包括了`get`参数,这里也会进行值替代和域查看,从而检索出Bug的细节(details域的数据)。 对于太大的集合,`sort`命令的执行可能会变得很慢。好消息是,`sort`命令的输出可以被存储起来: sort watch:leto by bug:*->priority get bug:*->details store watch_by_priority:leto 使用我们已经看过的`expiration`命令,再结合`sort`命令的`store`能力,这是一个美妙的组合。 ### 小结 这一章主要关注那些非特定数据结构关联的命令。和其他事情一样,它们的使用依情况而定。构建一个程序或特性时,可能不会用到使用期限、发布和订阅或者排序等功能。但知道这些功能的存在是很好的。而且,我们也只接触到了一些命令。还有更多的命令,当你消化理解完这本书后,非常值得去浏览一下[完整的命令列表](http://redis.io/commands)。 \clearpage ## 第5章 - 管理 在最后一章里,我们将集中谈论Redis运行中的一些管理方面内容。这是一个不完整的Redis管理指南,我们将会回答一些基本的问题,初接触Redis的新用户可能会很感兴趣。 ### 配置(Configuration) 当你第一次运行Redis的服务器,它会向你显示一个警告,指`redis.conf`文件没有被找到。这个文件可以被用来配置Redis的各个方面。一个充分定义(well-documented)的`redis.conf`文件对各个版本的Redis都有效。范例文件包含了默认的配置选项,因此,对于想要了解设置在干什么,或默认设置是什么,都会很有用。你可以在<https://github.com/antirez/redis/raw/2.4.6/redis.conf>找到这个文件。 **这个配置文件针对的是Redis 2.4.6,你应该用你的版本号替代上面URL里的"2.4.6"。运行`info`命令,其显示的第一个值就是Redis的版本号。** 因为这个文件已经是充分定义(well-documented),我们就不去再进行设置了。 除了通过`redis.conf`文件来配置Redis,`config set`命令可以用来对个别值进行设置。实际上,在将`slowlog-log-slower-than`设置为0时,我们就已经使用过这个命令了。 还有一个`config get`命令能显示一个设置值。这个命令支持模式匹配,因此如果我们想要显示关联于日志(logging)的所有设置,我们可以这样做: config get *log* ### 验证(Authentication) 通过设置`requirepass`(使用`config set`命令或`redis.conf`文件),可以让Redis需要一个密码验证。当`requirepass`被设置了一个值(就是待用的密码),客户端将需要执行一个`auth password`命令。 一旦一个客户端通过了验证,就可以在任意数据库里执行任何一条命令,包括`flushall`命令,这将会清除掉每一个数据库里的所有关键字。通过配置,你可以重命名一些重要命令为混乱的字符串,从而获得一些安全性。 rename-command CONFIG 5ec4db169f9d4dddacbfb0c26ea7e5ef rename-command FLUSHALL 1041285018a942a4922cbf76623b741e 或者,你可以将新名字设置为一个空字符串,从而禁用掉一个命令。 ### 大小限制(Size Limitations) 当你开始使用Redis,你可能会想知道,我能使用多少个关键字?还可能想知道,一个散列数据结构能有多少个域(尤其是当你用它来组织数据时),或者是,一个列表数据结构或集合数据结构能有多少个元素?对于每一个实例,实际限制都能达到亿万级别(hundreds of millions)。 ### 复制(Replication) Redis支持复制功能,这意味着当你向一个Redis实例(Master)进行写入时,一个或多个其他实例(Slaves)能通过Master实例来保持更新。可以在配置文件里设置`slaveof`,或使用`slaveof`命令来配置一个Slave实例。对于那些没有进行这些设置的Redis实例,就可能一个Master实例。 为了更好保护你的数据,复制功能拷贝数据到不同的服务器。复制功能还能用于改善性能,因为读取请求可以被发送到Slave实例。他们可能会返回一些稍微滞后的数据,但对于大多数程序来说,这是一个值得做的折衷。 遗憾的是,Redis的复制功能还没有提供自动故障恢复。如果Master实例崩溃了,一个Slave实例需要手动的进行升级。如果你想使用Redis去达到某种高可用性,对于使用心跳监控(heartbeat monitoring)和脚本自动开关(scripts to automate the switch)的传统高可用性工具来说,现在还是一个棘手的难题。 ### 备份文件(Backups) 备份Redis非常简单,你可以将Redis的快照(snapshot)拷贝到任何地方,包括S3、FTP等。默认情况下,Redis会把快照存储为一个名为`dump.rdb`的文件。在任何时候,你都可以对这个文件执行`scp`、`ftp`或`cp`等常用命令。 有一种常见情况,在Master实例上会停用快照以及单一附加文件(aof),然后让一个Slave实例去处理备份事宜。这可以帮助减少Master实例的载荷。在不损害整体系统响应性的情况下,你还可以在Slave实例上设置更多主动存储的参数。 ### 缩放和Redis集群(Scaling and Redis Cluster) 复制功能(Replication)是一个成长中的网站可以利用的第一个工具。有一些命令会比另外一些来的昂贵(例如`sort`命令),将这些运行载荷转移到一个Slave实例里,可以保持整体系统对于查询的快速响应。 此外,通过分发你的关键字到多个Redis实例里,可以达到真正的缩放Redis(记住,Redis是单线程的,这些可以运行在同一个逻辑框里)。随着时间的推移,你将需要特别注意这些事情(尽管许多的Redis载体都提供了consistent-hashing算法)。对于数据水平分布(horizontal distribution)的考虑不在这本书所讨论的范围内。这些东西你也很可能不需要去担心,但是,无论你使用哪一种解决方案,有一些事情你还是必须意识到。 好消息是,这些工作都可在Redis集群下进行。不仅提供水平缩放(包括均衡),为了高可用性,还提供了自动故障恢复。 高可用性和缩放是可以达到的,只要你愿意为此付出时间和精力,Redis集群也使事情变得简单多了。 ### 小结 在过去的一段时间里,已经有许多的计划和网站使用了Redis,毫无疑问,Redis已经可以应用于实际生产中了。然而,一些工具还是不够成熟,尤其是一些安全性和可用性相关的工具。对于Redis集群,我们希望很快就能看到其实现,这应该能为一些现有的管理挑战提供处理帮忙。 \clearpage ## 总结 在许多方面,Redis体现了一种简易的数据处理方式,其剥离掉了大部分的复杂性和抽象,并可有效的在不同系统里运行。不少情况下,选择Redis不是最佳的选择。在另一些情况里,Redis就像是为你的数据提供了特别定制的解决方案。 最终,回到我最开始所说的:Redis很容易学习。现在有许多的新技术,很难弄清楚哪些才真正值得我们花时间去学习。如果你从实际好处来考虑,Redis提供了他的简单性。我坚信,对于你和你的团队,学习Redis是最好的技术投资之一。
--- title: The Little Redis Book cn --- \thispagestyle{empty} \changepage{}{}{}{-0.5cm}{}{2cm}{}{}{} ![The Little Redis Book cn, By Karl Seguin, Translate By Jason Lai](title.png)\ \clearpage \changepage{}{}{}{0.5cm}{}{-2cm}{}{}{} ## 关于此书 ### 许可证 《The Little Redis Book》是经由Attribution-NonCommercial 3.0 Unported license许可的,你不需要为此书付钱。 你可以自由地对此书进行复制,分发,修改或者展示等操作。当然,你必须知道且认可这本书的作者是Karl Seguin,译者是赖立维,而且不应该将此书用于商业用途。 关于这个**许可证**的*详细描述*在这里: <http://creativecommons.org/licenses/by-nc/3.0/legalcode> ### 关于作者 作者Karl Seguin是一名在多项技术领域浸淫多年的开发者。他是开源软件计划的活跃贡献者,同时也是一名技术作者以及业余演讲者。他写过若干关于Radis的文章以及一些工具。在他的一个面向业余游戏开发者的免费服务里,Redis为其中的评级和统计功能提供了支持:[mogade.com](http://mogade.com/)。 Karl之前还写了[《The Little MongoDB Book》](http://openmymind.net/2011/3/28/The-Little-MongoDB-Book/),这是一本免费且受好评,关于MongoDB的书。 他的博客是<http://openmymind.net>,你也可以关注他的Twitter帐号,via [@karlseguin](http://twitter.com/karlseguin)。 ### 关于译者 译者 赖立维 是一名长在天朝的普通程序员,对许多技术都有浓厚的兴趣,是开源软件的支持者,Emacs的轻度使用者。 虽然译者已经很认真地对待这次翻译,但是限于水平有限,肯定会有不少错漏,如果发现该书的翻译有什么需要修改,可以通过他的邮箱与他联系。他的邮箱是<[email protected]>。 ### 致谢 必须特别感谢[Perry Neal](https://twitter.com/perryneal)一直以来的指导,我的眼界、触觉以及激情都来源于你。你为我提供了无价的帮助,感谢你。 ### 最新版本 此书的最新有效资源在: <https://github.com/karlseguin/the-little-redis-book> 中文版是英文版的一个分支,最新的中文版本在: <https://github.com/JasonLai256/the-little-redis-book> \clearpage ## 简介 最近几年来,关于持久化和数据查询的相关技术,其需求已经增长到了让人惊讶的程度。可以断言,关系型数据库再也不是放之四海皆准。换一句话说,围绕数据的解决方案不可能再只有唯一一种。 对于我来说,在众多新出现的解决方案和工具里,最让人兴奋的,无疑是Redis。为什么?首先是因为其让人不可思议的容易学习,只需要简短的几个小时学习时间,就能对Redis有个大概的认识。还有,Redis在处理一组特定的问题集的同时能保持相当的通用性。更准确地说就是,Redis不会尝试去解决关于数据的所有事情。在你足够了解Redis后,事情就会变得越来越清晰,什么是可行的,什么是不应该由Redis来处理的。作为一名开发人员,如此的经验当是相当的美妙。 当你能仅使用Redis去构建一个完整系统时,我想大多数人将会发现,Redis能使得他们的许多数据方案变得更为通用,不论是一个传统的关系型数据库,一个面向文档的系统,或是其它更多的东西。这是一种用来实现某些特定特性的解决方法。就类似于一个索引引擎,你不会在Lucene上构建整个程序,但当你需要足够好的搜索,为什么不使用它呢?这对你和你的用户都有好处。当然,关于Redis和索引引擎之间相似性的讨论到此为止。 本书的目的是向读者传授掌握Redis所需要的基本知识。我们将会注重于学习Redis的5种数据结构,并研究各种数据建模方法。我们还会接触到一些主要的管理细节和调试技巧。 ## 入门 每个人的学习方式都不一样,有的人喜欢亲自实践学习,有的喜欢观看教学视频,还有的喜欢通过阅读来学习。对于Redis,没有什么比亲自实践学习来得效果更好的了。Redis的安装非常简单。而且通过随之安装的一个简单的命令解析程序,就能处理我们想做的一切事情。让我们先花几分钟的时间把Redis安装到我们的机器上。 ### Windows平台 Redis并没有官方支持Windows平台,但还是可供选择。你不会想在这里配置实际的生产环境,不过在我过往的开发经历里并没有感到有什么限制。 首先进入<https://github.com/dmajkic/redis/downloads>,然后下载最新的版本(应该会在列表的最上方)。 获取zip文件,然后根据你的系统架构,打开`64bit`或`32bit`文件夹。 ### *nix和MacOSX平台 对于*nix和MacOSX平台的用户,从源文件来安装是你的最佳选择。通过最新的版本号来选择,有效地址于<http://redis.io/download>。在编写此书的时候,最新的版本是2.4.6,我们可以运行下面的命令来安装该版本: wget http://redis.googlecode.com/files/redis-2.4.6.tar.gz tar xzf redis-2.4.6.tar.gz cd redis-2.4.6 make (当然,Redis同样可以通过套件管理程序来安装。例如,使用Homebrew的MaxOSX用户可以只键入`brew install redis`即可。) 如果你是通过源文件来安装,二进制可执行文件会被放置在`src`目录里。通过运行`cd src`可跳转到`src`目录。 ### 运行和连接Redis 如果一切都工作正常,那Redis的二进制文件应该已经可以曼妙地跳跃于你的指尖之下。Redis只有少量的可执行文件,我们将着重于Redis的服务器和命令行界面(一个类DOS的客户端)。首先,让我们来运行服务器。在Windows平台,双击`redis-server`,在*nix/MacOSX平台则运行`./redis-server`. 如果你仔细看了启动信息,你会看到一个警告,指没能找到`redis.conf`文件。Redis将会采用内置的默认设置,这对于我们将要做的已经足够了。 然后,通过双击`redis-cli`(Windows平台)或者运行`./redis-cli`(*nix/MacOSX平台),启动Redis的控制台。控制台将会通过默认的端口(6379)来连接本地运行的服务器。 可以在命令行界面键入`info`命令来查看一切是不是都运行正常。你会很乐意看到这么一大组关键字-值(key-value)对的显示,这为我们查看服务器的状态提供了大量有效信息。 如果在上面的启动步骤里遇到什么问题,我建议你到[Redis的官方支持组](https://groups.google.com/forum/#!forum/redis-db)里获取帮助。 ## 驱动Redis 很快你就会发现,Redis的API就如一组定义明确的函数那般容易理解。Redis具有让人难以置信的简单性,其操作过程也同样如此。这意味着,无论你是使用命令行程序,或是使用你喜欢的语言来驱动,整体的感觉都不会相差多少。因此,相对于命令行程序,如果你更愿意通过一种编程语言去驱动Redis,你不会感觉到有任何适应的问题。如果真想如此,可以到Redis的[客户端推荐页面](http://redis.io/clients)下载适合的Redis载体。 \clearpage ## 第1章 - 基础知识 是什么使Redis显得这么特别?Redis具体能解决什么类型的问题?要实际应用Redis,开发者必须储备什么知识?在我们能回答这么一些问题之前,我们需要明白Redis到底是什么。 Redis通常被人们认为是一种持久化的存储器关键字-值型存储(in-memory persistent key-value store)。我认为这种对Redis的描述并不太准确。Redis的确是将所有的数据存放于存储器(更多是是按位存储),而且也确实通过将数据写入磁盘来实现持久化,但是Redis的实际意义比单纯的关键字-值型存储要来得深远。纠正脑海里的这种误解观点非常关键,否则你对于Redis之道以及其应用的洞察力就会变得越发狭义。 事实是,Redis引入了5种不同的数据结构,只有一个是典型的关键字-值型结构。理解Redis的关键就在于搞清楚这5种数据结构,其工作的原理都是如何,有什么关联方法以及你能怎样应用这些数据结构去构建模型。首先,让我们来弄明白这些数据结构的实际意义。 应用上面提及的数据结构概念到我们熟悉的关系型数据库里,我们可以认为其引入了一个单独的数据结构——表格。表格既复杂又灵活,基于表格的存储和管理,没有多少东西是你不能进行建模的。然而,这种通用性并不是没有缺点。具体来说就是,事情并不是总能达到假设中的简单或者快速。相对于这种普遍适用(one-size-fits-all)的结构体系,我们可以使用更为专门化的结构体系。当然,因此可能有些事情我们会完成不了(至少,达不到很好的程度)。但话说回来,这样做就能确定我们可以获得想象中的简单性和速度吗? 针对特定类型的问题使用特定的数据结构?我们不就是这样进行编程的吗?你不会使用一个散列表去存储每份数据,也不会使用一个标量变量去存储。对我来说,这正是Redis的做法。如果你需要处理标量、列表、散列或者集合,为什么不直接就用标量、列表、散列和集合去存储他们?为什么不是直接调用`exists(key)`去检测一个已存在的值,而是要调用其他比O(1)(常量时间查找,不会因为待处理元素的增长而变慢)慢的操作? ### 数据库(Databases) 与你熟悉的关系型数据库一致,Redis有着相同的数据库基本概念,即一个数据库包含一组数据。典型的数据库应用案例是,将一个程序的所有数据组织起来,使之与另一个程序的数据保持独立。 在Redis里,数据库简单的使用一个数字编号来进行辨认,默认数据库的数字编号是`0`。如果你想切换到一个不同的数据库,你可以使用`select`命令来实现。在命令行界面里键入`select 1`,Redis应该会回复一条`OK`的信息,然后命令行界面里的提示符会变成类似`redis 127.0.0.1:6379[1]>`这样。如果你想切换回默认数据库,只要在命令行界面键入`select 0`即可。 ### 命令、关键字和值(Commands, Keys and Values) Redis不仅仅是一种简单的关键字-值型存储,从其核心概念来看,Redis的5种数据结构中的每一个都至少有一个关键字和一个值。在转入其它关于Redis的有用信息之前,我们必须理解关键字和值的概念。 关键字(Keys)是用来标识数据块。我们将会很常跟关键字打交道,不过在现在,明白关键字就是类似于`users:leto`这样的表述就足够了。一般都能很好地理解到,这样关键字包含的信息是一个名为`leto`的用户。这个关键字里的冒号没有任何特殊含义,对于Redis而言,使用分隔符来组织关键字是很常见的方法。 值(Values)是关联于关键字的实际值,可以是任何东西。有时候你会存储字符串,有时候是整数,还有时候你会存储序列化对象(使用JSON、XML或其他格式)。在大多数情况下,Redis会把值看做是一个字节序列,而不会关注它们实质上是什么。要注意,不同的Redis载体处理序列化会有所不同(一些会让你自己决定)。因此,在这本书里,我们将仅讨论字符串、整数和JSON。 现在让我们活动一下手指吧。在命令行界面键入下面的命令: set users:leto "{name: leto, planet: dune, likes: [spice]}" 这就是Redis命令的基本构成。首先我们要有一个确定的命令,在上面的语句里就是`set`。然后就是相应的参数,`set`命令接受两个参数,包括要设置的关键字,以及相应要设置的值。很多的情况是,命令接受一个关键字(当这种情况出现,其经常是第一个参数)。你能想到如何去获取这个值吗?我想你会说(当然一时拿不准也没什么): get users:leto 关键字和值的是Redis的基本概念,而`get`和`set`命令是对此最简单的使用。你可以创建更多的用户,去尝试不同类型的关键字以及不同的值,看看一些不同的组合。 ### 查询(Querying) 随着学习的持续深入,两件事情将变得清晰起来。对于Redis而言,关键字就是一切,而值是没有任何意义。更通俗来看就是,Redis不允许你通过值来进行查询。回到上面的例子,我们就不能查询生活在`dune`行星上的用户。 对许多人来说,这会引起一些担忧。在我们生活的世界里,数据查询是如此的灵活和强大,而Redis的方式看起来是这么的原始和不高效。不要让这些扰乱你太久。要记住,Redis不是一种普遍使用(one-size-fits-all)的解决方案,确实存在这么一些事情是不应该由Redis来解决的(因为其查询的限制)。事实上,在考虑了这些情况后,你会找到新的方法去构建你的数据。 很快,我们就能看到更多实际的用例。很重要的一点是,我们要明白关于Redis的这些基本事实。这能帮助我们弄清楚为什么值可以是任何东西,因为Redis从来不需要去读取或理解它们。而且,这也可以帮助我们理清思路,然后去思考如何在这个新世界里建立模型。 ### 存储器和持久化(Memory and Persistence) 我们之前提及过,Redis是一种持久化的存储器内存储(in-memory persistent store)。对于持久化,默认情况下,Redis会根据已变更的关键字数量来进行判断,然后在磁盘里创建数据库的快照(snapshot)。你可以对此进行设置,如果X个关键字已变更,那么每隔Y秒存储数据库一次。默认情况下,如果1000个或更多的关键字已变更,Redis会每隔60秒存储数据库;而如果9个或更少的关键字已变更,Redis会每隔15分钟存储数据库。 除了创建磁盘快照外,Redis可以在附加模式下运行。任何时候,如果有一个关键字变更,一个单一附加(append-only)的文件会在磁盘里进行更新。在一些情况里,虽然硬件或软件可能发生错误,但用那60秒有效数据存储去换取更好性能是可以接受的。而在另一些情况里,这种损失就难以让人接受,Redis为你提供了选择。在第5章里,我们将会看到第三种选择,其将持久化任务减荷到一个从属数据库里。 至于存储器,Redis会将所有数据都保留在存储器中。显而易见,运行Redis具有不低的成本:因为RAM仍然是最昂贵的服务器硬件部件。 我很清楚有一些开发者对即使是一点点的数据空间都是那么的敏感。一本《威廉·莎士比亚全集》需要近5.5MB的存储空间。对于缩放的需求,其它的解决方案趋向于IO-bound或者CPU-bound。这些限制(RAM或者IO)将会需要你去理解更多机器实际依赖的数据类型,以及应该如何去进行存储和查询。除非你是存储大容量的多媒体文件到Redis中,否则存储器内存储应该不会是一个问题。如果这对于一个程序是个问题,你就很可能不会用IO-bound的解决方案。 Redis有虚拟存储器的支持。然而,这个功能已经被认为是失败的了(通过Redis的开发者),而且它的使用已经被废弃了。 (从另一个角度来看,一本5.5MB的《威廉·莎士比亚全集》可以通过压缩减小到近2MB。当然,Redis不会自动对值进行压缩,但是因为其将所有值都看作是字节,没有什么限制让你不能对数据进行压缩/解压,通过牺牲处理时间来换取存储空间。) ### 整体来看(Putting It Together) 我们已经接触了好几个高层次的主题。在继续深入Redis之前,我想做的最后一件事情是将这些主题整合起来。这些主题包括,查询的限制,数据结构以及Redis在存储器内存储数据的方法。 当你将这3个主题整合起来,你最终会得出一个绝妙的结论:速度。一些人可能会想,当然Redis会很快速,要知道所以的东西都在存储器里。但这仅仅是其中的一部分,让Redis闪耀的真正原因是其不同于其它解决方案的特殊数据结构。 能有多快速?这依赖于很多东西,包括你正在使用着哪个命令,数据的类型等等。但Redis的性能测试是趋向于数万或数十万次操作**每秒**。你可以通过运行`redis-benchmark`(就在`redis-server`和`redis-cli`的同一个文件夹里)来进行测试。 我曾经试过将一组使用传统模型的代码转向使用Redis。在传统模型里,运行一个我写的载入测试,需要超过5分钟的时间来完成。而在Redis里,只需要150毫秒就完成了。你不会总能得到这么好的收获,但希望这能让你对我们所谈的东西有更清晰的理解。 理解Redis的这个特性很重要,因为这将影响到你如何去与Redis进行交互。拥有SQL背景的程序员通常会致力于让数据库的数据往返次数减至最小。这对于任何系统都是个好建议,包括Redis。然而,考虑到我们是在处理比较简单的数据结构,有时候我们还是需要与Redis服务器频繁交互,以达到我们的目的。刚开始的时候,可能会对这种数据访问模式感到不太自然。实际上,相对于我们通过Redis获得的高性能而言,这仅仅是微不足道的损失。 ### 小结 虽然我们只接触和摆弄了Redis的冰山一角,但我们讨论的主题已然覆盖了很大范围内的东西。如果觉得有些事情还是不太清楚(例如查询),不用为此而担心,在下一章我们将会继续深入探讨,希望你的问题都能得到解答。 这一章的要点包括: * 关键字(Keys)是用于标识一段数据的一个字符串 * 值(Values)是一段任意的字节序列,Redis不会关注它们实质上是什么 * Redis展示了(也实现了)5种专门的数据结构 * 上面的几点使得Redis快速而且容易使用,但要知道Redis并不适用于所有的应用场景 \clearpage ## 第2章 - 数据结构 现在开始将探究Redis的5种数据结构,我们会解释每种数据结构都是什么,包含了什么有效的方法(Method),以及你能用这些数据结构处理哪些类型的特性和数据。 目前为止,我们所知道的Redis构成仅包括命令、关键字和值,还没有接触到关于数据结构的具体概念。当我们使用`set`命令时,Redis是怎么知道我们是在使用哪个数据结构?其解决方法是,每个命令都相对应于一种特定的数据结构。例如,当你使用`set`命令,你就是将值存储到一个字符串数据结构里。而当你使用`hset`命令,你就是将值存储到一个散列数据结构里。考虑到Redis的关键字集很小,这样的机制具有相当的可管理性。 **[Redis的网站](http://redis.io/commands)里有着非常优秀的参考文档,没有任何理由去重造轮子。但为了搞清楚这些数据结构的作用,我们将会覆盖那些必须知道的重要命令。** 没有什么事情比高兴的玩和试验有趣的东西来得更重要的了。在任何时候,你都能通过键入`flushdb`命令将你数据库里的所有值清除掉,因此,不要再那么害羞了,去尝试做些疯狂的事情吧! ### 字符串(Strings) 在Redis里,字符串是最基本的数据结构。当你在思索着关键字-值对时,你就是在思索着字符串数据结构。不要被名字给搞混了,如之前说过的,你的值可以是任何东西。我更喜欢将他们称作“标量”(Scalars),但也许只有我才这样想。 我们已经看到了一个常见的字符串使用案例,即通过关键字存储对象的实例。有时候,你会频繁地用到这类操作: set users:leto "{name: leto, planet: dune, likes: [spice]}" 除了这些外,Redis还有一些常用的操作。例如,`strlen <key>`能用来获取一个关键字对应值的长度;`getrange <key> <start> <end>`将返回指定范围内的关键字对应值;`append <key> <value>`会将value附加到已存在的关键字对应值中(如果该关键字并不存在,则会创建一个新的关键字-值对)。不要犹豫,去试试看这些命令吧。下面是我得到的: > strlen users:leto (integer) 42 > getrange users:leto 27 40 "likes: [spice]" > append users:leto " OVER 9000!!" (integer) 54 现在你可能会想,这很好,但似乎没有什么意义。你不能有效地提取出一段范围内的JSON文件,或者为其附加一些值。你是对的,这里的经验是,一些命令,尤其是关于字符串数据结构的,只有在给定了明确的数据类型后,才会有实际意义。 之前我们知道了,Redis不会去关注你的值是什么东西。通常情况下,这没有错。然而,一些字符串命令是专门为一些类型或值的结构而设计的。作为一个有些含糊的用例,我们可以看到,对于一些自定义的空间效率很高的(space-efficient)串行化对象,`append`和`getrange`命令将会很有用。对于一个更为具体的用例,我们可以再看一下`incr`、`incrby`、`decr`和`decrby`命令。这些命令会增长或者缩减一个字符串数据结构的值: > incr stats:page:about (integer) 1 > incr stats:page:about (integer) 2 > incrby ratings:video:12333 5 (integer) 5 > incrby ratings:video:12333 3 (integer) 8 由此你可以想象到,Redis的字符串数据结构能很好地用于分析用途。你还可以去尝试增长`users:leto`(一个不是整数的值),然后看看会发生什么(应该会得到一个错误)。 更为进阶的用例是`setbit`和`getbit`命令。“今天我们有多少个独立用户访问”是个在Web应用里常见的问题,有一篇[精彩的博文](http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/),在里面可以看到Spool是如何使用这两个命令有效地解决此问题。对于1.28亿个用户,一部笔记本电脑在不到50毫秒的时间里就给出了答复,而且只用了16MB的存储空间。 最重要的事情不是在于你是否明白位图(Bitmaps)的工作原理,或者Spool是如何去使用这些命令,而是应该要清楚Redis的字符串数据结构比你当初所想的要有用许多。然而,最常见的应用案例还是上面我们给出的:存储对象(简单或复杂)和计数。同时,由于通过关键字来获取一个值是如此之快,字符串数据结构很常被用来缓存数据。 ### 散列(Hashes) 我们已经知道把Redis称为一种关键字-值型存储是不太准确的,散列数据结构是一个很好的例证。你会看到,在很多方面里,散列数据结构很像字符串数据结构。两者显著的区别在于,散列数据结构提供了一个额外的间接层:一个域(Field)。因此,散列数据结构中的`set`和`get`是: hset users:goku powerlevel 9000 hget users:goku powerlevel 相关的操作还包括在同一时间设置多个域、同一时间获取多个域、获取所有的域和值、列出所有的域或者删除指定的一个域: hmset users:goku race saiyan age 737 hmget users:goku race powerlevel hgetall users:goku hkeys users:goku hdel users:goku age 如你所见,散列数据结构比普通的字符串数据结构具有更多的可操作性。我们可以使用一个散列数据结构去获得更精确的描述,是存储一个用户,而不是一个序列化对象。从而得到的好处是能够提取、更新和删除具体的数据片段,而不必去获取或写入整个值。 对于散列数据结构,可以从一个经过明确定义的对象的角度来考虑,例如一个用户,关键之处在于要理解他们是如何工作的。从性能上的原因来看,这是正确的,更具粒度化的控制可能会相当有用。在下一章我们将会看到,如何用散列数据结构去组织你的数据,使查询变得更为实效。在我看来,这是散列真正耀眼的地方。 ### 列表(Lists) 对于一个给定的关键字,列表数据结构让你可以存储和处理一组值。你可以添加一个值到列表里、获取列表的第一个值或最后一个值以及用给定的索引来处理值。列表数据结构维护了值的顺序,提供了基于索引的高效操作。为了跟踪在网站里注册的最新用户,我们可以维护一个`newusers`的列表: lpush newusers goku ltrim newusers 0 50 **(译注:`ltrim`命令的具体构成是`LTRIM Key start stop`。要理解`ltrim`命令,首先要明白Key所存储的值是一个列表,理论上列表可以存放任意个值。对于指定的列表,根据所提供的两个范围参数start和stop,`ltrim`命令会将指定范围外的值都删除掉,只留下范围内的值。)** 首先,我们将一个新用户推入到列表的前端,然后对列表进行调整,使得该列表只包含50个最近被推入的用户。这是一种常见的模式。`ltrim`是一个具有O(N)时间复杂度的操作,N是被删除的值的数量。从上面的例子来看,我们总是在插入了一个用户后再进行列表调整,实际上,其将具有O(1)的时间复杂度(因为N将永远等于1)的常数性能。 这是我们第一次看到一个关键字的对应值索引另一个值。如果我们想要获取最近的10个用户的详细资料,我们可以运行下面的组合操作: keys = redis.lrange('newusers', 0, 10) redis.mget(*keys.map {|u| "users:#{u}"}) 我们之前谈论过关于多次往返数据的模式,上面的两行Ruby代码为我们进行了很好的演示。 当然,对于存储和索引关键字的功能,并不是只有列表数据结构这种方式。值可以是任意的东西,你可以使用列表数据结构去存储日志,也可以用来跟踪用户浏览网站时的路径。如果你过往曾构建过游戏,你可能会使用列表数据结构去跟踪用户的排队活动。 ### 集合 集合数据结构常常被用来存储只能唯一存在的值,并提供了许多的基于集合的操作,例如并集。集合数据结构没有对值进行排序,但是其提供了高效的基于值的操作。使用集合数据结构的典型用例是朋友名单的实现: sadd friends:leto ghanima paul chani jessica sadd friends:duncan paul jessica alia 不管一个用户有多少个朋友,我们都能高效地(O(1)时间复杂度)识别出用户X是不是用户Y的朋友: sismember friends:leto jessica sismember friends:leto vladimir 而且,我们可以查看两个或更多的人是不是有共同的朋友: sinter friends:leto friends:duncan 甚至可以在一个新的关键字里存储结果: sinterstore friends:leto_duncan friends:leto friends:duncan 有时候需要对值的属性进行标记和跟踪处理,但不能通过简单的复制操作完成,集合数据结构是解决此类问题的最好方法之一。当然,对于那些需要运用集合操作的地方(例如交集和并集),集合数据结构就是最好的选择。 ### 分类集合(Sorted Sets) 最后也是最强大的数据结构是分类集合数据结构。如果说散列数据结构类似于字符串数据结构,主要区分是域(field)的概念;那么分类集合数据结构就类似于集合数据结构,主要区分是标记(score)的概念。标记提供了排序(sorting)和秩划分(ranking)的功能。如果我们想要一个秩分类的朋友名单,可以这样做: zadd friends:duncan 70 ghanima 95 paul 95 chani 75 jessica 1 vladimir 对于`duncan`的朋友,要怎样计算出标记(score)为90或更高的人数? zcount friends:duncan 90 100 如何获取`chani`在名单里的秩(rank)? zrevrank friends:duncan chani **(译注:`zrank`命令的具体构成是`ZRANK Key menber`,要知道Key存储的Sorted Set默认是根据Score对各个menber进行升序的排列,该命令就是用来获取menber在该排列里的次序,这就是所谓的秩。)** 我们使用了`zrevrank`命令而不是`zrank`命令,这是因为Redis的默认排序是从低到高,但是在这个例子里我们的秩划分是从高到低。对于分类集合数据结构,最常见的应用案例是用来实现排行榜系统。事实上,对于一些基于整数排序,且能以标记(score)来进行有效操作的东西,使用分类集合数据结构来处理应该都是不错的选择。 ### 小结 对于Redis的5种数据结构,我们进行了高层次的概述。一件有趣的事情是,相对于最初构建时的想法,你经常能用Redis创造出一些更具实效的事情。对于字符串数据结构和分类集合数据结构的使用,很有可能存在一些构建方法是还没有人想到的。当你理解了那些常用的应用案例后,你将发现Redis对于许多类型的问题,都是很理想的选择。还有,不要因为Redis展示了5种数据结构和相应的各种方法,就认为你必须要把所有的东西都用上。只使用一些命令去构建一个特性是很常见的。 \clearpage ## 第3章 - 使用数据结构 在上一章里,我们谈论了Redis的5种数据结构,对于一些可能的用途也给出了用例。现在是时候来看看一些更高级,但依然很常见的主题和设计模式。 ### 大O表示法(Big O Notation) 在本书中,我们之前就已经看到过大O表示法,包括O(1)和O(N)的表示。大O表示法的惯常用途是,描述一些用于处理一定数量元素的行为的综合表现。在Redis里,对于一个要处理一定数量元素的命令,大O表示法让我们能了解该命令的大概运行速度。 在Redis的文档里,每一个命令的时间复杂度都用大O表示法进行了描述,还能知道各命令的具体性能会受什么因素影响。让我们来看看一些用例。 常数时间复杂度O(1)被认为是最快速的,无论我们是在处理5个元素还是5百万个元素,最终都能得到相同的性能。对于`sismember`命令,其作用是告诉我们一个值是否属于一个集合,时间复杂度为O(1)。`sismember`命令很强大,很大部分的原因是其高效的性能特征。许多Redis命令都具有O(1)的时间复杂度。 对数时间复杂度O(log(N))被认为是第二快速的,其通过使需扫描的区间不断皱缩来快速完成处理。使用这种“分而治之”的方式,大量的元素能在几个迭代过程里被快速分解完整。`zadd`命令的时间复杂度就是O(log(N)),其中N是在分类集合中的元素数量。 再下来就是线性时间复杂度O(N),在一个表格的非索引列里进行查找就需要O(N)次操作。`ltrim`命令具有O(N)的时间复杂度,但是,在`ltrim`命令里,N不是列表所拥有的元素数量,而是被删除的元素数量。从一个具有百万元素的列表里用`ltrim`命令删除1个元素,要比从一个具有一千个元素的列表里用`ltrim`命令删除10个元素来的快速(实际上,两者很可能会是一样快,因为两个时间都非常的小)。 根据给定的最小和最大的值的标记,`zremrangebyscore`命令会在一个分类集合里进行删除元素操作,其时间复杂度是O(log(N)+M)。这看起来似乎有点儿杂乱,通过阅读文档可以知道,这里的N指的是在分类集合里的总元素数量,而M则是被删除的元素数量。可以看出,对于性能而言,被删除的元素数量很可能会比分类集合里的总元素数量更为重要。 **(译注:`zremrangebyscore`命令的具体构成是`ZREMRANGEBYSCORE Key max mix`。)** 对于`sort`命令,其时间复杂度为O(N+M*log(M)),我们将会在下一章谈论更多的相关细节。从`sort`命令的性能特征来看,可以说这是Redis里最复杂的一个命令。 还存在其他的时间复杂度描述,包括O(N^2)和O(C^N)。随着N的增大,其性能将急速下降。在Redis里,没有任何一个命令具有这些类型的时间复杂度。 值得指出的一点是,在Redis里,当我们发现一些操作具有O(N)的时间复杂度时,我们可能可以找到更为好的方法去处理。 **(译注:对于Big O Notation,相信大家都非常的熟悉,虽然原文仅仅是对该表示法进行简单的介绍,但限于个人的算法知识和文笔水平实在有限,此小节的翻译让我头痛颇久,最终成果也确实难以让人满意,望见谅。)** ### 仿多关键字查询(Pseudo Multi Key Queries) 时常,你会想通过不同的关键字去查询相同的值。例如,你会想通过电子邮件(当用户开始登录时)去获取用户的具体信息,或者通过用户id(在用户登录后)去获取。有一种很不实效的解决方法,其将用户对象分别放置到两个字符串值里去: set users:[email protected] "{id: 9001, email: '[email protected]', ...}" set users:9001 "{id: 9001, email: '[email protected]', ...}" 这种方法很糟糕,如此不但会产生两倍数量的内存,而且这将会成为数据管理的恶梦。 如果Redis允许你将一个关键字链接到另一个的话,可能情况会好很多,可惜Redis并没有提供这样的功能(而且很可能永远都不会提供)。Redis发展到现在,其开发的首要目的是要保持代码和API的整洁简单,关键字链接功能的内部实现并不符合这个前提(对于关键字,我们还有很多相关方法没有谈论到)。其实,Redis已经提供了解决的方法:散列。 使用散列数据结构,我们可以摆脱重复的缠绕: set users:9001 "{id: 9001, email: [email protected], ...}" hset users:lookup:email [email protected] 9001 我们所做的是,使用域来作为一个二级索引,然后去引用单个用户对象。要通过id来获取用户信息,我们可以使用一个普通的`get`命令: get users:9001 而如果想通过电子邮箱来获取用户信息,我们可以使用`hget`命令再配合使用`get`命令(Ruby代码): id = redis.hget('users:lookup:email', '[email protected]') user = redis.get("users:#{id}") 你很可能将会经常使用这类用法。在我看来,这就是散列真正耀眼的地方。在你了解这类用法之前,这可能不是一个明显的用例。 ### 引用和索引(References and Indexes) 我们已经看过几个关于值引用的用例,包括介绍列表数据结构时的用例,以及在上面使用散列数据结构来使查询更灵活一些。进行归纳后会发现,对于那些值与值间的索引和引用,我们都必须手动的去管理。诚实来讲,这确实会让人有点沮丧,尤其是当你想到那些引用相关的操作,如管理、更新和删除等,都必须手动的进行时。在Redis里,这个问题还没有很好的解决方法。 我们已经看到,集合数据结构很常被用来实现这类索引: sadd friends:leto ghanima paul chani jessica 这个集合里的每一个成员都是一个Redis字符串数据结构的引用,而每一个引用的值则包含着用户对象的具体信息。那么如果`chani`改变了她的名字,或者删除了她的帐号,应该如何处理?从整个朋友圈的关系结构来看可能会更好理解,我们知道,`chani`也有她的朋友: sadd friends_of:chani leto paul 如果你有什么待处理情况像上面那样,那在维护成本之外,还会有对于额外索引值的处理和存储空间的成本。这可能会令你感到有点退缩。在下一小节里,我们将会谈论减少使用额外数据交互的性能成本的一些方法(在第1章我们粗略地讨论了下)。 如果你确实在担忧着这些情况,其实,关系型数据库也有同样的开销。索引需要一定的存储空间,必须通过扫描或查找,然后才能找到相应的记录。其开销也是存在的,当然他们对此做了很多的优化工作,使之变得更为有效。 再次说明,需要在Redis里手动地管理引用确实是颇为棘手。但是,对于你关心的那些问题,包括性能或存储空间等,应该在经过测试后,才会有真正的理解。我想你会发现这不会是一个大问题。 ### 数据交互和流水线(Round Trips and Pipelining) 我们已经提到过,与服务器频繁交互是Redis的一种常见模式。这类情况可能很常出现,为了使我们能获益更多,值得仔细去看看我们能利用哪些特性。 许多命令能接受一个或更多的参数,也有一种关联命令(sister-command)可以接受多个参数。例如早前我们看到过`mget`命令,接受多个关键字,然后返回值: keys = redis.lrange('newusers', 0, 10) redis.mget(*keys.map {|u| "users:#{u}"}) 或者是`sadd`命令,能添加一个或多个成员到集合里: sadd friends:vladimir piter sadd friends:paul jessica leto "leto II" chani Redis还支持流水线功能。通常情况下,当一个客户端发送请求到Redis后,在发送下一个请求之前必须等待Redis的答复。使用流水线功能,你可以发送多个请求,而不需要等待Redis响应。这不但减少了网络开销,还能获得性能上的显著提高。 值得一提的是,Redis会使用存储器去排列命令,因此批量执行命令是一个好主意。至于具体要多大的批量,将取决于你要使用什么命令(更明确来说,该参数有多大)。另一方面来看,如果你要执行的命令需要差不多50个字符的关键字,你大概可以对此进行数千或数万的批量操作。 对于不同的Redis载体,在流水线里运行命令的方式会有所差异。在Ruby里,你传递一个代码块到`pipelined`方法: redis.pipelined do 9001.times do redis.incr('powerlevel') end end 正如你可能猜想到的,流水线功能可以实际地加速一连串命令的处理。 ### 事务(Transactions) 每一个Redis命令都具有原子性,包括那些一次处理多项事情的命令。此外,对于使用多个命令,Redis支持事务功能。 你可能不知道,但Redis实际上是单线程运行的,这就是为什么每一个Redis命令都能够保证具有原子性。当一个命令在执行时,没有其他命令会运行(我们会在往后的章节里简略谈论一下Scaling)。在你考虑到一些命令去做多项事情时,这会特别的有用。例如: `incr`命令实际上就是一个`get`命令然后紧随一个`set`命令。 `getset`命令设置一个新的值然后返回原始值。 `setnx`命令首先测试关键字是否存在,只有当关键字不存在时才设置值 虽然这些都很有用,但在实际开发时,往往会需要运行具有原子性的一组命令。若要这样做,首先要执行`multi`命令,紧随其后的是所有你想要执行的命令(作为事务的一部分),最后执行`exec`命令去实际执行命令,或者使用`discard`命令放弃执行命令。Redis的事务功能保证了什么? * 事务中的命令将会按顺序地被执行 * 事务中的命令将会如单个原子操作般被执行(没有其它的客户端命令会在中途被执行) * 事务中的命令要么全部被执行,要么不会执行 你可以(也应该)在命令行界面对事务功能进行一下测试。还有一点要注意到,没有什么理由不能结合流水线功能和事务功能。 multi hincrby groups:1percent balance -9000000000 hincrby groups:99percent balance 9000000000 exec 最后,Redis能让你指定一个关键字(或多个关键字),当关键字有改变时,可以查看或者有条件地应用一个事务。这是用于当你需要获取值,且待运行的命令基于那些值时,所有都在一个事务里。对于上面展示的代码,我们不能去实现自己的`incr`命令,因为一旦`exec`命令被调用,他们会全部被执行在一块。我们不能这么做: redis.multi() current = redis.get('powerlevel') redis.set('powerlevel', current + 1) redis.exec() **(译注:虽然Redis是单线程运行的,但是我们可以同时运行多个Redis客户端进程,常见的并发问题还是会出现。像上面的代码,在`get`运行之后,`set`运行之前,`powerlevel`的值可能会被另一个Redis客户端给改变,从而造成错误。)** 这些不是Redis的事务功能的工作。但是,如果我们增加一个`watch`到`powerlevel`,我们可以这样做: redis.watch('powerlevel') current = redis.get('powerlevel') redis.multi() redis.set('powerlevel', current + 1) redis.exec() 在我们调用`watch`后,如果另一个客户端改变了`powerlevel`的值,我们的事务将会运行失败。如果没有客户端改变`powerlevel`的值,那么事务会继续工作。我们可以在一个循环里运行这些代码,直到其能正常工作。 ### 关键字反模式(Keys Anti-Pattern) 在下一章中,我们将会谈论那些没有确切关联到数据结构的命令,其中的一些是管理或调试工具。然而有一个命令我想特别地在这里进行谈论:`keys`命令。这个命令需要一个模式,然后查找所有匹配的关键字。这个命令看起来很适合一些任务,但这不应该用在实际的产品代码里。为什么?因为这个命令通过线性扫描所有的关键字来进行匹配。或者,简单地说,这个命令太慢了。 人们会如此去使用这个命令?一般会用来构建一个本地的Bug追踪服务。每一个帐号都有一个`id`,你可能会通过一个看起来像`bug:account_id:bug_id`的关键字,把每一个Bug存储到一个字符串数据结构值中去。如果你在任何时候需要查询一个帐号的Bug(显示它们,或者当用户删除了帐号时删除掉这些Bugs),你可能会尝试去使用`keys`命令: keys bug:1233:* 更好的解决方法应该使用一个散列数据结构,就像我们可以使用散列数据结构来提供一种方法去展示二级索引,因此我们可以使用域来组织数据: hset bugs:1233 1 "{id:1, account: 1233, subject: '...'}" hset bugs:1233 2 "{id:2, account: 1233, subject: '...'}" 从一个帐号里获取所有的Bug标识,可以简单地调用`hkeys bugs:1233`。去删除一个指定的Bug,可以调用`hdel bugs:1233 2`。如果要删除了一个帐号,可以通过`del bugs:1233`把关键字删除掉。 ### 小结 结合这一章以及前一章,希望能让你得到一些洞察力,了解如何使用Redis去支持(Power)实际项目。还有其他的模式可以让你去构建各种类型的东西,但真正的关键是要理解基本的数据结构。你将能领悟到,这些数据结构是如何能够实现你最初视角之外的东西。 \clearpage ## 第4章 超越数据结构 5种数据结构组成了Redis的基础,其他没有关联特定数据结构的命令也有很多。我们已经看过一些这样的命令:`info`, `select`, `flushdb`, `multi`, `exec`, `discard`, `watch`和`keys `。这一章将看看其他的一些重要命令。 ### 使用期限(Expiration) Redis允许你标记一个关键字的使用期限。你可以给予一个Unix时间戳形式(自1970年1月1日起)的绝对时间,或者一个基于秒的存活时间。这是一个基于关键字的命令,因此其不在乎关键字表示的是哪种类型的数据结构。 expire pages:about 30 expireat pages:about 1356933600 第一个命令将会在30秒后删除掉关键字(包括其关联的值)。第二个命令则会在2012年12月31日上午12点删除掉关键字。 这让Redis能成为一个理想的缓冲引擎。通过`ttl`命令,你可以知道一个关键字还能够存活多久。而通过`persist`命令,你可以把一个关键字的使用期限删除掉。 ttl pages:about persist pages:about 最后,有个特殊的字符串命令,`setex`命令让你可以在一个单独的原子命令里设置一个字符串值,同时里指定一个生存期(这比任何事情都要方便)。 setex pages:about 30 '<h1>about us</h1>....' ### 发布和订阅(Publication and Subscriptions) Redis的列表数据结构有`blpop`和`brpop`命令,能从列表里返回且删除第一个(或最后一个)元素,或者被堵塞,直到有一个元素可供操作。这可以用来实现一个简单的队列。 **(译注:对于`blpop`和`brpop`命令,如果列表里没有关键字可供操作,连接将被堵塞,直到有另外的Redis客户端使用`lpush`或`rpush`命令推入关键字为止。)** 此外,Redis对于消息发布和频道订阅有着一流的支持。你可以打开第二个`redis-cli`窗口,去尝试一下这些功能。在第一个窗口里订阅一个频道(我们会称它为`warnings`): subscribe warnings 其将会答复你订阅的信息。现在,在另一个窗口,发布一条消息到`warnings`频道: publish warnings "it's over 9000!" 如果你回到第一个窗口,你应该已经接收到`warnings`频道发来的消息。 你可以订阅多个频道(`subscribe channel1 channel2 ...`),订阅一组基于模式的频道(`psubscribe warnings:*`),以及使用`unsubscribe`和`punsubscribe`命令停止监听一个或多个频道,或一个频道模式。 最后,可以注意到`publish`命令的返回值是1,这指出了接收到消息的客户端数量。 ### 监控和延迟日志(Monitor and Slow Log) `monitor`命令可以让你查看Redis正在做什么。这是一个优秀的调试工具,能让你了解你的程序如何与Redis进行交互。在两个`redis-cli`窗口中选一个(如果其中一个还处于订阅状态,你可以使用`unsubscribe`命令退订,或者直接关掉窗口再重新打开一个新窗口)键入`monitor`命令。在另一个窗口,执行任何其他类型的命令(例如`get`或`set`命令)。在第一个窗口里,你应该可以看到这些命令,包括他们的参数。 在实际生产环境里,你应该谨慎运行`monitor`命令,这真的仅仅就是一个很有用的调试和开发工具。除此之外,没有更多要说的了。 随同`monitor`命令一起,Redis拥有一个`slowlog`命令,这是一个优秀的性能剖析工具。其会记录执行时间超过一定数量**微秒**的命令。在下一章节,我们会简略地涉及如何配置Redis,现在你可以按下面的输入配置Redis去记录所有的命令: config set slowlog-log-slower-than 0 然后,执行一些命令。最后,你可以检索到所有日志,或者检索最近的那些日志: slowlog get slowlog get 10 通过键入`slowlog len`,你可以获取延迟日志里的日志数量。 对于每个被你键入的命令,你应该查看4个参数: * 一个自动递增的id * 一个Unix时间戳,表示命令开始运行的时间 * 一个微妙级的时间,显示命令运行的总时间 * 该命令以及所带参数 延迟日志保存在存储器中,因此在生产环境中运行(即使有一个低阀值)也应该不是一个问题。默认情况下,它将会追踪最近的1024个日志。 ### 排序(Sort) `sort`命令是Redis最强大的命令之一。它让你可以在一个列表、集合或者分类集合里对值进行排序(分类集合是通过标记来进行排序,而不是集合里的成员)。下面是一个`sort`命令的简单用例: rpush users:leto:guesses 5 9 10 2 4 10 19 2 sort users:leto:guesses 这将返回进行升序排序后的值。这里有一个更高级的例子: sadd friends:ghanima leto paul chani jessica alia duncan sort friends:ghanima limit 0 3 desc alpha 上面的命令向我们展示了,如何对已排序的记录进行分页(通过`limit`),如何返回降序排序的结果(通过`desc`),以及如何用字典序排序代替数值序排序(通过`alpha`)。 `sort`命令的真正力量是其基于引用对象来进行排序的能力。早先的时候,我们说明了列表、集合和分类集合很常被用于引用其他的Redis对象,`sort`命令能够解引用这些关系,而且通过潜在值来进行排序。例如,假设我们有一个Bug追踪器能让用户看到各类已存在问题。我们可能使用一个集合数据结构去追踪正在被监视的问题: sadd watch:leto 12339 1382 338 9338 你可能会有强烈的感觉,想要通过id来排序这些问题(默认的排序就是这样的),但是,我们更可能是通过问题的严重性来对这些问题进行排序。为此,我们要告诉Redis将使用什么模式来进行排序。首先,为了可以看到一个有意义的结果,让我们添加多一点数据: set severity:12339 3 set severity:1382 2 set severity:338 5 set severity:9338 4 要通过问题的严重性来降序排序这些Bug,你可以这样做: sort watch:leto by severity:* desc Redis将会用存储在列表(集合或分类集合)中的值去替代模式中的`*`(通过`by`)。这会创建出关键字名字,Redis将通过查询其实际值来排序。 在Redis里,虽然你可以有成千上万个关键字,类似上面展示的关系还是会引起一些混乱。幸好,`sort`命令也可以工作在散列数据结构及其相关域里。相对于拥有大量的高层次关键字,你可以利用散列: hset bug:12339 severity 3 hset bug:12339 priority 1 hset bug:12339 details "{id: 12339, ....}" hset bug:1382 severity 2 hset bug:1382 priority 2 hset bug:1382 details "{id: 1382, ....}" hset bug:338 severity 5 hset bug:338 priority 3 hset bug:338 details "{id: 338, ....}" hset bug:9338 severity 4 hset bug:9338 priority 2 hset bug:9338 details "{id: 9338, ....}" 所有的事情不仅变得更为容易管理,而且我们能通过`severity`或`priority`来进行排序,还可以告诉`sort`命令具体要检索出哪一个域的数据: sort watch:leto by bug:*->priority get bug:*->details 相同的值替代出现了,但Redis还能识别`->`符号,用它来查看散列中指定的域。里面还包括了`get`参数,这里也会进行值替代和域查看,从而检索出Bug的细节(details域的数据)。 对于太大的集合,`sort`命令的执行可能会变得很慢。好消息是,`sort`命令的输出可以被存储起来: sort watch:leto by bug:*->priority get bug:*->details store watch_by_priority:leto 使用我们已经看过的`expiration`命令,再结合`sort`命令的`store`能力,这是一个美妙的组合。 ### 小结 这一章主要关注那些非特定数据结构关联的命令。和其他事情一样,它们的使用依情况而定。构建一个程序或特性时,可能不会用到使用期限、发布和订阅或者排序等功能。但知道这些功能的存在是很好的。而且,我们也只接触到了一些命令。还有更多的命令,当你消化理解完这本书后,非常值得去浏览一下[完整的命令列表](http://redis.io/commands)。 \clearpage ## 第5章 - 管理 在最后一章里,我们将集中谈论Redis运行中的一些管理方面内容。这是一个不完整的Redis管理指南,我们将会回答一些基本的问题,初接触Redis的新用户可能会很感兴趣。 ### 配置(Configuration) 当你第一次运行Redis的服务器,它会向你显示一个警告,指`redis.conf`文件没有被找到。这个文件可以被用来配置Redis的各个方面。一个充分定义(well-documented)的`redis.conf`文件对各个版本的Redis都有效。范例文件包含了默认的配置选项,因此,对于想要了解设置在干什么,或默认设置是什么,都会很有用。你可以在<https://github.com/antirez/redis/raw/2.4.6/redis.conf>找到这个文件。 **这个配置文件针对的是Redis 2.4.6,你应该用你的版本号替代上面URL里的"2.4.6"。运行`info`命令,其显示的第一个值就是Redis的版本号。** 因为这个文件已经是充分定义(well-documented),我们就不去再进行设置了。 除了通过`redis.conf`文件来配置Redis,`config set`命令可以用来对个别值进行设置。实际上,在将`slowlog-log-slower-than`设置为0时,我们就已经使用过这个命令了。 还有一个`config get`命令能显示一个设置值。这个命令支持模式匹配,因此如果我们想要显示关联于日志(logging)的所有设置,我们可以这样做: config get *log* ### 验证(Authentication) 通过设置`requirepass`(使用`config set`命令或`redis.conf`文件),可以让Redis需要一个密码验证。当`requirepass`被设置了一个值(就是待用的密码),客户端将需要执行一个`auth password`命令。 一旦一个客户端通过了验证,就可以在任意数据库里执行任何一条命令,包括`flushall`命令,这将会清除掉每一个数据库里的所有关键字。通过配置,你可以重命名一些重要命令为混乱的字符串,从而获得一些安全性。 rename-command CONFIG 5ec4db169f9d4dddacbfb0c26ea7e5ef rename-command FLUSHALL 1041285018a942a4922cbf76623b741e 或者,你可以将新名字设置为一个空字符串,从而禁用掉一个命令。 ### 大小限制(Size Limitations) 当你开始使用Redis,你可能会想知道,我能使用多少个关键字?还可能想知道,一个散列数据结构能有多少个域(尤其是当你用它来组织数据时),或者是,一个列表数据结构或集合数据结构能有多少个元素?对于每一个实例,实际限制都能达到亿万级别(hundreds of millions)。 ### 复制(Replication) Redis支持复制功能,这意味着当你向一个Redis实例(Master)进行写入时,一个或多个其他实例(Slaves)能通过Master实例来保持更新。可以在配置文件里设置`slaveof`,或使用`slaveof`命令来配置一个Slave实例。对于那些没有进行这些设置的Redis实例,就可能一个Master实例。 为了更好保护你的数据,复制功能拷贝数据到不同的服务器。复制功能还能用于改善性能,因为读取请求可以被发送到Slave实例。他们可能会返回一些稍微滞后的数据,但对于大多数程序来说,这是一个值得做的折衷。 遗憾的是,Redis的复制功能还没有提供自动故障恢复。如果Master实例崩溃了,一个Slave实例需要手动的进行升级。如果你想使用Redis去达到某种高可用性,对于使用心跳监控(heartbeat monitoring)和脚本自动开关(scripts to automate the switch)的传统高可用性工具来说,现在还是一个棘手的难题。 ### 备份文件(Backups) 备份Redis非常简单,你可以将Redis的快照(snapshot)拷贝到任何地方,包括S3、FTP等。默认情况下,Redis会把快照存储为一个名为`dump.rdb`的文件。在任何时候,你都可以对这个文件执行`scp`、`ftp`或`cp`等常用命令。 有一种常见情况,在Master实例上会停用快照以及单一附加文件(aof),然后让一个Slave实例去处理备份事宜。这可以帮助减少Master实例的载荷。在不损害整体系统响应性的情况下,你还可以在Slave实例上设置更多主动存储的参数。 ### 缩放和Redis集群(Scaling and Redis Cluster) 复制功能(Replication)是一个成长中的网站可以利用的第一个工具。有一些命令会比另外一些来的昂贵(例如`sort`命令),将这些运行载荷转移到一个Slave实例里,可以保持整体系统对于查询的快速响应。 此外,通过分发你的关键字到多个Redis实例里,可以达到真正的缩放Redis(记住,Redis是单线程的,这些可以运行在同一个逻辑框里)。随着时间的推移,你将需要特别注意这些事情(尽管许多的Redis载体都提供了consistent-hashing算法)。对于数据水平分布(horizontal distribution)的考虑不在这本书所讨论的范围内。这些东西你也很可能不需要去担心,但是,无论你使用哪一种解决方案,有一些事情你还是必须意识到。 好消息是,这些工作都可在Redis集群下进行。不仅提供水平缩放(包括均衡),为了高可用性,还提供了自动故障恢复。 高可用性和缩放是可以达到的,只要你愿意为此付出时间和精力,Redis集群也使事情变得简单多了。 ### 小结 在过去的一段时间里,已经有许多的计划和网站使用了Redis,毫无疑问,Redis已经可以应用于实际生产中了。然而,一些工具还是不够成熟,尤其是一些安全性和可用性相关的工具。对于Redis集群,我们希望很快就能看到其实现,这应该能为一些现有的管理挑战提供处理帮忙。 \clearpage ## 总结 在许多方面,Redis体现了一种简易的数据处理方式,其剥离掉了大部分的复杂性和抽象,并可有效的在不同系统里运行。不少情况下,选择Redis不是最佳的选择。在另一些情况里,Redis就像是为你的数据提供了特别定制的解决方案。 最终,回到我最开始所说的:Redis很容易学习。现在有许多的新技术,很难弄清楚哪些才真正值得我们花时间去学习。如果你从实际好处来考虑,Redis提供了他的简单性。我坚信,对于你和你的团队,学习Redis是最好的技术投资之一。
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./hugolib/page__per_output.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "bytes" "context" "fmt" "html/template" "runtime/debug" "strings" "sync" "unicode/utf8" "github.com/gohugoio/hugo/identity" "github.com/gohugoio/hugo/markup/converter/hooks" "github.com/gohugoio/hugo/markup/converter" "github.com/gohugoio/hugo/lazy" bp "github.com/gohugoio/hugo/bufferpool" "github.com/gohugoio/hugo/tpl" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/output" "github.com/gohugoio/hugo/resources/page" "github.com/gohugoio/hugo/resources/resource" ) var ( nopTargetPath = targetPathsHolder{} nopPagePerOutput = struct { resource.ResourceLinksProvider page.ContentProvider page.PageRenderProvider page.PaginatorProvider page.TableOfContentsProvider page.AlternativeOutputFormatsProvider targetPather }{ page.NopPage, page.NopPage, page.NopPage, page.NopPage, page.NopPage, page.NopPage, nopTargetPath, } ) var pageContentOutputDependenciesID = identity.KeyValueIdentity{Key: "pageOutput", Value: "dependencies"} func newPageContentOutput(p *pageState, po *pageOutput) (*pageContentOutput, error) { parent := p.init var dependencyTracker identity.Manager if p.s.running() { dependencyTracker = identity.NewManager(pageContentOutputDependenciesID) } cp := &pageContentOutput{ dependencyTracker: dependencyTracker, p: p, f: po.f, renderHooks: &renderHooks{}, } initContent := func() (err error) { p.s.h.IncrContentRender() if p.cmap == nil { // Nothing to do. return nil } defer func() { // See https://github.com/gohugoio/hugo/issues/6210 if r := recover(); r != nil { err = fmt.Errorf("%s", r) p.s.Log.Errorf("[BUG] Got panic:\n%s\n%s", r, string(debug.Stack())) } }() if err := po.initRenderHooks(); err != nil { return err } var hasShortcodeVariants bool f := po.f cp.contentPlaceholders, hasShortcodeVariants, err = p.shortcodeState.renderShortcodesForPage(p, f) if err != nil { return err } enableReuse := !(hasShortcodeVariants || cp.renderHooksHaveVariants) if enableReuse { // Reuse this for the other output formats. // We may improve on this, but we really want to avoid re-rendering the content // to all output formats. // The current rule is that if you need output format-aware shortcodes or // content rendering hooks, create a output format-specific template, e.g. // myshortcode.amp.html. cp.enableReuse() } cp.workContent = p.contentToRender(cp.contentPlaceholders) isHTML := cp.p.m.markup == "html" if !isHTML { r, err := cp.renderContent(cp.workContent, true) if err != nil { return err } cp.workContent = r.Bytes() if tocProvider, ok := r.(converter.TableOfContentsProvider); ok { cfg := p.s.ContentSpec.Converters.GetMarkupConfig() cp.tableOfContents = template.HTML( tocProvider.TableOfContents().ToHTML( cfg.TableOfContents.StartLevel, cfg.TableOfContents.EndLevel, cfg.TableOfContents.Ordered, ), ) } else { tmpContent, tmpTableOfContents := helpers.ExtractTOC(cp.workContent) cp.tableOfContents = helpers.BytesToHTML(tmpTableOfContents) cp.workContent = tmpContent } } if cp.placeholdersEnabled { // ToC was accessed via .Page.TableOfContents in the shortcode, // at a time when the ToC wasn't ready. cp.contentPlaceholders[tocShortcodePlaceholder] = string(cp.tableOfContents) } if p.cmap.hasNonMarkdownShortcode || cp.placeholdersEnabled { // There are one or more replacement tokens to be replaced. cp.workContent, err = replaceShortcodeTokens(cp.workContent, cp.contentPlaceholders) if err != nil { return err } } if cp.p.source.hasSummaryDivider { if isHTML { src := p.source.parsed.Input() // Use the summary sections as they are provided by the user. if p.source.posSummaryEnd != -1 { cp.summary = helpers.BytesToHTML(src[p.source.posMainContent:p.source.posSummaryEnd]) } if cp.p.source.posBodyStart != -1 { cp.workContent = src[cp.p.source.posBodyStart:] } } else { summary, content, err := splitUserDefinedSummaryAndContent(cp.p.m.markup, cp.workContent) if err != nil { cp.p.s.Log.Errorf("Failed to set user defined summary for page %q: %s", cp.p.pathOrTitle(), err) } else { cp.workContent = content cp.summary = helpers.BytesToHTML(summary) } } } else if cp.p.m.summary != "" { b, err := cp.renderContent([]byte(cp.p.m.summary), false) if err != nil { return err } html := cp.p.s.ContentSpec.TrimShortHTML(b.Bytes()) cp.summary = helpers.BytesToHTML(html) } cp.content = helpers.BytesToHTML(cp.workContent) return nil } // Recursive loops can only happen in content files with template code (shortcodes etc.) // Avoid creating new goroutines if we don't have to. needTimeout := p.shortcodeState.hasShortcodes() || cp.renderHooks != nil if needTimeout { cp.initMain = parent.BranchWithTimeout(p.s.siteCfg.timeout, func(ctx context.Context) (interface{}, error) { return nil, initContent() }) } else { cp.initMain = parent.Branch(func() (interface{}, error) { return nil, initContent() }) } cp.initPlain = cp.initMain.Branch(func() (interface{}, error) { cp.plain = helpers.StripHTML(string(cp.content)) cp.plainWords = strings.Fields(cp.plain) cp.setWordCounts(p.m.isCJKLanguage) if err := cp.setAutoSummary(); err != nil { return err, nil } return nil, nil }) return cp, nil } type renderHooks struct { hooks *hooks.Renderers init sync.Once } // pageContentOutput represents the Page content for a given output format. type pageContentOutput struct { f output.Format // If we can reuse this for other output formats. reuse bool reuseInit sync.Once p *pageState // Lazy load dependencies initMain *lazy.Init initPlain *lazy.Init placeholdersEnabled bool placeholdersEnabledInit sync.Once renderHooks *renderHooks // Set if there are more than one output format variant renderHooksHaveVariants bool // TODO(bep) reimplement this in another way, consolidate with shortcodes // Content state workContent []byte dependencyTracker identity.Manager // Set in server mode. // Temporary storage of placeholders mapped to their content. // These are shortcodes etc. Some of these will need to be replaced // after any markup is rendered, so they share a common prefix. contentPlaceholders map[string]string // Content sections content template.HTML summary template.HTML tableOfContents template.HTML truncated bool plainWords []string plain string fuzzyWordCount int wordCount int readingTime int } func (p *pageContentOutput) trackDependency(id identity.Provider) { if p.dependencyTracker != nil { p.dependencyTracker.Add(id) } } func (p *pageContentOutput) Reset() { if p.dependencyTracker != nil { p.dependencyTracker.Reset() } p.initMain.Reset() p.initPlain.Reset() p.renderHooks = &renderHooks{} } func (p *pageContentOutput) Content() (interface{}, error) { if p.p.s.initInit(p.initMain, p.p) { return p.content, nil } return nil, nil } func (p *pageContentOutput) FuzzyWordCount() int { p.p.s.initInit(p.initPlain, p.p) return p.fuzzyWordCount } func (p *pageContentOutput) Len() int { p.p.s.initInit(p.initMain, p.p) return len(p.content) } func (p *pageContentOutput) Plain() string { p.p.s.initInit(p.initPlain, p.p) return p.plain } func (p *pageContentOutput) PlainWords() []string { p.p.s.initInit(p.initPlain, p.p) return p.plainWords } func (p *pageContentOutput) ReadingTime() int { p.p.s.initInit(p.initPlain, p.p) return p.readingTime } func (p *pageContentOutput) Summary() template.HTML { p.p.s.initInit(p.initMain, p.p) if !p.p.source.hasSummaryDivider { p.p.s.initInit(p.initPlain, p.p) } return p.summary } func (p *pageContentOutput) TableOfContents() template.HTML { p.p.s.initInit(p.initMain, p.p) return p.tableOfContents } func (p *pageContentOutput) Truncated() bool { if p.p.truncated { return true } p.p.s.initInit(p.initPlain, p.p) return p.truncated } func (p *pageContentOutput) WordCount() int { p.p.s.initInit(p.initPlain, p.p) return p.wordCount } func (p *pageContentOutput) setAutoSummary() error { if p.p.source.hasSummaryDivider || p.p.m.summary != "" { return nil } var summary string var truncated bool if p.p.m.isCJKLanguage { summary, truncated = p.p.s.ContentSpec.TruncateWordsByRune(p.plainWords) } else { summary, truncated = p.p.s.ContentSpec.TruncateWordsToWholeSentence(p.plain) } p.summary = template.HTML(summary) p.truncated = truncated return nil } func (cp *pageContentOutput) renderContent(content []byte, renderTOC bool) (converter.Result, error) { c := cp.p.getContentConverter() return cp.renderContentWithConverter(c, content, renderTOC) } func (cp *pageContentOutput) renderContentWithConverter(c converter.Converter, content []byte, renderTOC bool) (converter.Result, error) { r, err := c.Convert( converter.RenderContext{ Src: content, RenderTOC: renderTOC, RenderHooks: cp.renderHooks.hooks, }) if err == nil { if ids, ok := r.(identity.IdentitiesProvider); ok { for _, v := range ids.GetIdentities() { cp.trackDependency(v) } } } return r, err } func (p *pageContentOutput) setWordCounts(isCJKLanguage bool) { if isCJKLanguage { p.wordCount = 0 for _, word := range p.plainWords { runeCount := utf8.RuneCountInString(word) if len(word) == runeCount { p.wordCount++ } else { p.wordCount += runeCount } } } else { p.wordCount = helpers.TotalWords(p.plain) } // TODO(bep) is set in a test. Fix that. if p.fuzzyWordCount == 0 { p.fuzzyWordCount = (p.wordCount + 100) / 100 * 100 } if isCJKLanguage { p.readingTime = (p.wordCount + 500) / 501 } else { p.readingTime = (p.wordCount + 212) / 213 } } // A callback to signal that we have inserted a placeholder into the rendered // content. This avoids doing extra replacement work. func (p *pageContentOutput) enablePlaceholders() { p.placeholdersEnabledInit.Do(func() { p.placeholdersEnabled = true }) } func (p *pageContentOutput) enableReuse() { p.reuseInit.Do(func() { p.reuse = true }) } // these will be shifted out when rendering a given output format. type pagePerOutputProviders interface { targetPather page.PaginatorProvider resource.ResourceLinksProvider } type targetPather interface { targetPaths() page.TargetPaths } type targetPathsHolder struct { paths page.TargetPaths page.OutputFormat } func (t targetPathsHolder) targetPaths() page.TargetPaths { return t.paths } func executeToString(h tpl.TemplateHandler, templ tpl.Template, data interface{}) (string, error) { b := bp.GetBuffer() defer bp.PutBuffer(b) if err := h.Execute(templ, b, data); err != nil { return "", err } return b.String(), nil } func splitUserDefinedSummaryAndContent(markup string, c []byte) (summary []byte, content []byte, err error) { defer func() { if r := recover(); r != nil { err = fmt.Errorf("summary split failed: %s", r) } }() startDivider := bytes.Index(c, internalSummaryDividerBaseBytes) if startDivider == -1 { return } startTag := "p" switch markup { case "asciidocext": startTag = "div" } // Walk back and forward to the surrounding tags. start := bytes.LastIndex(c[:startDivider], []byte("<"+startTag)) end := bytes.Index(c[startDivider:], []byte("</"+startTag)) if start == -1 { start = startDivider } else { start = startDivider - (startDivider - start) } if end == -1 { end = startDivider + len(internalSummaryDividerBase) } else { end = startDivider + end + len(startTag) + 3 } var addDiv bool switch markup { case "rst": addDiv = true } withoutDivider := append(c[:start], bytes.Trim(c[end:], "\n")...) if len(withoutDivider) > 0 { summary = bytes.TrimSpace(withoutDivider[:start]) } if addDiv { // For the rst summary = append(append([]byte(nil), summary...), []byte("</div>")...) } if err != nil { return } content = bytes.TrimSpace(withoutDivider) return }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "bytes" "context" "fmt" "html/template" "runtime/debug" "strings" "sync" "unicode/utf8" "github.com/gohugoio/hugo/identity" "github.com/gohugoio/hugo/markup/converter/hooks" "github.com/gohugoio/hugo/markup/converter" "github.com/gohugoio/hugo/lazy" bp "github.com/gohugoio/hugo/bufferpool" "github.com/gohugoio/hugo/tpl" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/output" "github.com/gohugoio/hugo/resources/page" "github.com/gohugoio/hugo/resources/resource" ) var ( nopTargetPath = targetPathsHolder{} nopPagePerOutput = struct { resource.ResourceLinksProvider page.ContentProvider page.PageRenderProvider page.PaginatorProvider page.TableOfContentsProvider page.AlternativeOutputFormatsProvider targetPather }{ page.NopPage, page.NopPage, page.NopPage, page.NopPage, page.NopPage, page.NopPage, nopTargetPath, } ) var pageContentOutputDependenciesID = identity.KeyValueIdentity{Key: "pageOutput", Value: "dependencies"} func newPageContentOutput(p *pageState, po *pageOutput) (*pageContentOutput, error) { parent := p.init var dependencyTracker identity.Manager if p.s.running() { dependencyTracker = identity.NewManager(pageContentOutputDependenciesID) } cp := &pageContentOutput{ dependencyTracker: dependencyTracker, p: p, f: po.f, renderHooks: &renderHooks{}, } initContent := func() (err error) { p.s.h.IncrContentRender() if p.cmap == nil { // Nothing to do. return nil } defer func() { // See https://github.com/gohugoio/hugo/issues/6210 if r := recover(); r != nil { err = fmt.Errorf("%s", r) p.s.Log.Errorf("[BUG] Got panic:\n%s\n%s", r, string(debug.Stack())) } }() if err := po.initRenderHooks(); err != nil { return err } var hasShortcodeVariants bool f := po.f cp.contentPlaceholders, hasShortcodeVariants, err = p.shortcodeState.renderShortcodesForPage(p, f) if err != nil { return err } enableReuse := !(hasShortcodeVariants || cp.renderHooksHaveVariants) if enableReuse { // Reuse this for the other output formats. // We may improve on this, but we really want to avoid re-rendering the content // to all output formats. // The current rule is that if you need output format-aware shortcodes or // content rendering hooks, create a output format-specific template, e.g. // myshortcode.amp.html. cp.enableReuse() } cp.workContent = p.contentToRender(cp.contentPlaceholders) isHTML := cp.p.m.markup == "html" if !isHTML { r, err := cp.renderContent(cp.workContent, true) if err != nil { return err } cp.workContent = r.Bytes() if tocProvider, ok := r.(converter.TableOfContentsProvider); ok { cfg := p.s.ContentSpec.Converters.GetMarkupConfig() cp.tableOfContents = template.HTML( tocProvider.TableOfContents().ToHTML( cfg.TableOfContents.StartLevel, cfg.TableOfContents.EndLevel, cfg.TableOfContents.Ordered, ), ) } else { tmpContent, tmpTableOfContents := helpers.ExtractTOC(cp.workContent) cp.tableOfContents = helpers.BytesToHTML(tmpTableOfContents) cp.workContent = tmpContent } } if cp.placeholdersEnabled { // ToC was accessed via .Page.TableOfContents in the shortcode, // at a time when the ToC wasn't ready. cp.contentPlaceholders[tocShortcodePlaceholder] = string(cp.tableOfContents) } if p.cmap.hasNonMarkdownShortcode || cp.placeholdersEnabled { // There are one or more replacement tokens to be replaced. cp.workContent, err = replaceShortcodeTokens(cp.workContent, cp.contentPlaceholders) if err != nil { return err } } if cp.p.source.hasSummaryDivider { if isHTML { src := p.source.parsed.Input() // Use the summary sections as they are provided by the user. if p.source.posSummaryEnd != -1 { cp.summary = helpers.BytesToHTML(src[p.source.posMainContent:p.source.posSummaryEnd]) } if cp.p.source.posBodyStart != -1 { cp.workContent = src[cp.p.source.posBodyStart:] } } else { summary, content, err := splitUserDefinedSummaryAndContent(cp.p.m.markup, cp.workContent) if err != nil { cp.p.s.Log.Errorf("Failed to set user defined summary for page %q: %s", cp.p.pathOrTitle(), err) } else { cp.workContent = content cp.summary = helpers.BytesToHTML(summary) } } } else if cp.p.m.summary != "" { b, err := cp.renderContent([]byte(cp.p.m.summary), false) if err != nil { return err } html := cp.p.s.ContentSpec.TrimShortHTML(b.Bytes()) cp.summary = helpers.BytesToHTML(html) } cp.content = helpers.BytesToHTML(cp.workContent) return nil } // Recursive loops can only happen in content files with template code (shortcodes etc.) // Avoid creating new goroutines if we don't have to. needTimeout := p.shortcodeState.hasShortcodes() || cp.renderHooks != nil if needTimeout { cp.initMain = parent.BranchWithTimeout(p.s.siteCfg.timeout, func(ctx context.Context) (interface{}, error) { return nil, initContent() }) } else { cp.initMain = parent.Branch(func() (interface{}, error) { return nil, initContent() }) } cp.initPlain = cp.initMain.Branch(func() (interface{}, error) { cp.plain = helpers.StripHTML(string(cp.content)) cp.plainWords = strings.Fields(cp.plain) cp.setWordCounts(p.m.isCJKLanguage) if err := cp.setAutoSummary(); err != nil { return err, nil } return nil, nil }) return cp, nil } type renderHooks struct { hooks *hooks.Renderers init sync.Once } // pageContentOutput represents the Page content for a given output format. type pageContentOutput struct { f output.Format // If we can reuse this for other output formats. reuse bool reuseInit sync.Once p *pageState // Lazy load dependencies initMain *lazy.Init initPlain *lazy.Init placeholdersEnabled bool placeholdersEnabledInit sync.Once renderHooks *renderHooks // Set if there are more than one output format variant renderHooksHaveVariants bool // TODO(bep) reimplement this in another way, consolidate with shortcodes // Content state workContent []byte dependencyTracker identity.Manager // Set in server mode. // Temporary storage of placeholders mapped to their content. // These are shortcodes etc. Some of these will need to be replaced // after any markup is rendered, so they share a common prefix. contentPlaceholders map[string]string // Content sections content template.HTML summary template.HTML tableOfContents template.HTML truncated bool plainWords []string plain string fuzzyWordCount int wordCount int readingTime int } func (p *pageContentOutput) trackDependency(id identity.Provider) { if p.dependencyTracker != nil { p.dependencyTracker.Add(id) } } func (p *pageContentOutput) Reset() { if p.dependencyTracker != nil { p.dependencyTracker.Reset() } p.initMain.Reset() p.initPlain.Reset() p.renderHooks = &renderHooks{} } func (p *pageContentOutput) Content() (interface{}, error) { if p.p.s.initInit(p.initMain, p.p) { return p.content, nil } return nil, nil } func (p *pageContentOutput) FuzzyWordCount() int { p.p.s.initInit(p.initPlain, p.p) return p.fuzzyWordCount } func (p *pageContentOutput) Len() int { p.p.s.initInit(p.initMain, p.p) return len(p.content) } func (p *pageContentOutput) Plain() string { p.p.s.initInit(p.initPlain, p.p) return p.plain } func (p *pageContentOutput) PlainWords() []string { p.p.s.initInit(p.initPlain, p.p) return p.plainWords } func (p *pageContentOutput) ReadingTime() int { p.p.s.initInit(p.initPlain, p.p) return p.readingTime } func (p *pageContentOutput) Summary() template.HTML { p.p.s.initInit(p.initMain, p.p) if !p.p.source.hasSummaryDivider { p.p.s.initInit(p.initPlain, p.p) } return p.summary } func (p *pageContentOutput) TableOfContents() template.HTML { p.p.s.initInit(p.initMain, p.p) return p.tableOfContents } func (p *pageContentOutput) Truncated() bool { if p.p.truncated { return true } p.p.s.initInit(p.initPlain, p.p) return p.truncated } func (p *pageContentOutput) WordCount() int { p.p.s.initInit(p.initPlain, p.p) return p.wordCount } func (p *pageContentOutput) setAutoSummary() error { if p.p.source.hasSummaryDivider || p.p.m.summary != "" { return nil } var summary string var truncated bool if p.p.m.isCJKLanguage { summary, truncated = p.p.s.ContentSpec.TruncateWordsByRune(p.plainWords) } else { summary, truncated = p.p.s.ContentSpec.TruncateWordsToWholeSentence(p.plain) } p.summary = template.HTML(summary) p.truncated = truncated return nil } func (cp *pageContentOutput) renderContent(content []byte, renderTOC bool) (converter.Result, error) { c := cp.p.getContentConverter() return cp.renderContentWithConverter(c, content, renderTOC) } func (cp *pageContentOutput) renderContentWithConverter(c converter.Converter, content []byte, renderTOC bool) (converter.Result, error) { r, err := c.Convert( converter.RenderContext{ Src: content, RenderTOC: renderTOC, RenderHooks: cp.renderHooks.hooks, }) if err == nil { if ids, ok := r.(identity.IdentitiesProvider); ok { for _, v := range ids.GetIdentities() { cp.trackDependency(v) } } } return r, err } func (p *pageContentOutput) setWordCounts(isCJKLanguage bool) { if isCJKLanguage { p.wordCount = 0 for _, word := range p.plainWords { runeCount := utf8.RuneCountInString(word) if len(word) == runeCount { p.wordCount++ } else { p.wordCount += runeCount } } } else { p.wordCount = helpers.TotalWords(p.plain) } // TODO(bep) is set in a test. Fix that. if p.fuzzyWordCount == 0 { p.fuzzyWordCount = (p.wordCount + 100) / 100 * 100 } if isCJKLanguage { p.readingTime = (p.wordCount + 500) / 501 } else { p.readingTime = (p.wordCount + 212) / 213 } } // A callback to signal that we have inserted a placeholder into the rendered // content. This avoids doing extra replacement work. func (p *pageContentOutput) enablePlaceholders() { p.placeholdersEnabledInit.Do(func() { p.placeholdersEnabled = true }) } func (p *pageContentOutput) enableReuse() { p.reuseInit.Do(func() { p.reuse = true }) } // these will be shifted out when rendering a given output format. type pagePerOutputProviders interface { targetPather page.PaginatorProvider resource.ResourceLinksProvider } type targetPather interface { targetPaths() page.TargetPaths } type targetPathsHolder struct { paths page.TargetPaths page.OutputFormat } func (t targetPathsHolder) targetPaths() page.TargetPaths { return t.paths } func executeToString(h tpl.TemplateHandler, templ tpl.Template, data interface{}) (string, error) { b := bp.GetBuffer() defer bp.PutBuffer(b) if err := h.Execute(templ, b, data); err != nil { return "", err } return b.String(), nil } func splitUserDefinedSummaryAndContent(markup string, c []byte) (summary []byte, content []byte, err error) { defer func() { if r := recover(); r != nil { err = fmt.Errorf("summary split failed: %s", r) } }() startDivider := bytes.Index(c, internalSummaryDividerBaseBytes) if startDivider == -1 { return } startTag := "p" switch markup { case "asciidocext": startTag = "div" } // Walk back and forward to the surrounding tags. start := bytes.LastIndex(c[:startDivider], []byte("<"+startTag)) end := bytes.Index(c[startDivider:], []byte("</"+startTag)) if start == -1 { start = startDivider } else { start = startDivider - (startDivider - start) } if end == -1 { end = startDivider + len(internalSummaryDividerBase) } else { end = startDivider + end + len(startTag) + 3 } var addDiv bool switch markup { case "rst": addDiv = true } withoutDivider := append(c[:start], bytes.Trim(c[end:], "\n")...) if len(withoutDivider) > 0 { summary = bytes.TrimSpace(withoutDivider[:start]) } if addDiv { // For the rst summary = append(append([]byte(nil), summary...), []byte("</div>")...) } if err != nil { return } content = bytes.TrimSpace(withoutDivider) return }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./docs/content/en/functions/replace.md
--- title: replace description: Replaces all occurrences of the search string with the replacement string. godocref: date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2020-09-07 categories: [functions] menu: docs: parent: "functions" keywords: [] signature: ["strings.Replace INPUT OLD NEW [LIMIT]", "replace INPUT OLD NEW [LIMIT]"] workson: [] hugoversion: relatedfuncs: [] deprecated: false aliases: [] --- Replace returns a copy of `INPUT` with all occurrences of `OLD` replaced with `NEW`. The number of replacements can be limited with an optional `LIMIT` parameter. ``` `{{ replace "Batman and Robin" "Robin" "Catwoman" }}` → "Batman and Catwoman" {{ replace "aabbaabb" "a" "z" 2 }} → "zzbbaabb" ```
--- title: replace description: Replaces all occurrences of the search string with the replacement string. godocref: date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2020-09-07 categories: [functions] menu: docs: parent: "functions" keywords: [] signature: ["strings.Replace INPUT OLD NEW [LIMIT]", "replace INPUT OLD NEW [LIMIT]"] workson: [] hugoversion: relatedfuncs: [] deprecated: false aliases: [] --- Replace returns a copy of `INPUT` with all occurrences of `OLD` replaced with `NEW`. The number of replacements can be limited with an optional `LIMIT` parameter. ``` `{{ replace "Batman and Robin" "Robin" "Catwoman" }}` → "Batman and Catwoman" {{ replace "aabbaabb" "a" "z" 2 }} → "zzbbaabb" ```
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./resources/testdata/golden/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_400x200_fill_q75_box_bottomleft.jpg
    $.' ",#(7),01444'9=82<.342  2!!22222222222222222222222222222222222222222222222222" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?)i@Lƅ҅iiihiiihij@-8%H# N RST)(-.PJP(JpJe8%M! J N @RBST)( *ˠ )|ӄtW˥՟.G@]]ZGVO.*t:cc:it]1LtDM10H f:a2S PV HbU!jEZP ZhZ-9V O O O @ O O O @STih ZxZ%8%J" N RvST)(0JpJ%8%L! N SSu0Jx ҈J]_˥Jv՟.eUߗHcp*yt]\<.34W RLt]1 t\ F:>iDL1”\EHJRiBԊj@ ZjH O O O E`ZxZpZ-iiii\0-8-<%<%0 JxJ.{iBQpJpJ%8% BSt\,BQpJpJGOҸX:.! K:.+yt`GNXկ.ˢb6{U..MԞ_\ t\,S1 u{˦\,R1 uxL)EFb)\v)6p*UT+ QBJE*Ԫ*ԁhXҪԊ(X@*@\,0-H<-EBSSpД\,4-8-8-<- N N O EBӂpZx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./tpl/internal/go_templates/htmltemplate/css_test.go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build go1.13,!windows package template import ( "strconv" "strings" "testing" ) func TestEndsWithCSSKeyword(t *testing.T) { tests := []struct { css, kw string want bool }{ {"", "url", false}, {"url", "url", true}, {"URL", "url", true}, {"Url", "url", true}, {"url", "important", false}, {"important", "important", true}, {"image-url", "url", false}, {"imageurl", "url", false}, {"image url", "url", true}, } for _, test := range tests { got := endsWithCSSKeyword([]byte(test.css), test.kw) if got != test.want { t.Errorf("want %t but got %t for css=%v, kw=%v", test.want, got, test.css, test.kw) } } } func TestIsCSSNmchar(t *testing.T) { tests := []struct { rune rune want bool }{ {0, false}, {'0', true}, {'9', true}, {'A', true}, {'Z', true}, {'a', true}, {'z', true}, {'_', true}, {'-', true}, {':', false}, {';', false}, {' ', false}, {0x7f, false}, {0x80, true}, {0x1234, true}, {0xd800, false}, {0xdc00, false}, {0xfffe, false}, {0x10000, true}, {0x110000, false}, } for _, test := range tests { got := isCSSNmchar(test.rune) if got != test.want { t.Errorf("%q: want %t but got %t", string(test.rune), test.want, got) } } } func TestDecodeCSS(t *testing.T) { tests := []struct { css, want string }{ {``, ``}, {`foo`, `foo`}, {`foo\`, `foo`}, {`foo\\`, `foo\`}, {`\`, ``}, {`\A`, "\n"}, {`\a`, "\n"}, {`\0a`, "\n"}, {`\00000a`, "\n"}, {`\000000a`, "\u0000a"}, {`\1234 5`, "\u1234" + "5"}, {`\1234\20 5`, "\u1234" + " 5"}, {`\1234\A 5`, "\u1234" + "\n5"}, {"\\1234\t5", "\u1234" + "5"}, {"\\1234\n5", "\u1234" + "5"}, {"\\1234\r\n5", "\u1234" + "5"}, {`\12345`, "\U00012345"}, {`\\`, `\`}, {`\\ `, `\ `}, {`\"`, `"`}, {`\'`, `'`}, {`\.`, `.`}, {`\. .`, `. .`}, { `The \3c i\3equick\3c/i\3e,\d\A\3cspan style=\27 color:brown\27\3e brown\3c/span\3e fox jumps\2028over the \3c canine class=\22lazy\22 \3e dog\3c/canine\3e`, "The <i>quick</i>,\r\n<span style='color:brown'>brown</span> fox jumps\u2028over the <canine class=\"lazy\">dog</canine>", }, } for _, test := range tests { got1 := string(decodeCSS([]byte(test.css))) if got1 != test.want { t.Errorf("%q: want\n\t%q\nbut got\n\t%q", test.css, test.want, got1) } recoded := cssEscaper(got1) if got2 := string(decodeCSS([]byte(recoded))); got2 != test.want { t.Errorf("%q: escape & decode not dual for %q", test.css, recoded) } } } func TestHexDecode(t *testing.T) { for i := 0; i < 0x200000; i += 101 /* coprime with 16 */ { s := strconv.FormatInt(int64(i), 16) if got := int(hexDecode([]byte(s))); got != i { t.Errorf("%s: want %d but got %d", s, i, got) } s = strings.ToUpper(s) if got := int(hexDecode([]byte(s))); got != i { t.Errorf("%s: want %d but got %d", s, i, got) } } } func TestSkipCSSSpace(t *testing.T) { tests := []struct { css, want string }{ {"", ""}, {"foo", "foo"}, {"\n", ""}, {"\r\n", ""}, {"\r", ""}, {"\t", ""}, {" ", ""}, {"\f", ""}, {" foo", "foo"}, {" foo", " foo"}, {`\20`, `\20`}, } for _, test := range tests { got := string(skipCSSSpace([]byte(test.css))) if got != test.want { t.Errorf("%q: want %q but got %q", test.css, test.want, got) } } } func TestCSSEscaper(t *testing.T) { input := ("\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + ` !"#$%&'()*+,-./` + `0123456789:;<=>?` + `@ABCDEFGHIJKLMNO` + `PQRSTUVWXYZ[\]^_` + "`abcdefghijklmno" + "pqrstuvwxyz{|}~\x7f" + "\u00A0\u0100\u2028\u2029\ufeff\U0001D11E") want := ("\\0\x01\x02\x03\x04\x05\x06\x07" + "\x08\\9 \\a\x0b\\c \\d\x0E\x0F" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + ` !\22#$%\26\27\28\29*\2b,-.\2f ` + `0123456789\3a\3b\3c=\3e?` + `@ABCDEFGHIJKLMNO` + `PQRSTUVWXYZ[\\]^_` + "`abcdefghijklmno" + `pqrstuvwxyz\7b|\7d~` + "\u007f" + "\u00A0\u0100\u2028\u2029\ufeff\U0001D11E") got := cssEscaper(input) if got != want { t.Errorf("encode: want\n\t%q\nbut got\n\t%q", want, got) } got = string(decodeCSS([]byte(got))) if input != got { t.Errorf("decode: want\n\t%q\nbut got\n\t%q", input, got) } } func TestCSSValueFilter(t *testing.T) { tests := []struct { css, want string }{ {"", ""}, {"foo", "foo"}, {"0", "0"}, {"0px", "0px"}, {"-5px", "-5px"}, {"1.25in", "1.25in"}, {"+.33em", "+.33em"}, {"100%", "100%"}, {"12.5%", "12.5%"}, {".foo", ".foo"}, {"#bar", "#bar"}, {"corner-radius", "corner-radius"}, {"-moz-corner-radius", "-moz-corner-radius"}, {"#000", "#000"}, {"#48f", "#48f"}, {"#123456", "#123456"}, {"U+00-FF, U+980-9FF", "U+00-FF, U+980-9FF"}, {"color: red", "color: red"}, {"<!--", "ZgotmplZ"}, {"-->", "ZgotmplZ"}, {"<![CDATA[", "ZgotmplZ"}, {"]]>", "ZgotmplZ"}, {"</style", "ZgotmplZ"}, {`"`, "ZgotmplZ"}, {`'`, "ZgotmplZ"}, {"`", "ZgotmplZ"}, {"\x00", "ZgotmplZ"}, {"/* foo */", "ZgotmplZ"}, {"//", "ZgotmplZ"}, {"[href=~", "ZgotmplZ"}, {"expression(alert(1337))", "ZgotmplZ"}, {"-expression(alert(1337))", "ZgotmplZ"}, {"expression", "ZgotmplZ"}, {"Expression", "ZgotmplZ"}, {"EXPRESSION", "ZgotmplZ"}, {"-moz-binding", "ZgotmplZ"}, {"-expr\x00ession(alert(1337))", "ZgotmplZ"}, {`-expr\0ession(alert(1337))`, "ZgotmplZ"}, {`-express\69on(alert(1337))`, "ZgotmplZ"}, {`-express\69 on(alert(1337))`, "ZgotmplZ"}, {`-exp\72 ession(alert(1337))`, "ZgotmplZ"}, {`-exp\52 ession(alert(1337))`, "ZgotmplZ"}, {`-exp\000052 ession(alert(1337))`, "ZgotmplZ"}, {`-expre\0000073sion`, "-expre\x073sion"}, {`@import url evil.css`, "ZgotmplZ"}, } for _, test := range tests { got := cssValueFilter(test.css) if got != test.want { t.Errorf("%q: want %q but got %q", test.css, test.want, got) } } } func BenchmarkCSSEscaper(b *testing.B) { for i := 0; i < b.N; i++ { cssEscaper("The <i>quick</i>,\r\n<span style='color:brown'>brown</span> fox jumps\u2028over the <canine class=\"lazy\">dog</canine>") } } func BenchmarkCSSEscaperNoSpecials(b *testing.B) { for i := 0; i < b.N; i++ { cssEscaper("The quick, brown fox jumps over the lazy dog.") } } func BenchmarkDecodeCSS(b *testing.B) { s := []byte(`The \3c i\3equick\3c/i\3e,\d\A\3cspan style=\27 color:brown\27\3e brown\3c/span\3e fox jumps\2028over the \3c canine class=\22lazy\22 \3edog\3c/canine\3e`) b.ResetTimer() for i := 0; i < b.N; i++ { decodeCSS(s) } } func BenchmarkDecodeCSSNoSpecials(b *testing.B) { s := []byte("The quick, brown fox jumps over the lazy dog.") b.ResetTimer() for i := 0; i < b.N; i++ { decodeCSS(s) } } func BenchmarkCSSValueFilter(b *testing.B) { for i := 0; i < b.N; i++ { cssValueFilter(` e\78preS\0Sio/**/n(alert(1337))`) } } func BenchmarkCSSValueFilterOk(b *testing.B) { for i := 0; i < b.N; i++ { cssValueFilter(`Times New Roman`) } }
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build go1.13,!windows package template import ( "strconv" "strings" "testing" ) func TestEndsWithCSSKeyword(t *testing.T) { tests := []struct { css, kw string want bool }{ {"", "url", false}, {"url", "url", true}, {"URL", "url", true}, {"Url", "url", true}, {"url", "important", false}, {"important", "important", true}, {"image-url", "url", false}, {"imageurl", "url", false}, {"image url", "url", true}, } for _, test := range tests { got := endsWithCSSKeyword([]byte(test.css), test.kw) if got != test.want { t.Errorf("want %t but got %t for css=%v, kw=%v", test.want, got, test.css, test.kw) } } } func TestIsCSSNmchar(t *testing.T) { tests := []struct { rune rune want bool }{ {0, false}, {'0', true}, {'9', true}, {'A', true}, {'Z', true}, {'a', true}, {'z', true}, {'_', true}, {'-', true}, {':', false}, {';', false}, {' ', false}, {0x7f, false}, {0x80, true}, {0x1234, true}, {0xd800, false}, {0xdc00, false}, {0xfffe, false}, {0x10000, true}, {0x110000, false}, } for _, test := range tests { got := isCSSNmchar(test.rune) if got != test.want { t.Errorf("%q: want %t but got %t", string(test.rune), test.want, got) } } } func TestDecodeCSS(t *testing.T) { tests := []struct { css, want string }{ {``, ``}, {`foo`, `foo`}, {`foo\`, `foo`}, {`foo\\`, `foo\`}, {`\`, ``}, {`\A`, "\n"}, {`\a`, "\n"}, {`\0a`, "\n"}, {`\00000a`, "\n"}, {`\000000a`, "\u0000a"}, {`\1234 5`, "\u1234" + "5"}, {`\1234\20 5`, "\u1234" + " 5"}, {`\1234\A 5`, "\u1234" + "\n5"}, {"\\1234\t5", "\u1234" + "5"}, {"\\1234\n5", "\u1234" + "5"}, {"\\1234\r\n5", "\u1234" + "5"}, {`\12345`, "\U00012345"}, {`\\`, `\`}, {`\\ `, `\ `}, {`\"`, `"`}, {`\'`, `'`}, {`\.`, `.`}, {`\. .`, `. .`}, { `The \3c i\3equick\3c/i\3e,\d\A\3cspan style=\27 color:brown\27\3e brown\3c/span\3e fox jumps\2028over the \3c canine class=\22lazy\22 \3e dog\3c/canine\3e`, "The <i>quick</i>,\r\n<span style='color:brown'>brown</span> fox jumps\u2028over the <canine class=\"lazy\">dog</canine>", }, } for _, test := range tests { got1 := string(decodeCSS([]byte(test.css))) if got1 != test.want { t.Errorf("%q: want\n\t%q\nbut got\n\t%q", test.css, test.want, got1) } recoded := cssEscaper(got1) if got2 := string(decodeCSS([]byte(recoded))); got2 != test.want { t.Errorf("%q: escape & decode not dual for %q", test.css, recoded) } } } func TestHexDecode(t *testing.T) { for i := 0; i < 0x200000; i += 101 /* coprime with 16 */ { s := strconv.FormatInt(int64(i), 16) if got := int(hexDecode([]byte(s))); got != i { t.Errorf("%s: want %d but got %d", s, i, got) } s = strings.ToUpper(s) if got := int(hexDecode([]byte(s))); got != i { t.Errorf("%s: want %d but got %d", s, i, got) } } } func TestSkipCSSSpace(t *testing.T) { tests := []struct { css, want string }{ {"", ""}, {"foo", "foo"}, {"\n", ""}, {"\r\n", ""}, {"\r", ""}, {"\t", ""}, {" ", ""}, {"\f", ""}, {" foo", "foo"}, {" foo", " foo"}, {`\20`, `\20`}, } for _, test := range tests { got := string(skipCSSSpace([]byte(test.css))) if got != test.want { t.Errorf("%q: want %q but got %q", test.css, test.want, got) } } } func TestCSSEscaper(t *testing.T) { input := ("\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + ` !"#$%&'()*+,-./` + `0123456789:;<=>?` + `@ABCDEFGHIJKLMNO` + `PQRSTUVWXYZ[\]^_` + "`abcdefghijklmno" + "pqrstuvwxyz{|}~\x7f" + "\u00A0\u0100\u2028\u2029\ufeff\U0001D11E") want := ("\\0\x01\x02\x03\x04\x05\x06\x07" + "\x08\\9 \\a\x0b\\c \\d\x0E\x0F" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + ` !\22#$%\26\27\28\29*\2b,-.\2f ` + `0123456789\3a\3b\3c=\3e?` + `@ABCDEFGHIJKLMNO` + `PQRSTUVWXYZ[\\]^_` + "`abcdefghijklmno" + `pqrstuvwxyz\7b|\7d~` + "\u007f" + "\u00A0\u0100\u2028\u2029\ufeff\U0001D11E") got := cssEscaper(input) if got != want { t.Errorf("encode: want\n\t%q\nbut got\n\t%q", want, got) } got = string(decodeCSS([]byte(got))) if input != got { t.Errorf("decode: want\n\t%q\nbut got\n\t%q", input, got) } } func TestCSSValueFilter(t *testing.T) { tests := []struct { css, want string }{ {"", ""}, {"foo", "foo"}, {"0", "0"}, {"0px", "0px"}, {"-5px", "-5px"}, {"1.25in", "1.25in"}, {"+.33em", "+.33em"}, {"100%", "100%"}, {"12.5%", "12.5%"}, {".foo", ".foo"}, {"#bar", "#bar"}, {"corner-radius", "corner-radius"}, {"-moz-corner-radius", "-moz-corner-radius"}, {"#000", "#000"}, {"#48f", "#48f"}, {"#123456", "#123456"}, {"U+00-FF, U+980-9FF", "U+00-FF, U+980-9FF"}, {"color: red", "color: red"}, {"<!--", "ZgotmplZ"}, {"-->", "ZgotmplZ"}, {"<![CDATA[", "ZgotmplZ"}, {"]]>", "ZgotmplZ"}, {"</style", "ZgotmplZ"}, {`"`, "ZgotmplZ"}, {`'`, "ZgotmplZ"}, {"`", "ZgotmplZ"}, {"\x00", "ZgotmplZ"}, {"/* foo */", "ZgotmplZ"}, {"//", "ZgotmplZ"}, {"[href=~", "ZgotmplZ"}, {"expression(alert(1337))", "ZgotmplZ"}, {"-expression(alert(1337))", "ZgotmplZ"}, {"expression", "ZgotmplZ"}, {"Expression", "ZgotmplZ"}, {"EXPRESSION", "ZgotmplZ"}, {"-moz-binding", "ZgotmplZ"}, {"-expr\x00ession(alert(1337))", "ZgotmplZ"}, {`-expr\0ession(alert(1337))`, "ZgotmplZ"}, {`-express\69on(alert(1337))`, "ZgotmplZ"}, {`-express\69 on(alert(1337))`, "ZgotmplZ"}, {`-exp\72 ession(alert(1337))`, "ZgotmplZ"}, {`-exp\52 ession(alert(1337))`, "ZgotmplZ"}, {`-exp\000052 ession(alert(1337))`, "ZgotmplZ"}, {`-expre\0000073sion`, "-expre\x073sion"}, {`@import url evil.css`, "ZgotmplZ"}, } for _, test := range tests { got := cssValueFilter(test.css) if got != test.want { t.Errorf("%q: want %q but got %q", test.css, test.want, got) } } } func BenchmarkCSSEscaper(b *testing.B) { for i := 0; i < b.N; i++ { cssEscaper("The <i>quick</i>,\r\n<span style='color:brown'>brown</span> fox jumps\u2028over the <canine class=\"lazy\">dog</canine>") } } func BenchmarkCSSEscaperNoSpecials(b *testing.B) { for i := 0; i < b.N; i++ { cssEscaper("The quick, brown fox jumps over the lazy dog.") } } func BenchmarkDecodeCSS(b *testing.B) { s := []byte(`The \3c i\3equick\3c/i\3e,\d\A\3cspan style=\27 color:brown\27\3e brown\3c/span\3e fox jumps\2028over the \3c canine class=\22lazy\22 \3edog\3c/canine\3e`) b.ResetTimer() for i := 0; i < b.N; i++ { decodeCSS(s) } } func BenchmarkDecodeCSSNoSpecials(b *testing.B) { s := []byte("The quick, brown fox jumps over the lazy dog.") b.ResetTimer() for i := 0; i < b.N; i++ { decodeCSS(s) } } func BenchmarkCSSValueFilter(b *testing.B) { for i := 0; i < b.N; i++ { cssValueFilter(` e\78preS\0Sio/**/n(alert(1337))`) } } func BenchmarkCSSValueFilterOk(b *testing.B) { for i := 0; i < b.N; i++ { cssValueFilter(`Times New Roman`) } }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./resources/images/config_test.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package images import ( "fmt" "strings" "testing" qt "github.com/frankban/quicktest" ) func TestDecodeConfig(t *testing.T) { c := qt.New(t) m := map[string]interface{}{ "quality": 42, "resampleFilter": "NearestNeighbor", "anchor": "topLeft", } imagingConfig, err := DecodeConfig(m) c.Assert(err, qt.IsNil) imaging := imagingConfig.Cfg c.Assert(imaging.Quality, qt.Equals, 42) c.Assert(imaging.ResampleFilter, qt.Equals, "nearestneighbor") c.Assert(imaging.Anchor, qt.Equals, "topleft") m = map[string]interface{}{} imagingConfig, err = DecodeConfig(m) c.Assert(err, qt.IsNil) imaging = imagingConfig.Cfg c.Assert(imaging.Quality, qt.Equals, defaultJPEGQuality) c.Assert(imaging.ResampleFilter, qt.Equals, "box") c.Assert(imaging.Anchor, qt.Equals, "smart") _, err = DecodeConfig(map[string]interface{}{ "quality": 123, }) c.Assert(err, qt.Not(qt.IsNil)) _, err = DecodeConfig(map[string]interface{}{ "resampleFilter": "asdf", }) c.Assert(err, qt.Not(qt.IsNil)) _, err = DecodeConfig(map[string]interface{}{ "anchor": "asdf", }) c.Assert(err, qt.Not(qt.IsNil)) imagingConfig, err = DecodeConfig(map[string]interface{}{ "anchor": "Smart", }) imaging = imagingConfig.Cfg c.Assert(err, qt.IsNil) c.Assert(imaging.Anchor, qt.Equals, "smart") imagingConfig, err = DecodeConfig(map[string]interface{}{ "exif": map[string]interface{}{ "disableLatLong": true, }, }) c.Assert(err, qt.IsNil) imaging = imagingConfig.Cfg c.Assert(imaging.Exif.DisableLatLong, qt.Equals, true) c.Assert(imaging.Exif.ExcludeFields, qt.Equals, "GPS|Exif|Exposure[M|P|B]|Contrast|Resolution|Sharp|JPEG|Metering|Sensing|Saturation|ColorSpace|Flash|WhiteBalance") } func TestDecodeImageConfig(t *testing.T) { for i, this := range []struct { in string expect interface{} }{ {"300x400", newImageConfig(300, 400, 0, 0, "", "", "")}, {"300x400 #fff", newImageConfig(300, 400, 0, 0, "", "", "fff")}, {"100x200 bottomRight", newImageConfig(100, 200, 0, 0, "", "BottomRight", "")}, {"10x20 topleft Lanczos", newImageConfig(10, 20, 0, 0, "Lanczos", "topleft", "")}, {"linear left 10x r180", newImageConfig(10, 0, 0, 180, "linear", "left", "")}, {"x20 riGht Cosine q95", newImageConfig(0, 20, 95, 0, "cosine", "right", "")}, {"", false}, {"foo", false}, } { result, err := DecodeImageConfig("resize", this.in, Imaging{}) if b, ok := this.expect.(bool); ok && !b { if err == nil { t.Errorf("[%d] parseImageConfig didn't return an expected error", i) } } else { if err != nil { t.Fatalf("[%d] err: %s", i, err) } if fmt.Sprint(result) != fmt.Sprint(this.expect) { t.Fatalf("[%d] got\n%v\n but expected\n%v", i, result, this.expect) } } } } func newImageConfig(width, height, quality, rotate int, filter, anchor, bgColor string) ImageConfig { var c ImageConfig c.Action = "resize" c.Width = width c.Height = height c.Quality = quality c.Rotate = rotate c.BgColorStr = bgColor c.BgColor, _ = hexStringToColor(bgColor) if filter != "" { filter = strings.ToLower(filter) if v, ok := imageFilters[filter]; ok { c.Filter = v c.FilterStr = filter } } if anchor != "" { anchor = strings.ToLower(anchor) if v, ok := anchorPositions[anchor]; ok { c.Anchor = v c.AnchorStr = anchor } } return c }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package images import ( "fmt" "strings" "testing" qt "github.com/frankban/quicktest" ) func TestDecodeConfig(t *testing.T) { c := qt.New(t) m := map[string]interface{}{ "quality": 42, "resampleFilter": "NearestNeighbor", "anchor": "topLeft", } imagingConfig, err := DecodeConfig(m) c.Assert(err, qt.IsNil) imaging := imagingConfig.Cfg c.Assert(imaging.Quality, qt.Equals, 42) c.Assert(imaging.ResampleFilter, qt.Equals, "nearestneighbor") c.Assert(imaging.Anchor, qt.Equals, "topleft") m = map[string]interface{}{} imagingConfig, err = DecodeConfig(m) c.Assert(err, qt.IsNil) imaging = imagingConfig.Cfg c.Assert(imaging.Quality, qt.Equals, defaultJPEGQuality) c.Assert(imaging.ResampleFilter, qt.Equals, "box") c.Assert(imaging.Anchor, qt.Equals, "smart") _, err = DecodeConfig(map[string]interface{}{ "quality": 123, }) c.Assert(err, qt.Not(qt.IsNil)) _, err = DecodeConfig(map[string]interface{}{ "resampleFilter": "asdf", }) c.Assert(err, qt.Not(qt.IsNil)) _, err = DecodeConfig(map[string]interface{}{ "anchor": "asdf", }) c.Assert(err, qt.Not(qt.IsNil)) imagingConfig, err = DecodeConfig(map[string]interface{}{ "anchor": "Smart", }) imaging = imagingConfig.Cfg c.Assert(err, qt.IsNil) c.Assert(imaging.Anchor, qt.Equals, "smart") imagingConfig, err = DecodeConfig(map[string]interface{}{ "exif": map[string]interface{}{ "disableLatLong": true, }, }) c.Assert(err, qt.IsNil) imaging = imagingConfig.Cfg c.Assert(imaging.Exif.DisableLatLong, qt.Equals, true) c.Assert(imaging.Exif.ExcludeFields, qt.Equals, "GPS|Exif|Exposure[M|P|B]|Contrast|Resolution|Sharp|JPEG|Metering|Sensing|Saturation|ColorSpace|Flash|WhiteBalance") } func TestDecodeImageConfig(t *testing.T) { for i, this := range []struct { in string expect interface{} }{ {"300x400", newImageConfig(300, 400, 0, 0, "", "", "")}, {"300x400 #fff", newImageConfig(300, 400, 0, 0, "", "", "fff")}, {"100x200 bottomRight", newImageConfig(100, 200, 0, 0, "", "BottomRight", "")}, {"10x20 topleft Lanczos", newImageConfig(10, 20, 0, 0, "Lanczos", "topleft", "")}, {"linear left 10x r180", newImageConfig(10, 0, 0, 180, "linear", "left", "")}, {"x20 riGht Cosine q95", newImageConfig(0, 20, 95, 0, "cosine", "right", "")}, {"", false}, {"foo", false}, } { result, err := DecodeImageConfig("resize", this.in, Imaging{}) if b, ok := this.expect.(bool); ok && !b { if err == nil { t.Errorf("[%d] parseImageConfig didn't return an expected error", i) } } else { if err != nil { t.Fatalf("[%d] err: %s", i, err) } if fmt.Sprint(result) != fmt.Sprint(this.expect) { t.Fatalf("[%d] got\n%v\n but expected\n%v", i, result, this.expect) } } } } func newImageConfig(width, height, quality, rotate int, filter, anchor, bgColor string) ImageConfig { var c ImageConfig c.Action = "resize" c.Width = width c.Height = height c.Quality = quality c.Rotate = rotate c.BgColorStr = bgColor c.BgColor, _ = hexStringToColor(bgColor) if filter != "" { filter = strings.ToLower(filter) if v, ok := imageFilters[filter]; ok { c.Filter = v c.FilterStr = filter } } if anchor != "" { anchor = strings.ToLower(anchor) if v, ok := anchorPositions[anchor]; ok { c.Anchor = v c.AnchorStr = anchor } } return c }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./transform/livereloadinject/livereloadinject_test.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package livereloadinject import ( "bytes" "net/url" "strings" "testing" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/transform" ) func TestLiveReloadInject(t *testing.T) { c := qt.New(t) lrurl, err := url.Parse("http://localhost:1234/subpath") if err != nil { t.Errorf("Parsing test URL failed") return } expectBase := `<script src="/subpath/livereload.js?mindelay=10&amp;v=2&amp;port=1234&amp;path=subpath/livereload" data-no-instant defer></script>` apply := func(s string) string { out := new(bytes.Buffer) in := strings.NewReader(s) tr := transform.New(New(*lrurl)) tr.Apply(out, in) return out.String() } c.Run("Head lower", func(c *qt.C) { c.Assert(apply("<html><head>foo"), qt.Equals, "<html><head>"+expectBase+"foo") }) c.Run("Head upper", func(c *qt.C) { c.Assert(apply("<html><HEAD>foo"), qt.Equals, "<html><HEAD>"+expectBase+"foo") }) c.Run("Body lower", func(c *qt.C) { c.Assert(apply("foo</body>"), qt.Equals, "foo"+expectBase+"</body>") }) c.Run("Body upper", func(c *qt.C) { c.Assert(apply("foo</BODY>"), qt.Equals, "foo"+expectBase+"</BODY>") }) c.Run("No match", func(c *qt.C) { c.Assert(apply("<h1>No match</h1>"), qt.Equals, "<h1>No match</h1>") }) }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package livereloadinject import ( "bytes" "net/url" "strings" "testing" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/transform" ) func TestLiveReloadInject(t *testing.T) { c := qt.New(t) lrurl, err := url.Parse("http://localhost:1234/subpath") if err != nil { t.Errorf("Parsing test URL failed") return } expectBase := `<script src="/subpath/livereload.js?mindelay=10&amp;v=2&amp;port=1234&amp;path=subpath/livereload" data-no-instant defer></script>` apply := func(s string) string { out := new(bytes.Buffer) in := strings.NewReader(s) tr := transform.New(New(*lrurl)) tr.Apply(out, in) return out.String() } c.Run("Head lower", func(c *qt.C) { c.Assert(apply("<html><head>foo"), qt.Equals, "<html><head>"+expectBase+"foo") }) c.Run("Head upper", func(c *qt.C) { c.Assert(apply("<html><HEAD>foo"), qt.Equals, "<html><HEAD>"+expectBase+"foo") }) c.Run("Body lower", func(c *qt.C) { c.Assert(apply("foo</body>"), qt.Equals, "foo"+expectBase+"</body>") }) c.Run("Body upper", func(c *qt.C) { c.Assert(apply("foo</BODY>"), qt.Equals, "foo"+expectBase+"</BODY>") }) c.Run("No match", func(c *qt.C) { c.Assert(apply("<h1>No match</h1>"), qt.Equals, "<h1>No match</h1>") }) }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./docs/layouts/shortcodes/warning.html
{{ $_hugo_config := `{ "version": 1 }` }} <aside class="admonition warning"> <div class="admonition-icon"> {{partial "svg/exclamation.svg" .}} </div> <!-- <h2 id="{{if .Get 0}}{{.Get 0 | urlize}}{{else}}warning{{end}}">{{if .Get 0}}{{.Get 0 | markdownify}}{{else}}Warning{{end}}</h2> --> <!-- <h3>Warning</h3> --> <div class="admonition-content">{{- .Inner -}}</div> </aside>
{{ $_hugo_config := `{ "version": 1 }` }} <aside class="admonition warning"> <div class="admonition-icon"> {{partial "svg/exclamation.svg" .}} </div> <!-- <h2 id="{{if .Get 0}}{{.Get 0 | urlize}}{{else}}warning{{end}}">{{if .Get 0}}{{.Get 0 | markdownify}}{{else}}Warning{{end}}</h2> --> <!-- <h3>Warning</h3> --> <div class="admonition-content">{{- .Inner -}}</div> </aside>
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./tpl/transform/remarshal_test.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package transform import ( "testing" "github.com/gohugoio/hugo/htesting" qt "github.com/frankban/quicktest" "github.com/spf13/viper" ) func TestRemarshal(t *testing.T) { t.Parallel() v := viper.New() v.Set("contentDir", "content") ns := New(newDeps(v)) c := qt.New(t) tomlExample := `title = "Test Metadata" [[resources]] src = "**image-4.png" title = "The Fourth Image!" [resources.params] byline = "picasso" [[resources]] name = "my-cool-image-:counter" src = "**.png" title = "TOML: The Image #:counter" [resources.params] byline = "bep" ` yamlExample := `resources: - params: byline: picasso src: '**image-4.png' title: The Fourth Image! - name: my-cool-image-:counter params: byline: bep src: '**.png' title: 'TOML: The Image #:counter' title: Test Metadata ` jsonExample := `{ "resources": [ { "params": { "byline": "picasso" }, "src": "**image-4.png", "title": "The Fourth Image!" }, { "name": "my-cool-image-:counter", "params": { "byline": "bep" }, "src": "**.png", "title": "TOML: The Image #:counter" } ], "title": "Test Metadata" } ` variants := []struct { format string data string }{ {"yaml", yamlExample}, {"json", jsonExample}, {"toml", tomlExample}, {"TOML", tomlExample}, {"Toml", tomlExample}, {" TOML ", tomlExample}, } for _, v1 := range variants { for _, v2 := range variants { // Both from and to may be the same here, but that is fine. fromTo := qt.Commentf("%s => %s", v2.format, v1.format) converted, err := ns.Remarshal(v1.format, v2.data) c.Assert(err, qt.IsNil, fromTo) diff := htesting.DiffStrings(v1.data, converted) if len(diff) > 0 { t.Errorf("[%s] Expected \n%v\ngot\n%v\ndiff:\n%v", fromTo, v1.data, converted, diff) } } } } func TestRemarshalComments(t *testing.T) { t.Parallel() v := viper.New() v.Set("contentDir", "content") ns := New(newDeps(v)) c := qt.New(t) input := ` Hugo = "Rules" # It really does! [m] # A comment a = "b" ` expected := ` Hugo = "Rules" [m] a = "b" ` for _, format := range []string{"json", "yaml", "toml"} { fromTo := qt.Commentf("%s => %s", "toml", format) converted := input var err error // Do a round-trip conversion for _, toFormat := range []string{format, "toml"} { converted, err = ns.Remarshal(toFormat, converted) c.Assert(err, qt.IsNil, fromTo) } diff := htesting.DiffStrings(expected, converted) if len(diff) > 0 { t.Fatalf("[%s] Expected \n%v\ngot\n%v\ndiff:\n%v\n", fromTo, expected, converted, diff) } } } func TestTestRemarshalError(t *testing.T) { t.Parallel() c := qt.New(t) v := viper.New() v.Set("contentDir", "content") ns := New(newDeps(v)) _, err := ns.Remarshal("asdf", "asdf") c.Assert(err, qt.Not(qt.IsNil)) _, err = ns.Remarshal("json", "asdf") c.Assert(err, qt.Not(qt.IsNil)) } func TestTestRemarshalMapInput(t *testing.T) { t.Parallel() c := qt.New(t) v := viper.New() v.Set("contentDir", "content") ns := New(newDeps(v)) input := map[string]interface{}{ "hello": "world", } output, err := ns.Remarshal("toml", input) c.Assert(err, qt.IsNil) c.Assert(output, qt.Equals, "hello = \"world\"\n") }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package transform import ( "testing" "github.com/gohugoio/hugo/htesting" qt "github.com/frankban/quicktest" "github.com/spf13/viper" ) func TestRemarshal(t *testing.T) { t.Parallel() v := viper.New() v.Set("contentDir", "content") ns := New(newDeps(v)) c := qt.New(t) tomlExample := `title = "Test Metadata" [[resources]] src = "**image-4.png" title = "The Fourth Image!" [resources.params] byline = "picasso" [[resources]] name = "my-cool-image-:counter" src = "**.png" title = "TOML: The Image #:counter" [resources.params] byline = "bep" ` yamlExample := `resources: - params: byline: picasso src: '**image-4.png' title: The Fourth Image! - name: my-cool-image-:counter params: byline: bep src: '**.png' title: 'TOML: The Image #:counter' title: Test Metadata ` jsonExample := `{ "resources": [ { "params": { "byline": "picasso" }, "src": "**image-4.png", "title": "The Fourth Image!" }, { "name": "my-cool-image-:counter", "params": { "byline": "bep" }, "src": "**.png", "title": "TOML: The Image #:counter" } ], "title": "Test Metadata" } ` variants := []struct { format string data string }{ {"yaml", yamlExample}, {"json", jsonExample}, {"toml", tomlExample}, {"TOML", tomlExample}, {"Toml", tomlExample}, {" TOML ", tomlExample}, } for _, v1 := range variants { for _, v2 := range variants { // Both from and to may be the same here, but that is fine. fromTo := qt.Commentf("%s => %s", v2.format, v1.format) converted, err := ns.Remarshal(v1.format, v2.data) c.Assert(err, qt.IsNil, fromTo) diff := htesting.DiffStrings(v1.data, converted) if len(diff) > 0 { t.Errorf("[%s] Expected \n%v\ngot\n%v\ndiff:\n%v", fromTo, v1.data, converted, diff) } } } } func TestRemarshalComments(t *testing.T) { t.Parallel() v := viper.New() v.Set("contentDir", "content") ns := New(newDeps(v)) c := qt.New(t) input := ` Hugo = "Rules" # It really does! [m] # A comment a = "b" ` expected := ` Hugo = "Rules" [m] a = "b" ` for _, format := range []string{"json", "yaml", "toml"} { fromTo := qt.Commentf("%s => %s", "toml", format) converted := input var err error // Do a round-trip conversion for _, toFormat := range []string{format, "toml"} { converted, err = ns.Remarshal(toFormat, converted) c.Assert(err, qt.IsNil, fromTo) } diff := htesting.DiffStrings(expected, converted) if len(diff) > 0 { t.Fatalf("[%s] Expected \n%v\ngot\n%v\ndiff:\n%v\n", fromTo, expected, converted, diff) } } } func TestTestRemarshalError(t *testing.T) { t.Parallel() c := qt.New(t) v := viper.New() v.Set("contentDir", "content") ns := New(newDeps(v)) _, err := ns.Remarshal("asdf", "asdf") c.Assert(err, qt.Not(qt.IsNil)) _, err = ns.Remarshal("json", "asdf") c.Assert(err, qt.Not(qt.IsNil)) } func TestTestRemarshalMapInput(t *testing.T) { t.Parallel() c := qt.New(t) v := viper.New() v.Set("contentDir", "content") ns := New(newDeps(v)) input := map[string]interface{}{ "hello": "world", } output, err := ns.Remarshal("toml", input) c.Assert(err, qt.IsNil) c.Assert(output, qt.Equals, "hello = \"world\"\n") }
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./examples/multilingual/README.md
# Multilingual website with Hugo This example was kindly contributed by Egon Elbre in November 2013 as a wonderful proof-of-concept for internationalization (i18n) and multilingualization (m17n) in Hugo-generated websites. The example works well for the most part, though some minor issues remain. Please see relevant discussions below: * https://github.com/gohugoio/hugo/issues/129 Multiple languages * https://github.com/gohugoio/hugo/issues/134 Example of a multilingual site Alternatively follow our [multilingual site tutorial](https://gohugo.io/content-management/multilingual/). All contributions are welcome!
# Multilingual website with Hugo This example was kindly contributed by Egon Elbre in November 2013 as a wonderful proof-of-concept for internationalization (i18n) and multilingualization (m17n) in Hugo-generated websites. The example works well for the most part, though some minor issues remain. Please see relevant discussions below: * https://github.com/gohugoio/hugo/issues/129 Multiple languages * https://github.com/gohugoio/hugo/issues/134 Example of a multilingual site Alternatively follow our [multilingual site tutorial](https://gohugo.io/content-management/multilingual/). All contributions are welcome!
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./tpl/internal/go_templates/texttemplate/testdata/file2.tmpl
{{define "dot"}}{{.}}{{end}} {{define "nested"}}{{template "dot" .}}{{end}}
{{define "dot"}}{{.}}{{end}} {{define "nested"}}{{template "dot" .}}{{end}}
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./docs/content/en/news/0.27-relnotes/index.md
--- date: 2017-09-11 title: "Hugo 0.27: Fast and Flexible Related Content!" description: "Makes it easy to add \"See Also\" sections etc. to your site." categories: ["Releases"] images: - images/blog/hugo-27-poster.png --- Hugo `0.27`comes with fast and flexible **Related Content** ([3b4f17bb](https://github.com/gohugoio/hugo/commit/3b4f17bbc9ff789faa581ac278ad109d1ac5b816) [@bep](https://github.com/bep) [#98](https://github.com/gohugoio/hugo/issues/98)). To add this to your site, put something like this in your single page template: ```go-html-template {{ $related := .Site.RegularPages.Related . | first 5 }} {{ with $related }} <h3>See Also</h3> <ul> {{ range . }} <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li> {{ end }} </ul> {{ end }} ``` The above translates to _list the five regular pages mostly related to the current page_. See the [Related Content Documentation](https://gohugo.io/content-management/related/) for details and configuration options. This release represents **37 contributions by 9 contributors** to the main Hugo code base. [@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@moorereason](https://github.com/moorereason), [@yihui](https://github.com/yihui), and [@oneleaftea](https://github.com/oneleaftea) for their ongoing contributions. And as always a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) for his relentless work on keeping the documentation and the themes site in pristine condition. Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs), which has received **44 contributions by 30 contributors**. A special thanks to [@bep](https://github.com/bep), [@sdomino](https://github.com/sdomino), [@gotgenes](https://github.com/gotgenes), and [@digitalcraftsman](https://github.com/digitalcraftsman) for their work on the documentation site. Hugo now has: * 19464+ [stars](https://github.com/gohugoio/hugo/stargazers) * 455+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors) * 178+ [themes](http://themes.gohugo.io/) ## Notes * We now only strip p tag in `markdownify` if there is only one paragraph. This allows blocks of paragraphs to be "markdownified" [33ae10b6](https://github.com/gohugoio/hugo/commit/33ae10b6ade67cd9618970121d7de5fd2ce7d781) [@bep](https://github.com/bep) [#3040](https://github.com/gohugoio/hugo/issues/3040) ## Enhancements ### Templates * Add `time.Duration` and `time.ParseDuration` template funcs [f4bf2141](https://github.com/gohugoio/hugo/commit/f4bf214137ebd24a0d12f16d3a98d9038e6eabd3) [@bep](https://github.com/bep) [#3828](https://github.com/gohugoio/hugo/issues/3828) * Add `cond` (ternary) template func [0462c96a](https://github.com/gohugoio/hugo/commit/0462c96a5a9da3e8adc78d96acd39575a8b46c40) [@bep](https://github.com/bep) [#3860](https://github.com/gohugoio/hugo/issues/3860) * Prepare for template metrics [d000cf60](https://github.com/gohugoio/hugo/commit/d000cf605091c6999b72d6c632752289bc680223) [@bep](https://github.com/bep) * Add `strings.TrimLeft` and `TrimRight` [7674ad73](https://github.com/gohugoio/hugo/commit/7674ad73825c61eecc4003475fe0577f225fe579) [@moorereason](https://github.com/moorereason) * compare, hugolib, tpl: Add `Eqer` interface [08f48b91](https://github.com/gohugoio/hugo/commit/08f48b91d68d3002b887ddf737456ff0cc4e786d) [@bep](https://github.com/bep) [#3807](https://github.com/gohugoio/hugo/issues/3807) * Only strip p tag in `markdownify` if only one paragraph [33ae10b6](https://github.com/gohugoio/hugo/commit/33ae10b6ade67cd9618970121d7de5fd2ce7d781) [@bep](https://github.com/bep) [#3040](https://github.com/gohugoio/hugo/issues/3040) * Cleanup `strings.TrimPrefix` and `TrimSuffix` [29a2da05](https://github.com/gohugoio/hugo/commit/29a2da0593b081cdd61b93c6328af2c9ea4eb20f) [@moorereason](https://github.com/moorereason) ### Output * Improve the base template (aka `baseof.html`) identification [0019ce00](https://github.com/gohugoio/hugo/commit/0019ce002449d671a20a69406da37b10977f9493) [@bep](https://github.com/bep) ### Core * Implement "related content" [3b4f17bb](https://github.com/gohugoio/hugo/commit/3b4f17bbc9ff789faa581ac278ad109d1ac5b816) [@bep](https://github.com/bep) [#98](https://github.com/gohugoio/hugo/issues/98) * Add `Page.Equals` [f0f49ed9](https://github.com/gohugoio/hugo/commit/f0f49ed9b0c9b4545a45c95d56340fcbf4aafbef) [@bep](https://github.com/bep) * Rewrite `replaceDivider` to reduce memory allocation [71ae9b45](https://github.com/gohugoio/hugo/commit/71ae9b4533083be185c5314c9c5b273cc3bd07bd) [@bep](https://github.com/bep) ### Other * Set up Hugo release flow on `CircleCI` [d2249c50](https://github.com/gohugoio/hugo/commit/d2249c50991ba7b00b092aca6e315ca1a4de75a1) [@bep](https://github.com/bep) [#3779](https://github.com/gohugoio/hugo/issues/3779) * Maintain the scroll position if possible [7231d5a8](https://github.com/gohugoio/hugo/commit/7231d5a829f8d97336a2120afde1260db6ee6541) [@yihui](https://github.com/yihui) [#3824](https://github.com/gohugoio/hugo/issues/3824) * Add an `iFrame` title to the `YouTube` shortcode [919bc921](https://github.com/gohugoio/hugo/commit/919bc9210a69c801c7304c0b529df93d1dca27aa) [@nraboy](https://github.com/nraboy) * Remove the theme submodule from /docs [ea2cc26b](https://github.com/gohugoio/hugo/commit/ea2cc26b390476f1c605405604f8c92afd09b6ee) [@bep](https://github.com/bep) [#3791](https://github.com/gohugoio/hugo/issues/3791) * Add support for multiple config files via `--config a.toml,b.toml,c.toml` [0f9f73cc](https://github.com/gohugoio/hugo/commit/0f9f73cce5c3f1f05be20bcf1d23b2332623d7f9) [@jgielstra](https://github.com/jgielstra) * Render task list item inside `label` for correct accessibility [c8257f8b](https://github.com/gohugoio/hugo/commit/c8257f8b726478ca70dc8984cdcc17b31e4bdc0c) [@danieka](https://github.com/danieka) [#3303](https://github.com/gohugoio/hugo/issues/3303) * Normalize `UniqueID` between Windows & Linux [0abdeeef](https://github.com/gohugoio/hugo/commit/0abdeeef6740a3cbba0db95374853d040f2022b8) [@Shywim](https://github.com/Shywim) ## Fixes ### Output * Fix taxonomy term base template lookup [f88fe312](https://github.com/gohugoio/hugo/commit/f88fe312cb35f7de1615c095edd2f898303dd23b) [@bep](https://github.com/bep) [#3856](https://github.com/gohugoio/hugo/issues/3856) * Fix `published` front matter handling [202510fd](https://github.com/gohugoio/hugo/commit/202510fdc92d52a20baeaa7edb1091f6882bd95f) [@bep](https://github.com/bep) [#3867](https://github.com/gohugoio/hugo/issues/3867)
--- date: 2017-09-11 title: "Hugo 0.27: Fast and Flexible Related Content!" description: "Makes it easy to add \"See Also\" sections etc. to your site." categories: ["Releases"] images: - images/blog/hugo-27-poster.png --- Hugo `0.27`comes with fast and flexible **Related Content** ([3b4f17bb](https://github.com/gohugoio/hugo/commit/3b4f17bbc9ff789faa581ac278ad109d1ac5b816) [@bep](https://github.com/bep) [#98](https://github.com/gohugoio/hugo/issues/98)). To add this to your site, put something like this in your single page template: ```go-html-template {{ $related := .Site.RegularPages.Related . | first 5 }} {{ with $related }} <h3>See Also</h3> <ul> {{ range . }} <li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li> {{ end }} </ul> {{ end }} ``` The above translates to _list the five regular pages mostly related to the current page_. See the [Related Content Documentation](https://gohugo.io/content-management/related/) for details and configuration options. This release represents **37 contributions by 9 contributors** to the main Hugo code base. [@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@moorereason](https://github.com/moorereason), [@yihui](https://github.com/yihui), and [@oneleaftea](https://github.com/oneleaftea) for their ongoing contributions. And as always a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) for his relentless work on keeping the documentation and the themes site in pristine condition. Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs), which has received **44 contributions by 30 contributors**. A special thanks to [@bep](https://github.com/bep), [@sdomino](https://github.com/sdomino), [@gotgenes](https://github.com/gotgenes), and [@digitalcraftsman](https://github.com/digitalcraftsman) for their work on the documentation site. Hugo now has: * 19464+ [stars](https://github.com/gohugoio/hugo/stargazers) * 455+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors) * 178+ [themes](http://themes.gohugo.io/) ## Notes * We now only strip p tag in `markdownify` if there is only one paragraph. This allows blocks of paragraphs to be "markdownified" [33ae10b6](https://github.com/gohugoio/hugo/commit/33ae10b6ade67cd9618970121d7de5fd2ce7d781) [@bep](https://github.com/bep) [#3040](https://github.com/gohugoio/hugo/issues/3040) ## Enhancements ### Templates * Add `time.Duration` and `time.ParseDuration` template funcs [f4bf2141](https://github.com/gohugoio/hugo/commit/f4bf214137ebd24a0d12f16d3a98d9038e6eabd3) [@bep](https://github.com/bep) [#3828](https://github.com/gohugoio/hugo/issues/3828) * Add `cond` (ternary) template func [0462c96a](https://github.com/gohugoio/hugo/commit/0462c96a5a9da3e8adc78d96acd39575a8b46c40) [@bep](https://github.com/bep) [#3860](https://github.com/gohugoio/hugo/issues/3860) * Prepare for template metrics [d000cf60](https://github.com/gohugoio/hugo/commit/d000cf605091c6999b72d6c632752289bc680223) [@bep](https://github.com/bep) * Add `strings.TrimLeft` and `TrimRight` [7674ad73](https://github.com/gohugoio/hugo/commit/7674ad73825c61eecc4003475fe0577f225fe579) [@moorereason](https://github.com/moorereason) * compare, hugolib, tpl: Add `Eqer` interface [08f48b91](https://github.com/gohugoio/hugo/commit/08f48b91d68d3002b887ddf737456ff0cc4e786d) [@bep](https://github.com/bep) [#3807](https://github.com/gohugoio/hugo/issues/3807) * Only strip p tag in `markdownify` if only one paragraph [33ae10b6](https://github.com/gohugoio/hugo/commit/33ae10b6ade67cd9618970121d7de5fd2ce7d781) [@bep](https://github.com/bep) [#3040](https://github.com/gohugoio/hugo/issues/3040) * Cleanup `strings.TrimPrefix` and `TrimSuffix` [29a2da05](https://github.com/gohugoio/hugo/commit/29a2da0593b081cdd61b93c6328af2c9ea4eb20f) [@moorereason](https://github.com/moorereason) ### Output * Improve the base template (aka `baseof.html`) identification [0019ce00](https://github.com/gohugoio/hugo/commit/0019ce002449d671a20a69406da37b10977f9493) [@bep](https://github.com/bep) ### Core * Implement "related content" [3b4f17bb](https://github.com/gohugoio/hugo/commit/3b4f17bbc9ff789faa581ac278ad109d1ac5b816) [@bep](https://github.com/bep) [#98](https://github.com/gohugoio/hugo/issues/98) * Add `Page.Equals` [f0f49ed9](https://github.com/gohugoio/hugo/commit/f0f49ed9b0c9b4545a45c95d56340fcbf4aafbef) [@bep](https://github.com/bep) * Rewrite `replaceDivider` to reduce memory allocation [71ae9b45](https://github.com/gohugoio/hugo/commit/71ae9b4533083be185c5314c9c5b273cc3bd07bd) [@bep](https://github.com/bep) ### Other * Set up Hugo release flow on `CircleCI` [d2249c50](https://github.com/gohugoio/hugo/commit/d2249c50991ba7b00b092aca6e315ca1a4de75a1) [@bep](https://github.com/bep) [#3779](https://github.com/gohugoio/hugo/issues/3779) * Maintain the scroll position if possible [7231d5a8](https://github.com/gohugoio/hugo/commit/7231d5a829f8d97336a2120afde1260db6ee6541) [@yihui](https://github.com/yihui) [#3824](https://github.com/gohugoio/hugo/issues/3824) * Add an `iFrame` title to the `YouTube` shortcode [919bc921](https://github.com/gohugoio/hugo/commit/919bc9210a69c801c7304c0b529df93d1dca27aa) [@nraboy](https://github.com/nraboy) * Remove the theme submodule from /docs [ea2cc26b](https://github.com/gohugoio/hugo/commit/ea2cc26b390476f1c605405604f8c92afd09b6ee) [@bep](https://github.com/bep) [#3791](https://github.com/gohugoio/hugo/issues/3791) * Add support for multiple config files via `--config a.toml,b.toml,c.toml` [0f9f73cc](https://github.com/gohugoio/hugo/commit/0f9f73cce5c3f1f05be20bcf1d23b2332623d7f9) [@jgielstra](https://github.com/jgielstra) * Render task list item inside `label` for correct accessibility [c8257f8b](https://github.com/gohugoio/hugo/commit/c8257f8b726478ca70dc8984cdcc17b31e4bdc0c) [@danieka](https://github.com/danieka) [#3303](https://github.com/gohugoio/hugo/issues/3303) * Normalize `UniqueID` between Windows & Linux [0abdeeef](https://github.com/gohugoio/hugo/commit/0abdeeef6740a3cbba0db95374853d040f2022b8) [@Shywim](https://github.com/Shywim) ## Fixes ### Output * Fix taxonomy term base template lookup [f88fe312](https://github.com/gohugoio/hugo/commit/f88fe312cb35f7de1615c095edd2f898303dd23b) [@bep](https://github.com/bep) [#3856](https://github.com/gohugoio/hugo/issues/3856) * Fix `published` front matter handling [202510fd](https://github.com/gohugoio/hugo/commit/202510fdc92d52a20baeaa7edb1091f6882bd95f) [@bep](https://github.com/bep) [#3867](https://github.com/gohugoio/hugo/issues/3867)
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./docs/content/en/news/0.55.2-relnotes/index.md
--- date: 2019-04-17 title: "Hugo 0.55.2: Some Important Bug Fixes" description: "Fixes some more issues introduced in Hugo 0.55.0." categories: ["Releases"] images: - images/blog/hugo-bug-poster.png --- This is a bug-fix release with a couple of important fixes. Hugo now has: * 34386+ [stars](https://github.com/gohugoio/hugo/stargazers) * 439+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors) * 307+ [themes](http://themes.gohugo.io/) ## Enhancements ### Templates * Handle late transformation of templates [2957795f](https://github.com/gohugoio/hugo/commit/2957795f5276cc9bc8d438da2d7d9b61defea225) [@bep](https://github.com/bep) [#5865](https://github.com/gohugoio/hugo/issues/5865) ### Core * Add more tests for Permalinkable [35f41834](https://github.com/gohugoio/hugo/commit/35f41834ea3a8799b9b7eda360cf8d30b1b727ba) [@bep](https://github.com/bep) [#5849](https://github.com/gohugoio/hugo/issues/5849) ## Fixes ### Core * Fix Pages reinitialization on rebuilds [9b17cbb6](https://github.com/gohugoio/hugo/commit/9b17cbb62a056ea7e26b1146cbf3ba42f5acf805) [@bep](https://github.com/bep) [#5833](https://github.com/gohugoio/hugo/issues/5833) * Fix shortcode namespace issue [56550d1e](https://github.com/gohugoio/hugo/commit/56550d1e449f45ebee398ac8a9e3b9818b3ee60e) [@bep](https://github.com/bep) [#5863](https://github.com/gohugoio/hugo/issues/5863) * Fix false WARNINGs in lang prefix check [7881b096](https://github.com/gohugoio/hugo/commit/7881b0965f8b83d03379e9ed102cd0c3bce297e2) [@bep](https://github.com/bep) [#5860](https://github.com/gohugoio/hugo/issues/5860) * Fix bundle resource publishing when multiple output formats [49d0a826](https://github.com/gohugoio/hugo/commit/49d0a82641581aa7dd66b9d5e8c7d75e23260083) [@bep](https://github.com/bep) [#5858](https://github.com/gohugoio/hugo/issues/5858) * Fix panic for unused taxonomy content files [b799b12f](https://github.com/gohugoio/hugo/commit/b799b12f4a693dfeae8a5a362f131081a727bb8f) [@bep](https://github.com/bep) [#5847](https://github.com/gohugoio/hugo/issues/5847) * Fix dates for sections with dates in front matter [70148672](https://github.com/gohugoio/hugo/commit/701486728e21bc0c6c78c2a8edb988abdf6116c7) [@bep](https://github.com/bep) [#5854](https://github.com/gohugoio/hugo/issues/5854) ### Other * Fix WeightedPages in union etc. [f2795d4d](https://github.com/gohugoio/hugo/commit/f2795d4d2cef30170af43327f3ff7114923833b1) [@bep](https://github.com/bep) [#5850](https://github.com/gohugoio/hugo/issues/5850)
--- date: 2019-04-17 title: "Hugo 0.55.2: Some Important Bug Fixes" description: "Fixes some more issues introduced in Hugo 0.55.0." categories: ["Releases"] images: - images/blog/hugo-bug-poster.png --- This is a bug-fix release with a couple of important fixes. Hugo now has: * 34386+ [stars](https://github.com/gohugoio/hugo/stargazers) * 439+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors) * 307+ [themes](http://themes.gohugo.io/) ## Enhancements ### Templates * Handle late transformation of templates [2957795f](https://github.com/gohugoio/hugo/commit/2957795f5276cc9bc8d438da2d7d9b61defea225) [@bep](https://github.com/bep) [#5865](https://github.com/gohugoio/hugo/issues/5865) ### Core * Add more tests for Permalinkable [35f41834](https://github.com/gohugoio/hugo/commit/35f41834ea3a8799b9b7eda360cf8d30b1b727ba) [@bep](https://github.com/bep) [#5849](https://github.com/gohugoio/hugo/issues/5849) ## Fixes ### Core * Fix Pages reinitialization on rebuilds [9b17cbb6](https://github.com/gohugoio/hugo/commit/9b17cbb62a056ea7e26b1146cbf3ba42f5acf805) [@bep](https://github.com/bep) [#5833](https://github.com/gohugoio/hugo/issues/5833) * Fix shortcode namespace issue [56550d1e](https://github.com/gohugoio/hugo/commit/56550d1e449f45ebee398ac8a9e3b9818b3ee60e) [@bep](https://github.com/bep) [#5863](https://github.com/gohugoio/hugo/issues/5863) * Fix false WARNINGs in lang prefix check [7881b096](https://github.com/gohugoio/hugo/commit/7881b0965f8b83d03379e9ed102cd0c3bce297e2) [@bep](https://github.com/bep) [#5860](https://github.com/gohugoio/hugo/issues/5860) * Fix bundle resource publishing when multiple output formats [49d0a826](https://github.com/gohugoio/hugo/commit/49d0a82641581aa7dd66b9d5e8c7d75e23260083) [@bep](https://github.com/bep) [#5858](https://github.com/gohugoio/hugo/issues/5858) * Fix panic for unused taxonomy content files [b799b12f](https://github.com/gohugoio/hugo/commit/b799b12f4a693dfeae8a5a362f131081a727bb8f) [@bep](https://github.com/bep) [#5847](https://github.com/gohugoio/hugo/issues/5847) * Fix dates for sections with dates in front matter [70148672](https://github.com/gohugoio/hugo/commit/701486728e21bc0c6c78c2a8edb988abdf6116c7) [@bep](https://github.com/bep) [#5854](https://github.com/gohugoio/hugo/issues/5854) ### Other * Fix WeightedPages in union etc. [f2795d4d](https://github.com/gohugoio/hugo/commit/f2795d4d2cef30170af43327f3ff7114923833b1) [@bep](https://github.com/bep) [#5850](https://github.com/gohugoio/hugo/issues/5850)
-1
gohugoio/hugo
8,171
js: Add Inject config option
Fixes #8164
bep
"2021-01-22T16:28:36Z"
"2021-01-22T22:43:45Z"
241b7483ea954653512d4895ad6bacf79ee26ddc
32b86076ee1c0833b538b84e1cc9e6d79babecf2
js: Add Inject config option. Fixes #8164
./tpl/openapi/openapi3/init.go
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package openapi3 import ( "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/tpl/internal" ) const name = "openapi3" func init() { f := func(d *deps.Deps) *internal.TemplateFuncsNamespace { ctx := New(d) ns := &internal.TemplateFuncsNamespace{ Name: name, Context: func(args ...interface{}) interface{} { return ctx }, } ns.AddMethodMapping(ctx.Unmarshal, nil, [][2]string{}, ) return ns } internal.AddTemplateFuncsNamespace(f) }
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package openapi3 import ( "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/tpl/internal" ) const name = "openapi3" func init() { f := func(d *deps.Deps) *internal.TemplateFuncsNamespace { ctx := New(d) ns := &internal.TemplateFuncsNamespace{ Name: name, Context: func(args ...interface{}) interface{} { return ctx }, } ns.AddMethodMapping(ctx.Unmarshal, nil, [][2]string{}, ) return ns } internal.AddTemplateFuncsNamespace(f) }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/hugo-pipes/js.md
--- title: JavaScript Building description: Hugo Pipes can process JavaScript files with [ESBuild](https://github.com/evanw/esbuild). date: 2020-07-20 publishdate: 2020-07-20 lastmod: 2020-07-20 categories: [asset management] keywords: [] menu: docs: parent: "pipes" weight: 45 weight: 45 sections_weight: 45 draft: false --- Any JavaScript resource file can be transpiled and "tree shaken" using `js.Build` which takes for argument either a string for the filepath or a dict of options listed below. ### Options targetPath [string] : If not set, the source path will be used as the base target path. Note that the target path's extension may change if the target MIME type is different, e.g. when the source is TypeScript. params [map or slice] {{< new-in "0.78.0" >}} : Params that can be imported as JSON in your JS files, e.g.: ```go-html-template {{ $js := resources.Get "js/main.js" | js.Build (dict "params" (dict "api" "https://example.org/api")) }} ``` And then in your JS file: ```js import * as params from '@params'; ``` Note that this is meant for small data sets, e.g. config settings. For larger data, please put/mount the files into `/assets` and import them directly. minify [bool] : Let `js.Build` handle the minification. avoidTDZ {{< new-in "0.78.0" >}} : There is/was a bug in WebKit with severe performance issue with the tracking of TDZ checks in JavaScriptCore. Enabling this flag removes the TDZ and `const` assignment checks and may improve performance of larger JS codebases until the WebKit fix is in widespread use. See https://bugs.webkit.org/show_bug.cgi?id=199866 target [string] : The language target. One of: `es5`, `es2015`, `es2016`, `es2017`, `es2018`, `es2019`, `es2020` or `esnext`. Default is `esnext`. externals [slice] : External dependencies. If a dependency should not be included in the bundle (Ex. library loaded from a CDN.), it should be listed here. ```go-html-template {{ $externals := slice "react" "react-dom" }} ``` > Marking a package as external doesn't imply that the library can be loaded from a CDN. It simply tells Hugo not to expand/include the package in the JS file. defines [map] : Allow to define a set of string replacement to be performed when building. Should be a map where each key is to be replaced by its value. ```go-html-template {{ $defines := dict "process.env.NODE_ENV" `"development"` }} ``` format [string] {{< new-in "0.74.3" >}} : The output format. One of: `iife`, `cjs`, `esm`. Default is `iife`, a self-executing function, suitable for inclusion as a <script> tag. sourceMap : Whether to generate source maps. Enum, currently only `inline` (we will improve that). ### Import JS code from /assets {{< new-in "0.78.0" >}} Since Hugo `v0.78.0` `js.Build` has full support for the virtual union file system in [Hugo Modules](/hugo-modules/). You can see some simple examples in this [test project](https://github.com/gohugoio/hugoTestProjectJSModImports), but in short this means that you can do this: ```js import { hello } from 'my/module'; ``` And it will resolve to the top-most `index.{js,ts,tsx,jsx}` inside `assets/my/module` in the layered file system. ```js import { hello3 } from 'my/module/hello3'; ``` Wil resolve to `hello3.{js,ts,tsx,jsx}` inside `assets/my/module`. Any imports starting with `.` is resolved relative to the current file: ```js import { hello4 } from './lib'; ``` For other files (e.g. `JSON`, `CSS`) you need to use the relative path including any extension, e.g: ```js import * as data from 'my/module/data.json'; ``` Any imports in a file outside `/assets` or that does not resolve to a component inside `/assets` will be resolved by [ESBuild](https://esbuild.github.io/) with the **project directory** as the resolve directory (used as the starting point when looking for `node_modules` etc.). Also see [hugo mod npm pack](/commands/hugo_mod_npm_pack/). If you have any imported NPM dependencies in your project, you need to make sure to run `npm install` before you run `hugo`. Also note the new `params` option that can be passed from template to your JS files, e.g.: ```go-html-template {{ $js := resources.Get "js/main.js" | js.Build (dict "params" (dict "api" "https://example.org/api")) }} ``` And then in your JS file: ```js import * as params from '@params'; ``` Hugo will, by default, generate a `assets/jsconfig.json` file that maps the imports. This is useful for navigation/intellisense help inside code editors, but if you don't need/want it, you can [turn it off](/getting-started/configuration/#configure-build). ### Include Dependencies In package.json / node_modules Any imports in a file outside `/assets` or that does not resolve to a component inside `/assets` will be resolved by [ESBuild](https://esbuild.github.io/) with the **project directory** as the resolve directory (used as the starting point when looking for `node_modules` etc.). Also see [hugo mod npm pack](/commands/hugo_mod_npm_pack/). If you have any imported NPM dependencies in your project, you need to make sure to run `npm install` before you run `hugo`. {{< new-in "0.78.1" >}} From Hugo `0.78.1` the start directory for resolving NPM packages (aka. packages that live inside a `node_modules` folder) is always the main project folder. **Note:** If you're developing a theme/component that is supposed to be imported and depends on dependencies inside `package.json`, we recommend reading about [hugo mod npm pack](/commands/hugo_mod_npm_pack/), a tool to consolidate all the NPM dependencies in a project. ### Examples ```go-html-template {{ $built := resources.Get "js/index.js" | js.Build "main.js" }} ``` Or with options: ```go-html-template {{ $externals := slice "react" "react-dom" }} {{ $defines := dict "process.env.NODE_ENV" `"development"` }} {{ $opts := dict "targetPath" "main.js" "externals" $externals "defines" $defines }} {{ $built := resources.Get "scripts/main.js" | js.Build $opts }} <script type="text/javascript" src="{{ $built.RelPermalink }}" defer></script> ``` #### Shimming a JS library It's a common practice to load external libraries using a content delivery network (CDN) rather than importing all packages in a single JS file. To load scripts from a CDN with Hugo, you'll need to shim the libraries as follows. In this example, `react` and `react-dom` will be shimmed. First, add React and ReactDOM [CDN script tags](https://reactjs.org/docs/add-react-to-a-website.html#tip-minify-javascript-for-production) in your HTML template files. Then create `assets/js/shims/react.js` and `assets/js/shims/react-dom.js` with the following contents: ```js // In assets/js/shims/react.js module.exports = window.React; // In assets/js/shims/react-dom.js module.exports = window.ReactDOM; ``` Finally, add the following to your project's `package.json`: ```json { "browser": { "react": "./assets/js/shims/react.js", "react-dom": "./assets/js/shims/react-dom.js" } } ``` This tells Hugo's `js.Build` command to look for `react` and `react-dom` in the project's `assets/js/shims` folder. Note that the `browser` field in your `package.json` file will cause React and ReactDOM to be excluded from your JavaScript bundle. Therefore, **it is unnecessary to add them to the `js.Build` command's `externals` argument.** That's it! You should now have a browser-friendly JS which can use external JS libraries.
--- title: JavaScript Building description: Hugo Pipes can process JavaScript files with [ESBuild](https://github.com/evanw/esbuild). date: 2020-07-20 publishdate: 2020-07-20 lastmod: 2020-07-20 categories: [asset management] keywords: [] menu: docs: parent: "pipes" weight: 45 weight: 45 sections_weight: 45 draft: false --- Any JavaScript resource file can be transpiled and "tree shaken" using `js.Build` which takes for argument either a string for the filepath or a dict of options listed below. ### Options targetPath [string] : If not set, the source path will be used as the base target path. Note that the target path's extension may change if the target MIME type is different, e.g. when the source is TypeScript. params [map or slice] {{< new-in "0.78.0" >}} : Params that can be imported as JSON in your JS files, e.g.: ```go-html-template {{ $js := resources.Get "js/main.js" | js.Build (dict "params" (dict "api" "https://example.org/api")) }} ``` And then in your JS file: ```js import * as params from '@params'; ``` Note that this is meant for small data sets, e.g. config settings. For larger data, please put/mount the files into `/assets` and import them directly. minify [bool] : Let `js.Build` handle the minification. avoidTDZ {{< new-in "0.78.0" >}} : There is/was a bug in WebKit with severe performance issue with the tracking of TDZ checks in JavaScriptCore. Enabling this flag removes the TDZ and `const` assignment checks and may improve performance of larger JS codebases until the WebKit fix is in widespread use. See https://bugs.webkit.org/show_bug.cgi?id=199866 shims {{< new-in "0.81.0" >}} : This option allows swapping out a component with another. A common use case is to load dependencies like React from a CDN (with _shims_) when in production, but running with the full bundled `node_modules` dependency during development: ``` {{ $shims := dict "react" "js/shims/react.js" "react-dom" "js/shims/react-dom.js" }} {{ $js = $js | js.Build dict "shims" $shims }} ``` The _shim_ files may look like these: ```js // js/shims/react.js module.exports = window.React; ``` ```js // js/shims/react-dom.js module.exports = window.ReactDOM; ``` With the above, these imports should work in both scenarios: ```js import * as React from 'react' import * as ReactDOM from 'react-dom'; ``` target [string] : The language target. One of: `es5`, `es2015`, `es2016`, `es2017`, `es2018`, `es2019`, `es2020` or `esnext`. Default is `esnext`. externals [slice] : External dependencies. Use this to trim dependencies you know will never be executed. See https://esbuild.github.io/api/#external defines [map] : Allow to define a set of string replacement to be performed when building. Should be a map where each key is to be replaced by its value. ```go-html-template {{ $defines := dict "process.env.NODE_ENV" `"development"` }} ``` format [string] {{< new-in "0.74.3" >}} : The output format. One of: `iife`, `cjs`, `esm`. Default is `iife`, a self-executing function, suitable for inclusion as a <script> tag. sourceMap : Whether to generate source maps. Enum, currently only `inline` (we will improve that). ### Import JS code from /assets {{< new-in "0.78.0" >}} Since Hugo `v0.78.0` `js.Build` has full support for the virtual union file system in [Hugo Modules](/hugo-modules/). You can see some simple examples in this [test project](https://github.com/gohugoio/hugoTestProjectJSModImports), but in short this means that you can do this: ```js import { hello } from 'my/module'; ``` And it will resolve to the top-most `index.{js,ts,tsx,jsx}` inside `assets/my/module` in the layered file system. ```js import { hello3 } from 'my/module/hello3'; ``` Wil resolve to `hello3.{js,ts,tsx,jsx}` inside `assets/my/module`. Any imports starting with `.` is resolved relative to the current file: ```js import { hello4 } from './lib'; ``` For other files (e.g. `JSON`, `CSS`) you need to use the relative path including any extension, e.g: ```js import * as data from 'my/module/data.json'; ``` Any imports in a file outside `/assets` or that does not resolve to a component inside `/assets` will be resolved by [ESBuild](https://esbuild.github.io/) with the **project directory** as the resolve directory (used as the starting point when looking for `node_modules` etc.). Also see [hugo mod npm pack](/commands/hugo_mod_npm_pack/). If you have any imported NPM dependencies in your project, you need to make sure to run `npm install` before you run `hugo`. Also note the new `params` option that can be passed from template to your JS files, e.g.: ```go-html-template {{ $js := resources.Get "js/main.js" | js.Build (dict "params" (dict "api" "https://example.org/api")) }} ``` And then in your JS file: ```js import * as params from '@params'; ``` Hugo will, by default, generate a `assets/jsconfig.json` file that maps the imports. This is useful for navigation/intellisense help inside code editors, but if you don't need/want it, you can [turn it off](/getting-started/configuration/#configure-build). ### Include Dependencies In package.json / node_modules Any imports in a file outside `/assets` or that does not resolve to a component inside `/assets` will be resolved by [ESBuild](https://esbuild.github.io/) with the **project directory** as the resolve directory (used as the starting point when looking for `node_modules` etc.). Also see [hugo mod npm pack](/commands/hugo_mod_npm_pack/). If you have any imported NPM dependencies in your project, you need to make sure to run `npm install` before you run `hugo`. {{< new-in "0.78.1" >}} From Hugo `0.78.1` the start directory for resolving NPM packages (aka. packages that live inside a `node_modules` folder) is always the main project folder. **Note:** If you're developing a theme/component that is supposed to be imported and depends on dependencies inside `package.json`, we recommend reading about [hugo mod npm pack](/commands/hugo_mod_npm_pack/), a tool to consolidate all the NPM dependencies in a project. ### Examples ```go-html-template {{ $built := resources.Get "js/index.js" | js.Build "main.js" }} ``` Or with options: ```go-html-template {{ $externals := slice "react" "react-dom" }} {{ $defines := dict "process.env.NODE_ENV" `"development"` }} {{ $opts := dict "targetPath" "main.js" "externals" $externals "defines" $defines }} {{ $built := resources.Get "scripts/main.js" | js.Build $opts }} <script type="text/javascript" src="{{ $built.RelPermalink }}" defer></script> ```
1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./hugolib/js_test.go
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "fmt" "os" "path/filepath" "runtime" "testing" "github.com/gohugoio/hugo/common/hexec" "github.com/gohugoio/hugo/htesting" "github.com/spf13/viper" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/common/loggers" ) func TestJSBuildWithNPM(t *testing.T) { if !htesting.IsCI() { t.Skip("skip (relative) long running modules test when running locally") } if runtime.GOOS == "windows" { t.Skip("skip NPM test on Windows") } wd, _ := os.Getwd() defer func() { os.Chdir(wd) }() c := qt.New(t) mainJS := ` import "./included"; import { toCamelCase } from "to-camel-case"; console.log("main"); console.log("To camel:", toCamelCase("space case")); ` includedJS := ` console.log("included"); ` jsxContent := ` import * as React from 'react' import * as ReactDOM from 'react-dom' ReactDOM.render( <h1>Hello, world!</h1>, document.getElementById('root') ); ` tsContent := `function greeter(person: string) { return "Hello, " + person; } let user = [0, 1, 2]; document.body.textContent = greeter(user);` packageJSON := `{ "scripts": {}, "dependencies": { "to-camel-case": "1.0.0" } } ` workDir, clean, err := htesting.CreateTempDir(hugofs.Os, "hugo-test-js-npm") c.Assert(err, qt.IsNil) defer clean() v := viper.New() v.Set("workingDir", workDir) v.Set("disableKinds", []string{"taxonomy", "term", "page"}) b := newTestSitesBuilder(t).WithLogger(loggers.NewWarningLogger()) // Need to use OS fs for this. b.Fs = hugofs.NewDefault(v) b.WithWorkingDir(workDir) b.WithViper(v) b.WithContent("p1.md", "") b.WithTemplates("index.html", ` {{ $options := dict "minify" false "externals" (slice "react" "react-dom") }} {{ $js := resources.Get "js/main.js" | js.Build $options }} JS: {{ template "print" $js }} {{ $jsx := resources.Get "js/myjsx.jsx" | js.Build $options }} JSX: {{ template "print" $jsx }} {{ $ts := resources.Get "js/myts.ts" | js.Build (dict "sourcemap" "inline")}} TS: {{ template "print" $ts }} {{ $ts2 := resources.Get "js/myts.ts" | js.Build (dict "sourcemap" "external" "TargetPath" "js/myts2.js")}} TS2: {{ template "print" $ts2 }} {{ define "print" }}RelPermalink: {{.RelPermalink}}|MIME: {{ .MediaType }}|Content: {{ .Content | safeJS }}{{ end }} `) jsDir := filepath.Join(workDir, "assets", "js") fmt.Println(workDir) b.Assert(os.MkdirAll(jsDir, 0777), qt.IsNil) b.Assert(os.Chdir(workDir), qt.IsNil) b.WithSourceFile("package.json", packageJSON) b.WithSourceFile("assets/js/main.js", mainJS) b.WithSourceFile("assets/js/myjsx.jsx", jsxContent) b.WithSourceFile("assets/js/myts.ts", tsContent) b.WithSourceFile("assets/js/included.js", includedJS) cmd, err := hexec.SafeCommand("npm", "install") b.Assert(err, qt.IsNil) out, err := cmd.CombinedOutput() b.Assert(err, qt.IsNil, qt.Commentf(string(out))) b.Build(BuildCfg{}) b.AssertFileContent("public/js/myts.js", `//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJz`) b.AssertFileContent("public/js/myts2.js.map", `"version": 3,`) b.AssertFileContent("public/index.html", ` console.log(&#34;included&#34;); if (hasSpace.test(string)) var React = __toModule(require(&#34;react&#34;)); function greeter(person) { `) } func TestJSBuild(t *testing.T) { if !htesting.IsCI() { t.Skip("skip (relative) long running modules test when running locally") } if runtime.GOOS == "windows" { // TODO(bep) we really need to get this working on Travis. t.Skip("skip npm test on Windows") } wd, _ := os.Getwd() defer func() { os.Chdir(wd) }() c := qt.New(t) workDir, clean, err := htesting.CreateTempDir(hugofs.Os, "hugo-test-js-mod") c.Assert(err, qt.IsNil) defer clean() config := fmt.Sprintf(` baseURL = "https://example.org" workingDir = %q disableKinds = ["page", "section", "term", "taxonomy"] [module] [[module.imports]] path="github.com/gohugoio/hugoTestProjectJSModImports" `, workDir) b := newTestSitesBuilder(t) b.Fs = hugofs.NewDefault(viper.New()) b.WithWorkingDir(workDir).WithConfigFile("toml", config).WithLogger(loggers.NewInfoLogger()) b.WithSourceFile("go.mod", `module github.com/gohugoio/tests/testHugoModules go 1.15 require github.com/gohugoio/hugoTestProjectJSModImports v0.5.0 // indirect `) b.WithContent("p1.md", "").WithNothingAdded() b.WithSourceFile("package.json", `{ "dependencies": { "date-fns": "^2.16.1" } }`) b.Assert(os.Chdir(workDir), qt.IsNil) cmd, _ := hexec.SafeCommand("npm", "install") _, err = cmd.CombinedOutput() b.Assert(err, qt.IsNil) b.Build(BuildCfg{}) b.AssertFileContent("public/js/main.js", ` greeting: "greeting configured in mod2" Hello1 from mod1: $ return "Hello2 from mod1"; var Hugo = "Rocks!"; Hello3 from mod2. Date from date-fns: ${today} Hello from lib in the main project Hello5 from mod2. var myparam = "Hugo Rocks!";`) }
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "fmt" "os" "path/filepath" "runtime" "testing" "github.com/gohugoio/hugo/common/hexec" "github.com/gohugoio/hugo/htesting" "github.com/spf13/viper" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/common/loggers" ) func TestJSBuildWithNPM(t *testing.T) { if !htesting.IsCI() { t.Skip("skip (relative) long running modules test when running locally") } if runtime.GOOS == "windows" { t.Skip("skip NPM test on Windows") } wd, _ := os.Getwd() defer func() { os.Chdir(wd) }() c := qt.New(t) mainJS := ` import "./included"; import { toCamelCase } from "to-camel-case"; console.log("main"); console.log("To camel:", toCamelCase("space case")); ` includedJS := ` console.log("included"); ` jsxContent := ` import * as React from 'react' import * as ReactDOM from 'react-dom' ReactDOM.render( <h1>Hello, world!</h1>, document.getElementById('root') ); ` tsContent := `function greeter(person: string) { return "Hello, " + person; } let user = [0, 1, 2]; document.body.textContent = greeter(user);` packageJSON := `{ "scripts": {}, "dependencies": { "to-camel-case": "1.0.0" } } ` workDir, clean, err := htesting.CreateTempDir(hugofs.Os, "hugo-test-js-npm") c.Assert(err, qt.IsNil) defer clean() v := viper.New() v.Set("workingDir", workDir) v.Set("disableKinds", []string{"taxonomy", "term", "page"}) b := newTestSitesBuilder(t).WithLogger(loggers.NewWarningLogger()) // Need to use OS fs for this. b.Fs = hugofs.NewDefault(v) b.WithWorkingDir(workDir) b.WithViper(v) b.WithContent("p1.md", "") b.WithTemplates("index.html", ` {{ $options := dict "minify" false "externals" (slice "react" "react-dom") }} {{ $js := resources.Get "js/main.js" | js.Build $options }} JS: {{ template "print" $js }} {{ $jsx := resources.Get "js/myjsx.jsx" | js.Build $options }} JSX: {{ template "print" $jsx }} {{ $ts := resources.Get "js/myts.ts" | js.Build (dict "sourcemap" "inline")}} TS: {{ template "print" $ts }} {{ $ts2 := resources.Get "js/myts.ts" | js.Build (dict "sourcemap" "external" "TargetPath" "js/myts2.js")}} TS2: {{ template "print" $ts2 }} {{ define "print" }}RelPermalink: {{.RelPermalink}}|MIME: {{ .MediaType }}|Content: {{ .Content | safeJS }}{{ end }} `) jsDir := filepath.Join(workDir, "assets", "js") fmt.Println(workDir) b.Assert(os.MkdirAll(jsDir, 0777), qt.IsNil) b.Assert(os.Chdir(workDir), qt.IsNil) b.WithSourceFile("package.json", packageJSON) b.WithSourceFile("assets/js/main.js", mainJS) b.WithSourceFile("assets/js/myjsx.jsx", jsxContent) b.WithSourceFile("assets/js/myts.ts", tsContent) b.WithSourceFile("assets/js/included.js", includedJS) cmd, err := hexec.SafeCommand("npm", "install") b.Assert(err, qt.IsNil) out, err := cmd.CombinedOutput() b.Assert(err, qt.IsNil, qt.Commentf(string(out))) b.Build(BuildCfg{}) b.AssertFileContent("public/js/myts.js", `//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJz`) b.AssertFileContent("public/js/myts2.js.map", `"version": 3,`) b.AssertFileContent("public/index.html", ` console.log(&#34;included&#34;); if (hasSpace.test(string)) var React = __toModule(require(&#34;react&#34;)); function greeter(person) { `) } func TestJSBuild(t *testing.T) { if !htesting.IsCI() { t.Skip("skip (relative) long running modules test when running locally") } if runtime.GOOS == "windows" { // TODO(bep) we really need to get this working on Travis. t.Skip("skip npm test on Windows") } wd, _ := os.Getwd() defer func() { os.Chdir(wd) }() c := qt.New(t) workDir, clean, err := htesting.CreateTempDir(hugofs.Os, "hugo-test-js-mod") c.Assert(err, qt.IsNil) defer clean() config := fmt.Sprintf(` baseURL = "https://example.org" workingDir = %q disableKinds = ["page", "section", "term", "taxonomy"] [module] [[module.imports]] path="github.com/gohugoio/hugoTestProjectJSModImports" `, workDir) b := newTestSitesBuilder(t) b.Fs = hugofs.NewDefault(viper.New()) b.WithWorkingDir(workDir).WithConfigFile("toml", config).WithLogger(loggers.NewInfoLogger()) b.WithSourceFile("go.mod", `module github.com/gohugoio/tests/testHugoModules go 1.15 require github.com/gohugoio/hugoTestProjectJSModImports v0.8.0 // indirect `) b.WithContent("p1.md", "").WithNothingAdded() b.WithSourceFile("package.json", `{ "dependencies": { "date-fns": "^2.16.1" } }`) b.Assert(os.Chdir(workDir), qt.IsNil) cmd, _ := hexec.SafeCommand("npm", "install") _, err = cmd.CombinedOutput() b.Assert(err, qt.IsNil) b.Build(BuildCfg{}) b.AssertFileContent("public/js/main.js", ` greeting: "greeting configured in mod2" Hello1 from mod1: $ return "Hello2 from mod1"; var Hugo = "Rocks!"; Hello3 from mod2. Date from date-fns: ${today} Hello from lib in the main project Hello5 from mod2. var myparam = "Hugo Rocks!";`) // React JSX, verify the shimming. b.AssertFileContent("public/js/like.js", `@v0.8.0/assets/js/shims/react.js module.exports = window.ReactDOM; `) }
1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./resources/resource_transformers/js/options.go
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package js import ( "encoding/json" "fmt" "io/ioutil" "path/filepath" "strings" "github.com/pkg/errors" "github.com/evanw/esbuild/pkg/api" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/media" "github.com/mitchellh/mapstructure" "github.com/spf13/cast" ) const ( nsImportHugo = "ns-hugo" nsParams = "ns-params" stdinImporter = "<stdin>" ) // Options esbuild configuration type Options struct { // If not set, the source path will be used as the base target path. // Note that the target path's extension may change if the target MIME type // is different, e.g. when the source is TypeScript. TargetPath string // Whether to minify to output. Minify bool // Whether to write mapfiles SourceMap string // The language target. // One of: es2015, es2016, es2017, es2018, es2019, es2020 or esnext. // Default is esnext. Target string // The output format. // One of: iife, cjs, esm // Default is to esm. Format string // External dependencies, e.g. "react". Externals []string `hash:"set"` // User defined symbols. Defines map[string]interface{} // User defined params. Will be marshaled to JSON and available as "@params", e.g. // import * as params from '@params'; Params interface{} // What to use instead of React.createElement. JSXFactory string // What to use instead of React.Fragment. JSXFragment string // There is/was a bug in WebKit with severe performance issue with the tracking // of TDZ checks in JavaScriptCore. // // Enabling this flag removes the TDZ and `const` assignment checks and // may improve performance of larger JS codebases until the WebKit fix // is in widespread use. // // See https://bugs.webkit.org/show_bug.cgi?id=199866 // Deprecated: This no longer have any effect and will be removed. // TODO(bep) remove. See https://github.com/evanw/esbuild/commit/869e8117b499ca1dbfc5b3021938a53ffe934dba AvoidTDZ bool mediaType media.Type outDir string contents string sourcefile string resolveDir string tsConfig string } func decodeOptions(m map[string]interface{}) (Options, error) { var opts Options if err := mapstructure.WeakDecode(m, &opts); err != nil { return opts, err } if opts.TargetPath != "" { opts.TargetPath = helpers.ToSlashTrimLeading(opts.TargetPath) } opts.Target = strings.ToLower(opts.Target) opts.Format = strings.ToLower(opts.Format) return opts, nil } var extensionToLoaderMap = map[string]api.Loader{ ".js": api.LoaderJS, ".mjs": api.LoaderJS, ".cjs": api.LoaderJS, ".jsx": api.LoaderJSX, ".ts": api.LoaderTS, ".tsx": api.LoaderTSX, ".css": api.LoaderCSS, ".json": api.LoaderJSON, ".txt": api.LoaderText, } func loaderFromFilename(filename string) api.Loader { l, found := extensionToLoaderMap[filepath.Ext(filename)] if found { return l } return api.LoaderJS } func createBuildPlugins(c *Client, opts Options) ([]api.Plugin, error) { fs := c.rs.Assets resolveImport := func(args api.OnResolveArgs) (api.OnResolveResult, error) { isStdin := args.Importer == stdinImporter var relDir string if !isStdin { rel, found := fs.MakePathRelative(args.Importer) if !found { // Not in any of the /assets folders. // This is an import from a node_modules, let // ESBuild resolve this. return api.OnResolveResult{}, nil } relDir = filepath.Dir(rel) } else { relDir = filepath.Dir(opts.sourcefile) } impPath := args.Path // Imports not starting with a "." is assumed to live relative to /assets. // Hugo makes no assumptions about the directory structure below /assets. if relDir != "" && strings.HasPrefix(impPath, ".") { impPath = filepath.Join(relDir, impPath) } findFirst := func(base string) hugofs.FileMeta { // This is the most common sub-set of ESBuild's default extensions. // We assume that imports of JSON, CSS etc. will be using their full // name with extension. for _, ext := range []string{".js", ".ts", ".tsx", ".jsx"} { if fi, err := fs.Fs.Stat(base + ext); err == nil { return fi.(hugofs.FileMetaInfo).Meta() } } // Not found. return nil } var m hugofs.FileMeta // First the path as is. fi, err := fs.Fs.Stat(impPath) if err == nil { if fi.IsDir() { m = findFirst(filepath.Join(impPath, "index")) } else { m = fi.(hugofs.FileMetaInfo).Meta() } } else { // It may be a regular file imported without an extension. m = findFirst(impPath) } // if m != nil { // Store the source root so we can create a jsconfig.json // to help intellisense when the build is done. // This should be a small number of elements, and when // in server mode, we may get stale entries on renames etc., // but that shouldn't matter too much. c.rs.JSConfigBuilder.AddSourceRoot(m.SourceRoot()) return api.OnResolveResult{Path: m.Filename(), Namespace: nsImportHugo}, nil } // Fall back to ESBuild's resolve. return api.OnResolveResult{}, nil } importResolver := api.Plugin{ Name: "hugo-import-resolver", Setup: func(build api.PluginBuild) { build.OnResolve(api.OnResolveOptions{Filter: `.*`}, func(args api.OnResolveArgs) (api.OnResolveResult, error) { return resolveImport(args) }) build.OnLoad(api.OnLoadOptions{Filter: `.*`, Namespace: nsImportHugo}, func(args api.OnLoadArgs) (api.OnLoadResult, error) { b, err := ioutil.ReadFile(args.Path) if err != nil { return api.OnLoadResult{}, errors.Wrapf(err, "failed to read %q", args.Path) } c := string(b) return api.OnLoadResult{ // See https://github.com/evanw/esbuild/issues/502 // This allows all modules to resolve dependencies // in the main project's node_modules. ResolveDir: opts.resolveDir, Contents: &c, Loader: loaderFromFilename(args.Path), }, nil }) }, } params := opts.Params if params == nil { // This way @params will always resolve to something. params = make(map[string]interface{}) } b, err := json.Marshal(params) if err != nil { return nil, errors.Wrap(err, "failed to marshal params") } bs := string(b) paramsPlugin := api.Plugin{ Name: "hugo-params-plugin", Setup: func(build api.PluginBuild) { build.OnResolve(api.OnResolveOptions{Filter: `^@params$`}, func(args api.OnResolveArgs) (api.OnResolveResult, error) { return api.OnResolveResult{ Path: args.Path, Namespace: nsParams, }, nil }) build.OnLoad(api.OnLoadOptions{Filter: `.*`, Namespace: nsParams}, func(args api.OnLoadArgs) (api.OnLoadResult, error) { return api.OnLoadResult{ Contents: &bs, Loader: api.LoaderJSON, }, nil }) }, } return []api.Plugin{importResolver, paramsPlugin}, nil } func toBuildOptions(opts Options) (buildOptions api.BuildOptions, err error) { var target api.Target switch opts.Target { case "", "esnext": target = api.ESNext case "es5": target = api.ES5 case "es6", "es2015": target = api.ES2015 case "es2016": target = api.ES2016 case "es2017": target = api.ES2017 case "es2018": target = api.ES2018 case "es2019": target = api.ES2019 case "es2020": target = api.ES2020 default: err = fmt.Errorf("invalid target: %q", opts.Target) return } mediaType := opts.mediaType if mediaType.IsZero() { mediaType = media.JavascriptType } var loader api.Loader switch mediaType.SubType { // TODO(bep) ESBuild support a set of other loaders, but I currently fail // to see the relevance. That may change as we start using this. case media.JavascriptType.SubType: loader = api.LoaderJS case media.TypeScriptType.SubType: loader = api.LoaderTS case media.TSXType.SubType: loader = api.LoaderTSX case media.JSXType.SubType: loader = api.LoaderJSX default: err = fmt.Errorf("unsupported Media Type: %q", opts.mediaType) return } var format api.Format // One of: iife, cjs, esm switch opts.Format { case "", "iife": format = api.FormatIIFE case "esm": format = api.FormatESModule case "cjs": format = api.FormatCommonJS default: err = fmt.Errorf("unsupported script output format: %q", opts.Format) return } var defines map[string]string if opts.Defines != nil { defines = cast.ToStringMapString(opts.Defines) } // By default we only need to specify outDir and no outFile outDir := opts.outDir outFile := "" var sourceMap api.SourceMap switch opts.SourceMap { case "inline": sourceMap = api.SourceMapInline case "external": sourceMap = api.SourceMapExternal case "": sourceMap = api.SourceMapNone default: err = fmt.Errorf("unsupported sourcemap type: %q", opts.SourceMap) return } buildOptions = api.BuildOptions{ Outfile: outFile, Bundle: true, Target: target, Format: format, Sourcemap: sourceMap, MinifyWhitespace: opts.Minify, MinifyIdentifiers: opts.Minify, MinifySyntax: opts.Minify, Outdir: outDir, Define: defines, External: opts.Externals, JSXFactory: opts.JSXFactory, JSXFragment: opts.JSXFragment, AvoidTDZ: opts.AvoidTDZ, Tsconfig: opts.tsConfig, Stdin: &api.StdinOptions{ Contents: opts.contents, Sourcefile: opts.sourcefile, ResolveDir: opts.resolveDir, Loader: loader, }, } return }
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package js import ( "encoding/json" "fmt" "io/ioutil" "path/filepath" "strings" "github.com/pkg/errors" "github.com/evanw/esbuild/pkg/api" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/media" "github.com/mitchellh/mapstructure" "github.com/spf13/cast" ) const ( nsImportHugo = "ns-hugo" nsParams = "ns-params" stdinImporter = "<stdin>" ) // Options esbuild configuration type Options struct { // If not set, the source path will be used as the base target path. // Note that the target path's extension may change if the target MIME type // is different, e.g. when the source is TypeScript. TargetPath string // Whether to minify to output. Minify bool // Whether to write mapfiles SourceMap string // The language target. // One of: es2015, es2016, es2017, es2018, es2019, es2020 or esnext. // Default is esnext. Target string // The output format. // One of: iife, cjs, esm // Default is to esm. Format string // External dependencies, e.g. "react". Externals []string // User defined symbols. Defines map[string]interface{} // Maps a component import to another. Shims map[string]string // User defined params. Will be marshaled to JSON and available as "@params", e.g. // import * as params from '@params'; Params interface{} // What to use instead of React.createElement. JSXFactory string // What to use instead of React.Fragment. JSXFragment string // There is/was a bug in WebKit with severe performance issue with the tracking // of TDZ checks in JavaScriptCore. // // Enabling this flag removes the TDZ and `const` assignment checks and // may improve performance of larger JS codebases until the WebKit fix // is in widespread use. // // See https://bugs.webkit.org/show_bug.cgi?id=199866 // Deprecated: This no longer have any effect and will be removed. // TODO(bep) remove. See https://github.com/evanw/esbuild/commit/869e8117b499ca1dbfc5b3021938a53ffe934dba AvoidTDZ bool mediaType media.Type outDir string contents string sourcefile string resolveDir string tsConfig string } func decodeOptions(m map[string]interface{}) (Options, error) { var opts Options if err := mapstructure.WeakDecode(m, &opts); err != nil { return opts, err } if opts.TargetPath != "" { opts.TargetPath = helpers.ToSlashTrimLeading(opts.TargetPath) } opts.Target = strings.ToLower(opts.Target) opts.Format = strings.ToLower(opts.Format) return opts, nil } var extensionToLoaderMap = map[string]api.Loader{ ".js": api.LoaderJS, ".mjs": api.LoaderJS, ".cjs": api.LoaderJS, ".jsx": api.LoaderJSX, ".ts": api.LoaderTS, ".tsx": api.LoaderTSX, ".css": api.LoaderCSS, ".json": api.LoaderJSON, ".txt": api.LoaderText, } func loaderFromFilename(filename string) api.Loader { l, found := extensionToLoaderMap[filepath.Ext(filename)] if found { return l } return api.LoaderJS } func createBuildPlugins(c *Client, opts Options) ([]api.Plugin, error) { fs := c.rs.Assets resolveImport := func(args api.OnResolveArgs) (api.OnResolveResult, error) { impPath := args.Path if opts.Shims != nil { override, found := opts.Shims[impPath] if found { impPath = override } } isStdin := args.Importer == stdinImporter var relDir string if !isStdin { rel, found := fs.MakePathRelative(args.Importer) if !found { // Not in any of the /assets folders. // This is an import from a node_modules, let // ESBuild resolve this. return api.OnResolveResult{}, nil } relDir = filepath.Dir(rel) } else { relDir = filepath.Dir(opts.sourcefile) } // Imports not starting with a "." is assumed to live relative to /assets. // Hugo makes no assumptions about the directory structure below /assets. if relDir != "" && strings.HasPrefix(impPath, ".") { impPath = filepath.Join(relDir, impPath) } findFirst := func(base string) hugofs.FileMeta { // This is the most common sub-set of ESBuild's default extensions. // We assume that imports of JSON, CSS etc. will be using their full // name with extension. for _, ext := range []string{".js", ".ts", ".tsx", ".jsx"} { if fi, err := fs.Fs.Stat(base + ext); err == nil { return fi.(hugofs.FileMetaInfo).Meta() } } // Not found. return nil } var m hugofs.FileMeta // First the path as is. fi, err := fs.Fs.Stat(impPath) if err == nil { if fi.IsDir() { m = findFirst(filepath.Join(impPath, "index")) } else { m = fi.(hugofs.FileMetaInfo).Meta() } } else { // It may be a regular file imported without an extension. m = findFirst(impPath) } // if m != nil { // Store the source root so we can create a jsconfig.json // to help intellisense when the build is done. // This should be a small number of elements, and when // in server mode, we may get stale entries on renames etc., // but that shouldn't matter too much. c.rs.JSConfigBuilder.AddSourceRoot(m.SourceRoot()) return api.OnResolveResult{Path: m.Filename(), Namespace: nsImportHugo}, nil } // Fall back to ESBuild's resolve. return api.OnResolveResult{}, nil } importResolver := api.Plugin{ Name: "hugo-import-resolver", Setup: func(build api.PluginBuild) { build.OnResolve(api.OnResolveOptions{Filter: `.*`}, func(args api.OnResolveArgs) (api.OnResolveResult, error) { return resolveImport(args) }) build.OnLoad(api.OnLoadOptions{Filter: `.*`, Namespace: nsImportHugo}, func(args api.OnLoadArgs) (api.OnLoadResult, error) { b, err := ioutil.ReadFile(args.Path) if err != nil { return api.OnLoadResult{}, errors.Wrapf(err, "failed to read %q", args.Path) } c := string(b) return api.OnLoadResult{ // See https://github.com/evanw/esbuild/issues/502 // This allows all modules to resolve dependencies // in the main project's node_modules. ResolveDir: opts.resolveDir, Contents: &c, Loader: loaderFromFilename(args.Path), }, nil }) }, } params := opts.Params if params == nil { // This way @params will always resolve to something. params = make(map[string]interface{}) } b, err := json.Marshal(params) if err != nil { return nil, errors.Wrap(err, "failed to marshal params") } bs := string(b) paramsPlugin := api.Plugin{ Name: "hugo-params-plugin", Setup: func(build api.PluginBuild) { build.OnResolve(api.OnResolveOptions{Filter: `^@params$`}, func(args api.OnResolveArgs) (api.OnResolveResult, error) { return api.OnResolveResult{ Path: args.Path, Namespace: nsParams, }, nil }) build.OnLoad(api.OnLoadOptions{Filter: `.*`, Namespace: nsParams}, func(args api.OnLoadArgs) (api.OnLoadResult, error) { return api.OnLoadResult{ Contents: &bs, Loader: api.LoaderJSON, }, nil }) }, } return []api.Plugin{importResolver, paramsPlugin}, nil } func toBuildOptions(opts Options) (buildOptions api.BuildOptions, err error) { var target api.Target switch opts.Target { case "", "esnext": target = api.ESNext case "es5": target = api.ES5 case "es6", "es2015": target = api.ES2015 case "es2016": target = api.ES2016 case "es2017": target = api.ES2017 case "es2018": target = api.ES2018 case "es2019": target = api.ES2019 case "es2020": target = api.ES2020 default: err = fmt.Errorf("invalid target: %q", opts.Target) return } mediaType := opts.mediaType if mediaType.IsZero() { mediaType = media.JavascriptType } var loader api.Loader switch mediaType.SubType { // TODO(bep) ESBuild support a set of other loaders, but I currently fail // to see the relevance. That may change as we start using this. case media.JavascriptType.SubType: loader = api.LoaderJS case media.TypeScriptType.SubType: loader = api.LoaderTS case media.TSXType.SubType: loader = api.LoaderTSX case media.JSXType.SubType: loader = api.LoaderJSX default: err = fmt.Errorf("unsupported Media Type: %q", opts.mediaType) return } var format api.Format // One of: iife, cjs, esm switch opts.Format { case "", "iife": format = api.FormatIIFE case "esm": format = api.FormatESModule case "cjs": format = api.FormatCommonJS default: err = fmt.Errorf("unsupported script output format: %q", opts.Format) return } var defines map[string]string if opts.Defines != nil { defines = cast.ToStringMapString(opts.Defines) } // By default we only need to specify outDir and no outFile outDir := opts.outDir outFile := "" var sourceMap api.SourceMap switch opts.SourceMap { case "inline": sourceMap = api.SourceMapInline case "external": sourceMap = api.SourceMapExternal case "": sourceMap = api.SourceMapNone default: err = fmt.Errorf("unsupported sourcemap type: %q", opts.SourceMap) return } buildOptions = api.BuildOptions{ Outfile: outFile, Bundle: true, Target: target, Format: format, Sourcemap: sourceMap, MinifyWhitespace: opts.Minify, MinifyIdentifiers: opts.Minify, MinifySyntax: opts.Minify, Outdir: outDir, Define: defines, External: opts.Externals, JSXFactory: opts.JSXFactory, JSXFragment: opts.JSXFragment, AvoidTDZ: opts.AvoidTDZ, Tsconfig: opts.tsConfig, Stdin: &api.StdinOptions{ Contents: opts.contents, Sourcefile: opts.sourcefile, ResolveDir: opts.resolveDir, Loader: loader, }, } return }
1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/news/0.40.1-relnotes/index.md
--- date: 2018-04-25 title: "Hugo 0.40.1: One Bug Fix" description: "Fixes some shortcode vs .Content corner cases." categories: ["Releases"] images: - images/blog/hugo-bug-poster.png --- This release fixes some shortcode vs `.Content` corner cases introduced in Hugo `0.40` [288c3964](https://github.com/gohugoio/hugo/commit/288c39643906b4194a0a6acfbaf87cb0fbdeb361) [@bep](https://github.com/bep) [#4632](https://github.com/gohugoio/hugo/issues/4632)[#4664](https://github.com/gohugoio/hugo/issues/4664).
--- date: 2018-04-25 title: "Hugo 0.40.1: One Bug Fix" description: "Fixes some shortcode vs .Content corner cases." categories: ["Releases"] images: - images/blog/hugo-bug-poster.png --- This release fixes some shortcode vs `.Content` corner cases introduced in Hugo `0.40` [288c3964](https://github.com/gohugoio/hugo/commit/288c39643906b4194a0a6acfbaf87cb0fbdeb361) [@bep](https://github.com/bep) [#4632](https://github.com/gohugoio/hugo/issues/4632)[#4664](https://github.com/gohugoio/hugo/issues/4664).
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./tpl/internal/go_templates/htmltemplate/html.go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package template import ( "bytes" "fmt" "strings" "unicode/utf8" ) // htmlNospaceEscaper escapes for inclusion in unquoted attribute values. func htmlNospaceEscaper(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeHTML { return htmlReplacer(stripTags(s), htmlNospaceNormReplacementTable, false) } return htmlReplacer(s, htmlNospaceReplacementTable, false) } // attrEscaper escapes for inclusion in quoted attribute values. func attrEscaper(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeHTML { return htmlReplacer(stripTags(s), htmlNormReplacementTable, true) } return htmlReplacer(s, htmlReplacementTable, true) } // rcdataEscaper escapes for inclusion in an RCDATA element body. func rcdataEscaper(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeHTML { return htmlReplacer(s, htmlNormReplacementTable, true) } return htmlReplacer(s, htmlReplacementTable, true) } // htmlEscaper escapes for inclusion in HTML text. func htmlEscaper(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeHTML { return s } return htmlReplacer(s, htmlReplacementTable, true) } // htmlReplacementTable contains the runes that need to be escaped // inside a quoted attribute value or in a text node. var htmlReplacementTable = []string{ // https://www.w3.org/TR/html5/syntax.html#attribute-value-(unquoted)-state // U+0000 NULL Parse error. Append a U+FFFD REPLACEMENT // CHARACTER character to the current attribute's value. // " // and similarly // https://www.w3.org/TR/html5/syntax.html#before-attribute-value-state 0: "\uFFFD", '"': "&#34;", '&': "&amp;", '\'': "&#39;", '+': "&#43;", '<': "&lt;", '>': "&gt;", } // htmlNormReplacementTable is like htmlReplacementTable but without '&' to // avoid over-encoding existing entities. var htmlNormReplacementTable = []string{ 0: "\uFFFD", '"': "&#34;", '\'': "&#39;", '+': "&#43;", '<': "&lt;", '>': "&gt;", } // htmlNospaceReplacementTable contains the runes that need to be escaped // inside an unquoted attribute value. // The set of runes escaped is the union of the HTML specials and // those determined by running the JS below in browsers: // <div id=d></div> // <script>(function () { // var a = [], d = document.getElementById("d"), i, c, s; // for (i = 0; i < 0x10000; ++i) { // c = String.fromCharCode(i); // d.innerHTML = "<span title=" + c + "lt" + c + "></span>" // s = d.getElementsByTagName("SPAN")[0]; // if (!s || s.title !== c + "lt" + c) { a.push(i.toString(16)); } // } // document.write(a.join(", ")); // })()</script> var htmlNospaceReplacementTable = []string{ 0: "&#xfffd;", '\t': "&#9;", '\n': "&#10;", '\v': "&#11;", '\f': "&#12;", '\r': "&#13;", ' ': "&#32;", '"': "&#34;", '&': "&amp;", '\'': "&#39;", '+': "&#43;", '<': "&lt;", '=': "&#61;", '>': "&gt;", // A parse error in the attribute value (unquoted) and // before attribute value states. // Treated as a quoting character by IE. '`': "&#96;", } // htmlNospaceNormReplacementTable is like htmlNospaceReplacementTable but // without '&' to avoid over-encoding existing entities. var htmlNospaceNormReplacementTable = []string{ 0: "&#xfffd;", '\t': "&#9;", '\n': "&#10;", '\v': "&#11;", '\f': "&#12;", '\r': "&#13;", ' ': "&#32;", '"': "&#34;", '\'': "&#39;", '+': "&#43;", '<': "&lt;", '=': "&#61;", '>': "&gt;", // A parse error in the attribute value (unquoted) and // before attribute value states. // Treated as a quoting character by IE. '`': "&#96;", } // htmlReplacer returns s with runes replaced according to replacementTable // and when badRunes is true, certain bad runes are allowed through unescaped. func htmlReplacer(s string, replacementTable []string, badRunes bool) string { written, b := 0, new(strings.Builder) r, w := rune(0), 0 for i := 0; i < len(s); i += w { // Cannot use 'for range s' because we need to preserve the width // of the runes in the input. If we see a decoding error, the input // width will not be utf8.Runelen(r) and we will overrun the buffer. r, w = utf8.DecodeRuneInString(s[i:]) if int(r) < len(replacementTable) { if repl := replacementTable[r]; len(repl) != 0 { if written == 0 { b.Grow(len(s)) } b.WriteString(s[written:i]) b.WriteString(repl) written = i + w } } else if badRunes { // No-op. // IE does not allow these ranges in unquoted attrs. } else if 0xfdd0 <= r && r <= 0xfdef || 0xfff0 <= r && r <= 0xffff { if written == 0 { b.Grow(len(s)) } fmt.Fprintf(b, "%s&#x%x;", s[written:i], r) written = i + w } } if written == 0 { return s } b.WriteString(s[written:]) return b.String() } // stripTags takes a snippet of HTML and returns only the text content. // For example, `<b>&iexcl;Hi!</b> <script>...</script>` -> `&iexcl;Hi! `. func stripTags(html string) string { var b bytes.Buffer s, c, i, allText := []byte(html), context{}, 0, true // Using the transition funcs helps us avoid mangling // `<div title="1>2">` or `I <3 Ponies!`. for i != len(s) { if c.delim == delimNone { st := c.state // Use RCDATA instead of parsing into JS or CSS styles. if c.element != elementNone && !isInTag(st) { st = stateRCDATA } d, nread := transitionFunc[st](c, s[i:]) i1 := i + nread if c.state == stateText || c.state == stateRCDATA { // Emit text up to the start of the tag or comment. j := i1 if d.state != c.state { for j1 := j - 1; j1 >= i; j1-- { if s[j1] == '<' { j = j1 break } } } b.Write(s[i:j]) } else { allText = false } c, i = d, i1 continue } i1 := i + bytes.IndexAny(s[i:], delimEnds[c.delim]) if i1 < i { break } if c.delim != delimSpaceOrTagEnd { // Consume any quote. i1++ } c, i = context{state: stateTag, element: c.element}, i1 } if allText { return html } else if c.state == stateText || c.state == stateRCDATA { b.Write(s[i:]) } return b.String() } // htmlNameFilter accepts valid parts of an HTML attribute or tag name or // a known-safe HTML attribute. func htmlNameFilter(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeHTMLAttr { return s } if len(s) == 0 { // Avoid violation of structure preservation. // <input checked {{.K}}={{.V}}>. // Without this, if .K is empty then .V is the value of // checked, but otherwise .V is the value of the attribute // named .K. return filterFailsafe } s = strings.ToLower(s) if t := attrType(s); t != contentTypePlain { // TODO: Split attr and element name part filters so we can whitelist // attributes. return filterFailsafe } for _, r := range s { switch { case '0' <= r && r <= '9': case 'a' <= r && r <= 'z': default: return filterFailsafe } } return s } // commentEscaper returns the empty string regardless of input. // Comment content does not correspond to any parsed structure or // human-readable content, so the simplest and most secure policy is to drop // content interpolated into comments. // This approach is equally valid whether or not static comment content is // removed from the template. func commentEscaper(args ...interface{}) string { return "" }
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package template import ( "bytes" "fmt" "strings" "unicode/utf8" ) // htmlNospaceEscaper escapes for inclusion in unquoted attribute values. func htmlNospaceEscaper(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeHTML { return htmlReplacer(stripTags(s), htmlNospaceNormReplacementTable, false) } return htmlReplacer(s, htmlNospaceReplacementTable, false) } // attrEscaper escapes for inclusion in quoted attribute values. func attrEscaper(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeHTML { return htmlReplacer(stripTags(s), htmlNormReplacementTable, true) } return htmlReplacer(s, htmlReplacementTable, true) } // rcdataEscaper escapes for inclusion in an RCDATA element body. func rcdataEscaper(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeHTML { return htmlReplacer(s, htmlNormReplacementTable, true) } return htmlReplacer(s, htmlReplacementTable, true) } // htmlEscaper escapes for inclusion in HTML text. func htmlEscaper(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeHTML { return s } return htmlReplacer(s, htmlReplacementTable, true) } // htmlReplacementTable contains the runes that need to be escaped // inside a quoted attribute value or in a text node. var htmlReplacementTable = []string{ // https://www.w3.org/TR/html5/syntax.html#attribute-value-(unquoted)-state // U+0000 NULL Parse error. Append a U+FFFD REPLACEMENT // CHARACTER character to the current attribute's value. // " // and similarly // https://www.w3.org/TR/html5/syntax.html#before-attribute-value-state 0: "\uFFFD", '"': "&#34;", '&': "&amp;", '\'': "&#39;", '+': "&#43;", '<': "&lt;", '>': "&gt;", } // htmlNormReplacementTable is like htmlReplacementTable but without '&' to // avoid over-encoding existing entities. var htmlNormReplacementTable = []string{ 0: "\uFFFD", '"': "&#34;", '\'': "&#39;", '+': "&#43;", '<': "&lt;", '>': "&gt;", } // htmlNospaceReplacementTable contains the runes that need to be escaped // inside an unquoted attribute value. // The set of runes escaped is the union of the HTML specials and // those determined by running the JS below in browsers: // <div id=d></div> // <script>(function () { // var a = [], d = document.getElementById("d"), i, c, s; // for (i = 0; i < 0x10000; ++i) { // c = String.fromCharCode(i); // d.innerHTML = "<span title=" + c + "lt" + c + "></span>" // s = d.getElementsByTagName("SPAN")[0]; // if (!s || s.title !== c + "lt" + c) { a.push(i.toString(16)); } // } // document.write(a.join(", ")); // })()</script> var htmlNospaceReplacementTable = []string{ 0: "&#xfffd;", '\t': "&#9;", '\n': "&#10;", '\v': "&#11;", '\f': "&#12;", '\r': "&#13;", ' ': "&#32;", '"': "&#34;", '&': "&amp;", '\'': "&#39;", '+': "&#43;", '<': "&lt;", '=': "&#61;", '>': "&gt;", // A parse error in the attribute value (unquoted) and // before attribute value states. // Treated as a quoting character by IE. '`': "&#96;", } // htmlNospaceNormReplacementTable is like htmlNospaceReplacementTable but // without '&' to avoid over-encoding existing entities. var htmlNospaceNormReplacementTable = []string{ 0: "&#xfffd;", '\t': "&#9;", '\n': "&#10;", '\v': "&#11;", '\f': "&#12;", '\r': "&#13;", ' ': "&#32;", '"': "&#34;", '\'': "&#39;", '+': "&#43;", '<': "&lt;", '=': "&#61;", '>': "&gt;", // A parse error in the attribute value (unquoted) and // before attribute value states. // Treated as a quoting character by IE. '`': "&#96;", } // htmlReplacer returns s with runes replaced according to replacementTable // and when badRunes is true, certain bad runes are allowed through unescaped. func htmlReplacer(s string, replacementTable []string, badRunes bool) string { written, b := 0, new(strings.Builder) r, w := rune(0), 0 for i := 0; i < len(s); i += w { // Cannot use 'for range s' because we need to preserve the width // of the runes in the input. If we see a decoding error, the input // width will not be utf8.Runelen(r) and we will overrun the buffer. r, w = utf8.DecodeRuneInString(s[i:]) if int(r) < len(replacementTable) { if repl := replacementTable[r]; len(repl) != 0 { if written == 0 { b.Grow(len(s)) } b.WriteString(s[written:i]) b.WriteString(repl) written = i + w } } else if badRunes { // No-op. // IE does not allow these ranges in unquoted attrs. } else if 0xfdd0 <= r && r <= 0xfdef || 0xfff0 <= r && r <= 0xffff { if written == 0 { b.Grow(len(s)) } fmt.Fprintf(b, "%s&#x%x;", s[written:i], r) written = i + w } } if written == 0 { return s } b.WriteString(s[written:]) return b.String() } // stripTags takes a snippet of HTML and returns only the text content. // For example, `<b>&iexcl;Hi!</b> <script>...</script>` -> `&iexcl;Hi! `. func stripTags(html string) string { var b bytes.Buffer s, c, i, allText := []byte(html), context{}, 0, true // Using the transition funcs helps us avoid mangling // `<div title="1>2">` or `I <3 Ponies!`. for i != len(s) { if c.delim == delimNone { st := c.state // Use RCDATA instead of parsing into JS or CSS styles. if c.element != elementNone && !isInTag(st) { st = stateRCDATA } d, nread := transitionFunc[st](c, s[i:]) i1 := i + nread if c.state == stateText || c.state == stateRCDATA { // Emit text up to the start of the tag or comment. j := i1 if d.state != c.state { for j1 := j - 1; j1 >= i; j1-- { if s[j1] == '<' { j = j1 break } } } b.Write(s[i:j]) } else { allText = false } c, i = d, i1 continue } i1 := i + bytes.IndexAny(s[i:], delimEnds[c.delim]) if i1 < i { break } if c.delim != delimSpaceOrTagEnd { // Consume any quote. i1++ } c, i = context{state: stateTag, element: c.element}, i1 } if allText { return html } else if c.state == stateText || c.state == stateRCDATA { b.Write(s[i:]) } return b.String() } // htmlNameFilter accepts valid parts of an HTML attribute or tag name or // a known-safe HTML attribute. func htmlNameFilter(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeHTMLAttr { return s } if len(s) == 0 { // Avoid violation of structure preservation. // <input checked {{.K}}={{.V}}>. // Without this, if .K is empty then .V is the value of // checked, but otherwise .V is the value of the attribute // named .K. return filterFailsafe } s = strings.ToLower(s) if t := attrType(s); t != contentTypePlain { // TODO: Split attr and element name part filters so we can whitelist // attributes. return filterFailsafe } for _, r := range s { switch { case '0' <= r && r <= '9': case 'a' <= r && r <= 'z': default: return filterFailsafe } } return s } // commentEscaper returns the empty string regardless of input. // Comment content does not correspond to any parsed structure or // human-readable content, so the simplest and most secure policy is to drop // content interpolated into comments. // This approach is equally valid whether or not static comment content is // removed from the template. func commentEscaper(args ...interface{}) string { return "" }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./tpl/site/init_test.go
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package site import ( "testing" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/htesting/hqt" "github.com/gohugoio/hugo/resources/page" "github.com/gohugoio/hugo/tpl/internal" "github.com/spf13/viper" ) func TestInit(t *testing.T) { c := qt.New(t) var found bool var ns *internal.TemplateFuncsNamespace v := viper.New() v.Set("contentDir", "content") s := page.NewDummyHugoSite(v) for _, nsf := range internal.TemplateFuncsNamespaceRegistry { ns = nsf(&deps.Deps{Site: s}) if ns.Name == name { found = true break } } c.Assert(found, qt.Equals, true) c.Assert(ns.Context(), hqt.IsSameType, s) }
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package site import ( "testing" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/htesting/hqt" "github.com/gohugoio/hugo/resources/page" "github.com/gohugoio/hugo/tpl/internal" "github.com/spf13/viper" ) func TestInit(t *testing.T) { c := qt.New(t) var found bool var ns *internal.TemplateFuncsNamespace v := viper.New() v.Set("contentDir", "content") s := page.NewDummyHugoSite(v) for _, nsf := range internal.TemplateFuncsNamespaceRegistry { ns = nsf(&deps.Deps{Site: s}) if ns.Name == name { found = true break } } c.Assert(found, qt.Equals, true) c.Assert(ns.Context(), hqt.IsSameType, s) }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/functions/relref.md
--- title: relref linktitle: relref description: Returns the relative permalink to a page. godocref: date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2020-09-05 categories: [functions] menu: docs: parent: "functions" keywords: [cross references, anchors] signature: ["relref . PAGE"] workson: [] hugoversion: relatedfuncs: [ref] deprecated: false aliases: [] --- This function takes two parameters: - The context of the page from which to resolve relative paths, typically the current page (`.`) - The path to a page, with or without a file extension, with or without an anchor. A path without a leading `/` is first resolved relative to the given context, then to the remainder of the site. ```go-html-template {{ relref . "about" }} {{ relref . "about#anchor" }} {{ relref . "about.md" }} {{ relref . "about.md#anchor" }} {{ relref . "#anchor" }} {{ relref . "/blog/my-post" }} {{ relref . "/blog/my-post.md" }} ``` The permalink returned is relative to the protocol+host portion of the baseURL specified in the site configuration. For example: Code|baseURL|Permalink :--|:--|:-- `{{ relref . "/about" }}`|`http://example.org/`|`/about/` `{{ relref . "/about" }}`|`http://example.org/x/`|`/x/about/` To return the relative permalink to another language version of a page: ```go-html-template {{ relref . (dict "path" "about.md" "lang" "fr") }} ``` To return the relative permalink to another Output Format of a page: ```go-html-template {{ relref . (dict "path" "about.md" "outputFormat" "rss") }} ``` Hugo emits an error or warning if the page cannot be uniquely resolved. The error behavior is configurable; see [Ref and RelRef Configuration](/content-management/cross-references/#ref-and-relref-configuration). This function is used by Hugo's built-in [`relref`](/content-management/shortcodes/#ref-and-relref) shortcode. For a detailed explanation of how to leverage this shortcode for content management, see [Links and Cross References](/content-management/cross-references/).
--- title: relref linktitle: relref description: Returns the relative permalink to a page. godocref: date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2020-09-05 categories: [functions] menu: docs: parent: "functions" keywords: [cross references, anchors] signature: ["relref . PAGE"] workson: [] hugoversion: relatedfuncs: [ref] deprecated: false aliases: [] --- This function takes two parameters: - The context of the page from which to resolve relative paths, typically the current page (`.`) - The path to a page, with or without a file extension, with or without an anchor. A path without a leading `/` is first resolved relative to the given context, then to the remainder of the site. ```go-html-template {{ relref . "about" }} {{ relref . "about#anchor" }} {{ relref . "about.md" }} {{ relref . "about.md#anchor" }} {{ relref . "#anchor" }} {{ relref . "/blog/my-post" }} {{ relref . "/blog/my-post.md" }} ``` The permalink returned is relative to the protocol+host portion of the baseURL specified in the site configuration. For example: Code|baseURL|Permalink :--|:--|:-- `{{ relref . "/about" }}`|`http://example.org/`|`/about/` `{{ relref . "/about" }}`|`http://example.org/x/`|`/x/about/` To return the relative permalink to another language version of a page: ```go-html-template {{ relref . (dict "path" "about.md" "lang" "fr") }} ``` To return the relative permalink to another Output Format of a page: ```go-html-template {{ relref . (dict "path" "about.md" "outputFormat" "rss") }} ``` Hugo emits an error or warning if the page cannot be uniquely resolved. The error behavior is configurable; see [Ref and RelRef Configuration](/content-management/cross-references/#ref-and-relref-configuration). This function is used by Hugo's built-in [`relref`](/content-management/shortcodes/#ref-and-relref) shortcode. For a detailed explanation of how to leverage this shortcode for content management, see [Links and Cross References](/content-management/cross-references/).
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./tpl/internal/go_templates/htmltemplate/url.go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package template import ( "bytes" "fmt" "strings" ) // urlFilter returns its input unless it contains an unsafe scheme in which // case it defangs the entire URL. // // Schemes that cause unintended side effects that are irreversible without user // interaction are considered unsafe. For example, clicking on a "javascript:" // link can immediately trigger JavaScript code execution. // // This filter conservatively assumes that all schemes other than the following // are unsafe: // * http: Navigates to a new website, and may open a new window or tab. // These side effects can be reversed by navigating back to the // previous website, or closing the window or tab. No irreversible // changes will take place without further user interaction with // the new website. // * https: Same as http. // * mailto: Opens an email program and starts a new draft. This side effect // is not irreversible until the user explicitly clicks send; it // can be undone by closing the email program. // // To allow URLs containing other schemes to bypass this filter, developers must // explicitly indicate that such a URL is expected and safe by encapsulating it // in a template.URL value. func urlFilter(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeURL { return s } if !isSafeURL(s) { return "#" + filterFailsafe } return s } // isSafeURL is true if s is a relative URL or if URL has a protocol in // (http, https, mailto). func isSafeURL(s string) bool { if i := strings.IndexRune(s, ':'); i >= 0 && !strings.ContainsRune(s[:i], '/') { protocol := s[:i] if !strings.EqualFold(protocol, "http") && !strings.EqualFold(protocol, "https") && !strings.EqualFold(protocol, "mailto") { return false } } return true } // urlEscaper produces an output that can be embedded in a URL query. // The output can be embedded in an HTML attribute without further escaping. func urlEscaper(args ...interface{}) string { return urlProcessor(false, args...) } // urlNormalizer normalizes URL content so it can be embedded in a quote-delimited // string or parenthesis delimited url(...). // The normalizer does not encode all HTML specials. Specifically, it does not // encode '&' so correct embedding in an HTML attribute requires escaping of // '&' to '&amp;'. func urlNormalizer(args ...interface{}) string { return urlProcessor(true, args...) } // urlProcessor normalizes (when norm is true) or escapes its input to produce // a valid hierarchical or opaque URL part. func urlProcessor(norm bool, args ...interface{}) string { s, t := stringify(args...) if t == contentTypeURL { norm = true } var b bytes.Buffer if processURLOnto(s, norm, &b) { return b.String() } return s } // processURLOnto appends a normalized URL corresponding to its input to b // and reports whether the appended content differs from s. func processURLOnto(s string, norm bool, b *bytes.Buffer) bool { b.Grow(len(s) + 16) written := 0 // The byte loop below assumes that all URLs use UTF-8 as the // content-encoding. This is similar to the URI to IRI encoding scheme // defined in section 3.1 of RFC 3987, and behaves the same as the // EcmaScript builtin encodeURIComponent. // It should not cause any misencoding of URLs in pages with // Content-type: text/html;charset=UTF-8. for i, n := 0, len(s); i < n; i++ { c := s[i] switch c { // Single quote and parens are sub-delims in RFC 3986, but we // escape them so the output can be embedded in single // quoted attributes and unquoted CSS url(...) constructs. // Single quotes are reserved in URLs, but are only used in // the obsolete "mark" rule in an appendix in RFC 3986 // so can be safely encoded. case '!', '#', '$', '&', '*', '+', ',', '/', ':', ';', '=', '?', '@', '[', ']': if norm { continue } // Unreserved according to RFC 3986 sec 2.3 // "For consistency, percent-encoded octets in the ranges of // ALPHA (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), // period (%2E), underscore (%5F), or tilde (%7E) should not be // created by URI producers case '-', '.', '_', '~': continue case '%': // When normalizing do not re-encode valid escapes. if norm && i+2 < len(s) && isHex(s[i+1]) && isHex(s[i+2]) { continue } default: // Unreserved according to RFC 3986 sec 2.3 if 'a' <= c && c <= 'z' { continue } if 'A' <= c && c <= 'Z' { continue } if '0' <= c && c <= '9' { continue } } b.WriteString(s[written:i]) fmt.Fprintf(b, "%%%02x", c) written = i + 1 } b.WriteString(s[written:]) return written != 0 } // Filters and normalizes srcset values which are comma separated // URLs followed by metadata. func srcsetFilterAndEscaper(args ...interface{}) string { s, t := stringify(args...) switch t { case contentTypeSrcset: return s case contentTypeURL: // Normalizing gets rid of all HTML whitespace // which separate the image URL from its metadata. var b bytes.Buffer if processURLOnto(s, true, &b) { s = b.String() } // Additionally, commas separate one source from another. return strings.ReplaceAll(s, ",", "%2c") } var b bytes.Buffer written := 0 for i := 0; i < len(s); i++ { if s[i] == ',' { filterSrcsetElement(s, written, i, &b) b.WriteString(",") written = i + 1 } } filterSrcsetElement(s, written, len(s), &b) return b.String() } // Derived from https://play.golang.org/p/Dhmj7FORT5 const htmlSpaceAndASCIIAlnumBytes = "\x00\x36\x00\x00\x01\x00\xff\x03\xfe\xff\xff\x07\xfe\xff\xff\x07" // isHTMLSpace is true iff c is a whitespace character per // https://infra.spec.whatwg.org/#ascii-whitespace func isHTMLSpace(c byte) bool { return (c <= 0x20) && 0 != (htmlSpaceAndASCIIAlnumBytes[c>>3]&(1<<uint(c&0x7))) } func isHTMLSpaceOrASCIIAlnum(c byte) bool { return (c < 0x80) && 0 != (htmlSpaceAndASCIIAlnumBytes[c>>3]&(1<<uint(c&0x7))) } func filterSrcsetElement(s string, left int, right int, b *bytes.Buffer) { start := left for start < right && isHTMLSpace(s[start]) { start++ } end := right for i := start; i < right; i++ { if isHTMLSpace(s[i]) { end = i break } } if url := s[start:end]; isSafeURL(url) { // If image metadata is only spaces or alnums then // we don't need to URL normalize it. metadataOk := true for i := end; i < right; i++ { if !isHTMLSpaceOrASCIIAlnum(s[i]) { metadataOk = false break } } if metadataOk { b.WriteString(s[left:start]) processURLOnto(url, true, b) b.WriteString(s[end:right]) return } } b.WriteString("#") b.WriteString(filterFailsafe) }
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package template import ( "bytes" "fmt" "strings" ) // urlFilter returns its input unless it contains an unsafe scheme in which // case it defangs the entire URL. // // Schemes that cause unintended side effects that are irreversible without user // interaction are considered unsafe. For example, clicking on a "javascript:" // link can immediately trigger JavaScript code execution. // // This filter conservatively assumes that all schemes other than the following // are unsafe: // * http: Navigates to a new website, and may open a new window or tab. // These side effects can be reversed by navigating back to the // previous website, or closing the window or tab. No irreversible // changes will take place without further user interaction with // the new website. // * https: Same as http. // * mailto: Opens an email program and starts a new draft. This side effect // is not irreversible until the user explicitly clicks send; it // can be undone by closing the email program. // // To allow URLs containing other schemes to bypass this filter, developers must // explicitly indicate that such a URL is expected and safe by encapsulating it // in a template.URL value. func urlFilter(args ...interface{}) string { s, t := stringify(args...) if t == contentTypeURL { return s } if !isSafeURL(s) { return "#" + filterFailsafe } return s } // isSafeURL is true if s is a relative URL or if URL has a protocol in // (http, https, mailto). func isSafeURL(s string) bool { if i := strings.IndexRune(s, ':'); i >= 0 && !strings.ContainsRune(s[:i], '/') { protocol := s[:i] if !strings.EqualFold(protocol, "http") && !strings.EqualFold(protocol, "https") && !strings.EqualFold(protocol, "mailto") { return false } } return true } // urlEscaper produces an output that can be embedded in a URL query. // The output can be embedded in an HTML attribute without further escaping. func urlEscaper(args ...interface{}) string { return urlProcessor(false, args...) } // urlNormalizer normalizes URL content so it can be embedded in a quote-delimited // string or parenthesis delimited url(...). // The normalizer does not encode all HTML specials. Specifically, it does not // encode '&' so correct embedding in an HTML attribute requires escaping of // '&' to '&amp;'. func urlNormalizer(args ...interface{}) string { return urlProcessor(true, args...) } // urlProcessor normalizes (when norm is true) or escapes its input to produce // a valid hierarchical or opaque URL part. func urlProcessor(norm bool, args ...interface{}) string { s, t := stringify(args...) if t == contentTypeURL { norm = true } var b bytes.Buffer if processURLOnto(s, norm, &b) { return b.String() } return s } // processURLOnto appends a normalized URL corresponding to its input to b // and reports whether the appended content differs from s. func processURLOnto(s string, norm bool, b *bytes.Buffer) bool { b.Grow(len(s) + 16) written := 0 // The byte loop below assumes that all URLs use UTF-8 as the // content-encoding. This is similar to the URI to IRI encoding scheme // defined in section 3.1 of RFC 3987, and behaves the same as the // EcmaScript builtin encodeURIComponent. // It should not cause any misencoding of URLs in pages with // Content-type: text/html;charset=UTF-8. for i, n := 0, len(s); i < n; i++ { c := s[i] switch c { // Single quote and parens are sub-delims in RFC 3986, but we // escape them so the output can be embedded in single // quoted attributes and unquoted CSS url(...) constructs. // Single quotes are reserved in URLs, but are only used in // the obsolete "mark" rule in an appendix in RFC 3986 // so can be safely encoded. case '!', '#', '$', '&', '*', '+', ',', '/', ':', ';', '=', '?', '@', '[', ']': if norm { continue } // Unreserved according to RFC 3986 sec 2.3 // "For consistency, percent-encoded octets in the ranges of // ALPHA (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), // period (%2E), underscore (%5F), or tilde (%7E) should not be // created by URI producers case '-', '.', '_', '~': continue case '%': // When normalizing do not re-encode valid escapes. if norm && i+2 < len(s) && isHex(s[i+1]) && isHex(s[i+2]) { continue } default: // Unreserved according to RFC 3986 sec 2.3 if 'a' <= c && c <= 'z' { continue } if 'A' <= c && c <= 'Z' { continue } if '0' <= c && c <= '9' { continue } } b.WriteString(s[written:i]) fmt.Fprintf(b, "%%%02x", c) written = i + 1 } b.WriteString(s[written:]) return written != 0 } // Filters and normalizes srcset values which are comma separated // URLs followed by metadata. func srcsetFilterAndEscaper(args ...interface{}) string { s, t := stringify(args...) switch t { case contentTypeSrcset: return s case contentTypeURL: // Normalizing gets rid of all HTML whitespace // which separate the image URL from its metadata. var b bytes.Buffer if processURLOnto(s, true, &b) { s = b.String() } // Additionally, commas separate one source from another. return strings.ReplaceAll(s, ",", "%2c") } var b bytes.Buffer written := 0 for i := 0; i < len(s); i++ { if s[i] == ',' { filterSrcsetElement(s, written, i, &b) b.WriteString(",") written = i + 1 } } filterSrcsetElement(s, written, len(s), &b) return b.String() } // Derived from https://play.golang.org/p/Dhmj7FORT5 const htmlSpaceAndASCIIAlnumBytes = "\x00\x36\x00\x00\x01\x00\xff\x03\xfe\xff\xff\x07\xfe\xff\xff\x07" // isHTMLSpace is true iff c is a whitespace character per // https://infra.spec.whatwg.org/#ascii-whitespace func isHTMLSpace(c byte) bool { return (c <= 0x20) && 0 != (htmlSpaceAndASCIIAlnumBytes[c>>3]&(1<<uint(c&0x7))) } func isHTMLSpaceOrASCIIAlnum(c byte) bool { return (c < 0x80) && 0 != (htmlSpaceAndASCIIAlnumBytes[c>>3]&(1<<uint(c&0x7))) } func filterSrcsetElement(s string, left int, right int, b *bytes.Buffer) { start := left for start < right && isHTMLSpace(s[start]) { start++ } end := right for i := start; i < right; i++ { if isHTMLSpace(s[i]) { end = i break } } if url := s[start:end]; isSafeURL(url) { // If image metadata is only spaces or alnums then // we don't need to URL normalize it. metadataOk := true for i := end; i < right; i++ { if !isHTMLSpaceOrASCIIAlnum(s[i]) { metadataOk = false break } } if metadataOk { b.WriteString(s[left:start]) processURLOnto(url, true, b) b.WriteString(s[end:right]) return } } b.WriteString("#") b.WriteString(filterFailsafe) }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/commands/hugo_server.md
--- date: 2020-09-13 title: "hugo server" slug: hugo_server url: /commands/hugo_server/ --- ## hugo server A high performance webserver ### Synopsis Hugo provides its own webserver which builds and serves the site. While hugo server is high performance, it is a webserver with limited options. Many run it in production, but the standard behavior is for people to use it in development and use a more full featured server such as Nginx or Caddy. 'hugo server' will avoid writing the rendered and served content to disk, preferring to store it in memory. By default hugo will also watch your files for any changes you make and automatically rebuild the site. It will then live reload any open browser pages and push the latest content to them. As most Hugo sites are built in a fraction of a second, you will be able to save and see your changes nearly instantly. ``` hugo server [flags] ``` ### Options ``` --appendPort append port to baseURL (default true) -b, --baseURL string hostname (and path) to the root, e.g. http://spf13.com/ --bind string interface to which the server will bind (default "127.0.0.1") -D, --buildDrafts include content marked as draft -E, --buildExpired include expired content -F, --buildFuture include content with publishdate in the future --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/ --cleanDestinationDir remove files from destination not found in static directories -c, --contentDir string filesystem path to content directory -d, --destination string filesystem path to write files to --disableBrowserError do not show build errors in the browser --disableFastRender enables full re-renders on changes --disableKinds strings disable different kind of pages (home, RSS etc.) --disableLiveReload watch without enabling live browser reload on rebuild --enableGitInfo add Git revision, date and author info to the pages --forceSyncStatic copy all files when static is changed. --gc enable to run some cleanup tasks (remove unused cache files) after the build -h, --help help for server --i18n-warnings print missing translations --ignoreCache ignores the cache directory -l, --layoutDir string filesystem path to layout directory --liveReloadPort int port for live reloading (i.e. 443 in HTTPS proxy situations) (default -1) --meminterval string interval to poll memory usage (requires --memstats), valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". (default "100ms") --memstats string log memory usage to this file --minify minify any supported output format (HTML, XML etc.) --navigateToChanged navigate to changed content file on live browser reload --noChmod don't sync permission mode of files --noHTTPCache prevent HTTP caching --noTimes don't sync modification time of files --path-warnings print warnings on duplicate target paths etc. -p, --port int port on which the server will listen (default 1313) --print-mem print memory usage to screen at intervals --renderToDisk render to Destination path (default is render to memory & serve from there) --templateMetrics display metrics about template executions --templateMetricsHints calculate some improvement hints when combined with --templateMetrics -t, --theme strings themes to use (located in /themes/THEMENAME/) --trace file write trace to file (not useful in general) -w, --watch watch filesystem for changes and recreate as needed (default true) ``` ### Options inherited from parent commands ``` --config string config file (default is path/config.yaml|json|toml) --configDir string config dir (default "config") --debug debug output -e, --environment string build environment --ignoreVendor ignores any _vendor directory --ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode -s, --source string filesystem path to read files relative from --themesDir string filesystem path to themes directory -v, --verbose verbose output --verboseLog verbose logging ``` ### SEE ALSO * [hugo](/commands/hugo/) - hugo builds your site ###### Auto generated by spf13/cobra on 13-Sep-2020
--- date: 2020-09-13 title: "hugo server" slug: hugo_server url: /commands/hugo_server/ --- ## hugo server A high performance webserver ### Synopsis Hugo provides its own webserver which builds and serves the site. While hugo server is high performance, it is a webserver with limited options. Many run it in production, but the standard behavior is for people to use it in development and use a more full featured server such as Nginx or Caddy. 'hugo server' will avoid writing the rendered and served content to disk, preferring to store it in memory. By default hugo will also watch your files for any changes you make and automatically rebuild the site. It will then live reload any open browser pages and push the latest content to them. As most Hugo sites are built in a fraction of a second, you will be able to save and see your changes nearly instantly. ``` hugo server [flags] ``` ### Options ``` --appendPort append port to baseURL (default true) -b, --baseURL string hostname (and path) to the root, e.g. http://spf13.com/ --bind string interface to which the server will bind (default "127.0.0.1") -D, --buildDrafts include content marked as draft -E, --buildExpired include expired content -F, --buildFuture include content with publishdate in the future --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/ --cleanDestinationDir remove files from destination not found in static directories -c, --contentDir string filesystem path to content directory -d, --destination string filesystem path to write files to --disableBrowserError do not show build errors in the browser --disableFastRender enables full re-renders on changes --disableKinds strings disable different kind of pages (home, RSS etc.) --disableLiveReload watch without enabling live browser reload on rebuild --enableGitInfo add Git revision, date and author info to the pages --forceSyncStatic copy all files when static is changed. --gc enable to run some cleanup tasks (remove unused cache files) after the build -h, --help help for server --i18n-warnings print missing translations --ignoreCache ignores the cache directory -l, --layoutDir string filesystem path to layout directory --liveReloadPort int port for live reloading (i.e. 443 in HTTPS proxy situations) (default -1) --meminterval string interval to poll memory usage (requires --memstats), valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". (default "100ms") --memstats string log memory usage to this file --minify minify any supported output format (HTML, XML etc.) --navigateToChanged navigate to changed content file on live browser reload --noChmod don't sync permission mode of files --noHTTPCache prevent HTTP caching --noTimes don't sync modification time of files --path-warnings print warnings on duplicate target paths etc. -p, --port int port on which the server will listen (default 1313) --print-mem print memory usage to screen at intervals --renderToDisk render to Destination path (default is render to memory & serve from there) --templateMetrics display metrics about template executions --templateMetricsHints calculate some improvement hints when combined with --templateMetrics -t, --theme strings themes to use (located in /themes/THEMENAME/) --trace file write trace to file (not useful in general) -w, --watch watch filesystem for changes and recreate as needed (default true) ``` ### Options inherited from parent commands ``` --config string config file (default is path/config.yaml|json|toml) --configDir string config dir (default "config") --debug debug output -e, --environment string build environment --ignoreVendor ignores any _vendor directory --ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern --log enable Logging --logFile string log File path (if set, logging enabled automatically) --quiet build in quiet mode -s, --source string filesystem path to read files relative from --themesDir string filesystem path to themes directory -v, --verbose verbose output --verboseLog verbose logging ``` ### SEE ALSO * [hugo](/commands/hugo/) - hugo builds your site ###### Auto generated by spf13/cobra on 13-Sep-2020
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./markup/asciidocext/convert.go
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package asciidocext converts AsciiDoc to HTML using Asciidoctor // external binary. The `asciidoc` module is reserved for a future golang // implementation. package asciidocext import ( "bytes" "path/filepath" "github.com/gohugoio/hugo/htesting" "github.com/cli/safeexec" "github.com/gohugoio/hugo/identity" "github.com/gohugoio/hugo/markup/asciidocext/asciidocext_config" "github.com/gohugoio/hugo/markup/converter" "github.com/gohugoio/hugo/markup/internal" "github.com/gohugoio/hugo/markup/tableofcontents" "golang.org/x/net/html" ) /* ToDo: RelPermalink patch for svg posts not working*/ type pageSubset interface { RelPermalink() string } // Provider is the package entry point. var Provider converter.ProviderProvider = provider{} type provider struct{} func (p provider) New(cfg converter.ProviderConfig) (converter.Provider, error) { return converter.NewProvider("asciidocext", func(ctx converter.DocumentContext) (converter.Converter, error) { return &asciidocConverter{ ctx: ctx, cfg: cfg, }, nil }), nil } type asciidocResult struct { converter.Result toc tableofcontents.Root } func (r asciidocResult) TableOfContents() tableofcontents.Root { return r.toc } type asciidocConverter struct { ctx converter.DocumentContext cfg converter.ProviderConfig } func (a *asciidocConverter) Convert(ctx converter.RenderContext) (converter.Result, error) { content, toc, err := a.extractTOC(a.getAsciidocContent(ctx.Src, a.ctx)) if err != nil { return nil, err } return asciidocResult{ Result: converter.Bytes(content), toc: toc, }, nil } func (a *asciidocConverter) Supports(_ identity.Identity) bool { return false } // getAsciidocContent calls asciidoctor as an external helper // to convert AsciiDoc content to HTML. func (a *asciidocConverter) getAsciidocContent(src []byte, ctx converter.DocumentContext) []byte { path := getAsciidoctorExecPath() if path == "" { a.cfg.Logger.Errorln("asciidoctor not found in $PATH: Please install.\n", " Leaving AsciiDoc content unrendered.") return src } args := a.parseArgs(ctx) args = append(args, "-") a.cfg.Logger.Infoln("Rendering", ctx.DocumentName, "with", path, "using asciidoctor args", args, "...") return internal.ExternallyRenderContent(a.cfg, ctx, src, path, args) } func (a *asciidocConverter) parseArgs(ctx converter.DocumentContext) []string { cfg := a.cfg.MarkupConfig.AsciidocExt args := []string{} args = a.appendArg(args, "-b", cfg.Backend, asciidocext_config.CliDefault.Backend, asciidocext_config.AllowedBackend) for _, extension := range cfg.Extensions { if !asciidocext_config.AllowedExtensions[extension] { a.cfg.Logger.Errorln("Unsupported asciidoctor extension was passed in. Extension `" + extension + "` ignored.") continue } args = append(args, "-r", extension) } for attributeKey, attributeValue := range cfg.Attributes { if asciidocext_config.DisallowedAttributes[attributeKey] { a.cfg.Logger.Errorln("Unsupported asciidoctor attribute was passed in. Attribute `" + attributeKey + "` ignored.") continue } args = append(args, "-a", attributeKey+"="+attributeValue) } if cfg.WorkingFolderCurrent { contentDir := filepath.Dir(ctx.Filename) sourceDir := a.cfg.Cfg.GetString("source") destinationDir := a.cfg.Cfg.GetString("destination") if destinationDir == "" { a.cfg.Logger.Errorln("markup.asciidocext.workingFolderCurrent requires hugo command option --destination to be set") } if !filepath.IsAbs(destinationDir) && sourceDir != "" { destinationDir = filepath.Join(sourceDir, destinationDir) } var outDir string var err error file := filepath.Base(ctx.Filename) if a.cfg.Cfg.GetBool("uglyUrls") || file == "_index.adoc" || file == "index.adoc" { outDir, err = filepath.Abs(filepath.Dir(filepath.Join(destinationDir, ctx.DocumentName))) } else { postDir := "" page, ok := ctx.Document.(pageSubset) if ok { postDir = filepath.Base(page.RelPermalink()) } else { a.cfg.Logger.Errorln("unable to cast interface to pageSubset") } outDir, err = filepath.Abs(filepath.Join(destinationDir, filepath.Dir(ctx.DocumentName), postDir)) } if err != nil { a.cfg.Logger.Errorln("asciidoctor outDir: ", err) } args = append(args, "--base-dir", contentDir, "-a", "outdir="+outDir) } if cfg.NoHeaderOrFooter { args = append(args, "--no-header-footer") } else { a.cfg.Logger.Warnln("asciidoctor parameter NoHeaderOrFooter is expected for correct html rendering") } if cfg.SectionNumbers { args = append(args, "--section-numbers") } if cfg.Verbose { args = append(args, "--verbose") } if cfg.Trace { args = append(args, "--trace") } args = a.appendArg(args, "--failure-level", cfg.FailureLevel, asciidocext_config.CliDefault.FailureLevel, asciidocext_config.AllowedFailureLevel) args = a.appendArg(args, "--safe-mode", cfg.SafeMode, asciidocext_config.CliDefault.SafeMode, asciidocext_config.AllowedSafeMode) return args } func (a *asciidocConverter) appendArg(args []string, option, value, defaultValue string, allowedValues map[string]bool) []string { if value != defaultValue { if allowedValues[value] { args = append(args, option, value) } else { a.cfg.Logger.Errorln("Unsupported asciidoctor value `" + value + "` for option " + option + " was passed in and will be ignored.") } } return args } func getAsciidoctorExecPath() string { path, err := safeexec.LookPath("asciidoctor") if err != nil { return "" } return path } // extractTOC extracts the toc from the given src html. // It returns the html without the TOC, and the TOC data func (a *asciidocConverter) extractTOC(src []byte) ([]byte, tableofcontents.Root, error) { var buf bytes.Buffer buf.Write(src) node, err := html.Parse(&buf) if err != nil { return nil, tableofcontents.Root{}, err } var ( f func(*html.Node) bool toc tableofcontents.Root toVisit []*html.Node ) f = func(n *html.Node) bool { if n.Type == html.ElementNode && n.Data == "div" && attr(n, "id") == "toc" { toc = parseTOC(n) if !a.cfg.MarkupConfig.AsciidocExt.PreserveTOC { n.Parent.RemoveChild(n) } return true } if n.FirstChild != nil { toVisit = append(toVisit, n.FirstChild) } if n.NextSibling != nil && f(n.NextSibling) { return true } for len(toVisit) > 0 { nv := toVisit[0] toVisit = toVisit[1:] if f(nv) { return true } } return false } f(node) if err != nil { return nil, tableofcontents.Root{}, err } buf.Reset() err = html.Render(&buf, node) if err != nil { return nil, tableofcontents.Root{}, err } // ltrim <html><head></head><body> and rtrim </body></html> which are added by html.Render res := buf.Bytes()[25:] res = res[:len(res)-14] return res, toc, nil } // parseTOC returns a TOC root from the given toc Node func parseTOC(doc *html.Node) tableofcontents.Root { var ( toc tableofcontents.Root f func(*html.Node, int, int) ) f = func(n *html.Node, row, level int) { if n.Type == html.ElementNode { switch n.Data { case "ul": if level == 0 { row++ } level++ f(n.FirstChild, row, level) case "li": for c := n.FirstChild; c != nil; c = c.NextSibling { if c.Type != html.ElementNode || c.Data != "a" { continue } href := attr(c, "href")[1:] toc.AddAt(tableofcontents.Header{ Text: nodeContent(c), ID: href, }, row, level) } f(n.FirstChild, row, level) } } if n.NextSibling != nil { f(n.NextSibling, row, level) } } f(doc.FirstChild, -1, 0) return toc } func attr(node *html.Node, key string) string { for _, a := range node.Attr { if a.Key == key { return a.Val } } return "" } func nodeContent(node *html.Node) string { var buf bytes.Buffer for c := node.FirstChild; c != nil; c = c.NextSibling { html.Render(&buf, c) } return buf.String() } // Supports returns whether Asciidoctor is installed on this computer. func Supports() bool { if htesting.SupportsAll() { return true } return getAsciidoctorExecPath() != "" }
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package asciidocext converts AsciiDoc to HTML using Asciidoctor // external binary. The `asciidoc` module is reserved for a future golang // implementation. package asciidocext import ( "bytes" "path/filepath" "github.com/gohugoio/hugo/htesting" "github.com/cli/safeexec" "github.com/gohugoio/hugo/identity" "github.com/gohugoio/hugo/markup/asciidocext/asciidocext_config" "github.com/gohugoio/hugo/markup/converter" "github.com/gohugoio/hugo/markup/internal" "github.com/gohugoio/hugo/markup/tableofcontents" "golang.org/x/net/html" ) /* ToDo: RelPermalink patch for svg posts not working*/ type pageSubset interface { RelPermalink() string } // Provider is the package entry point. var Provider converter.ProviderProvider = provider{} type provider struct{} func (p provider) New(cfg converter.ProviderConfig) (converter.Provider, error) { return converter.NewProvider("asciidocext", func(ctx converter.DocumentContext) (converter.Converter, error) { return &asciidocConverter{ ctx: ctx, cfg: cfg, }, nil }), nil } type asciidocResult struct { converter.Result toc tableofcontents.Root } func (r asciidocResult) TableOfContents() tableofcontents.Root { return r.toc } type asciidocConverter struct { ctx converter.DocumentContext cfg converter.ProviderConfig } func (a *asciidocConverter) Convert(ctx converter.RenderContext) (converter.Result, error) { content, toc, err := a.extractTOC(a.getAsciidocContent(ctx.Src, a.ctx)) if err != nil { return nil, err } return asciidocResult{ Result: converter.Bytes(content), toc: toc, }, nil } func (a *asciidocConverter) Supports(_ identity.Identity) bool { return false } // getAsciidocContent calls asciidoctor as an external helper // to convert AsciiDoc content to HTML. func (a *asciidocConverter) getAsciidocContent(src []byte, ctx converter.DocumentContext) []byte { path := getAsciidoctorExecPath() if path == "" { a.cfg.Logger.Errorln("asciidoctor not found in $PATH: Please install.\n", " Leaving AsciiDoc content unrendered.") return src } args := a.parseArgs(ctx) args = append(args, "-") a.cfg.Logger.Infoln("Rendering", ctx.DocumentName, "with", path, "using asciidoctor args", args, "...") return internal.ExternallyRenderContent(a.cfg, ctx, src, path, args) } func (a *asciidocConverter) parseArgs(ctx converter.DocumentContext) []string { cfg := a.cfg.MarkupConfig.AsciidocExt args := []string{} args = a.appendArg(args, "-b", cfg.Backend, asciidocext_config.CliDefault.Backend, asciidocext_config.AllowedBackend) for _, extension := range cfg.Extensions { if !asciidocext_config.AllowedExtensions[extension] { a.cfg.Logger.Errorln("Unsupported asciidoctor extension was passed in. Extension `" + extension + "` ignored.") continue } args = append(args, "-r", extension) } for attributeKey, attributeValue := range cfg.Attributes { if asciidocext_config.DisallowedAttributes[attributeKey] { a.cfg.Logger.Errorln("Unsupported asciidoctor attribute was passed in. Attribute `" + attributeKey + "` ignored.") continue } args = append(args, "-a", attributeKey+"="+attributeValue) } if cfg.WorkingFolderCurrent { contentDir := filepath.Dir(ctx.Filename) sourceDir := a.cfg.Cfg.GetString("source") destinationDir := a.cfg.Cfg.GetString("destination") if destinationDir == "" { a.cfg.Logger.Errorln("markup.asciidocext.workingFolderCurrent requires hugo command option --destination to be set") } if !filepath.IsAbs(destinationDir) && sourceDir != "" { destinationDir = filepath.Join(sourceDir, destinationDir) } var outDir string var err error file := filepath.Base(ctx.Filename) if a.cfg.Cfg.GetBool("uglyUrls") || file == "_index.adoc" || file == "index.adoc" { outDir, err = filepath.Abs(filepath.Dir(filepath.Join(destinationDir, ctx.DocumentName))) } else { postDir := "" page, ok := ctx.Document.(pageSubset) if ok { postDir = filepath.Base(page.RelPermalink()) } else { a.cfg.Logger.Errorln("unable to cast interface to pageSubset") } outDir, err = filepath.Abs(filepath.Join(destinationDir, filepath.Dir(ctx.DocumentName), postDir)) } if err != nil { a.cfg.Logger.Errorln("asciidoctor outDir: ", err) } args = append(args, "--base-dir", contentDir, "-a", "outdir="+outDir) } if cfg.NoHeaderOrFooter { args = append(args, "--no-header-footer") } else { a.cfg.Logger.Warnln("asciidoctor parameter NoHeaderOrFooter is expected for correct html rendering") } if cfg.SectionNumbers { args = append(args, "--section-numbers") } if cfg.Verbose { args = append(args, "--verbose") } if cfg.Trace { args = append(args, "--trace") } args = a.appendArg(args, "--failure-level", cfg.FailureLevel, asciidocext_config.CliDefault.FailureLevel, asciidocext_config.AllowedFailureLevel) args = a.appendArg(args, "--safe-mode", cfg.SafeMode, asciidocext_config.CliDefault.SafeMode, asciidocext_config.AllowedSafeMode) return args } func (a *asciidocConverter) appendArg(args []string, option, value, defaultValue string, allowedValues map[string]bool) []string { if value != defaultValue { if allowedValues[value] { args = append(args, option, value) } else { a.cfg.Logger.Errorln("Unsupported asciidoctor value `" + value + "` for option " + option + " was passed in and will be ignored.") } } return args } func getAsciidoctorExecPath() string { path, err := safeexec.LookPath("asciidoctor") if err != nil { return "" } return path } // extractTOC extracts the toc from the given src html. // It returns the html without the TOC, and the TOC data func (a *asciidocConverter) extractTOC(src []byte) ([]byte, tableofcontents.Root, error) { var buf bytes.Buffer buf.Write(src) node, err := html.Parse(&buf) if err != nil { return nil, tableofcontents.Root{}, err } var ( f func(*html.Node) bool toc tableofcontents.Root toVisit []*html.Node ) f = func(n *html.Node) bool { if n.Type == html.ElementNode && n.Data == "div" && attr(n, "id") == "toc" { toc = parseTOC(n) if !a.cfg.MarkupConfig.AsciidocExt.PreserveTOC { n.Parent.RemoveChild(n) } return true } if n.FirstChild != nil { toVisit = append(toVisit, n.FirstChild) } if n.NextSibling != nil && f(n.NextSibling) { return true } for len(toVisit) > 0 { nv := toVisit[0] toVisit = toVisit[1:] if f(nv) { return true } } return false } f(node) if err != nil { return nil, tableofcontents.Root{}, err } buf.Reset() err = html.Render(&buf, node) if err != nil { return nil, tableofcontents.Root{}, err } // ltrim <html><head></head><body> and rtrim </body></html> which are added by html.Render res := buf.Bytes()[25:] res = res[:len(res)-14] return res, toc, nil } // parseTOC returns a TOC root from the given toc Node func parseTOC(doc *html.Node) tableofcontents.Root { var ( toc tableofcontents.Root f func(*html.Node, int, int) ) f = func(n *html.Node, row, level int) { if n.Type == html.ElementNode { switch n.Data { case "ul": if level == 0 { row++ } level++ f(n.FirstChild, row, level) case "li": for c := n.FirstChild; c != nil; c = c.NextSibling { if c.Type != html.ElementNode || c.Data != "a" { continue } href := attr(c, "href")[1:] toc.AddAt(tableofcontents.Header{ Text: nodeContent(c), ID: href, }, row, level) } f(n.FirstChild, row, level) } } if n.NextSibling != nil { f(n.NextSibling, row, level) } } f(doc.FirstChild, -1, 0) return toc } func attr(node *html.Node, key string) string { for _, a := range node.Attr { if a.Key == key { return a.Val } } return "" } func nodeContent(node *html.Node) string { var buf bytes.Buffer for c := node.FirstChild; c != nil; c = c.NextSibling { html.Render(&buf, c) } return buf.String() } // Supports returns whether Asciidoctor is installed on this computer. func Supports() bool { if htesting.SupportsAll() { return true } return getAsciidoctorExecPath() != "" }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/functions/reflect.IsSlice.md
--- title: reflect.IsSlice description: Reports if a value is a slice. godocref: date: 2018-11-28 publishdate: 2018-11-28 lastmod: 2018-11-28 categories: [functions] menu: docs: parent: "functions" keywords: [reflect, reflection, kind] signature: ["reflect.IsSlice INPUT"] workson: [] hugoversion: "0.53" relatedfuncs: [reflect.IsMap] deprecated: false --- `reflect.IsSlice` reports if `VALUE` is a slice. Returns a boolean. ``` {{ reflect.IsSlice (slice 1 2 3) }} → true {{ reflect.IsSlice "yo" }} → false ```
--- title: reflect.IsSlice description: Reports if a value is a slice. godocref: date: 2018-11-28 publishdate: 2018-11-28 lastmod: 2018-11-28 categories: [functions] menu: docs: parent: "functions" keywords: [reflect, reflection, kind] signature: ["reflect.IsSlice INPUT"] workson: [] hugoversion: "0.53" relatedfuncs: [reflect.IsMap] deprecated: false --- `reflect.IsSlice` reports if `VALUE` is a slice. Returns a boolean. ``` {{ reflect.IsSlice (slice 1 2 3) }} → true {{ reflect.IsSlice "yo" }} → false ```
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/templates/section-templates.md
--- title: Section Page Templates linktitle: Section Templates description: Templates used for section pages are **lists** and therefore have all the variables and methods available to list pages. date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [templates] keywords: [lists,sections,templates] menu: docs: parent: "templates" weight: 40 weight: 40 sections_weight: 40 draft: false aliases: [/templates/sections/] toc: true --- ## Add Content and Front Matter to Section Templates To effectively leverage section page templates, you should first understand Hugo's [content organization](/content-management/organization/) and, specifically, the purpose of `_index.md` for adding content and front matter to section and other list pages. ## Section Template Lookup Order See [Template Lookup](/templates/lookup-order/). ## Page Kinds Every `Page` in Hugo has a `.Kind` attribute. {{% page-kinds %}} ## `.Site.GetPage` with Sections `Kind` can easily be combined with the [`where` function][where] in your templates to create kind-specific lists of content. This method is ideal for creating lists, but there are times where you may want to fetch just the index page of a single section via the section's path. The [`.GetPage` function][getpage] looks up an index page of a given `Kind` and `path`. You can call `.Site.GetPage` with two arguments: `kind` (one of the valid values of `Kind` from above) and `kind value`. Examples: - `{{ .Site.GetPage "section" "posts" }}` - `{{ .Site.GetPage "page" "search" }}` ## Example: Creating a Default Section Template {{< code file="layouts/_default/section.html" download="section.html" >}} {{ define "main" }} <main> {{ .Content }} <ul class="contents"> {{ range .Paginator.Pages }} <li>{{.Title}} <div> {{ partial "summary.html" . }} </div> </li> {{ end }} </ul> {{ partial "pagination.html" . }} </main> {{ end }} {{< /code >}} ### Example: Using `.Site.GetPage` The `.Site.GetPage` example that follows assumes the following project directory structure: ``` . └── content ├── blog │   ├── _index.md # "title: My Hugo Blog" in the front matter │   ├── post-1.md │   ├── post-2.md │   └── post-3.md └── events #Note there is no _index.md file in "events" ├── event-1.md └── event-2.md ``` `.Site.GetPage` will return `nil` if no `_index.md` page is found. Therefore, if `content/blog/_index.md` does not exist, the template will output the section name: ``` <h1>{{ with .Site.GetPage "section" "blog" }}{{ .Title }}{{ end }}</h1> ``` Since `blog` has a section index page with front matter at `content/blog/_index.md`, the above code will return the following result: ``` <h1>My Hugo Blog</h1> ``` If we try the same code with the `events` section, however, Hugo will default to the section title because there is no `content/events/_index.md` from which to pull content and front matter: ``` <h1>{{ with .Site.GetPage "section" "events" }}{{ .Title }}{{ end }}</h1> ``` Which then returns the following: ``` <h1>Events</h1> ``` [contentorg]: /content-management/organization/ [getpage]: /functions/getpage/ [lists]: /templates/lists/ [lookup]: /templates/lookup-order/ [where]: /functions/where/ [sections]: /content-management/sections/
--- title: Section Page Templates linktitle: Section Templates description: Templates used for section pages are **lists** and therefore have all the variables and methods available to list pages. date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [templates] keywords: [lists,sections,templates] menu: docs: parent: "templates" weight: 40 weight: 40 sections_weight: 40 draft: false aliases: [/templates/sections/] toc: true --- ## Add Content and Front Matter to Section Templates To effectively leverage section page templates, you should first understand Hugo's [content organization](/content-management/organization/) and, specifically, the purpose of `_index.md` for adding content and front matter to section and other list pages. ## Section Template Lookup Order See [Template Lookup](/templates/lookup-order/). ## Page Kinds Every `Page` in Hugo has a `.Kind` attribute. {{% page-kinds %}} ## `.Site.GetPage` with Sections `Kind` can easily be combined with the [`where` function][where] in your templates to create kind-specific lists of content. This method is ideal for creating lists, but there are times where you may want to fetch just the index page of a single section via the section's path. The [`.GetPage` function][getpage] looks up an index page of a given `Kind` and `path`. You can call `.Site.GetPage` with two arguments: `kind` (one of the valid values of `Kind` from above) and `kind value`. Examples: - `{{ .Site.GetPage "section" "posts" }}` - `{{ .Site.GetPage "page" "search" }}` ## Example: Creating a Default Section Template {{< code file="layouts/_default/section.html" download="section.html" >}} {{ define "main" }} <main> {{ .Content }} <ul class="contents"> {{ range .Paginator.Pages }} <li>{{.Title}} <div> {{ partial "summary.html" . }} </div> </li> {{ end }} </ul> {{ partial "pagination.html" . }} </main> {{ end }} {{< /code >}} ### Example: Using `.Site.GetPage` The `.Site.GetPage` example that follows assumes the following project directory structure: ``` . └── content ├── blog │   ├── _index.md # "title: My Hugo Blog" in the front matter │   ├── post-1.md │   ├── post-2.md │   └── post-3.md └── events #Note there is no _index.md file in "events" ├── event-1.md └── event-2.md ``` `.Site.GetPage` will return `nil` if no `_index.md` page is found. Therefore, if `content/blog/_index.md` does not exist, the template will output the section name: ``` <h1>{{ with .Site.GetPage "section" "blog" }}{{ .Title }}{{ end }}</h1> ``` Since `blog` has a section index page with front matter at `content/blog/_index.md`, the above code will return the following result: ``` <h1>My Hugo Blog</h1> ``` If we try the same code with the `events` section, however, Hugo will default to the section title because there is no `content/events/_index.md` from which to pull content and front matter: ``` <h1>{{ with .Site.GetPage "section" "events" }}{{ .Title }}{{ end }}</h1> ``` Which then returns the following: ``` <h1>Events</h1> ``` [contentorg]: /content-management/organization/ [getpage]: /functions/getpage/ [lists]: /templates/lists/ [lookup]: /templates/lookup-order/ [where]: /functions/where/ [sections]: /content-management/sections/
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./tpl/path/init.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package path import ( "fmt" "path/filepath" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/tpl/internal" ) const name = "path" func init() { f := func(d *deps.Deps) *internal.TemplateFuncsNamespace { ctx := New(d) ns := &internal.TemplateFuncsNamespace{ Name: name, Context: func(args ...interface{}) interface{} { return ctx }, } ns.AddMethodMapping(ctx.Split, nil, [][2]string{ {`{{ "/my/path/filename.txt" | path.Split }}`, `/my/path/|filename.txt`}, {fmt.Sprintf(`{{ %q | path.Split }}`, filepath.FromSlash("/my/path/filename.txt")), `/my/path/|filename.txt`}, }, ) testDir := filepath.Join("my", "path") testFile := filepath.Join(testDir, "filename.txt") ns.AddMethodMapping(ctx.Join, nil, [][2]string{ {fmt.Sprintf(`{{ slice %q "filename.txt" | path.Join }}`, testDir), `my/path/filename.txt`}, {`{{ path.Join "my" "path" "filename.txt" }}`, `my/path/filename.txt`}, {fmt.Sprintf(`{{ %q | path.Ext }}`, testFile), `.txt`}, {fmt.Sprintf(`{{ %q | path.Base }}`, testFile), `filename.txt`}, {fmt.Sprintf(`{{ %q | path.Dir }}`, testFile), `my/path`}, }, ) return ns } internal.AddTemplateFuncsNamespace(f) }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package path import ( "fmt" "path/filepath" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/tpl/internal" ) const name = "path" func init() { f := func(d *deps.Deps) *internal.TemplateFuncsNamespace { ctx := New(d) ns := &internal.TemplateFuncsNamespace{ Name: name, Context: func(args ...interface{}) interface{} { return ctx }, } ns.AddMethodMapping(ctx.Split, nil, [][2]string{ {`{{ "/my/path/filename.txt" | path.Split }}`, `/my/path/|filename.txt`}, {fmt.Sprintf(`{{ %q | path.Split }}`, filepath.FromSlash("/my/path/filename.txt")), `/my/path/|filename.txt`}, }, ) testDir := filepath.Join("my", "path") testFile := filepath.Join(testDir, "filename.txt") ns.AddMethodMapping(ctx.Join, nil, [][2]string{ {fmt.Sprintf(`{{ slice %q "filename.txt" | path.Join }}`, testDir), `my/path/filename.txt`}, {`{{ path.Join "my" "path" "filename.txt" }}`, `my/path/filename.txt`}, {fmt.Sprintf(`{{ %q | path.Ext }}`, testFile), `.txt`}, {fmt.Sprintf(`{{ %q | path.Base }}`, testFile), `filename.txt`}, {fmt.Sprintf(`{{ %q | path.Dir }}`, testFile), `my/path`}, }, ) return ns } internal.AddTemplateFuncsNamespace(f) }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/functions/in.md
--- title: in linktitle: description: Checks if an element is in an array or slice--or a substring in a string---and returns a boolean. godocref: date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [functions] menu: docs: parent: "functions" keywords: [strings] signature: ["in SET ITEM"] workson: [] hugoversion: relatedfuncs: [] deprecated: false aliases: [] --- The elements supported are strings, integers and floats, although only float64 will match as expected. In addition, `in` can also check if a substring exists in a string. ``` {{ if in .Params.tags "Git" }}Follow me on GitHub!{{ end }} ``` ``` {{ if in "this string contains a substring" "substring" }}Substring found!{{ end }} ```
--- title: in linktitle: description: Checks if an element is in an array or slice--or a substring in a string---and returns a boolean. godocref: date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [functions] menu: docs: parent: "functions" keywords: [strings] signature: ["in SET ITEM"] workson: [] hugoversion: relatedfuncs: [] deprecated: false aliases: [] --- The elements supported are strings, integers and floats, although only float64 will match as expected. In addition, `in` can also check if a substring exists in a string. ``` {{ if in .Params.tags "Git" }}Follow me on GitHub!{{ end }} ``` ``` {{ if in "this string contains a substring" "substring" }}Substring found!{{ end }} ```
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/news/0.60.1-relnotes/index.md
--- date: 2019-11-29 title: "Hugo 0.60.1: A couple of Bug Fixes" description: "This version fixes a couple of bugs introduced in 0.60.0." categories: ["Releases"] --- This is a bug-fix release with a couple of important fixes. * deps: Update minify [86a5b59f](https://github.com/gohugoio/hugo/commit/86a5b59f64dd6c4d338a9e091e98cd0ad6d4824f) [@MeiK2333](https://github.com/MeiK2333) [#6475](https://github.com/gohugoio/hugo/issues/6475) * Fix headless regression [bb80fff6](https://github.com/gohugoio/hugo/commit/bb80fff69ad3f2ddff23819bf6eb6f4b8512dc2a) [@bep](https://github.com/bep) [#6552](https://github.com/gohugoio/hugo/issues/6552) * deps: Update Goldmark [347cfb0c](https://github.com/gohugoio/hugo/commit/347cfb0c17b08626250180e8a84b53fc4800473f) [@bep](https://github.com/bep) [#6549](https://github.com/gohugoio/hugo/issues/6549)[#6551](https://github.com/gohugoio/hugo/issues/6551) * hugolib: Fix timeout number parsing for YAML/JSON config [b60ae35b](https://github.com/gohugoio/hugo/commit/b60ae35b97c4f44b9b09fcf06c863c695bc3c73a) [@bep](https://github.com/bep) [#6555](https://github.com/gohugoio/hugo/issues/6555)
--- date: 2019-11-29 title: "Hugo 0.60.1: A couple of Bug Fixes" description: "This version fixes a couple of bugs introduced in 0.60.0." categories: ["Releases"] --- This is a bug-fix release with a couple of important fixes. * deps: Update minify [86a5b59f](https://github.com/gohugoio/hugo/commit/86a5b59f64dd6c4d338a9e091e98cd0ad6d4824f) [@MeiK2333](https://github.com/MeiK2333) [#6475](https://github.com/gohugoio/hugo/issues/6475) * Fix headless regression [bb80fff6](https://github.com/gohugoio/hugo/commit/bb80fff69ad3f2ddff23819bf6eb6f4b8512dc2a) [@bep](https://github.com/bep) [#6552](https://github.com/gohugoio/hugo/issues/6552) * deps: Update Goldmark [347cfb0c](https://github.com/gohugoio/hugo/commit/347cfb0c17b08626250180e8a84b53fc4800473f) [@bep](https://github.com/bep) [#6549](https://github.com/gohugoio/hugo/issues/6549)[#6551](https://github.com/gohugoio/hugo/issues/6551) * hugolib: Fix timeout number parsing for YAML/JSON config [b60ae35b](https://github.com/gohugoio/hugo/commit/b60ae35b97c4f44b9b09fcf06c863c695bc3c73a) [@bep](https://github.com/bep) [#6555](https://github.com/gohugoio/hugo/issues/6555)
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./hugolib/taxonomy_test.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "fmt" "path/filepath" "reflect" "strings" "testing" "github.com/gohugoio/hugo/resources/page" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" ) func TestTaxonomiesCountOrder(t *testing.T) { t.Parallel() taxonomies := make(map[string]string) taxonomies["tag"] = "tags" taxonomies["category"] = "categories" cfg, fs := newTestCfg() cfg.Set("taxonomies", taxonomies) const pageContent = `--- tags: ['a', 'B', 'c'] categories: 'd' --- YAML frontmatter with tags and categories taxonomy.` writeSource(t, fs, filepath.Join("content", "page.md"), pageContent) s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{}) st := make([]string, 0) for _, t := range s.Taxonomies()["tags"].ByCount() { st = append(st, t.Page().Title()+":"+t.Name) } expect := []string{"a:a", "B:b", "c:c"} if !reflect.DeepEqual(st, expect) { t.Fatalf("ordered taxonomies mismatch, expected\n%v\ngot\n%q", expect, st) } } // func TestTaxonomiesWithAndWithoutContentFile(t *testing.T) { for _, uglyURLs := range []bool{false, true} { uglyURLs := uglyURLs t.Run(fmt.Sprintf("uglyURLs=%t", uglyURLs), func(t *testing.T) { t.Parallel() doTestTaxonomiesWithAndWithoutContentFile(t, uglyURLs) }) } } func doTestTaxonomiesWithAndWithoutContentFile(t *testing.T, uglyURLs bool) { siteConfig := ` baseURL = "http://example.com/blog" uglyURLs = %t paginate = 1 defaultContentLanguage = "en" [Taxonomies] tag = "tags" category = "categories" other = "others" empty = "empties" permalinked = "permalinkeds" [permalinks] permalinkeds = "/perma/:slug/" ` pageTemplate := `--- title: "%s" tags: %s categories: %s others: %s permalinkeds: %s --- # Doc ` siteConfig = fmt.Sprintf(siteConfig, uglyURLs) b := newTestSitesBuilder(t).WithConfigFile("toml", siteConfig) b.WithContent( "p1.md", fmt.Sprintf(pageTemplate, "t1/c1", "- Tag1", "- cAt1", "- o1", "- Pl1"), "p2.md", fmt.Sprintf(pageTemplate, "t2/c1", "- tag2", "- cAt1", "- o1", "- Pl1"), "p3.md", fmt.Sprintf(pageTemplate, "t2/c12", "- tag2", "- cat2", "- o1", "- Pl1"), "p4.md", fmt.Sprintf(pageTemplate, "Hello World", "", "", "- \"Hello Hugo world\"", "- Pl1"), "categories/_index.md", newTestPage("Category Terms", "2017-01-01", 10), "tags/Tag1/_index.md", newTestPage("Tag1 List", "2017-01-01", 10), // https://github.com/gohugoio/hugo/issues/5847 "/tags/not-used/_index.md", newTestPage("Unused Tag List", "2018-01-01", 10), ) b.Build(BuildCfg{}) // So what we have now is: // 1. categories with terms content page, but no content page for the only c1 category // 2. tags with no terms content page, but content page for one of 2 tags (tag1) // 3. the "others" taxonomy with no content pages. // 4. the "permalinkeds" taxonomy with permalinks configuration. pathFunc := func(s string) string { if uglyURLs { return strings.Replace(s, "/index.html", ".html", 1) } return s } // 1. b.AssertFileContent(pathFunc("public/categories/cat1/index.html"), "List", "cAt1") b.AssertFileContent(pathFunc("public/categories/index.html"), "Taxonomy Term Page", "Category Terms") // 2. b.AssertFileContent(pathFunc("public/tags/tag2/index.html"), "List", "tag2") b.AssertFileContent(pathFunc("public/tags/tag1/index.html"), "List", "Tag1") b.AssertFileContent(pathFunc("public/tags/index.html"), "Taxonomy Term Page", "Tags") // 3. b.AssertFileContent(pathFunc("public/others/o1/index.html"), "List", "o1") b.AssertFileContent(pathFunc("public/others/index.html"), "Taxonomy Term Page", "Others") // 4. b.AssertFileContent(pathFunc("public/perma/pl1/index.html"), "List", "Pl1") // This looks kind of funky, but the taxonomy terms do not have a permalinks definition, // for good reasons. b.AssertFileContent(pathFunc("public/permalinkeds/index.html"), "Taxonomy Term Page", "Permalinkeds") s := b.H.Sites[0] // Make sure that each page.KindTaxonomyTerm page has an appropriate number // of page.KindTaxonomy pages in its Pages slice. taxonomyTermPageCounts := map[string]int{ "tags": 3, "categories": 2, "others": 2, "empties": 0, "permalinkeds": 1, } for taxonomy, count := range taxonomyTermPageCounts { msg := qt.Commentf(taxonomy) term := s.getPage(page.KindTaxonomy, taxonomy) b.Assert(term, qt.Not(qt.IsNil), msg) b.Assert(len(term.Pages()), qt.Equals, count, msg) for _, p := range term.Pages() { b.Assert(p.Kind(), qt.Equals, page.KindTerm) } } cat1 := s.getPage(page.KindTerm, "categories", "cat1") b.Assert(cat1, qt.Not(qt.IsNil)) if uglyURLs { b.Assert(cat1.RelPermalink(), qt.Equals, "/blog/categories/cat1.html") } else { b.Assert(cat1.RelPermalink(), qt.Equals, "/blog/categories/cat1/") } pl1 := s.getPage(page.KindTerm, "permalinkeds", "pl1") permalinkeds := s.getPage(page.KindTaxonomy, "permalinkeds") b.Assert(pl1, qt.Not(qt.IsNil)) b.Assert(permalinkeds, qt.Not(qt.IsNil)) if uglyURLs { b.Assert(pl1.RelPermalink(), qt.Equals, "/blog/perma/pl1.html") b.Assert(permalinkeds.RelPermalink(), qt.Equals, "/blog/permalinkeds.html") } else { b.Assert(pl1.RelPermalink(), qt.Equals, "/blog/perma/pl1/") b.Assert(permalinkeds.RelPermalink(), qt.Equals, "/blog/permalinkeds/") } helloWorld := s.getPage(page.KindTerm, "others", "hello-hugo-world") b.Assert(helloWorld, qt.Not(qt.IsNil)) b.Assert(helloWorld.Title(), qt.Equals, "Hello Hugo world") // Issue #2977 b.AssertFileContent(pathFunc("public/empties/index.html"), "Taxonomy Term Page", "Empties") } // https://github.com/gohugoio/hugo/issues/5513 // https://github.com/gohugoio/hugo/issues/5571 func TestTaxonomiesPathSeparation(t *testing.T) { t.Parallel() config := ` baseURL = "https://example.com" [taxonomies] "news/tag" = "news/tags" "news/category" = "news/categories" "t1/t2/t3" = "t1/t2/t3s" "s1/s2/s3" = "s1/s2/s3s" ` pageContent := ` +++ title = "foo" "news/categories" = ["a", "b", "c", "d/e", "f/g/h"] "t1/t2/t3s" = ["t4/t5", "t4/t5/t6"] +++ Content. ` b := newTestSitesBuilder(t) b.WithConfigFile("toml", config) b.WithContent("page.md", pageContent) b.WithContent("news/categories/b/_index.md", ` --- title: "This is B" --- `) b.WithContent("news/categories/f/g/h/_index.md", ` --- title: "This is H" --- `) b.WithContent("t1/t2/t3s/t4/t5/_index.md", ` --- title: "This is T5" --- `) b.WithContent("s1/s2/s3s/_index.md", ` --- title: "This is S3s" --- `) b.CreateSites().Build(BuildCfg{}) s := b.H.Sites[0] filterbyKind := func(kind string) page.Pages { var pages page.Pages for _, p := range s.Pages() { if p.Kind() == kind { pages = append(pages, p) } } return pages } ta := filterbyKind(page.KindTerm) te := filterbyKind(page.KindTaxonomy) b.Assert(len(te), qt.Equals, 4) b.Assert(len(ta), qt.Equals, 7) b.AssertFileContent("public/news/categories/a/index.html", "Taxonomy List Page 1|a|Hello|https://example.com/news/categories/a/|") b.AssertFileContent("public/news/categories/b/index.html", "Taxonomy List Page 1|This is B|Hello|https://example.com/news/categories/b/|") b.AssertFileContent("public/news/categories/d/e/index.html", "Taxonomy List Page 1|d/e|Hello|https://example.com/news/categories/d/e/|") b.AssertFileContent("public/news/categories/f/g/h/index.html", "Taxonomy List Page 1|This is H|Hello|https://example.com/news/categories/f/g/h/|") b.AssertFileContent("public/t1/t2/t3s/t4/t5/index.html", "Taxonomy List Page 1|This is T5|Hello|https://example.com/t1/t2/t3s/t4/t5/|") b.AssertFileContent("public/t1/t2/t3s/t4/t5/t6/index.html", "Taxonomy List Page 1|t4/t5/t6|Hello|https://example.com/t1/t2/t3s/t4/t5/t6/|") b.AssertFileContent("public/news/categories/index.html", "Taxonomy Term Page 1|News/Categories|Hello|https://example.com/news/categories/|") b.AssertFileContent("public/t1/t2/t3s/index.html", "Taxonomy Term Page 1|T1/T2/T3s|Hello|https://example.com/t1/t2/t3s/|") b.AssertFileContent("public/s1/s2/s3s/index.html", "Taxonomy Term Page 1|This is S3s|Hello|https://example.com/s1/s2/s3s/|") } // https://github.com/gohugoio/hugo/issues/5719 func TestTaxonomiesNextGenLoops(t *testing.T) { b := newTestSitesBuilder(t).WithSimpleConfigFile() b.WithTemplatesAdded("index.html", ` <h1>Tags</h1> <ul> {{ range .Site.Taxonomies.tags }} <li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li> {{ end }} </ul> `) b.WithTemplatesAdded("_default/terms.html", ` <h1>Terms</h1> <ul> {{ range .Data.Terms.Alphabetical }} <li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li> {{ end }} </ul> `) for i := 0; i < 10; i++ { b.WithContent(fmt.Sprintf("page%d.md", i+1), ` --- Title: "Taxonomy!" tags: ["Hugo Rocks!", "Rocks I say!" ] categories: ["This is Cool", "And new" ] --- Content. `) } b.CreateSites().Build(BuildCfg{}) b.AssertFileContent("public/index.html", `<li><a href="http://example.com/tags/hugo-rocks/">Hugo Rocks!</a> 10</li>`) b.AssertFileContent("public/categories/index.html", `<li><a href="http://example.com/categories/this-is-cool/">This is Cool</a> 10</li>`) b.AssertFileContent("public/tags/index.html", `<li><a href="http://example.com/tags/rocks-i-say/">Rocks I say!</a> 10</li>`) } // Issue 6213 func TestTaxonomiesNotForDrafts(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t) b.WithContent("draft.md", `--- title: "Draft" draft: true categories: ["drafts"] --- `, "regular.md", `--- title: "Not Draft" categories: ["regular"] --- `) b.Build(BuildCfg{}) s := b.H.Sites[0] b.Assert(b.CheckExists("public/categories/regular/index.html"), qt.Equals, true) b.Assert(b.CheckExists("public/categories/drafts/index.html"), qt.Equals, false) reg, _ := s.getPageNew(nil, "categories/regular") dra, _ := s.getPageNew(nil, "categories/draft") b.Assert(reg, qt.Not(qt.IsNil)) b.Assert(dra, qt.IsNil) } func TestTaxonomiesIndexDraft(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t) b.WithContent( "categories/_index.md", `--- title: "The Categories" draft: true --- Content. `, "page.md", `--- title: "The Page" categories: ["cool"] --- Content. `, ) b.WithTemplates("index.html", ` {{ range .Site.Pages }} {{ .RelPermalink }}|{{ .Title }}|{{ .WordCount }}|{{ .Content }}| {{ end }} `) b.Build(BuildCfg{}) b.AssertFileContentFn("public/index.html", func(s string) bool { return !strings.Contains(s, "categories") }) } // https://github.com/gohugoio/hugo/issues/6927 func TestTaxonomiesHomeDraft(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t) b.WithContent( "_index.md", `--- title: "Home" draft: true --- Content. `, "posts/_index.md", `--- title: "Posts" draft: true --- Content. `, "posts/page.md", `--- title: "The Page" categories: ["cool"] --- Content. `, ) b.WithTemplates("index.html", ` NO HOME FOR YOU `) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/index.html"), qt.Equals, false) b.Assert(b.CheckExists("public/categories/index.html"), qt.Equals, false) b.Assert(b.CheckExists("public/posts/index.html"), qt.Equals, false) } // https://github.com/gohugoio/hugo/issues/6173 func TestTaxonomiesWithBundledResources(t *testing.T) { b := newTestSitesBuilder(t) b.WithTemplates("_default/list.html", ` List {{ .Title }}: {{ range .Resources }} Resource: {{ .RelPermalink }}|{{ .MediaType }} {{ end }} `) b.WithContent("p1.md", `--- title: Page categories: ["funny"] --- `, "categories/_index.md", "---\ntitle: Categories Page\n---", "categories/data.json", "Category data", "categories/funny/_index.md", "---\ntitle: Funny Category\n---", "categories/funny/funnydata.json", "Category funny data", ) b.Build(BuildCfg{}) b.AssertFileContent("public/categories/index.html", `Resource: /categories/data.json|application/json`) b.AssertFileContent("public/categories/funny/index.html", `Resource: /categories/funny/funnydata.json|application/json`) } func TestTaxonomiesRemoveOne(t *testing.T) { b := newTestSitesBuilder(t).Running() b.WithTemplates("index.html", ` {{ $cats := .Site.Taxonomies.categories.cats }} {{ if $cats }} Len cats: {{ len $cats }} {{ range $cats }} Cats:|{{ .Page.RelPermalink }}| {{ end }} {{ end }} {{ $funny := .Site.Taxonomies.categories.funny }} {{ if $funny }} Len funny: {{ len $funny }} {{ range $funny }} Funny:|{{ .Page.RelPermalink }}| {{ end }} {{ end }} `) b.WithContent("p1.md", `--- title: Page categories: ["funny", "cats"] --- `, "p2.md", `--- title: Page2 categories: ["funny", "cats"] --- `, ) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Len cats: 2 Len funny: 2 Cats:|/p1/| Cats:|/p2/| Funny:|/p1/| Funny:|/p2/|`) // Remove one category from one of the pages. b.EditFiles("content/p1.md", `--- title: Page categories: ["funny"] --- `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Len cats: 1 Len funny: 2 Cats:|/p2/| Funny:|/p1/| Funny:|/p2/|`) } //https://github.com/gohugoio/hugo/issues/6590 func TestTaxonomiesListPages(t *testing.T) { b := newTestSitesBuilder(t) b.WithTemplates("_default/list.html", ` {{ template "print-taxo" "categories.cats" }} {{ template "print-taxo" "categories.funny" }} {{ define "print-taxo" }} {{ $node := index site.Taxonomies (split $ ".") }} {{ if $node }} Len {{ $ }}: {{ len $node }} {{ range $node }} {{ $ }}:|{{ .Page.RelPermalink }}| {{ end }} {{ else }} {{ $ }} not found. {{ end }} {{ end }} `) b.WithContent("_index.md", `--- title: Home categories: ["funny", "cats"] --- `, "blog/p1.md", `--- title: Page1 categories: ["funny"] --- `, "blog/_index.md", `--- title: Blog Section categories: ["cats"] --- `, ) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Len categories.cats: 2 categories.cats:|/blog/| categories.cats:|/| Len categories.funny: 2 categories.funny:|/| categories.funny:|/blog/p1/| `) } func TestTaxonomiesPageCollections(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t) b.WithContent( "_index.md", `--- title: "Home Sweet Home" categories: [ "dogs", "gorillas"] --- `, "section/_index.md", `--- title: "Section" categories: [ "cats", "dogs", "birds"] --- `, "section/p1.md", `--- title: "Page1" categories: ["funny", "cats"] --- `, "section/p2.md", `--- title: "Page2" categories: ["funny"] --- `) b.WithTemplatesAdded("index.html", ` {{ $home := site.Home }} {{ $section := site.GetPage "section" }} {{ $categories := site.GetPage "categories" }} {{ $funny := site.GetPage "categories/funny" }} {{ $cats := site.GetPage "categories/cats" }} {{ $p1 := site.GetPage "section/p1" }} Categories Pages: {{ range $categories.Pages}}{{.RelPermalink }}|{{ end }}:END Funny Pages: {{ range $funny.Pages}}{{.RelPermalink }}|{{ end }}:END Cats Pages: {{ range $cats.Pages}}{{.RelPermalink }}|{{ end }}:END P1 Terms: {{ range $p1.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END Section Terms: {{ range $section.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END Home Terms: {{ range $home.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END Category Paginator {{ range $categories.Paginator.Pages }}{{ .RelPermalink }}|{{ end }}:END Cats Paginator {{ range $cats.Paginator.Pages }}{{ .RelPermalink }}|{{ end }}:END `) b.WithTemplatesAdded("404.html", ` 404 Terms: {{ range .GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END `) b.Build(BuildCfg{}) cat := b.GetPage("categories") funny := b.GetPage("categories/funny") b.Assert(cat, qt.Not(qt.IsNil)) b.Assert(funny, qt.Not(qt.IsNil)) b.Assert(cat.Parent().IsHome(), qt.Equals, true) b.Assert(funny.Kind(), qt.Equals, "term") b.Assert(funny.Parent(), qt.Equals, cat) b.AssertFileContent("public/index.html", ` Categories Pages: /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END Funny Pages: /section/p1/|/section/p2/|:END Cats Pages: /section/p1/|/section/|:END P1 Terms: /categories/funny/|/categories/cats/|:END Section Terms: /categories/cats/|/categories/dogs/|/categories/birds/|:END Home Terms: /categories/dogs/|/categories/gorillas/|:END Cats Paginator /section/p1/|/section/|:END Category Paginator /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END`, ) b.AssertFileContent("public/404.html", "\n404 Terms: :END\n\t") b.AssertFileContent("public/categories/funny/index.xml", `<link>http://example.com/section/p1/</link>`) b.AssertFileContent("public/categories/index.xml", `<link>http://example.com/categories/funny/</link>`) } func TestTaxonomiesDirectoryOverlaps(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t).WithContent( "abc/_index.md", "---\ntitle: \"abc\"\nabcdefgs: [abc]\n---", "abc/p1.md", "---\ntitle: \"abc-p\"\n---", "abcdefgh/_index.md", "---\ntitle: \"abcdefgh\"\n---", "abcdefgh/p1.md", "---\ntitle: \"abcdefgh-p\"\n---", "abcdefghijk/index.md", "---\ntitle: \"abcdefghijk\"\n---", ) b.WithConfigFile("toml", ` baseURL = "https://example.org" [taxonomies] abcdef = "abcdefs" abcdefg = "abcdefgs" abcdefghi = "abcdefghis" `) b.WithTemplatesAdded("index.html", ` {{ range site.Pages }}Page: {{ template "print-page" . }} {{ end }} {{ $abc := site.GetPage "abcdefgs/abc" }} {{ $abcdefgs := site.GetPage "abcdefgs" }} abc: {{ template "print-page" $abc }}|IsAncestor: {{ $abc.IsAncestor $abcdefgs }}|IsDescendant: {{ $abc.IsDescendant $abcdefgs }} abcdefgs: {{ template "print-page" $abcdefgs }}|IsAncestor: {{ $abcdefgs.IsAncestor $abc }}|IsDescendant: {{ $abcdefgs.IsDescendant $abc }} {{ define "print-page" }}{{ .RelPermalink }}|{{ .Title }}|{{.Kind }}|Parent: {{ with .Parent }}{{ .RelPermalink }}{{ end }}|CurrentSection: {{ .CurrentSection.RelPermalink}}|FirstSection: {{ .FirstSection.RelPermalink }}{{ end }} `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Page: /||home|Parent: |CurrentSection: /| Page: /abc/|abc|section|Parent: /|CurrentSection: /abc/| Page: /abc/p1/|abc-p|page|Parent: /abc/|CurrentSection: /abc/| Page: /abcdefgh/|abcdefgh|section|Parent: /|CurrentSection: /abcdefgh/| Page: /abcdefgh/p1/|abcdefgh-p|page|Parent: /abcdefgh/|CurrentSection: /abcdefgh/| Page: /abcdefghijk/|abcdefghijk|page|Parent: /|CurrentSection: /| Page: /abcdefghis/|Abcdefghis|taxonomy|Parent: /|CurrentSection: /| Page: /abcdefgs/|Abcdefgs|taxonomy|Parent: /|CurrentSection: /| Page: /abcdefs/|Abcdefs|taxonomy|Parent: /|CurrentSection: /| abc: /abcdefgs/abc/|abc|term|Parent: /abcdefgs/|CurrentSection: /abcdefgs/| abcdefgs: /abcdefgs/|Abcdefgs|taxonomy|Parent: /|CurrentSection: /| abc: /abcdefgs/abc/|abc|term|Parent: /abcdefgs/|CurrentSection: /abcdefgs/|FirstSection: /|IsAncestor: false|IsDescendant: true abcdefgs: /abcdefgs/|Abcdefgs|taxonomy|Parent: /|CurrentSection: /|FirstSection: /|IsAncestor: true|IsDescendant: false `) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "fmt" "path/filepath" "reflect" "strings" "testing" "github.com/gohugoio/hugo/resources/page" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" ) func TestTaxonomiesCountOrder(t *testing.T) { t.Parallel() taxonomies := make(map[string]string) taxonomies["tag"] = "tags" taxonomies["category"] = "categories" cfg, fs := newTestCfg() cfg.Set("taxonomies", taxonomies) const pageContent = `--- tags: ['a', 'B', 'c'] categories: 'd' --- YAML frontmatter with tags and categories taxonomy.` writeSource(t, fs, filepath.Join("content", "page.md"), pageContent) s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{}) st := make([]string, 0) for _, t := range s.Taxonomies()["tags"].ByCount() { st = append(st, t.Page().Title()+":"+t.Name) } expect := []string{"a:a", "B:b", "c:c"} if !reflect.DeepEqual(st, expect) { t.Fatalf("ordered taxonomies mismatch, expected\n%v\ngot\n%q", expect, st) } } // func TestTaxonomiesWithAndWithoutContentFile(t *testing.T) { for _, uglyURLs := range []bool{false, true} { uglyURLs := uglyURLs t.Run(fmt.Sprintf("uglyURLs=%t", uglyURLs), func(t *testing.T) { t.Parallel() doTestTaxonomiesWithAndWithoutContentFile(t, uglyURLs) }) } } func doTestTaxonomiesWithAndWithoutContentFile(t *testing.T, uglyURLs bool) { siteConfig := ` baseURL = "http://example.com/blog" uglyURLs = %t paginate = 1 defaultContentLanguage = "en" [Taxonomies] tag = "tags" category = "categories" other = "others" empty = "empties" permalinked = "permalinkeds" [permalinks] permalinkeds = "/perma/:slug/" ` pageTemplate := `--- title: "%s" tags: %s categories: %s others: %s permalinkeds: %s --- # Doc ` siteConfig = fmt.Sprintf(siteConfig, uglyURLs) b := newTestSitesBuilder(t).WithConfigFile("toml", siteConfig) b.WithContent( "p1.md", fmt.Sprintf(pageTemplate, "t1/c1", "- Tag1", "- cAt1", "- o1", "- Pl1"), "p2.md", fmt.Sprintf(pageTemplate, "t2/c1", "- tag2", "- cAt1", "- o1", "- Pl1"), "p3.md", fmt.Sprintf(pageTemplate, "t2/c12", "- tag2", "- cat2", "- o1", "- Pl1"), "p4.md", fmt.Sprintf(pageTemplate, "Hello World", "", "", "- \"Hello Hugo world\"", "- Pl1"), "categories/_index.md", newTestPage("Category Terms", "2017-01-01", 10), "tags/Tag1/_index.md", newTestPage("Tag1 List", "2017-01-01", 10), // https://github.com/gohugoio/hugo/issues/5847 "/tags/not-used/_index.md", newTestPage("Unused Tag List", "2018-01-01", 10), ) b.Build(BuildCfg{}) // So what we have now is: // 1. categories with terms content page, but no content page for the only c1 category // 2. tags with no terms content page, but content page for one of 2 tags (tag1) // 3. the "others" taxonomy with no content pages. // 4. the "permalinkeds" taxonomy with permalinks configuration. pathFunc := func(s string) string { if uglyURLs { return strings.Replace(s, "/index.html", ".html", 1) } return s } // 1. b.AssertFileContent(pathFunc("public/categories/cat1/index.html"), "List", "cAt1") b.AssertFileContent(pathFunc("public/categories/index.html"), "Taxonomy Term Page", "Category Terms") // 2. b.AssertFileContent(pathFunc("public/tags/tag2/index.html"), "List", "tag2") b.AssertFileContent(pathFunc("public/tags/tag1/index.html"), "List", "Tag1") b.AssertFileContent(pathFunc("public/tags/index.html"), "Taxonomy Term Page", "Tags") // 3. b.AssertFileContent(pathFunc("public/others/o1/index.html"), "List", "o1") b.AssertFileContent(pathFunc("public/others/index.html"), "Taxonomy Term Page", "Others") // 4. b.AssertFileContent(pathFunc("public/perma/pl1/index.html"), "List", "Pl1") // This looks kind of funky, but the taxonomy terms do not have a permalinks definition, // for good reasons. b.AssertFileContent(pathFunc("public/permalinkeds/index.html"), "Taxonomy Term Page", "Permalinkeds") s := b.H.Sites[0] // Make sure that each page.KindTaxonomyTerm page has an appropriate number // of page.KindTaxonomy pages in its Pages slice. taxonomyTermPageCounts := map[string]int{ "tags": 3, "categories": 2, "others": 2, "empties": 0, "permalinkeds": 1, } for taxonomy, count := range taxonomyTermPageCounts { msg := qt.Commentf(taxonomy) term := s.getPage(page.KindTaxonomy, taxonomy) b.Assert(term, qt.Not(qt.IsNil), msg) b.Assert(len(term.Pages()), qt.Equals, count, msg) for _, p := range term.Pages() { b.Assert(p.Kind(), qt.Equals, page.KindTerm) } } cat1 := s.getPage(page.KindTerm, "categories", "cat1") b.Assert(cat1, qt.Not(qt.IsNil)) if uglyURLs { b.Assert(cat1.RelPermalink(), qt.Equals, "/blog/categories/cat1.html") } else { b.Assert(cat1.RelPermalink(), qt.Equals, "/blog/categories/cat1/") } pl1 := s.getPage(page.KindTerm, "permalinkeds", "pl1") permalinkeds := s.getPage(page.KindTaxonomy, "permalinkeds") b.Assert(pl1, qt.Not(qt.IsNil)) b.Assert(permalinkeds, qt.Not(qt.IsNil)) if uglyURLs { b.Assert(pl1.RelPermalink(), qt.Equals, "/blog/perma/pl1.html") b.Assert(permalinkeds.RelPermalink(), qt.Equals, "/blog/permalinkeds.html") } else { b.Assert(pl1.RelPermalink(), qt.Equals, "/blog/perma/pl1/") b.Assert(permalinkeds.RelPermalink(), qt.Equals, "/blog/permalinkeds/") } helloWorld := s.getPage(page.KindTerm, "others", "hello-hugo-world") b.Assert(helloWorld, qt.Not(qt.IsNil)) b.Assert(helloWorld.Title(), qt.Equals, "Hello Hugo world") // Issue #2977 b.AssertFileContent(pathFunc("public/empties/index.html"), "Taxonomy Term Page", "Empties") } // https://github.com/gohugoio/hugo/issues/5513 // https://github.com/gohugoio/hugo/issues/5571 func TestTaxonomiesPathSeparation(t *testing.T) { t.Parallel() config := ` baseURL = "https://example.com" [taxonomies] "news/tag" = "news/tags" "news/category" = "news/categories" "t1/t2/t3" = "t1/t2/t3s" "s1/s2/s3" = "s1/s2/s3s" ` pageContent := ` +++ title = "foo" "news/categories" = ["a", "b", "c", "d/e", "f/g/h"] "t1/t2/t3s" = ["t4/t5", "t4/t5/t6"] +++ Content. ` b := newTestSitesBuilder(t) b.WithConfigFile("toml", config) b.WithContent("page.md", pageContent) b.WithContent("news/categories/b/_index.md", ` --- title: "This is B" --- `) b.WithContent("news/categories/f/g/h/_index.md", ` --- title: "This is H" --- `) b.WithContent("t1/t2/t3s/t4/t5/_index.md", ` --- title: "This is T5" --- `) b.WithContent("s1/s2/s3s/_index.md", ` --- title: "This is S3s" --- `) b.CreateSites().Build(BuildCfg{}) s := b.H.Sites[0] filterbyKind := func(kind string) page.Pages { var pages page.Pages for _, p := range s.Pages() { if p.Kind() == kind { pages = append(pages, p) } } return pages } ta := filterbyKind(page.KindTerm) te := filterbyKind(page.KindTaxonomy) b.Assert(len(te), qt.Equals, 4) b.Assert(len(ta), qt.Equals, 7) b.AssertFileContent("public/news/categories/a/index.html", "Taxonomy List Page 1|a|Hello|https://example.com/news/categories/a/|") b.AssertFileContent("public/news/categories/b/index.html", "Taxonomy List Page 1|This is B|Hello|https://example.com/news/categories/b/|") b.AssertFileContent("public/news/categories/d/e/index.html", "Taxonomy List Page 1|d/e|Hello|https://example.com/news/categories/d/e/|") b.AssertFileContent("public/news/categories/f/g/h/index.html", "Taxonomy List Page 1|This is H|Hello|https://example.com/news/categories/f/g/h/|") b.AssertFileContent("public/t1/t2/t3s/t4/t5/index.html", "Taxonomy List Page 1|This is T5|Hello|https://example.com/t1/t2/t3s/t4/t5/|") b.AssertFileContent("public/t1/t2/t3s/t4/t5/t6/index.html", "Taxonomy List Page 1|t4/t5/t6|Hello|https://example.com/t1/t2/t3s/t4/t5/t6/|") b.AssertFileContent("public/news/categories/index.html", "Taxonomy Term Page 1|News/Categories|Hello|https://example.com/news/categories/|") b.AssertFileContent("public/t1/t2/t3s/index.html", "Taxonomy Term Page 1|T1/T2/T3s|Hello|https://example.com/t1/t2/t3s/|") b.AssertFileContent("public/s1/s2/s3s/index.html", "Taxonomy Term Page 1|This is S3s|Hello|https://example.com/s1/s2/s3s/|") } // https://github.com/gohugoio/hugo/issues/5719 func TestTaxonomiesNextGenLoops(t *testing.T) { b := newTestSitesBuilder(t).WithSimpleConfigFile() b.WithTemplatesAdded("index.html", ` <h1>Tags</h1> <ul> {{ range .Site.Taxonomies.tags }} <li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li> {{ end }} </ul> `) b.WithTemplatesAdded("_default/terms.html", ` <h1>Terms</h1> <ul> {{ range .Data.Terms.Alphabetical }} <li><a href="{{ .Page.Permalink }}">{{ .Page.Title }}</a> {{ .Count }}</li> {{ end }} </ul> `) for i := 0; i < 10; i++ { b.WithContent(fmt.Sprintf("page%d.md", i+1), ` --- Title: "Taxonomy!" tags: ["Hugo Rocks!", "Rocks I say!" ] categories: ["This is Cool", "And new" ] --- Content. `) } b.CreateSites().Build(BuildCfg{}) b.AssertFileContent("public/index.html", `<li><a href="http://example.com/tags/hugo-rocks/">Hugo Rocks!</a> 10</li>`) b.AssertFileContent("public/categories/index.html", `<li><a href="http://example.com/categories/this-is-cool/">This is Cool</a> 10</li>`) b.AssertFileContent("public/tags/index.html", `<li><a href="http://example.com/tags/rocks-i-say/">Rocks I say!</a> 10</li>`) } // Issue 6213 func TestTaxonomiesNotForDrafts(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t) b.WithContent("draft.md", `--- title: "Draft" draft: true categories: ["drafts"] --- `, "regular.md", `--- title: "Not Draft" categories: ["regular"] --- `) b.Build(BuildCfg{}) s := b.H.Sites[0] b.Assert(b.CheckExists("public/categories/regular/index.html"), qt.Equals, true) b.Assert(b.CheckExists("public/categories/drafts/index.html"), qt.Equals, false) reg, _ := s.getPageNew(nil, "categories/regular") dra, _ := s.getPageNew(nil, "categories/draft") b.Assert(reg, qt.Not(qt.IsNil)) b.Assert(dra, qt.IsNil) } func TestTaxonomiesIndexDraft(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t) b.WithContent( "categories/_index.md", `--- title: "The Categories" draft: true --- Content. `, "page.md", `--- title: "The Page" categories: ["cool"] --- Content. `, ) b.WithTemplates("index.html", ` {{ range .Site.Pages }} {{ .RelPermalink }}|{{ .Title }}|{{ .WordCount }}|{{ .Content }}| {{ end }} `) b.Build(BuildCfg{}) b.AssertFileContentFn("public/index.html", func(s string) bool { return !strings.Contains(s, "categories") }) } // https://github.com/gohugoio/hugo/issues/6927 func TestTaxonomiesHomeDraft(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t) b.WithContent( "_index.md", `--- title: "Home" draft: true --- Content. `, "posts/_index.md", `--- title: "Posts" draft: true --- Content. `, "posts/page.md", `--- title: "The Page" categories: ["cool"] --- Content. `, ) b.WithTemplates("index.html", ` NO HOME FOR YOU `) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/index.html"), qt.Equals, false) b.Assert(b.CheckExists("public/categories/index.html"), qt.Equals, false) b.Assert(b.CheckExists("public/posts/index.html"), qt.Equals, false) } // https://github.com/gohugoio/hugo/issues/6173 func TestTaxonomiesWithBundledResources(t *testing.T) { b := newTestSitesBuilder(t) b.WithTemplates("_default/list.html", ` List {{ .Title }}: {{ range .Resources }} Resource: {{ .RelPermalink }}|{{ .MediaType }} {{ end }} `) b.WithContent("p1.md", `--- title: Page categories: ["funny"] --- `, "categories/_index.md", "---\ntitle: Categories Page\n---", "categories/data.json", "Category data", "categories/funny/_index.md", "---\ntitle: Funny Category\n---", "categories/funny/funnydata.json", "Category funny data", ) b.Build(BuildCfg{}) b.AssertFileContent("public/categories/index.html", `Resource: /categories/data.json|application/json`) b.AssertFileContent("public/categories/funny/index.html", `Resource: /categories/funny/funnydata.json|application/json`) } func TestTaxonomiesRemoveOne(t *testing.T) { b := newTestSitesBuilder(t).Running() b.WithTemplates("index.html", ` {{ $cats := .Site.Taxonomies.categories.cats }} {{ if $cats }} Len cats: {{ len $cats }} {{ range $cats }} Cats:|{{ .Page.RelPermalink }}| {{ end }} {{ end }} {{ $funny := .Site.Taxonomies.categories.funny }} {{ if $funny }} Len funny: {{ len $funny }} {{ range $funny }} Funny:|{{ .Page.RelPermalink }}| {{ end }} {{ end }} `) b.WithContent("p1.md", `--- title: Page categories: ["funny", "cats"] --- `, "p2.md", `--- title: Page2 categories: ["funny", "cats"] --- `, ) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Len cats: 2 Len funny: 2 Cats:|/p1/| Cats:|/p2/| Funny:|/p1/| Funny:|/p2/|`) // Remove one category from one of the pages. b.EditFiles("content/p1.md", `--- title: Page categories: ["funny"] --- `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Len cats: 1 Len funny: 2 Cats:|/p2/| Funny:|/p1/| Funny:|/p2/|`) } //https://github.com/gohugoio/hugo/issues/6590 func TestTaxonomiesListPages(t *testing.T) { b := newTestSitesBuilder(t) b.WithTemplates("_default/list.html", ` {{ template "print-taxo" "categories.cats" }} {{ template "print-taxo" "categories.funny" }} {{ define "print-taxo" }} {{ $node := index site.Taxonomies (split $ ".") }} {{ if $node }} Len {{ $ }}: {{ len $node }} {{ range $node }} {{ $ }}:|{{ .Page.RelPermalink }}| {{ end }} {{ else }} {{ $ }} not found. {{ end }} {{ end }} `) b.WithContent("_index.md", `--- title: Home categories: ["funny", "cats"] --- `, "blog/p1.md", `--- title: Page1 categories: ["funny"] --- `, "blog/_index.md", `--- title: Blog Section categories: ["cats"] --- `, ) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Len categories.cats: 2 categories.cats:|/blog/| categories.cats:|/| Len categories.funny: 2 categories.funny:|/| categories.funny:|/blog/p1/| `) } func TestTaxonomiesPageCollections(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t) b.WithContent( "_index.md", `--- title: "Home Sweet Home" categories: [ "dogs", "gorillas"] --- `, "section/_index.md", `--- title: "Section" categories: [ "cats", "dogs", "birds"] --- `, "section/p1.md", `--- title: "Page1" categories: ["funny", "cats"] --- `, "section/p2.md", `--- title: "Page2" categories: ["funny"] --- `) b.WithTemplatesAdded("index.html", ` {{ $home := site.Home }} {{ $section := site.GetPage "section" }} {{ $categories := site.GetPage "categories" }} {{ $funny := site.GetPage "categories/funny" }} {{ $cats := site.GetPage "categories/cats" }} {{ $p1 := site.GetPage "section/p1" }} Categories Pages: {{ range $categories.Pages}}{{.RelPermalink }}|{{ end }}:END Funny Pages: {{ range $funny.Pages}}{{.RelPermalink }}|{{ end }}:END Cats Pages: {{ range $cats.Pages}}{{.RelPermalink }}|{{ end }}:END P1 Terms: {{ range $p1.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END Section Terms: {{ range $section.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END Home Terms: {{ range $home.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END Category Paginator {{ range $categories.Paginator.Pages }}{{ .RelPermalink }}|{{ end }}:END Cats Paginator {{ range $cats.Paginator.Pages }}{{ .RelPermalink }}|{{ end }}:END `) b.WithTemplatesAdded("404.html", ` 404 Terms: {{ range .GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END `) b.Build(BuildCfg{}) cat := b.GetPage("categories") funny := b.GetPage("categories/funny") b.Assert(cat, qt.Not(qt.IsNil)) b.Assert(funny, qt.Not(qt.IsNil)) b.Assert(cat.Parent().IsHome(), qt.Equals, true) b.Assert(funny.Kind(), qt.Equals, "term") b.Assert(funny.Parent(), qt.Equals, cat) b.AssertFileContent("public/index.html", ` Categories Pages: /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END Funny Pages: /section/p1/|/section/p2/|:END Cats Pages: /section/p1/|/section/|:END P1 Terms: /categories/funny/|/categories/cats/|:END Section Terms: /categories/cats/|/categories/dogs/|/categories/birds/|:END Home Terms: /categories/dogs/|/categories/gorillas/|:END Cats Paginator /section/p1/|/section/|:END Category Paginator /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END`, ) b.AssertFileContent("public/404.html", "\n404 Terms: :END\n\t") b.AssertFileContent("public/categories/funny/index.xml", `<link>http://example.com/section/p1/</link>`) b.AssertFileContent("public/categories/index.xml", `<link>http://example.com/categories/funny/</link>`) } func TestTaxonomiesDirectoryOverlaps(t *testing.T) { t.Parallel() b := newTestSitesBuilder(t).WithContent( "abc/_index.md", "---\ntitle: \"abc\"\nabcdefgs: [abc]\n---", "abc/p1.md", "---\ntitle: \"abc-p\"\n---", "abcdefgh/_index.md", "---\ntitle: \"abcdefgh\"\n---", "abcdefgh/p1.md", "---\ntitle: \"abcdefgh-p\"\n---", "abcdefghijk/index.md", "---\ntitle: \"abcdefghijk\"\n---", ) b.WithConfigFile("toml", ` baseURL = "https://example.org" [taxonomies] abcdef = "abcdefs" abcdefg = "abcdefgs" abcdefghi = "abcdefghis" `) b.WithTemplatesAdded("index.html", ` {{ range site.Pages }}Page: {{ template "print-page" . }} {{ end }} {{ $abc := site.GetPage "abcdefgs/abc" }} {{ $abcdefgs := site.GetPage "abcdefgs" }} abc: {{ template "print-page" $abc }}|IsAncestor: {{ $abc.IsAncestor $abcdefgs }}|IsDescendant: {{ $abc.IsDescendant $abcdefgs }} abcdefgs: {{ template "print-page" $abcdefgs }}|IsAncestor: {{ $abcdefgs.IsAncestor $abc }}|IsDescendant: {{ $abcdefgs.IsDescendant $abc }} {{ define "print-page" }}{{ .RelPermalink }}|{{ .Title }}|{{.Kind }}|Parent: {{ with .Parent }}{{ .RelPermalink }}{{ end }}|CurrentSection: {{ .CurrentSection.RelPermalink}}|FirstSection: {{ .FirstSection.RelPermalink }}{{ end }} `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Page: /||home|Parent: |CurrentSection: /| Page: /abc/|abc|section|Parent: /|CurrentSection: /abc/| Page: /abc/p1/|abc-p|page|Parent: /abc/|CurrentSection: /abc/| Page: /abcdefgh/|abcdefgh|section|Parent: /|CurrentSection: /abcdefgh/| Page: /abcdefgh/p1/|abcdefgh-p|page|Parent: /abcdefgh/|CurrentSection: /abcdefgh/| Page: /abcdefghijk/|abcdefghijk|page|Parent: /|CurrentSection: /| Page: /abcdefghis/|Abcdefghis|taxonomy|Parent: /|CurrentSection: /| Page: /abcdefgs/|Abcdefgs|taxonomy|Parent: /|CurrentSection: /| Page: /abcdefs/|Abcdefs|taxonomy|Parent: /|CurrentSection: /| abc: /abcdefgs/abc/|abc|term|Parent: /abcdefgs/|CurrentSection: /abcdefgs/| abcdefgs: /abcdefgs/|Abcdefgs|taxonomy|Parent: /|CurrentSection: /| abc: /abcdefgs/abc/|abc|term|Parent: /abcdefgs/|CurrentSection: /abcdefgs/|FirstSection: /|IsAncestor: false|IsDescendant: true abcdefgs: /abcdefgs/|Abcdefgs|taxonomy|Parent: /|CurrentSection: /|FirstSection: /|IsAncestor: true|IsDescendant: false `) }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./common/hugo/version_current.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugo // CurrentVersion represents the current build version. // This should be the only one. var CurrentVersion = Version{ Number: 0.81, PatchLevel: 0, Suffix: "-DEV", }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugo // CurrentVersion represents the current build version. // This should be the only one. var CurrentVersion = Version{ Number: 0.81, PatchLevel: 0, Suffix: "-DEV", }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/news/0.34-relnotes/index.md
--- date: 2018-01-22 title: "Hugo 0.34: Pattern matching to filter images and other resources" description: "Hugo 0.34 adds full glob with super-asterisk support, for example `*.jpg`." categories: ["Releases"] --- Hugo `0.34` is a small release. It contains a few smaller bug-fixes, but more important is an overhaul of the API used to find images and other resources in your page bundles. We have added two simple methods on the `Resources` object: * `.Match` finds every resource matching a pattern. Examples: `.Match "images/*.jpg"` finds every JPEG image in `images` and `.Match "**.jpg"` finds every JPEG image in the bundle. * `.GetMatch` finds the first resource matching the pattern given. **Note: The path separators used are Unix-style forward slashes, even on Windows.** It uses [standard wildcard syntax](http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm) with the addition of the `**`, aka super-asterisk, which matches across path boundaries. Thanks to [@gobwas](https://github.com/gobwas/glob) for a fast and easy-to-use Glob library. This release represents **5 contributions by 1 contributors** to the main Hugo code base. Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs), which has received **25 contributions by 16 contributors**. A special thanks to [@bep](https://github.com/bep), [@rmetzler](https://github.com/rmetzler), [@chris-rudmin](https://github.com/chris-rudmin), and [@stkevintan](https://github.com/stkevintan) for their work on the documentation site. Hugo now has: * 22689+ [stars](https://github.com/gohugoio/hugo/stargazers) * 448+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors) * 197+ [themes](http://themes.gohugo.io/) ## Notes * `Resources.GetByPrefix` and `Resources.ByPrefix` are deprecated. They still work, but will eventually be removed. Use `Resources.Match` (many) and `Resources.GetMatch` (one). * When filtering bundles pages in sub-folders, you need to include the sub-folder when matching. This was a bug introduced in `0.33` and gets it in line with images and other resources. ## Enhancements * Add `Resources.Match` and `Resources.GetMatch` [94213801](https://github.com/gohugoio/hugo/commit/9421380168f66620cb73203e1267814b3086d805) [@bep](https://github.com/bep) [#4301](https://github.com/gohugoio/hugo/issues/4301) ## Fixes * Add validation for `defaultContentLanguage` [4d5e4f37](https://github.com/gohugoio/hugo/commit/4d5e4f379a890a3c6cbc11ddb40d77a90f14c015) [@bep](https://github.com/bep) [#4298](https://github.com/gohugoio/hugo/issues/4298) * Fix lookup of pages bundled in sub-folders in `ByPrefix` etc. [5d030869](https://github.com/gohugoio/hugo/commit/5d03086981b4a7d4bc450269a6a2e0fd22dbeed7) [@bep](https://github.com/bep) [#4295](https://github.com/gohugoio/hugo/issues/4295)
--- date: 2018-01-22 title: "Hugo 0.34: Pattern matching to filter images and other resources" description: "Hugo 0.34 adds full glob with super-asterisk support, for example `*.jpg`." categories: ["Releases"] --- Hugo `0.34` is a small release. It contains a few smaller bug-fixes, but more important is an overhaul of the API used to find images and other resources in your page bundles. We have added two simple methods on the `Resources` object: * `.Match` finds every resource matching a pattern. Examples: `.Match "images/*.jpg"` finds every JPEG image in `images` and `.Match "**.jpg"` finds every JPEG image in the bundle. * `.GetMatch` finds the first resource matching the pattern given. **Note: The path separators used are Unix-style forward slashes, even on Windows.** It uses [standard wildcard syntax](http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm) with the addition of the `**`, aka super-asterisk, which matches across path boundaries. Thanks to [@gobwas](https://github.com/gobwas/glob) for a fast and easy-to-use Glob library. This release represents **5 contributions by 1 contributors** to the main Hugo code base. Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs), which has received **25 contributions by 16 contributors**. A special thanks to [@bep](https://github.com/bep), [@rmetzler](https://github.com/rmetzler), [@chris-rudmin](https://github.com/chris-rudmin), and [@stkevintan](https://github.com/stkevintan) for their work on the documentation site. Hugo now has: * 22689+ [stars](https://github.com/gohugoio/hugo/stargazers) * 448+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors) * 197+ [themes](http://themes.gohugo.io/) ## Notes * `Resources.GetByPrefix` and `Resources.ByPrefix` are deprecated. They still work, but will eventually be removed. Use `Resources.Match` (many) and `Resources.GetMatch` (one). * When filtering bundles pages in sub-folders, you need to include the sub-folder when matching. This was a bug introduced in `0.33` and gets it in line with images and other resources. ## Enhancements * Add `Resources.Match` and `Resources.GetMatch` [94213801](https://github.com/gohugoio/hugo/commit/9421380168f66620cb73203e1267814b3086d805) [@bep](https://github.com/bep) [#4301](https://github.com/gohugoio/hugo/issues/4301) ## Fixes * Add validation for `defaultContentLanguage` [4d5e4f37](https://github.com/gohugoio/hugo/commit/4d5e4f379a890a3c6cbc11ddb40d77a90f14c015) [@bep](https://github.com/bep) [#4298](https://github.com/gohugoio/hugo/issues/4298) * Fix lookup of pages bundled in sub-folders in `ByPrefix` etc. [5d030869](https://github.com/gohugoio/hugo/commit/5d03086981b4a7d4bc450269a6a2e0fd22dbeed7) [@bep](https://github.com/bep) [#4295](https://github.com/gohugoio/hugo/issues/4295)
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./media/docshelper.go
package media import ( "github.com/gohugoio/hugo/docshelper" ) // This is is just some helpers used to create some JSON used in the Hugo docs. func init() { docsProvider := func() docshelper.DocProvider { return docshelper.DocProvider{"media": map[string]interface{}{"types": DefaultTypes}} } docshelper.AddDocProviderFunc(docsProvider) }
package media import ( "github.com/gohugoio/hugo/docshelper" ) // This is is just some helpers used to create some JSON used in the Hugo docs. func init() { docsProvider := func() docshelper.DocProvider { return docshelper.DocProvider{"media": map[string]interface{}{"types": DefaultTypes}} } docshelper.AddDocProviderFunc(docsProvider) }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./tpl/internal/go_templates/fmtsort/export_test.go
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package fmtsort import "reflect" func Compare(a, b reflect.Value) int { return compare(a, b) }
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package fmtsort import "reflect" func Compare(a, b reflect.Value) int { return compare(a, b) }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/functions/echoparam.md
--- title: echoParam description: Prints a parameter if it is set. godocref: date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [functions] menu: docs: parent: "functions" keywords: [] signature: ["echoParam DICTIONARY KEY"] workson: [] hugoversion: relatedfuncs: [] deprecated: false draft: false aliases: [] --- ``` {{ echoParam .Params "project_url" }} ```
--- title: echoParam description: Prints a parameter if it is set. godocref: date: 2017-02-01 publishdate: 2017-02-01 lastmod: 2017-02-01 categories: [functions] menu: docs: parent: "functions" keywords: [] signature: ["echoParam DICTIONARY KEY"] workson: [] hugoversion: relatedfuncs: [] deprecated: false draft: false aliases: [] --- ``` {{ echoParam .Params "project_url" }} ```
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./examples/multilingual/i18n/et.toml
[head_title] other = "Mitmekeelne"
[head_title] other = "Mitmekeelne"
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/resources/_gen/images/news/0.54.0-relnotes/featured-hugo-54.0-poster_hufa0b7b755124a76fe71c5c70a25724c2_59805_480x0_resize_catmullrom_2.png
PNG  IHDRGPLTEJG~@KČJKIHID  F>J&E?C@@ :A7#B(4=<E:H9J0B87;5=;ik x)92LlhPN+\vbqRYx{_sMeoVzz^-qeOS|]|MXŊW~TVRQ}ƉnȗjIvaZLǐlLJW\ZJ]mwN~EEcǞhǻ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ÄF` ([FY"e$ Dbи]d6f_1\lVleB)0SabK :!pWPN\ 9EP T$V"LwqIa/(n)^2^QO+IU@C%aftO8hUl`*HU3T~VST iI8`tt!"SC|U>2LUI #VENxN<x@vvqB~!>OfT b)ӌQ,3G*y<ssÏ}`x8,M vr2b;l^Ec' \Z ʂmXnwx"nћ._cW rDh-V_MS~b!C<yTۭH[q Ӿ.o% Ջ--zNk{_~_/n/ ZIENDB`
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/_vendor/github.com/gohugoio/gohugoioTheme/layouts/_default/terms.html
{{ define "main" }} {{ $section_to_display := .Pages }} <div class="w-100 ph4 pb5 pb6-ns pt1 pt3-ns"> <div class="flex"> <div class="dn db-l w-20"> {{ partial "nav-links-docs.html" . }} </div> <div class="w-100 w-80-l ph0 ph4-l"> <article class="w-100 nested-copy-line-height nested-links nested-img"> <h1 class="primary-color-dark f2"> {{ .Title }} </h1> </article> <div class="pa3 pa4-ns w-100 v-top column-count-3-l column-gap-1-l"> {{ range $key, $value := .Data.Terms }} <div class="break-inside-avoid-l nested-copy-line-height mb5"> <h2 class="f3"> <a href="{{ "/" | relLangURL }}{{ $.Data.Plural | urlize }}/{{ $key | urlize }}" class="link black hover-blue"> {{ $key }} <span class="f6 gray"> &#8599;</span> </a> </h2> {{ range $value.Pages }} <h3> <a href="{{ .Permalink }}" class="link blue"> {{ .Title }} </a> </h3> {{ end }} </div> {{ end }} </div> </div> </div> </div> {{ end }}
{{ define "main" }} {{ $section_to_display := .Pages }} <div class="w-100 ph4 pb5 pb6-ns pt1 pt3-ns"> <div class="flex"> <div class="dn db-l w-20"> {{ partial "nav-links-docs.html" . }} </div> <div class="w-100 w-80-l ph0 ph4-l"> <article class="w-100 nested-copy-line-height nested-links nested-img"> <h1 class="primary-color-dark f2"> {{ .Title }} </h1> </article> <div class="pa3 pa4-ns w-100 v-top column-count-3-l column-gap-1-l"> {{ range $key, $value := .Data.Terms }} <div class="break-inside-avoid-l nested-copy-line-height mb5"> <h2 class="f3"> <a href="{{ "/" | relLangURL }}{{ $.Data.Plural | urlize }}/{{ $key | urlize }}" class="link black hover-blue"> {{ $key }} <span class="f6 gray"> &#8599;</span> </a> </h2> {{ range $value.Pages }} <h3> <a href="{{ .Permalink }}" class="link blue"> {{ .Title }} </a> </h3> {{ end }} </div> {{ end }} </div> </div> </div> </div> {{ end }}
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./tpl/internal/go_templates/texttemplate/example_test.go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build go1.13 package template_test import ( "log" "os" "strings" "text/template" ) func ExampleTemplate() { // Define a template. const letter = ` Dear {{.Name}}, {{if .Attended}} It was a pleasure to see you at the wedding. {{- else}} It is a shame you couldn't make it to the wedding. {{- end}} {{with .Gift -}} Thank you for the lovely {{.}}. {{end}} Best wishes, Josie ` // Prepare some data to insert into the template. type Recipient struct { Name, Gift string Attended bool } var recipients = []Recipient{ {"Aunt Mildred", "bone china tea set", true}, {"Uncle John", "moleskin pants", false}, {"Cousin Rodney", "", false}, } // Create a new template and parse the letter into it. t := template.Must(template.New("letter").Parse(letter)) // Execute the template for each recipient. for _, r := range recipients { err := t.Execute(os.Stdout, r) if err != nil { log.Println("executing template:", err) } } // Output: // Dear Aunt Mildred, // // It was a pleasure to see you at the wedding. // Thank you for the lovely bone china tea set. // // Best wishes, // Josie // // Dear Uncle John, // // It is a shame you couldn't make it to the wedding. // Thank you for the lovely moleskin pants. // // Best wishes, // Josie // // Dear Cousin Rodney, // // It is a shame you couldn't make it to the wedding. // // Best wishes, // Josie } // The following example is duplicated in html/template; keep them in sync. func ExampleTemplate_block() { const ( master = `Names:{{block "list" .}}{{"\n"}}{{range .}}{{println "-" .}}{{end}}{{end}}` overlay = `{{define "list"}} {{join . ", "}}{{end}} ` ) var ( funcs = template.FuncMap{"join": strings.Join} guardians = []string{"Gamora", "Groot", "Nebula", "Rocket", "Star-Lord"} ) masterTmpl, err := template.New("master").Funcs(funcs).Parse(master) if err != nil { log.Fatal(err) } overlayTmpl, err := template.Must(masterTmpl.Clone()).Parse(overlay) if err != nil { log.Fatal(err) } if err := masterTmpl.Execute(os.Stdout, guardians); err != nil { log.Fatal(err) } if err := overlayTmpl.Execute(os.Stdout, guardians); err != nil { log.Fatal(err) } // Output: // Names: // - Gamora // - Groot // - Nebula // - Rocket // - Star-Lord // Names: Gamora, Groot, Nebula, Rocket, Star-Lord }
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build go1.13 package template_test import ( "log" "os" "strings" "text/template" ) func ExampleTemplate() { // Define a template. const letter = ` Dear {{.Name}}, {{if .Attended}} It was a pleasure to see you at the wedding. {{- else}} It is a shame you couldn't make it to the wedding. {{- end}} {{with .Gift -}} Thank you for the lovely {{.}}. {{end}} Best wishes, Josie ` // Prepare some data to insert into the template. type Recipient struct { Name, Gift string Attended bool } var recipients = []Recipient{ {"Aunt Mildred", "bone china tea set", true}, {"Uncle John", "moleskin pants", false}, {"Cousin Rodney", "", false}, } // Create a new template and parse the letter into it. t := template.Must(template.New("letter").Parse(letter)) // Execute the template for each recipient. for _, r := range recipients { err := t.Execute(os.Stdout, r) if err != nil { log.Println("executing template:", err) } } // Output: // Dear Aunt Mildred, // // It was a pleasure to see you at the wedding. // Thank you for the lovely bone china tea set. // // Best wishes, // Josie // // Dear Uncle John, // // It is a shame you couldn't make it to the wedding. // Thank you for the lovely moleskin pants. // // Best wishes, // Josie // // Dear Cousin Rodney, // // It is a shame you couldn't make it to the wedding. // // Best wishes, // Josie } // The following example is duplicated in html/template; keep them in sync. func ExampleTemplate_block() { const ( master = `Names:{{block "list" .}}{{"\n"}}{{range .}}{{println "-" .}}{{end}}{{end}}` overlay = `{{define "list"}} {{join . ", "}}{{end}} ` ) var ( funcs = template.FuncMap{"join": strings.Join} guardians = []string{"Gamora", "Groot", "Nebula", "Rocket", "Star-Lord"} ) masterTmpl, err := template.New("master").Funcs(funcs).Parse(master) if err != nil { log.Fatal(err) } overlayTmpl, err := template.Must(masterTmpl.Clone()).Parse(overlay) if err != nil { log.Fatal(err) } if err := masterTmpl.Execute(os.Stdout, guardians); err != nil { log.Fatal(err) } if err := overlayTmpl.Execute(os.Stdout, guardians); err != nil { log.Fatal(err) } // Output: // Names: // - Gamora // - Groot // - Nebula // - Rocket // - Star-Lord // Names: Gamora, Groot, Nebula, Rocket, Star-Lord }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/showcase/forestry/index.md
--- title: Forestry.io date: 2018-03-16 description: "Showcase: \"Seeing Hugo in action is a whole different world of awesome.\"" siteURL: https://forestry.io/ siteSource: https://github.com/forestryio/forestry.io --- It was clear from the get-go that we had to go with a static site generator. Static sites are secure, performant, and give you 100% flexibility. At [Forestry.io](https://forestry.io/) we provide Content Management Solutions for websites built with static site generators, so we might be a little biased. The only question: Which static site generator was the right choice for us? ### Why Hugo? In our early research we looked at Ionic’s [site](https://github.com/ionic-team/ionic) to get some inspiration. They used Jekyll to build their website. While Jekyll is a great generator, the build times for larger sites can be painfully slow. With more than 150 pages plus many custom configurations and add-ons, our website doesn’t fall into the low-volume category anymore. Our developers want a smooth experience when working on the website and our content editors need the ability to preview content quickly. In short, we need our builds to be lightning fast. We knew Hugo was fast but we did [some additional benchmarking](https://forestry.io/blog/hugo-vs-jekyll-benchmark/) before making our decision. Seeing Hugo in action is a whole different world of awesome. Hugo takes less than one second to build our 150-page site! Take a look: ```bash | EN +------------------+-----+ Pages | 141 Paginator pages | 4 Non-page files | 0 Static files | 537 Processed images | 0 Aliases | 60 Sitemaps | 1 Cleaned | 0 Total in 739 ms ``` In fact, we liked Hugo so much that our wizard Chris made his workflow public and we started the open-source project [Create-Static-Site](https://github.com/forestryio/create-static-site). It's [a simple way to spin up sites](https://forestry.io/blog/up-and-running-with-hugo/) and set up a modern web development workflow with one line of code. Essentially it adds build configurations as a dependency for JS, CSS and Image Processing. Lastly, we want to take the opportunity to give some love to other amazing tools we used building our website. ### What tools did we use? * Our Norwegian designer Nichlas is in love with [**Sketch**](https://www.sketchapp.com/). From what we hear it’s a designer’s dream come true. * Some say our main graphic is [mesmerizing](https://twitter.com/hmncllctv/status/968907474664284160). Nichlas created it using [**3DS Max**](https://www.autodesk.com/products/3ds-max/overview). * [**Hugo**](https://gohugo.io/) -- of course. * Chris can’t think of modern web development without [**Gulp**](https://gulpjs.com/) & [**Webpack**](https://webpack.js.org/). We used them to add additional build steps such as Browsersync, CSS, JS and SVG optimization. * Speaking about adding steps to our build, our lives would be much harder without [**CircleCI**](https://circleci.com/) for continuous deployment and automated testing purposes. * We can’t stop raving about [**Algolia**](https://www.algolia.com/). Chris loves it and even wrote a tutorial on [how to implement Algolia](https://forestry.io/blog/search-with-algolia-in-hugo/) into static sites using Hugo’s [Custom Outputs](https://gohugo.io/templates/output-formats/). * [**Cloudinary**](https://cloudinary.com/) is probably one of the easiest ways to get responsive images into your website. * We might be a little biased on this one - We think [**Forestry.io**](https://forestry.io/) is a great way to add a content management system with a clean UI on top of your site without interrupting your experience as a developer. * For hosting purposes we use the almighty [**AWS**](https://aws.amazon.com/). * [**Formspree.io**](https://formspree.io/) is managing our support and enterprise requests. * We also use browser cookies and JS to customize our user’s experience and give it a more dynamic feel.
--- title: Forestry.io date: 2018-03-16 description: "Showcase: \"Seeing Hugo in action is a whole different world of awesome.\"" siteURL: https://forestry.io/ siteSource: https://github.com/forestryio/forestry.io --- It was clear from the get-go that we had to go with a static site generator. Static sites are secure, performant, and give you 100% flexibility. At [Forestry.io](https://forestry.io/) we provide Content Management Solutions for websites built with static site generators, so we might be a little biased. The only question: Which static site generator was the right choice for us? ### Why Hugo? In our early research we looked at Ionic’s [site](https://github.com/ionic-team/ionic) to get some inspiration. They used Jekyll to build their website. While Jekyll is a great generator, the build times for larger sites can be painfully slow. With more than 150 pages plus many custom configurations and add-ons, our website doesn’t fall into the low-volume category anymore. Our developers want a smooth experience when working on the website and our content editors need the ability to preview content quickly. In short, we need our builds to be lightning fast. We knew Hugo was fast but we did [some additional benchmarking](https://forestry.io/blog/hugo-vs-jekyll-benchmark/) before making our decision. Seeing Hugo in action is a whole different world of awesome. Hugo takes less than one second to build our 150-page site! Take a look: ```bash | EN +------------------+-----+ Pages | 141 Paginator pages | 4 Non-page files | 0 Static files | 537 Processed images | 0 Aliases | 60 Sitemaps | 1 Cleaned | 0 Total in 739 ms ``` In fact, we liked Hugo so much that our wizard Chris made his workflow public and we started the open-source project [Create-Static-Site](https://github.com/forestryio/create-static-site). It's [a simple way to spin up sites](https://forestry.io/blog/up-and-running-with-hugo/) and set up a modern web development workflow with one line of code. Essentially it adds build configurations as a dependency for JS, CSS and Image Processing. Lastly, we want to take the opportunity to give some love to other amazing tools we used building our website. ### What tools did we use? * Our Norwegian designer Nichlas is in love with [**Sketch**](https://www.sketchapp.com/). From what we hear it’s a designer’s dream come true. * Some say our main graphic is [mesmerizing](https://twitter.com/hmncllctv/status/968907474664284160). Nichlas created it using [**3DS Max**](https://www.autodesk.com/products/3ds-max/overview). * [**Hugo**](https://gohugo.io/) -- of course. * Chris can’t think of modern web development without [**Gulp**](https://gulpjs.com/) & [**Webpack**](https://webpack.js.org/). We used them to add additional build steps such as Browsersync, CSS, JS and SVG optimization. * Speaking about adding steps to our build, our lives would be much harder without [**CircleCI**](https://circleci.com/) for continuous deployment and automated testing purposes. * We can’t stop raving about [**Algolia**](https://www.algolia.com/). Chris loves it and even wrote a tutorial on [how to implement Algolia](https://forestry.io/blog/search-with-algolia-in-hugo/) into static sites using Hugo’s [Custom Outputs](https://gohugo.io/templates/output-formats/). * [**Cloudinary**](https://cloudinary.com/) is probably one of the easiest ways to get responsive images into your website. * We might be a little biased on this one - We think [**Forestry.io**](https://forestry.io/) is a great way to add a content management system with a clean UI on top of your site without interrupting your experience as a developer. * For hosting purposes we use the almighty [**AWS**](https://aws.amazon.com/). * [**Formspree.io**](https://formspree.io/) is managing our support and enterprise requests. * We also use browser cookies and JS to customize our user’s experience and give it a more dynamic feel.
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/content/en/content-management/syntax-highlighting.md
--- title: Syntax Highlighting description: Hugo comes with really fast syntax highlighting from Chroma. date: 2017-02-01 publishdate: 2017-02-01 keywords: [highlighting,chroma,code blocks,syntax] categories: [content management] menu: docs: parent: "content-management" weight: 300 weight: 20 sections_weight: 20 draft: false aliases: [/extras/highlighting/,/extras/highlight/,/tools/syntax-highlighting/] toc: true --- Hugo uses [Chroma](https://github.com/alecthomas/chroma) as its code highlighter; it is built in Go and is really, really fast -- and for the most important parts compatible with Pygments we used before. ## Configure Syntax Highlighter See [Configure Highlight](/getting-started/configuration-markup#highlight). ## Generate Syntax Highlighter CSS If you run with `pygmentsUseClasses=true` in your site config, you need a style sheet. You can generate one with Hugo: ```bash hugo gen chromastyles --style=monokai > syntax.css ``` Run `hugo gen chromastyles -h` for more options. See https://xyproto.github.io/splash/docs/ for a gallery of available styles. ## Highlight Shortcode Highlighting is carried out via the [built-in shortcode](/content-management/shortcodes/) `highlight`. `highlight` takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode. Note that `highlight` is *not* used for client-side javascript highlighting. Options: * `linenos`: configure line numbers. Valid values are `true`, `false`, `table`, or `inline`. `false` will turn off line numbers if it's configured to be on in site config. {{< new-in "0.60.0" >}} `table` will give copy-and-paste friendly code blocks. * `hl_lines`: lists a set of line numbers or line number ranges to be highlighted. * `linenostart=199`: starts the line number count from 199. * `anchorlinenos`: Configure anchors on line numbers. Valid values are `true` or `false`; * `lineanchors`: Configure a prefix for the anchors on line numbers. Will be suffixed with `-`, so linking to the line number 1 with the option `lineanchors=prefix` adds the anchor `prefix-1` to the page. ### Example: Highlight Shortcode ``` {{</* highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" */>}} // ... code {{</* / highlight */>}} ``` Gives this: {{< highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" >}} // GetTitleFunc returns a func that can be used to transform a string to // title case. // // The supported styles are // // - "Go" (strings.Title) // - "AP" (see https://www.apstylebook.com/) // - "Chicago" (see https://www.chicagomanualofstyle.org/home.html) // // If an unknown or empty style is provided, AP style is what you get. func GetTitleFunc(style string) func(s string) string { switch strings.ToLower(style) { case "go": return strings.Title case "chicago": return transform.NewTitleConverter(transform.ChicagoStyle) default: return transform.NewTitleConverter(transform.APStyle) } } {{< / highlight >}} ## Highlight Template Func See [Highlight](/functions/highlight/). ## Highlighting in Code Fences Highlighting in code fences is enabled by default.{{< new-in "0.60.0" >}} ```` ```go {linenos=table,hl_lines=[8,"15-17"],linenostart=199} // ... code ``` ```` Gives this: ```go {linenos=table,hl_lines=[8,"15-17"],linenostart=199} // GetTitleFunc returns a func that can be used to transform a string to // title case. // // The supported styles are // // - "Go" (strings.Title) // - "AP" (see https://www.apstylebook.com/) // - "Chicago" (see https://www.chicagomanualofstyle.org/home.html) // // If an unknown or empty style is provided, AP style is what you get. func GetTitleFunc(style string) func(s string) string { switch strings.ToLower(style) { case "go": return strings.Title case "chicago": return transform.NewTitleConverter(transform.ChicagoStyle) default: return transform.NewTitleConverter(transform.APStyle) } } ``` {{< new-in "0.60.0" >}}Note that only Goldmark supports passing attributes such as `hl_lines`, and it's important that it does not contain any spaces. See [goldmark-highlighting](https://github.com/yuin/goldmark-highlighting) for more information. The options are the same as in the [highlighting shortcode](/content-management/syntax-highlighting/#highlight-shortcode),including `linenos=false`, but note the slightly different Markdown attribute syntax. ## List of Chroma Highlighting Languages The full list of Chroma lexers and their aliases (which is the identifier used in the `highlight` template func or when doing highlighting in code fences): {{< chroma-lexers >}} [Prism]: https://prismjs.com [prismdownload]: https://prismjs.com/download.html [Highlight.js]: https://highlightjs.org/ [Rainbow]: https://craig.is/making/rainbows [Syntax Highlighter]: https://alexgorbatchev.com/SyntaxHighlighter/ [Google Prettify]: https://github.com/google/code-prettify [Yandex]: https://yandex.ru/
--- title: Syntax Highlighting description: Hugo comes with really fast syntax highlighting from Chroma. date: 2017-02-01 publishdate: 2017-02-01 keywords: [highlighting,chroma,code blocks,syntax] categories: [content management] menu: docs: parent: "content-management" weight: 300 weight: 20 sections_weight: 20 draft: false aliases: [/extras/highlighting/,/extras/highlight/,/tools/syntax-highlighting/] toc: true --- Hugo uses [Chroma](https://github.com/alecthomas/chroma) as its code highlighter; it is built in Go and is really, really fast -- and for the most important parts compatible with Pygments we used before. ## Configure Syntax Highlighter See [Configure Highlight](/getting-started/configuration-markup#highlight). ## Generate Syntax Highlighter CSS If you run with `pygmentsUseClasses=true` in your site config, you need a style sheet. You can generate one with Hugo: ```bash hugo gen chromastyles --style=monokai > syntax.css ``` Run `hugo gen chromastyles -h` for more options. See https://xyproto.github.io/splash/docs/ for a gallery of available styles. ## Highlight Shortcode Highlighting is carried out via the [built-in shortcode](/content-management/shortcodes/) `highlight`. `highlight` takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode. Note that `highlight` is *not* used for client-side javascript highlighting. Options: * `linenos`: configure line numbers. Valid values are `true`, `false`, `table`, or `inline`. `false` will turn off line numbers if it's configured to be on in site config. {{< new-in "0.60.0" >}} `table` will give copy-and-paste friendly code blocks. * `hl_lines`: lists a set of line numbers or line number ranges to be highlighted. * `linenostart=199`: starts the line number count from 199. * `anchorlinenos`: Configure anchors on line numbers. Valid values are `true` or `false`; * `lineanchors`: Configure a prefix for the anchors on line numbers. Will be suffixed with `-`, so linking to the line number 1 with the option `lineanchors=prefix` adds the anchor `prefix-1` to the page. ### Example: Highlight Shortcode ``` {{</* highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" */>}} // ... code {{</* / highlight */>}} ``` Gives this: {{< highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" >}} // GetTitleFunc returns a func that can be used to transform a string to // title case. // // The supported styles are // // - "Go" (strings.Title) // - "AP" (see https://www.apstylebook.com/) // - "Chicago" (see https://www.chicagomanualofstyle.org/home.html) // // If an unknown or empty style is provided, AP style is what you get. func GetTitleFunc(style string) func(s string) string { switch strings.ToLower(style) { case "go": return strings.Title case "chicago": return transform.NewTitleConverter(transform.ChicagoStyle) default: return transform.NewTitleConverter(transform.APStyle) } } {{< / highlight >}} ## Highlight Template Func See [Highlight](/functions/highlight/). ## Highlighting in Code Fences Highlighting in code fences is enabled by default.{{< new-in "0.60.0" >}} ```` ```go {linenos=table,hl_lines=[8,"15-17"],linenostart=199} // ... code ``` ```` Gives this: ```go {linenos=table,hl_lines=[8,"15-17"],linenostart=199} // GetTitleFunc returns a func that can be used to transform a string to // title case. // // The supported styles are // // - "Go" (strings.Title) // - "AP" (see https://www.apstylebook.com/) // - "Chicago" (see https://www.chicagomanualofstyle.org/home.html) // // If an unknown or empty style is provided, AP style is what you get. func GetTitleFunc(style string) func(s string) string { switch strings.ToLower(style) { case "go": return strings.Title case "chicago": return transform.NewTitleConverter(transform.ChicagoStyle) default: return transform.NewTitleConverter(transform.APStyle) } } ``` {{< new-in "0.60.0" >}}Note that only Goldmark supports passing attributes such as `hl_lines`, and it's important that it does not contain any spaces. See [goldmark-highlighting](https://github.com/yuin/goldmark-highlighting) for more information. The options are the same as in the [highlighting shortcode](/content-management/syntax-highlighting/#highlight-shortcode),including `linenos=false`, but note the slightly different Markdown attribute syntax. ## List of Chroma Highlighting Languages The full list of Chroma lexers and their aliases (which is the identifier used in the `highlight` template func or when doing highlighting in code fences): {{< chroma-lexers >}} [Prism]: https://prismjs.com [prismdownload]: https://prismjs.com/download.html [Highlight.js]: https://highlightjs.org/ [Rainbow]: https://craig.is/making/rainbows [Syntax Highlighter]: https://alexgorbatchev.com/SyntaxHighlighter/ [Google Prettify]: https://github.com/google/code-prettify [Yandex]: https://yandex.ru/
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./tpl/compare/compare.go
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package compare provides template functions for comparing values. package compare import ( "fmt" "reflect" "strconv" "time" "github.com/gohugoio/hugo/compare" "github.com/gohugoio/hugo/common/types" ) // New returns a new instance of the compare-namespaced template functions. func New(caseInsensitive bool) *Namespace { return &Namespace{caseInsensitive: caseInsensitive} } // Namespace provides template functions for the "compare" namespace. type Namespace struct { // Enable to do case insensitive string compares. caseInsensitive bool } // Default checks whether a given value is set and returns a default value if it // is not. "Set" in this context means non-zero for numeric types and times; // non-zero length for strings, arrays, slices, and maps; // any boolean or struct value; or non-nil for any other types. func (*Namespace) Default(dflt interface{}, given ...interface{}) (interface{}, error) { // given is variadic because the following construct will not pass a piped // argument when the key is missing: {{ index . "key" | default "foo" }} // The Go template will complain that we got 1 argument when we expected 2. if len(given) == 0 { return dflt, nil } if len(given) != 1 { return nil, fmt.Errorf("wrong number of args for default: want 2 got %d", len(given)+1) } g := reflect.ValueOf(given[0]) if !g.IsValid() { return dflt, nil } set := false switch g.Kind() { case reflect.Bool: set = true case reflect.String, reflect.Array, reflect.Slice, reflect.Map: set = g.Len() != 0 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: set = g.Int() != 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: set = g.Uint() != 0 case reflect.Float32, reflect.Float64: set = g.Float() != 0 case reflect.Complex64, reflect.Complex128: set = g.Complex() != 0 case reflect.Struct: switch actual := given[0].(type) { case time.Time: set = !actual.IsZero() default: set = true } default: set = !g.IsNil() } if set { return given[0], nil } return dflt, nil } // Eq returns the boolean truth of arg1 == arg2 || arg1 == arg3 || arg1 == arg4. func (n *Namespace) Eq(first interface{}, others ...interface{}) bool { if n.caseInsensitive { panic("caseInsensitive not implemented for Eq") } if len(others) == 0 { panic("missing arguments for comparison") } normalize := func(v interface{}) interface{} { if types.IsNil(v) { return nil } vv := reflect.ValueOf(v) switch vv.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return vv.Int() case reflect.Float32, reflect.Float64: return vv.Float() case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return vv.Uint() case reflect.String: return vv.String() default: return v } } normFirst := normalize(first) for _, other := range others { if e, ok := first.(compare.Eqer); ok { if e.Eq(other) { return true } continue } if e, ok := other.(compare.Eqer); ok { if e.Eq(first) { return true } continue } other = normalize(other) if reflect.DeepEqual(normFirst, other) { return true } } return false } // Ne returns the boolean truth of arg1 != arg2 && arg1 != arg3 && arg1 != arg4. func (n *Namespace) Ne(first interface{}, others ...interface{}) bool { for _, other := range others { if n.Eq(first, other) { return false } } return true } // Ge returns the boolean truth of arg1 >= arg2 && arg1 >= arg3 && arg1 >= arg4. func (n *Namespace) Ge(first interface{}, others ...interface{}) bool { for _, other := range others { left, right := n.compareGet(first, other) if !(left >= right) { return false } } return true } // Gt returns the boolean truth of arg1 > arg2 && arg1 > arg3 && arg1 > arg4. func (n *Namespace) Gt(first interface{}, others ...interface{}) bool { for _, other := range others { left, right := n.compareGet(first, other) if !(left > right) { return false } } return true } // Le returns the boolean truth of arg1 <= arg2 && arg1 <= arg3 && arg1 <= arg4. func (n *Namespace) Le(first interface{}, others ...interface{}) bool { for _, other := range others { left, right := n.compareGet(first, other) if !(left <= right) { return false } } return true } // Lt returns the boolean truth of arg1 < arg2 && arg1 < arg3 && arg1 < arg4. func (n *Namespace) Lt(first interface{}, others ...interface{}) bool { for _, other := range others { left, right := n.compareGet(first, other) if !(left < right) { return false } } return true } // Conditional can be used as a ternary operator. // It returns a if condition, else b. func (n *Namespace) Conditional(condition bool, a, b interface{}) interface{} { if condition { return a } return b } func (ns *Namespace) compareGet(a interface{}, b interface{}) (float64, float64) { if ac, ok := a.(compare.Comparer); ok { c := ac.Compare(b) if c < 0 { return 1, 0 } else if c == 0 { return 0, 0 } else { return 0, 1 } } if bc, ok := b.(compare.Comparer); ok { c := bc.Compare(a) if c < 0 { return 0, 1 } else if c == 0 { return 0, 0 } else { return 1, 0 } } var left, right float64 var leftStr, rightStr *string av := reflect.ValueOf(a) switch av.Kind() { case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: left = float64(av.Len()) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: left = float64(av.Int()) case reflect.Float32, reflect.Float64: left = av.Float() case reflect.String: var err error left, err = strconv.ParseFloat(av.String(), 64) if err != nil { str := av.String() leftStr = &str } case reflect.Struct: switch av.Type() { case timeType: left = float64(toTimeUnix(av)) } case reflect.Bool: left = 0 if av.Bool() { left = 1 } } bv := reflect.ValueOf(b) switch bv.Kind() { case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: right = float64(bv.Len()) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: right = float64(bv.Int()) case reflect.Float32, reflect.Float64: right = bv.Float() case reflect.String: var err error right, err = strconv.ParseFloat(bv.String(), 64) if err != nil { str := bv.String() rightStr = &str } case reflect.Struct: switch bv.Type() { case timeType: right = float64(toTimeUnix(bv)) } case reflect.Bool: right = 0 if bv.Bool() { right = 1 } } if ns.caseInsensitive && leftStr != nil && rightStr != nil { c := compare.Strings(*leftStr, *rightStr) if c < 0 { return 0, 1 } else if c > 0 { return 1, 0 } else { return 0, 0 } } switch { case leftStr == nil || rightStr == nil: case *leftStr < *rightStr: return 0, 1 case *leftStr > *rightStr: return 1, 0 default: return 0, 0 } return left, right } var timeType = reflect.TypeOf((*time.Time)(nil)).Elem() func toTimeUnix(v reflect.Value) int64 { if v.Kind() == reflect.Interface { return toTimeUnix(v.Elem()) } if v.Type() != timeType { panic("coding error: argument must be time.Time type reflect Value") } return v.MethodByName("Unix").Call([]reflect.Value{})[0].Int() }
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package compare provides template functions for comparing values. package compare import ( "fmt" "reflect" "strconv" "time" "github.com/gohugoio/hugo/compare" "github.com/gohugoio/hugo/common/types" ) // New returns a new instance of the compare-namespaced template functions. func New(caseInsensitive bool) *Namespace { return &Namespace{caseInsensitive: caseInsensitive} } // Namespace provides template functions for the "compare" namespace. type Namespace struct { // Enable to do case insensitive string compares. caseInsensitive bool } // Default checks whether a given value is set and returns a default value if it // is not. "Set" in this context means non-zero for numeric types and times; // non-zero length for strings, arrays, slices, and maps; // any boolean or struct value; or non-nil for any other types. func (*Namespace) Default(dflt interface{}, given ...interface{}) (interface{}, error) { // given is variadic because the following construct will not pass a piped // argument when the key is missing: {{ index . "key" | default "foo" }} // The Go template will complain that we got 1 argument when we expected 2. if len(given) == 0 { return dflt, nil } if len(given) != 1 { return nil, fmt.Errorf("wrong number of args for default: want 2 got %d", len(given)+1) } g := reflect.ValueOf(given[0]) if !g.IsValid() { return dflt, nil } set := false switch g.Kind() { case reflect.Bool: set = true case reflect.String, reflect.Array, reflect.Slice, reflect.Map: set = g.Len() != 0 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: set = g.Int() != 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: set = g.Uint() != 0 case reflect.Float32, reflect.Float64: set = g.Float() != 0 case reflect.Complex64, reflect.Complex128: set = g.Complex() != 0 case reflect.Struct: switch actual := given[0].(type) { case time.Time: set = !actual.IsZero() default: set = true } default: set = !g.IsNil() } if set { return given[0], nil } return dflt, nil } // Eq returns the boolean truth of arg1 == arg2 || arg1 == arg3 || arg1 == arg4. func (n *Namespace) Eq(first interface{}, others ...interface{}) bool { if n.caseInsensitive { panic("caseInsensitive not implemented for Eq") } if len(others) == 0 { panic("missing arguments for comparison") } normalize := func(v interface{}) interface{} { if types.IsNil(v) { return nil } vv := reflect.ValueOf(v) switch vv.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return vv.Int() case reflect.Float32, reflect.Float64: return vv.Float() case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return vv.Uint() case reflect.String: return vv.String() default: return v } } normFirst := normalize(first) for _, other := range others { if e, ok := first.(compare.Eqer); ok { if e.Eq(other) { return true } continue } if e, ok := other.(compare.Eqer); ok { if e.Eq(first) { return true } continue } other = normalize(other) if reflect.DeepEqual(normFirst, other) { return true } } return false } // Ne returns the boolean truth of arg1 != arg2 && arg1 != arg3 && arg1 != arg4. func (n *Namespace) Ne(first interface{}, others ...interface{}) bool { for _, other := range others { if n.Eq(first, other) { return false } } return true } // Ge returns the boolean truth of arg1 >= arg2 && arg1 >= arg3 && arg1 >= arg4. func (n *Namespace) Ge(first interface{}, others ...interface{}) bool { for _, other := range others { left, right := n.compareGet(first, other) if !(left >= right) { return false } } return true } // Gt returns the boolean truth of arg1 > arg2 && arg1 > arg3 && arg1 > arg4. func (n *Namespace) Gt(first interface{}, others ...interface{}) bool { for _, other := range others { left, right := n.compareGet(first, other) if !(left > right) { return false } } return true } // Le returns the boolean truth of arg1 <= arg2 && arg1 <= arg3 && arg1 <= arg4. func (n *Namespace) Le(first interface{}, others ...interface{}) bool { for _, other := range others { left, right := n.compareGet(first, other) if !(left <= right) { return false } } return true } // Lt returns the boolean truth of arg1 < arg2 && arg1 < arg3 && arg1 < arg4. func (n *Namespace) Lt(first interface{}, others ...interface{}) bool { for _, other := range others { left, right := n.compareGet(first, other) if !(left < right) { return false } } return true } // Conditional can be used as a ternary operator. // It returns a if condition, else b. func (n *Namespace) Conditional(condition bool, a, b interface{}) interface{} { if condition { return a } return b } func (ns *Namespace) compareGet(a interface{}, b interface{}) (float64, float64) { if ac, ok := a.(compare.Comparer); ok { c := ac.Compare(b) if c < 0 { return 1, 0 } else if c == 0 { return 0, 0 } else { return 0, 1 } } if bc, ok := b.(compare.Comparer); ok { c := bc.Compare(a) if c < 0 { return 0, 1 } else if c == 0 { return 0, 0 } else { return 1, 0 } } var left, right float64 var leftStr, rightStr *string av := reflect.ValueOf(a) switch av.Kind() { case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: left = float64(av.Len()) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: left = float64(av.Int()) case reflect.Float32, reflect.Float64: left = av.Float() case reflect.String: var err error left, err = strconv.ParseFloat(av.String(), 64) if err != nil { str := av.String() leftStr = &str } case reflect.Struct: switch av.Type() { case timeType: left = float64(toTimeUnix(av)) } case reflect.Bool: left = 0 if av.Bool() { left = 1 } } bv := reflect.ValueOf(b) switch bv.Kind() { case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: right = float64(bv.Len()) case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: right = float64(bv.Int()) case reflect.Float32, reflect.Float64: right = bv.Float() case reflect.String: var err error right, err = strconv.ParseFloat(bv.String(), 64) if err != nil { str := bv.String() rightStr = &str } case reflect.Struct: switch bv.Type() { case timeType: right = float64(toTimeUnix(bv)) } case reflect.Bool: right = 0 if bv.Bool() { right = 1 } } if ns.caseInsensitive && leftStr != nil && rightStr != nil { c := compare.Strings(*leftStr, *rightStr) if c < 0 { return 0, 1 } else if c > 0 { return 1, 0 } else { return 0, 0 } } switch { case leftStr == nil || rightStr == nil: case *leftStr < *rightStr: return 0, 1 case *leftStr > *rightStr: return 1, 0 default: return 0, 0 } return left, right } var timeType = reflect.TypeOf((*time.Time)(nil)).Elem() func toTimeUnix(v reflect.Value) int64 { if v.Kind() == reflect.Interface { return toTimeUnix(v.Elem()) } if v.Type() != timeType { panic("coding error: argument must be time.Time type reflect Value") } return v.MethodByName("Unix").Call([]reflect.Value{})[0].Int() }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/_vendor/github.com/gohugoio/gohugoioTheme/static/fonts/muli-latin-300italic.woff
wOFFTGDEF,.cGPOSVG\?GSUB tܙ_OS/2 ,P`icmap |Tecvt N:fpgm` vdzgasptglyf|7 bLݼheadK66 5hheaK"$ehmtxK#locaM=VmaxpO ^ nameP$BpostP*LprepSx96NoxA ~S !B@+񋪉n(%#@xڅeH?QRx43̌~c\ffeFywy/^(l1-+3KI'Jҗog|M _ >/2Hii:%O{siBoSmz !bo\R$B%Sh!!.N|kRȪ8YKIEu!V5qf %u%]_rW{JK|J"OE+%8gbɶfy q]l~e]VdG7<Mh2]+/{i !ַ) MZ:qx鑎҄p[$18'~>^B]a/mSFZWXڤti1|ѽ?Є֍2C26$NиDoXY)w c7kXYbgSkkyE/;-,eak1f[ϨazWV;E?f=9^ `_.а$%j1hόCd ^2ծec^UW!B<:v. zXƍQ]^BDk=A+m϶=w!n'qTt5s>>XQDϝq)ػSv&Ωʆ$&T{ 88^Efo9gL=d$*`JJ_@3 qp ƒ4gyOS]@@3oX]*ݯq;H*rOAjOWK_p`"tvRWW2& U[A{`+<]V٬jV~О\:P{8WWkg:{R2L _aqY$yz7ό ς&Gc)y8/#ᩬƃlBh H2"c9' mBW? /<ADAPdS?!ٌx0syxs\hҾkf_3RiRp>) ״mc{]x!/^!ͫx,xp o G4p 0˗9׵-ww<~HSU;`?/N`ĉ#Nf8Sxg %gs \ Hs1I H\%ˆkU[qPZX.MBA>&L/f+٥WC+v4cr(EJfUɸjbʹ8$Lilޢ&Wxd6Y[܏gۤѷøi}ksdA3BcDˌ@'ZXY0ܯSVsOJB2}frx4Fvs}+J/L>PvDL>rXPX<Yg"f= 8v^`)Hyüq7cfoXe1f 3Fӌ2c]3 ]FǼ孼yེ~?`L2g&I0o>O'9_*Y4*CJϬ22t0on\s+Oε|n |2$޳DXQ?8Kbj?qʬ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ߺw#f6*
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/static/images/hosting-and-deployment/deployment-with-wercker/configure-the-deploy-step.png
PNG  IHDRX pHYs  ~ IDATxgpYy\]OeUl4ss9G3BAD Q9}-iĐ&]uvXzu}w_͜9Yr-XeYeY7,SVYYYM$I$Iz(T?~|D$I$SV}YjI$IL[ $I$IX$I$IO`ݺuKeYeY͛v ˓eYeY><`aI$I$X$I$I,I$I$$I$IK$I$I`I$I$ $I$IX$I$I,$I$IK$I$I%I$I$`I$I$ $I$IX$I$I,$InTص'[Q^}j jjX$It7 Mg{B[[Y^g,7^ҍsX$It7=;c5Sߚ;f_>`I$IL|#$I$ X,I$I` X?`Xyyۍ9*73\777ϖ,_eUUU l݆-܊KJKKˬB$IK%m֭[l֫ݏ֦CWkhduOdursFEk;hc'GAV]]N_Z:k߹?p7i\̺d{,:N;$Iz\y.jJX` > fׯpQ(|F5|8y!YOkLǎ6^l%;vG0JJJ쳯Z۹GZnvN_wҕrz$=\}uڔ`o;>?e+xGVrr3XIq]" ֫`ԪuqsVvX ٗٛn۶5z7^ -kPG2|-Zm¾;zD)¯}>[;rDdb?h={'`]zիk7[}a|ҎWu8}u[[xKQ5cמ4@*PIy55-#v,Ԗˇxf `(0? "ںTKߦ$IzeG9b-OQ4 9 >\#ÍлuYp8UFWZI+۷*2-oZ~כ^[ ~ibTu0U{C.((WVYo".\d/ -5-ݢ!ne+V[箽9r$ۼ5N?ȼ`1yͮ^KVD---[Kd`g`[| 㸉ӬȶlFf[7vI۴e7,Y7o-E.z)[a5TJnFVmw w0Y l 5sн}ۡM< [\}:ve7]n^E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zry'}3`>Oo<~\!XC * `@?,!@,  B,@,  B, zAn=vJA,Hk}}}nA`\B,H4cuwWlշn>6$6 y҉2`@`!X`!X`!X`!X X X X``` X X X XVljnn***!B#B!JOK+\T!BF$Xuuu/X` XE{~zUEE5B!ȥTr+SA^[B!ҥRխ Ak B!mu?R:?@IENDB`
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./resources/resource_transformers/tocss/dartsass/transform.go
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package dartsass import ( "fmt" "io" "net/url" "path" "path/filepath" "strings" "github.com/cli/safeexec" "github.com/gohugoio/hugo/common/herrors" "github.com/gohugoio/hugo/htesting" "github.com/gohugoio/hugo/media" "github.com/gohugoio/hugo/resources" "github.com/gohugoio/hugo/resources/internal" "github.com/spf13/afero" "github.com/gohugoio/hugo/hugofs" "github.com/bep/godartsass" ) // See https://github.com/sass/dart-sass-embedded/issues/24 const stdinPlaceholder = "HUGOSTDIN" // Supports returns whether dart-sass-embedded is found in $PATH. func Supports() bool { if htesting.SupportsAll() { return true } p, err := safeexec.LookPath("dart-sass-embedded") return err == nil && p != "" } type transform struct { optsm map[string]interface{} c *Client } func (t *transform) Key() internal.ResourceTransformationKey { return internal.NewResourceTransformationKey(transformationName, t.optsm) } func (t *transform) Transform(ctx *resources.ResourceTransformationCtx) error { ctx.OutMediaType = media.CSSType opts, err := decodeOptions(t.optsm) if err != nil { return err } if opts.TargetPath != "" { ctx.OutPath = opts.TargetPath } else { ctx.ReplaceOutPathExtension(".css") } baseDir := path.Dir(ctx.SourcePath) args := godartsass.Args{ URL: stdinPlaceholder, IncludePaths: t.c.sfs.RealDirs(baseDir), ImportResolver: importResolver{ baseDir: baseDir, c: t.c, }, OutputStyle: godartsass.ParseOutputStyle(opts.OutputStyle), EnableSourceMap: opts.EnableSourceMap, } // Append any workDir relative include paths for _, ip := range opts.IncludePaths { info, err := t.c.workFs.Stat(filepath.Clean(ip)) if err == nil { filename := info.(hugofs.FileMetaInfo).Meta().Filename() args.IncludePaths = append(args.IncludePaths, filename) } } if ctx.InMediaType.SubType == media.SASSType.SubType { args.SourceSyntax = godartsass.SourceSyntaxSASS } res, err := t.c.toCSS(args, ctx.From) if err != nil { if sassErr, ok := err.(godartsass.SassError); ok { start := sassErr.Span.Start context := strings.TrimSpace(sassErr.Span.Context) filename, _ := urlToFilename(sassErr.Span.Url) if filename == stdinPlaceholder { if ctx.SourcePath == "" { return sassErr } filename = t.c.sfs.RealFilename(ctx.SourcePath) } offsetMatcher := func(m herrors.LineMatcher) bool { return m.Offset+len(m.Line) >= start.Offset && strings.Contains(m.Line, context) } ferr, ok := herrors.WithFileContextForFile( herrors.NewFileError("scss", -1, -1, start.Column, sassErr), filename, filename, hugofs.Os, offsetMatcher) if !ok { return sassErr } return ferr } return err } out := res.CSS _, err = io.WriteString(ctx.To, out) if err != nil { return err } if opts.EnableSourceMap && res.SourceMap != "" { if err := ctx.PublishSourceMap(res.SourceMap); err != nil { return err } _, err = fmt.Fprintf(ctx.To, "\n\n/*# sourceMappingURL=%s */", path.Base(ctx.OutPath)+".map") } return err } type importResolver struct { baseDir string c *Client } func (t importResolver) CanonicalizeURL(url string) (string, error) { filePath, isURL := urlToFilename(url) var prevDir string var pathDir string if isURL { var found bool prevDir, found = t.c.sfs.MakePathRelative(filepath.Dir(filePath)) if !found { // Not a member of this filesystem, let Dart Sass handle it. return "", nil } } else { prevDir = t.baseDir pathDir = path.Dir(url) } basePath := filepath.Join(prevDir, pathDir) name := filepath.Base(filePath) // Pick the first match. var namePatterns []string if strings.Contains(name, ".") { namePatterns = []string{"_%s", "%s"} } else if strings.HasPrefix(name, "_") { namePatterns = []string{"_%s.scss", "_%s.sass"} } else { namePatterns = []string{"_%s.scss", "%s.scss", "_%s.sass", "%s.sass"} } name = strings.TrimPrefix(name, "_") for _, namePattern := range namePatterns { filenameToCheck := filepath.Join(basePath, fmt.Sprintf(namePattern, name)) fi, err := t.c.sfs.Fs.Stat(filenameToCheck) if err == nil { if fim, ok := fi.(hugofs.FileMetaInfo); ok { return "file://" + filepath.ToSlash(fim.Meta().Filename()), nil } } } // Not found, let Dart Dass handle it return "", nil } func (t importResolver) Load(url string) (string, error) { filename, _ := urlToFilename(url) b, err := afero.ReadFile(hugofs.Os, filename) return string(b), err } // TODO(bep) add tests func urlToFilename(urls string) (string, bool) { u, err := url.ParseRequestURI(urls) if err != nil { return filepath.FromSlash(urls), false } p := filepath.FromSlash(u.Path) if u.Host != "" { // C:\data\file.txt p = strings.ToUpper(u.Host) + ":" + p } return p, true }
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package dartsass import ( "fmt" "io" "net/url" "path" "path/filepath" "strings" "github.com/cli/safeexec" "github.com/gohugoio/hugo/common/herrors" "github.com/gohugoio/hugo/htesting" "github.com/gohugoio/hugo/media" "github.com/gohugoio/hugo/resources" "github.com/gohugoio/hugo/resources/internal" "github.com/spf13/afero" "github.com/gohugoio/hugo/hugofs" "github.com/bep/godartsass" ) // See https://github.com/sass/dart-sass-embedded/issues/24 const stdinPlaceholder = "HUGOSTDIN" // Supports returns whether dart-sass-embedded is found in $PATH. func Supports() bool { if htesting.SupportsAll() { return true } p, err := safeexec.LookPath("dart-sass-embedded") return err == nil && p != "" } type transform struct { optsm map[string]interface{} c *Client } func (t *transform) Key() internal.ResourceTransformationKey { return internal.NewResourceTransformationKey(transformationName, t.optsm) } func (t *transform) Transform(ctx *resources.ResourceTransformationCtx) error { ctx.OutMediaType = media.CSSType opts, err := decodeOptions(t.optsm) if err != nil { return err } if opts.TargetPath != "" { ctx.OutPath = opts.TargetPath } else { ctx.ReplaceOutPathExtension(".css") } baseDir := path.Dir(ctx.SourcePath) args := godartsass.Args{ URL: stdinPlaceholder, IncludePaths: t.c.sfs.RealDirs(baseDir), ImportResolver: importResolver{ baseDir: baseDir, c: t.c, }, OutputStyle: godartsass.ParseOutputStyle(opts.OutputStyle), EnableSourceMap: opts.EnableSourceMap, } // Append any workDir relative include paths for _, ip := range opts.IncludePaths { info, err := t.c.workFs.Stat(filepath.Clean(ip)) if err == nil { filename := info.(hugofs.FileMetaInfo).Meta().Filename() args.IncludePaths = append(args.IncludePaths, filename) } } if ctx.InMediaType.SubType == media.SASSType.SubType { args.SourceSyntax = godartsass.SourceSyntaxSASS } res, err := t.c.toCSS(args, ctx.From) if err != nil { if sassErr, ok := err.(godartsass.SassError); ok { start := sassErr.Span.Start context := strings.TrimSpace(sassErr.Span.Context) filename, _ := urlToFilename(sassErr.Span.Url) if filename == stdinPlaceholder { if ctx.SourcePath == "" { return sassErr } filename = t.c.sfs.RealFilename(ctx.SourcePath) } offsetMatcher := func(m herrors.LineMatcher) bool { return m.Offset+len(m.Line) >= start.Offset && strings.Contains(m.Line, context) } ferr, ok := herrors.WithFileContextForFile( herrors.NewFileError("scss", -1, -1, start.Column, sassErr), filename, filename, hugofs.Os, offsetMatcher) if !ok { return sassErr } return ferr } return err } out := res.CSS _, err = io.WriteString(ctx.To, out) if err != nil { return err } if opts.EnableSourceMap && res.SourceMap != "" { if err := ctx.PublishSourceMap(res.SourceMap); err != nil { return err } _, err = fmt.Fprintf(ctx.To, "\n\n/*# sourceMappingURL=%s */", path.Base(ctx.OutPath)+".map") } return err } type importResolver struct { baseDir string c *Client } func (t importResolver) CanonicalizeURL(url string) (string, error) { filePath, isURL := urlToFilename(url) var prevDir string var pathDir string if isURL { var found bool prevDir, found = t.c.sfs.MakePathRelative(filepath.Dir(filePath)) if !found { // Not a member of this filesystem, let Dart Sass handle it. return "", nil } } else { prevDir = t.baseDir pathDir = path.Dir(url) } basePath := filepath.Join(prevDir, pathDir) name := filepath.Base(filePath) // Pick the first match. var namePatterns []string if strings.Contains(name, ".") { namePatterns = []string{"_%s", "%s"} } else if strings.HasPrefix(name, "_") { namePatterns = []string{"_%s.scss", "_%s.sass"} } else { namePatterns = []string{"_%s.scss", "%s.scss", "_%s.sass", "%s.sass"} } name = strings.TrimPrefix(name, "_") for _, namePattern := range namePatterns { filenameToCheck := filepath.Join(basePath, fmt.Sprintf(namePattern, name)) fi, err := t.c.sfs.Fs.Stat(filenameToCheck) if err == nil { if fim, ok := fi.(hugofs.FileMetaInfo); ok { return "file://" + filepath.ToSlash(fim.Meta().Filename()), nil } } } // Not found, let Dart Dass handle it return "", nil } func (t importResolver) Load(url string) (string, error) { filename, _ := urlToFilename(url) b, err := afero.ReadFile(hugofs.Os, filename) return string(b), err } // TODO(bep) add tests func urlToFilename(urls string) (string, bool) { u, err := url.ParseRequestURI(urls) if err != nil { return filepath.FromSlash(urls), false } p := filepath.FromSlash(u.Path) if u.Host != "" { // C:\data\file.txt p = strings.ToUpper(u.Host) + ":" + p } return p, true }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./commands/server_errors.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package commands import ( "bytes" "io" "net/url" "github.com/gohugoio/hugo/transform" "github.com/gohugoio/hugo/transform/livereloadinject" ) var buildErrorTemplate = `<!doctype html> <html class="no-js" lang=""> <head> <meta charset="utf-8"> <title>Hugo Server: Error</title> <style type="text/css"> body { font-family: "Muli",avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 16px; background-color: #2f1e2e; } main { margin: auto; width: 95%; padding: 1rem; } .version { color: #ccc; padding: 1rem 0; } .stack { margin-top: 4rem; } pre { white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word; } .highlight { overflow-x: auto; margin-bottom: 1rem; } a { color: #0594cb; text-decoration: none; } a:hover { color: #ccc; } </style> </head> <body> <main> {{ highlight .Error "apl" "linenos=false,noclasses=true,style=paraiso-dark" }} {{ with .File }} {{ $params := printf "noclasses=true,style=paraiso-dark,linenos=table,hl_lines=%d,linenostart=%d" (add .LinesPos 1) (sub .Position.LineNumber .LinesPos) }} {{ $lexer := .ChromaLexer | default "go-html-template" }} {{ highlight (delimit .Lines "\n") $lexer $params }} {{ end }} {{ with .StackTrace }} {{ highlight . "apl" "noclasses=true,style=paraiso-dark" }} {{ end }} <p class="version">{{ .Version }}</p> <a href="">Reload Page</a> </main> </body> </html> ` func injectLiveReloadScript(src io.Reader, baseURL url.URL) string { var b bytes.Buffer chain := transform.Chain{livereloadinject.New(baseURL)} chain.Apply(&b, src) return b.String() }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package commands import ( "bytes" "io" "net/url" "github.com/gohugoio/hugo/transform" "github.com/gohugoio/hugo/transform/livereloadinject" ) var buildErrorTemplate = `<!doctype html> <html class="no-js" lang=""> <head> <meta charset="utf-8"> <title>Hugo Server: Error</title> <style type="text/css"> body { font-family: "Muli",avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 16px; background-color: #2f1e2e; } main { margin: auto; width: 95%; padding: 1rem; } .version { color: #ccc; padding: 1rem 0; } .stack { margin-top: 4rem; } pre { white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word; } .highlight { overflow-x: auto; margin-bottom: 1rem; } a { color: #0594cb; text-decoration: none; } a:hover { color: #ccc; } </style> </head> <body> <main> {{ highlight .Error "apl" "linenos=false,noclasses=true,style=paraiso-dark" }} {{ with .File }} {{ $params := printf "noclasses=true,style=paraiso-dark,linenos=table,hl_lines=%d,linenostart=%d" (add .LinesPos 1) (sub .Position.LineNumber .LinesPos) }} {{ $lexer := .ChromaLexer | default "go-html-template" }} {{ highlight (delimit .Lines "\n") $lexer $params }} {{ end }} {{ with .StackTrace }} {{ highlight . "apl" "noclasses=true,style=paraiso-dark" }} {{ end }} <p class="version">{{ .Version }}</p> <a href="">Reload Page</a> </main> </body> </html> ` func injectLiveReloadScript(src io.Reader, baseURL url.URL) string { var b bytes.Buffer chain := transform.Chain{livereloadinject.New(baseURL)} chain.Apply(&b, src) return b.String() }
-1
gohugoio/hugo
8,167
js: Add Shims option
https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
bep
"2021-01-21T18:42:27Z"
"2021-01-22T08:03:25Z"
a1fe552fc9e622a15010a94281f604eb85bebd84
e19a046c4be9b0654884259b9df94f41561e4fc3
js: Add Shims option. https://github.com/gohugoio/hugoTestProjectJSModImports has a running example with shimming when in production. Fixes #8165
./docs/resources/_gen/images/news/0.68.0-relnotes/hugo-68-featured_hubf411be7de0d7016f242fc7f0c46d71c_65337_480x0_resize_catmullrom_2.png
PNG  IHDRGPLTE67CGF:EHB(?MFJ<f <6S[)^ Gc Oj m p {LQAMGIJVXLJHLIIJ` H~r 5xtJvKw|pNIO4 |MMCKzxLmuj3sL0.:/p<*9 w 1;@Y+S.vh df ` WSp ~` f LT[ |\ }J7'}h \ 6/wxU +m"zQ o q~p Kw\7e&O5lbE\m7;sV RS"Yvڃ)Ag`2KImz{*)Ujoq![8_MwY?VwuGy"R8εa#bLD.l@kϱڞcoh"q j3{NA8wKMƢ+xo__kOJbIDATx XU#6޴P`1L< X zG<9 ΙD))36&[_^;j[^{{v_ U),TK<Lԣ?+&Nfح]/h"Jڔ0YP6ڣoMar&# N3&a8v aa G|?H`ka$%$akAׇ,4]=;O(ܐ aX,jb'.^mK?8zi%s[zb%dwl ,SC$0$0ZvpTBPaIOΎx<I`'Z?JX>s&<OJ Bba752 &pqZ'Kn%( 8Kl}cbjXG(%tL舭1&!,&cDŽa# [a 1 c:td5`,OASLǘ8a8!w qoXLX Kń)Fcb:ڄ0А' e XgC`O {NHp*v2`0íC;bA#c:hChN FO1aмV9¨G=dY|V n%F0\aL܍$B `VLz)6t5ڊhIN#ȋ:h: Žd?_9ʟS!tqa(+0X?AWUfGDwP?F?>F1X qZ$ Ħ?QEbh:hciBL!t}Q`QhvBN)7;_un^\4:+F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77"@g1f|"szxL>4{Frv|%C%s;v{B!B!B!B!B!B!B!B!B!B!B!B֜OIENDB`
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./go.mod
module github.com/gohugoio/hugo require ( github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 github.com/BurntSushi/toml v0.3.1 github.com/PuerkitoBio/purell v1.1.1 github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/alecthomas/chroma v0.8.2 github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 // indirect github.com/armon/go-radix v1.0.0 github.com/aws/aws-sdk-go v1.35.0 github.com/bep/debounce v1.2.0 github.com/bep/gitmap v1.1.2 github.com/bep/godartsass v0.11.0 github.com/bep/golibsass v0.7.0 github.com/bep/tmc v0.5.1 github.com/cli/safeexec v1.0.0 github.com/disintegration/gift v1.2.1 github.com/dlclark/regexp2 v1.4.0 // indirect github.com/dustin/go-humanize v1.0.0 github.com/evanw/esbuild v0.8.17 github.com/fortytw2/leaktest v1.3.0 github.com/frankban/quicktest v1.11.2 github.com/fsnotify/fsnotify v1.4.9 github.com/getkin/kin-openapi v0.32.0 github.com/ghodss/yaml v1.0.0 github.com/gobwas/glob v0.2.3 github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95 github.com/google/go-cmp v0.5.3 github.com/gorilla/websocket v1.4.2 github.com/jdkato/prose v1.2.0 github.com/kylelemons/godebug v1.1.0 github.com/kyokomi/emoji/v2 v2.2.7 github.com/magefile/mage v1.10.0 github.com/markbates/inflect v1.0.4 github.com/mattn/go-isatty v0.0.12 github.com/miekg/mmark v1.3.6 github.com/mitchellh/hashstructure v1.0.0 github.com/mitchellh/mapstructure v1.3.3 github.com/muesli/smartcrop v0.3.0 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect github.com/nicksnyder/go-i18n/v2 v2.1.1 github.com/niklasfasching/go-org v1.4.0 github.com/olekukonko/tablewriter v0.0.4 github.com/pelletier/go-toml v1.8.1 github.com/pkg/errors v0.9.1 github.com/rogpeppe/go-internal v1.6.2 github.com/russross/blackfriday v1.5.3-0.20200218234912-41c5fccfd6f6 github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd github.com/sanity-io/litter v1.3.0 github.com/spf13/afero v1.4.1 github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.1.1 github.com/spf13/fsync v0.9.0 github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.1 github.com/tdewolff/minify/v2 v2.6.2 github.com/yuin/goldmark v1.2.1 github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691 gocloud.dev v0.20.0 golang.org/x/image v0.0.0-20191214001246-9130b4cfad52 golang.org/x/net v0.0.0-20201224014010-6772e930b67b golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a golang.org/x/text v0.3.4 google.golang.org/api v0.26.0 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/ini.v1 v1.51.1 // indirect gopkg.in/yaml.v2 v2.4.0 ) replace github.com/markbates/inflect => github.com/markbates/inflect v0.0.0-20171215194931-a12c3aec81a6 go 1.12
module github.com/gohugoio/hugo require ( github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 github.com/BurntSushi/toml v0.3.1 github.com/PuerkitoBio/purell v1.1.1 github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/alecthomas/chroma v0.8.2 github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 // indirect github.com/armon/go-radix v1.0.0 github.com/aws/aws-sdk-go v1.35.0 github.com/bep/debounce v1.2.0 github.com/bep/gitmap v1.1.2 github.com/bep/godartsass v0.11.0 github.com/bep/golibsass v0.7.0 github.com/bep/tmc v0.5.1 github.com/cli/safeexec v1.0.0 github.com/disintegration/gift v1.2.1 github.com/dlclark/regexp2 v1.4.0 // indirect github.com/dustin/go-humanize v1.0.0 github.com/evanw/esbuild v0.8.17 github.com/fortytw2/leaktest v1.3.0 github.com/frankban/quicktest v1.11.2 github.com/fsnotify/fsnotify v1.4.9 github.com/getkin/kin-openapi v0.32.0 github.com/ghodss/yaml v1.0.0 github.com/gobwas/glob v0.2.3 github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95 github.com/google/go-cmp v0.5.3 github.com/gorilla/websocket v1.4.2 github.com/jdkato/prose v1.2.0 github.com/kylelemons/godebug v1.1.0 github.com/kyokomi/emoji/v2 v2.2.7 github.com/magefile/mage v1.10.0 github.com/markbates/inflect v1.0.4 github.com/mattn/go-isatty v0.0.12 github.com/miekg/mmark v1.3.6 github.com/mitchellh/hashstructure v1.0.0 github.com/mitchellh/mapstructure v1.3.3 github.com/muesli/smartcrop v0.3.0 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect github.com/nicksnyder/go-i18n/v2 v2.1.1 github.com/niklasfasching/go-org v1.4.0 github.com/olekukonko/tablewriter v0.0.4 github.com/pelletier/go-toml v1.8.1 github.com/pkg/errors v0.9.1 github.com/rogpeppe/go-internal v1.6.2 github.com/russross/blackfriday v1.5.3-0.20200218234912-41c5fccfd6f6 github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd github.com/sanity-io/litter v1.3.0 github.com/spf13/afero v1.5.1 github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.1.1 github.com/spf13/fsync v0.9.0 github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.7.1 github.com/tdewolff/minify/v2 v2.6.2 github.com/yuin/goldmark v1.2.1 github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691 gocloud.dev v0.20.0 golang.org/x/image v0.0.0-20191214001246-9130b4cfad52 golang.org/x/net v0.0.0-20201224014010-6772e930b67b golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a golang.org/x/text v0.3.4 google.golang.org/api v0.26.0 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/ini.v1 v1.51.1 // indirect gopkg.in/yaml.v2 v2.4.0 ) replace github.com/markbates/inflect => github.com/markbates/inflect v0.0.0-20171215194931-a12c3aec81a6 go 1.12
1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./go.sum
bazil.org/fuse v0.0.0-20180421153158-65cc252bf669/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.39.0/go.mod h1:rVLT6fkc8chs9sfPtFc1SBH6em7n+ZoXaG+87tDISts= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= cloud.google.com/go v0.55.0/go.mod h1:ZHmoY+/lIMNkN2+fBmuTiqZ4inFhvQad8ft7MT8IV5Y= cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.58.0 h1:vtAfVc723K3xKq1BQydk/FyCldnaNFhGhpJxaJzgRMQ= cloud.google.com/go v0.58.0/go.mod h1:W+9FnSUw6nhVwXlFcp1eL+krq5+HQUJeUogSeJZZiWg= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0 h1:PQcPefKFdaIzjQFbiyOgAqyx8q5djaE7x9Sqe712DPA= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0 h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/firestore v1.2.0/go.mod h1:iISCjWnTpnoJT1R287xRdjvQHJrxQOpeah4phb5D3h0= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1 h1:ukjixP1wl0LpnZ6LWtZJ0mX5tBmjp1f8Sqer8Z2OMUU= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.9.0 h1:oXnZyBjHB6hC8TnSle0AWW6pGJ29EuSo5ww+SFmdNBg= cloud.google.com/go/storage v1.9.0/go.mod h1:m+/etGaqZbylxaNT876QGXqEHp4PR2Rq5GMqICWb9bU= contrib.go.opencensus.io/exporter/aws v0.0.0-20181029163544-2befc13012d0/go.mod h1:uu1P0UCM/6RbsMrgPa98ll8ZcHM858i/AD06a9aLRCA= contrib.go.opencensus.io/exporter/stackdriver v0.12.1/go.mod h1:iwB6wGarfphGGe/e5CWqyUk/cLzKnWsOKPVW3no6OTw= contrib.go.opencensus.io/integrations/ocsql v0.1.4/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE= contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/azure-amqp-common-go/v3 v3.0.0/go.mod h1:SY08giD/XbhTz07tJdpw1SoxQXHPN30+DI3Z04SYqyg= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= github.com/Azure/azure-pipeline-go v0.2.2 h1:6oiIS9yaG6XCCzhgAgKFfIWyo4LLCiDhZot6ltoThhY= github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= github.com/Azure/azure-sdk-for-go v37.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-service-bus-go v0.10.1/go.mod h1:E/FOceuKAFUfpbIJDKWz/May6guE+eGibfGT6q+n1to= github.com/Azure/azure-storage-blob-go v0.9.0 h1:kORqvzXP8ORhKbW13FflGUaSE5CMyDWun9UwMxY8gPs= github.com/Azure/azure-storage-blob-go v0.9.0/go.mod h1:8UBPbiOhrMQ4pLPi3gA1tXnpjrS76UYE/fo5A40vf4g= github.com/Azure/go-amqp v0.12.6/go.mod h1:qApuH6OFTSKZFmCOxccvAv5rLizBQf4v8pRmG138DPo= github.com/Azure/go-amqp v0.12.7/go.mod h1:qApuH6OFTSKZFmCOxccvAv5rLizBQf4v8pRmG138DPo= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest v0.9.3 h1:OZEIaBbMdUE/Js+BQKlpO81XlISgipr6yDJ+PSwsgi4= github.com/Azure/go-autorest/autorest v0.9.3/go.mod h1:GsRuLYvwzLjjjRoWEIyMUaYq8GNUx2nRB378IPt/1p0= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= github.com/Azure/go-autorest/autorest/adal v0.8.1/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= github.com/Azure/go-autorest/autorest/adal v0.8.3 h1:O1AGG9Xig71FxdX9HO5pGNyZ7TbSyHaVg+5eJO/jSGw= github.com/Azure/go-autorest/autorest/adal v0.8.3/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= github.com/Azure/go-autorest/autorest/azure/auth v0.4.2 h1:iM6UAvjR97ZIeR93qTcwpKNMpV+/FTWjwEbuPD495Tk= github.com/Azure/go-autorest/autorest/azure/auth v0.4.2/go.mod h1:90gmfKdlmKgfjUpnCEpOJzsUEjrWDSLwHIG73tSXddM= github.com/Azure/go-autorest/autorest/azure/cli v0.3.1 h1:LXl088ZQlP0SBppGFsRZonW6hSvwgL5gRByMbvUbx8U= github.com/Azure/go-autorest/autorest/azure/cli v0.3.1/go.mod h1:ZG5p860J94/0kI9mNJVoIoLgXcirM2gF5i2kWloofxw= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/date v0.2.0 h1:yW+Zlqf26583pE43KhfnhFcdmSWlm5Ew6bxipnr/tbM= github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.3.0 h1:qJumjCaCudz+OcqE9/XtEPfvtOjOmKaui4EOpFI6zZc= github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= github.com/Azure/go-autorest/autorest/to v0.3.0/go.mod h1:MgwOyqaIuKdG4TL/2ywSsIWKAfJfgHDo8ObuUk3t5sA= github.com/Azure/go-autorest/autorest/validation v0.2.0/go.mod h1:3EEqHnBxQGHXRYq3HT1WyXAvT7LLY3tl70hw6tQIbjI= github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 h1:+tu3HOoMXB7RXEINRVIpxJCT+KdYiI7LAEAUrOw3dIU= github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69/go.mod h1:L1AbZdiDllfyYH5l5OkAaZtk7VkWe89bPJFmnDBNHxg= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0= github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20191009163259-e802c2cb94ae/go.mod h1:mjwGPas4yKduTyubHvD1Atl9r1rUq8DfVy+gkVvZ+oo= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U= github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI= github.com/alecthomas/chroma v0.7.2-0.20200305040604-4f3623dce67a/go.mod h1:fv5SzZPFJbwp2NXJWpFIX7DZS4HgV1K4ew4Pc2OZD9s= github.com/alecthomas/chroma v0.8.2 h1:x3zkuE2lUk/RIekyAJ3XRqSCP4zwWDfcw/YJCuCAACg= github.com/alecthomas/chroma v0.8.2/go.mod h1:sko8vR34/90zvl5QdcUdvzL3J8NKjAUx9va9jPuFNoM= github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo= github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= github.com/alecthomas/kong v0.1.17-0.20190424132513-439c674f7ae0/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI= github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI= github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8/go.mod h1:MRgZdU3vrFd05IQ89AxUZ0aYdF39BYoNFa324SodPCA= github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 h1:GDQdwm/gAcJcLAKQQZGOJ4knlw+7rfEQQcmwTbt4p5E= github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aws/aws-sdk-go v1.15.27/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= github.com/aws/aws-sdk-go v1.19.18/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.31.13/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.35.0 h1:Pxqn1MWNfBCNcX7jrXCCTfsKpg5ms2IMUMmmcGtYJuo= github.com/aws/aws-sdk-go v1.35.0/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/bep/debounce v1.2.0 h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo= github.com/bep/debounce v1.2.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= github.com/bep/gitmap v1.1.2 h1:zk04w1qc1COTZPPYWDQHvns3y1afOsdRfraFQ3qI840= github.com/bep/gitmap v1.1.2/go.mod h1:g9VRETxFUXNWzMiuxOwcudo6DfZkW9jOsOW0Ft4kYaY= github.com/bep/godartsass v0.11.0 h1:62x1zaOzIP2NUzFb3Wob6sNyrtMp0JN61FFg30yQVb8= github.com/bep/godartsass v0.11.0/go.mod h1:nXQlHHk4H1ghUk6n/JkYKG5RD43yJfcfp5aHRqT/pc4= github.com/bep/golibsass v0.7.0 h1:/ocxgtPZ5rgp7FA+mktzyent+fAg82tJq4iMsTMBAtA= github.com/bep/golibsass v0.7.0/go.mod h1:DL87K8Un/+pWUS75ggYv41bliGiolxzDKWJAq3eJ1MA= github.com/bep/tmc v0.5.1 h1:CsQnSC6MsomH64gw0cT5f+EwQDcvZz4AazKunFwTpuI= github.com/bep/tmc v0.5.1/go.mod h1:tGYHN8fS85aJPhDLgXETVKp+PR382OvFi2+q2GkGsq0= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI= github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4= github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= github.com/disintegration/gift v1.2.1 h1:Y005a1X4Z7Uc+0gLpSAsKhWi4qLtsdEcMIbbdvdZ6pc= github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI= github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanw/esbuild v0.8.17 h1:kwPgM6nrZrSUqI1rlgNG9vv5u9cAMaz6HmZ+Ns+3cfQ= github.com/evanw/esbuild v0.8.17/go.mod h1:y2AFBAGVelPqPodpdtxWWqe6n2jYf5FrsJbligmRmuw= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o= github.com/frankban/quicktest v1.11.2 h1:mjwHjStlXWibxOohM7HYieIViKyh56mmt3+6viyhDDI= github.com/frankban/quicktest v1.11.2/go.mod h1:K+q6oSqb0W0Ininfk863uOk1lMy69l/P6txr3mVT54s= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/getkin/kin-openapi v0.32.0 h1:zzeKoKewdKT9bBdRMwYEhJgB2rKSKGFKE1iOKF7KgNs= github.com/getkin/kin-openapi v0.32.0/go.mod h1:WGRs2ZMM1Q8LR1QBEwUxC6RJEfaBcD0s+pcEVXFuAjw= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95 h1:sgew0XCnZwnzpWxTt3V8LLiCO7OQi3C6dycaE67wfkU= github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95/go.mod h1:bOlVlCa1/RajcHpXkrUXPSHB/Re1UnlXxD1Qp8SKOd8= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-replayers/grpcreplay v0.1.0 h1:eNb1y9rZFmY4ax45uEEECSa8fsxGRU+8Bil52ASAwic= github.com/google/go-replayers/grpcreplay v0.1.0/go.mod h1:8Ig2Idjpr6gifRd6pNVggX6TC1Zw6Jx74AKp7QNH2QE= github.com/google/go-replayers/httpreplay v0.1.0 h1:AX7FUb4BjrrzNvblr/OlgwrmFiep6soj5K2QSDW7BGk= github.com/google/go-replayers/httpreplay v0.1.0/go.mod h1:YKZViNhiGgqdBlUbI2MwGpq4pXxNmhJLPHQ7cv2b5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible h1:xmapqc1AyLoB+ddYT6r04bD9lIjlOqGaREovi0SzFaE= github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200507031123-427632fa3b1c/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.4.0 h1:kXcsA/rIGzJImVqPdhfnr6q0xsS9gU0515q1EPpJ9fE= github.com/google/wire v0.4.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU= github.com/googleapis/gax-go v2.0.2+incompatible h1:silFMLAnr330+NRuag/VjIGF7TLp/LBrV2CJKFLWEww= github.com/googleapis/gax-go v2.0.2+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/csrf v1.6.0/go.mod h1:7tSf8kmjNYr7IWDCYhd3U8Ck34iQ/Yw5CJu7bAkHEGI= github.com/gorilla/handlers v1.4.1/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jdkato/prose v1.2.0 h1:t/R3H6xOrVuIgNevWiOSJf1kEoeF2VWlrN6w76Tkzow= github.com/jdkato/prose v1.2.0/go.mod h1:WC4YKHtBdAMgBdmfdqBmEuVbBD0U5c9HQ6l1U8Cq0ts= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/kyokomi/emoji/v2 v2.2.7 h1:v12BHO3OBfwokUfaQghK4RSDFpG4WfxeKJPSdcc73Nk= github.com/kyokomi/emoji/v2 v2.2.7/go.mod h1:JUcn42DTdsXJo1SWanHh4HKDEyPaR5CqkmoirZZP9qE= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/magefile/mage v1.10.0 h1:3HiXzCUY12kh9bIuyXShaVe529fJfyqoVM42o/uom2g= github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/markbates/inflect v0.0.0-20171215194931-a12c3aec81a6 h1:LZhVjIISSbj8qLf2qDPP0D8z0uvOWAW5C85ly5mJW6c= github.com/markbates/inflect v0.0.0-20171215194931-a12c3aec81a6/go.mod h1:oTeZL2KHA7CUX6X+fovmK9OvIOFuqu0TwdQrZjLTh88= github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-ieproxy v0.0.1 h1:qiyop7gCflfhwCzGyeT0gro3sF9AIg9HU98JORTkqfI= github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/mmark v1.3.6 h1:t47x5vThdwgLJzofNsbsAl7gmIiJ7kbDQN5BxwBmwvY= github.com/miekg/mmark v1.3.6/go.mod h1:w7r9mkTvpS55jlfyn22qJ618itLryxXBhA7Jp3FIlkw= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/hashstructure v1.0.0 h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9dGS02Q3Y= github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/montanaflynn/stats v0.6.3/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/muesli/smartcrop v0.3.0 h1:JTlSkmxWg/oQ1TcLDoypuirdE8Y/jzNirQeLkxpA6Oc= github.com/muesli/smartcrop v0.3.0/go.mod h1:i2fCI/UorTfgEpPPLWiFBv4pye+YAG78RwcQLUkocpI= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/nicksnyder/go-i18n/v2 v2.1.1 h1:ATCOanRDlrfKVB4WHAdJnLEqZtDmKYsweqsOUYflnBU= github.com/nicksnyder/go-i18n/v2 v2.1.1/go.mod h1:d++QJC9ZVf7pa48qrsRWhMJ5pSHIPmS3OLqK1niyLxs= github.com/niklasfasching/go-org v1.4.0 h1:qPy4VEdX55f5QcLiaD3X7N/tY5XOgk4y2uEyQa02i7A= github.com/niklasfasching/go-org v1.4.0/go.mod h1:4FWT4U/Anir9ewjwNpbZIzMjG5RaXFafkyWZNEPRdk8= github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8= github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.2 h1:aIihoIOHCiLZHxyoNQ+ABL4NKhFTgKLBdMLyEAh98m0= github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/russross/blackfriday v1.5.3-0.20200218234912-41c5fccfd6f6 h1:tlXG832s5pa9x9Gs3Rp2rTvEqjiDEuETUOSfBEiTcns= github.com/russross/blackfriday v1.5.3-0.20200218234912-41c5fccfd6f6/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd h1:CmH9+J6ZSsIjUK3dcGsnCnO41eRBOnY12zwkn5qVwgc= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sanity-io/litter v1.3.0 h1:5ZO+weUsqdSWMUng5JnpkW/Oz8iTXiIdeumhQr1sSjs= github.com/sanity-io/litter v1.3.0/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shogo82148/go-shuffle v0.0.0-20180218125048-27e6095f230d/go.mod h1:2htx6lmL0NGLHlO8ZCf+lQBGBHIbEujyywxJArf+2Yc= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.4.1 h1:asw9sl74539yqavKaglDM5hFpdJVK0Y5Dr/JOgQ89nQ= github.com/spf13/afero v1.4.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/fsync v0.9.0 h1:f9CEt3DOB2mnHxZaftmEOFWjABEvKM/xpf3cUwJrGOY= github.com/spf13/fsync v0.9.0/go.mod h1:fNtJEfG3HiltN3y4cPOz6MLjos9+2pIEqLIgszqhp/0= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tdewolff/minify/v2 v2.6.2 h1:Jaod6aSABWmhftvnxvXogxcEoQt6yogfFeZgIQEMPOw= github.com/tdewolff/minify/v2 v2.6.2/go.mod h1:BkDSm8aMMT0ALGmpt7j3Ra7nLUgZL0qhyrAHXwxcy5w= github.com/tdewolff/parse/v2 v2.4.2 h1:Bu2Qv6wepkc+Ou7iB/qHjAhEImlAP5vedzlQRUdj3BI= github.com/tdewolff/parse/v2 v2.4.2/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho= github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4= github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.1.22/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1 h1:ruQGxdhGHe7FWOJPT0mKs5+pD2Xs1Bm/kdGlHO04FmM= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691 h1:VWSxtAiQNh3zgHJpdpkpVYjTPqRE3P6UZCOPa1nRDio= github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691/go.mod h1:YLF3kDffRfUH/bTxOxHhV6lxwIB3Vfj91rEwNMS9MXo= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= gocloud.dev v0.20.0 h1:mbEKMfnyPV7W1Rj35R1xXfjszs9dXkwSOq2KoFr25g8= gocloud.dev v0.20.0/go.mod h1:+Y/RpSXrJthIOM8uFNzWp6MRu9pFPNFEEZrQMxpkfIc= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20191214001246-9130b4cfad52 h1:2fktqPPvDiVEEVT/vSTeoUPXfmRxRaGy6GU8jypvEn0= golang.org/x/image v0.0.0-20191214001246-9130b4cfad52/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190619014844-b5b0513f8c1b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181031143558-9b800f95dbbc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200317113312-5766fd39f98d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200317043434-63da46f3035e/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200601175630-2caf76543d99/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200606014950-c42cb6316fb6/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200608174601-1b747fd94509 h1:MI14dOfl3OG6Zd32w3ugsrvcUO810fDZdWakTq39dH4= golang.org/x/tools v0.0.0-20200608174601-1b747fd94509/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.5.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.26.0 h1:VJZ8h6E8ip82FRpQl848c5vAadxlTXrUh8RzQzSRm08= google.golang.org/api v0.26.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190508193815-b515fa19cec8/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200317114155-1f3552e48f24/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200325114520-5b2d0af7952b/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200603110839-e855014d5736/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200608115520-7c474a2e3482 h1:i+Aiej6cta/Frzp13/swvwz5O00kYcSe0A/C5Wd7zX8= google.golang.org/genproto v0.0.0-20200608115520-7c474a2e3482/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.1 h1:GyboHr4UqMiLUybYjd22ZjQIKEJEpgtLXtuGbR21Oho= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/neurosnap/sentences.v1 v1.0.6/go.mod h1:YlK+SN+fLQZj+kY3r8DkGDhDr91+S3JmTb5LSxFRQo0= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
bazil.org/fuse v0.0.0-20180421153158-65cc252bf669/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.39.0/go.mod h1:rVLT6fkc8chs9sfPtFc1SBH6em7n+ZoXaG+87tDISts= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= cloud.google.com/go v0.55.0/go.mod h1:ZHmoY+/lIMNkN2+fBmuTiqZ4inFhvQad8ft7MT8IV5Y= cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.58.0 h1:vtAfVc723K3xKq1BQydk/FyCldnaNFhGhpJxaJzgRMQ= cloud.google.com/go v0.58.0/go.mod h1:W+9FnSUw6nhVwXlFcp1eL+krq5+HQUJeUogSeJZZiWg= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0 h1:PQcPefKFdaIzjQFbiyOgAqyx8q5djaE7x9Sqe712DPA= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0 h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/firestore v1.2.0/go.mod h1:iISCjWnTpnoJT1R287xRdjvQHJrxQOpeah4phb5D3h0= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1 h1:ukjixP1wl0LpnZ6LWtZJ0mX5tBmjp1f8Sqer8Z2OMUU= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.9.0 h1:oXnZyBjHB6hC8TnSle0AWW6pGJ29EuSo5ww+SFmdNBg= cloud.google.com/go/storage v1.9.0/go.mod h1:m+/etGaqZbylxaNT876QGXqEHp4PR2Rq5GMqICWb9bU= contrib.go.opencensus.io/exporter/aws v0.0.0-20181029163544-2befc13012d0/go.mod h1:uu1P0UCM/6RbsMrgPa98ll8ZcHM858i/AD06a9aLRCA= contrib.go.opencensus.io/exporter/stackdriver v0.12.1/go.mod h1:iwB6wGarfphGGe/e5CWqyUk/cLzKnWsOKPVW3no6OTw= contrib.go.opencensus.io/integrations/ocsql v0.1.4/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE= contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/azure-amqp-common-go/v3 v3.0.0/go.mod h1:SY08giD/XbhTz07tJdpw1SoxQXHPN30+DI3Z04SYqyg= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= github.com/Azure/azure-pipeline-go v0.2.2 h1:6oiIS9yaG6XCCzhgAgKFfIWyo4LLCiDhZot6ltoThhY= github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= github.com/Azure/azure-sdk-for-go v37.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-service-bus-go v0.10.1/go.mod h1:E/FOceuKAFUfpbIJDKWz/May6guE+eGibfGT6q+n1to= github.com/Azure/azure-storage-blob-go v0.9.0 h1:kORqvzXP8ORhKbW13FflGUaSE5CMyDWun9UwMxY8gPs= github.com/Azure/azure-storage-blob-go v0.9.0/go.mod h1:8UBPbiOhrMQ4pLPi3gA1tXnpjrS76UYE/fo5A40vf4g= github.com/Azure/go-amqp v0.12.6/go.mod h1:qApuH6OFTSKZFmCOxccvAv5rLizBQf4v8pRmG138DPo= github.com/Azure/go-amqp v0.12.7/go.mod h1:qApuH6OFTSKZFmCOxccvAv5rLizBQf4v8pRmG138DPo= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest v0.9.3 h1:OZEIaBbMdUE/Js+BQKlpO81XlISgipr6yDJ+PSwsgi4= github.com/Azure/go-autorest/autorest v0.9.3/go.mod h1:GsRuLYvwzLjjjRoWEIyMUaYq8GNUx2nRB378IPt/1p0= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= github.com/Azure/go-autorest/autorest/adal v0.8.1/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= github.com/Azure/go-autorest/autorest/adal v0.8.3 h1:O1AGG9Xig71FxdX9HO5pGNyZ7TbSyHaVg+5eJO/jSGw= github.com/Azure/go-autorest/autorest/adal v0.8.3/go.mod h1:ZjhuQClTqx435SRJ2iMlOxPYt3d2C/T/7TiQCVZSn3Q= github.com/Azure/go-autorest/autorest/azure/auth v0.4.2 h1:iM6UAvjR97ZIeR93qTcwpKNMpV+/FTWjwEbuPD495Tk= github.com/Azure/go-autorest/autorest/azure/auth v0.4.2/go.mod h1:90gmfKdlmKgfjUpnCEpOJzsUEjrWDSLwHIG73tSXddM= github.com/Azure/go-autorest/autorest/azure/cli v0.3.1 h1:LXl088ZQlP0SBppGFsRZonW6hSvwgL5gRByMbvUbx8U= github.com/Azure/go-autorest/autorest/azure/cli v0.3.1/go.mod h1:ZG5p860J94/0kI9mNJVoIoLgXcirM2gF5i2kWloofxw= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/date v0.2.0 h1:yW+Zlqf26583pE43KhfnhFcdmSWlm5Ew6bxipnr/tbM= github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.3.0 h1:qJumjCaCudz+OcqE9/XtEPfvtOjOmKaui4EOpFI6zZc= github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= github.com/Azure/go-autorest/autorest/to v0.3.0/go.mod h1:MgwOyqaIuKdG4TL/2ywSsIWKAfJfgHDo8ObuUk3t5sA= github.com/Azure/go-autorest/autorest/validation v0.2.0/go.mod h1:3EEqHnBxQGHXRYq3HT1WyXAvT7LLY3tl70hw6tQIbjI= github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 h1:+tu3HOoMXB7RXEINRVIpxJCT+KdYiI7LAEAUrOw3dIU= github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69/go.mod h1:L1AbZdiDllfyYH5l5OkAaZtk7VkWe89bPJFmnDBNHxg= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0= github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20191009163259-e802c2cb94ae/go.mod h1:mjwGPas4yKduTyubHvD1Atl9r1rUq8DfVy+gkVvZ+oo= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U= github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI= github.com/alecthomas/chroma v0.7.2-0.20200305040604-4f3623dce67a/go.mod h1:fv5SzZPFJbwp2NXJWpFIX7DZS4HgV1K4ew4Pc2OZD9s= github.com/alecthomas/chroma v0.8.2 h1:x3zkuE2lUk/RIekyAJ3XRqSCP4zwWDfcw/YJCuCAACg= github.com/alecthomas/chroma v0.8.2/go.mod h1:sko8vR34/90zvl5QdcUdvzL3J8NKjAUx9va9jPuFNoM= github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo= github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= github.com/alecthomas/kong v0.1.17-0.20190424132513-439c674f7ae0/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI= github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI= github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8/go.mod h1:MRgZdU3vrFd05IQ89AxUZ0aYdF39BYoNFa324SodPCA= github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 h1:GDQdwm/gAcJcLAKQQZGOJ4knlw+7rfEQQcmwTbt4p5E= github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aws/aws-sdk-go v1.15.27/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= github.com/aws/aws-sdk-go v1.19.18/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.31.13/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.35.0 h1:Pxqn1MWNfBCNcX7jrXCCTfsKpg5ms2IMUMmmcGtYJuo= github.com/aws/aws-sdk-go v1.35.0/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/bep/debounce v1.2.0 h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo= github.com/bep/debounce v1.2.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= github.com/bep/gitmap v1.1.2 h1:zk04w1qc1COTZPPYWDQHvns3y1afOsdRfraFQ3qI840= github.com/bep/gitmap v1.1.2/go.mod h1:g9VRETxFUXNWzMiuxOwcudo6DfZkW9jOsOW0Ft4kYaY= github.com/bep/godartsass v0.11.0 h1:62x1zaOzIP2NUzFb3Wob6sNyrtMp0JN61FFg30yQVb8= github.com/bep/godartsass v0.11.0/go.mod h1:nXQlHHk4H1ghUk6n/JkYKG5RD43yJfcfp5aHRqT/pc4= github.com/bep/golibsass v0.7.0 h1:/ocxgtPZ5rgp7FA+mktzyent+fAg82tJq4iMsTMBAtA= github.com/bep/golibsass v0.7.0/go.mod h1:DL87K8Un/+pWUS75ggYv41bliGiolxzDKWJAq3eJ1MA= github.com/bep/tmc v0.5.1 h1:CsQnSC6MsomH64gw0cT5f+EwQDcvZz4AazKunFwTpuI= github.com/bep/tmc v0.5.1/go.mod h1:tGYHN8fS85aJPhDLgXETVKp+PR382OvFi2+q2GkGsq0= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/cli/safeexec v1.0.0 h1:0VngyaIyqACHdcMNWfo6+KdUYnqEr2Sg+bSP1pdF+dI= github.com/cli/safeexec v1.0.0/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4= github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= github.com/disintegration/gift v1.2.1 h1:Y005a1X4Z7Uc+0gLpSAsKhWi4qLtsdEcMIbbdvdZ6pc= github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI= github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanw/esbuild v0.8.17 h1:kwPgM6nrZrSUqI1rlgNG9vv5u9cAMaz6HmZ+Ns+3cfQ= github.com/evanw/esbuild v0.8.17/go.mod h1:y2AFBAGVelPqPodpdtxWWqe6n2jYf5FrsJbligmRmuw= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o= github.com/frankban/quicktest v1.11.2 h1:mjwHjStlXWibxOohM7HYieIViKyh56mmt3+6viyhDDI= github.com/frankban/quicktest v1.11.2/go.mod h1:K+q6oSqb0W0Ininfk863uOk1lMy69l/P6txr3mVT54s= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/getkin/kin-openapi v0.32.0 h1:zzeKoKewdKT9bBdRMwYEhJgB2rKSKGFKE1iOKF7KgNs= github.com/getkin/kin-openapi v0.32.0/go.mod h1:WGRs2ZMM1Q8LR1QBEwUxC6RJEfaBcD0s+pcEVXFuAjw= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95 h1:sgew0XCnZwnzpWxTt3V8LLiCO7OQi3C6dycaE67wfkU= github.com/gohugoio/testmodBuilder/mods v0.0.0-20190520184928-c56af20f2e95/go.mod h1:bOlVlCa1/RajcHpXkrUXPSHB/Re1UnlXxD1Qp8SKOd8= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-replayers/grpcreplay v0.1.0 h1:eNb1y9rZFmY4ax45uEEECSa8fsxGRU+8Bil52ASAwic= github.com/google/go-replayers/grpcreplay v0.1.0/go.mod h1:8Ig2Idjpr6gifRd6pNVggX6TC1Zw6Jx74AKp7QNH2QE= github.com/google/go-replayers/httpreplay v0.1.0 h1:AX7FUb4BjrrzNvblr/OlgwrmFiep6soj5K2QSDW7BGk= github.com/google/go-replayers/httpreplay v0.1.0/go.mod h1:YKZViNhiGgqdBlUbI2MwGpq4pXxNmhJLPHQ7cv2b5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible h1:xmapqc1AyLoB+ddYT6r04bD9lIjlOqGaREovi0SzFaE= github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200507031123-427632fa3b1c/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.4.0 h1:kXcsA/rIGzJImVqPdhfnr6q0xsS9gU0515q1EPpJ9fE= github.com/google/wire v0.4.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU= github.com/googleapis/gax-go v2.0.2+incompatible h1:silFMLAnr330+NRuag/VjIGF7TLp/LBrV2CJKFLWEww= github.com/googleapis/gax-go v2.0.2+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/csrf v1.6.0/go.mod h1:7tSf8kmjNYr7IWDCYhd3U8Ck34iQ/Yw5CJu7bAkHEGI= github.com/gorilla/handlers v1.4.1/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jdkato/prose v1.2.0 h1:t/R3H6xOrVuIgNevWiOSJf1kEoeF2VWlrN6w76Tkzow= github.com/jdkato/prose v1.2.0/go.mod h1:WC4YKHtBdAMgBdmfdqBmEuVbBD0U5c9HQ6l1U8Cq0ts= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/kyokomi/emoji/v2 v2.2.7 h1:v12BHO3OBfwokUfaQghK4RSDFpG4WfxeKJPSdcc73Nk= github.com/kyokomi/emoji/v2 v2.2.7/go.mod h1:JUcn42DTdsXJo1SWanHh4HKDEyPaR5CqkmoirZZP9qE= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/magefile/mage v1.10.0 h1:3HiXzCUY12kh9bIuyXShaVe529fJfyqoVM42o/uom2g= github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/markbates/inflect v0.0.0-20171215194931-a12c3aec81a6 h1:LZhVjIISSbj8qLf2qDPP0D8z0uvOWAW5C85ly5mJW6c= github.com/markbates/inflect v0.0.0-20171215194931-a12c3aec81a6/go.mod h1:oTeZL2KHA7CUX6X+fovmK9OvIOFuqu0TwdQrZjLTh88= github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-ieproxy v0.0.1 h1:qiyop7gCflfhwCzGyeT0gro3sF9AIg9HU98JORTkqfI= github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/mmark v1.3.6 h1:t47x5vThdwgLJzofNsbsAl7gmIiJ7kbDQN5BxwBmwvY= github.com/miekg/mmark v1.3.6/go.mod h1:w7r9mkTvpS55jlfyn22qJ618itLryxXBhA7Jp3FIlkw= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/hashstructure v1.0.0 h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9dGS02Q3Y= github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/montanaflynn/stats v0.6.3/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/muesli/smartcrop v0.3.0 h1:JTlSkmxWg/oQ1TcLDoypuirdE8Y/jzNirQeLkxpA6Oc= github.com/muesli/smartcrop v0.3.0/go.mod h1:i2fCI/UorTfgEpPPLWiFBv4pye+YAG78RwcQLUkocpI= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/nicksnyder/go-i18n/v2 v2.1.1 h1:ATCOanRDlrfKVB4WHAdJnLEqZtDmKYsweqsOUYflnBU= github.com/nicksnyder/go-i18n/v2 v2.1.1/go.mod h1:d++QJC9ZVf7pa48qrsRWhMJ5pSHIPmS3OLqK1niyLxs= github.com/niklasfasching/go-org v1.4.0 h1:qPy4VEdX55f5QcLiaD3X7N/tY5XOgk4y2uEyQa02i7A= github.com/niklasfasching/go-org v1.4.0/go.mod h1:4FWT4U/Anir9ewjwNpbZIzMjG5RaXFafkyWZNEPRdk8= github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8= github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.2 h1:aIihoIOHCiLZHxyoNQ+ABL4NKhFTgKLBdMLyEAh98m0= github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/russross/blackfriday v1.5.3-0.20200218234912-41c5fccfd6f6 h1:tlXG832s5pa9x9Gs3Rp2rTvEqjiDEuETUOSfBEiTcns= github.com/russross/blackfriday v1.5.3-0.20200218234912-41c5fccfd6f6/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd h1:CmH9+J6ZSsIjUK3dcGsnCnO41eRBOnY12zwkn5qVwgc= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sanity-io/litter v1.3.0 h1:5ZO+weUsqdSWMUng5JnpkW/Oz8iTXiIdeumhQr1sSjs= github.com/sanity-io/litter v1.3.0/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shogo82148/go-shuffle v0.0.0-20180218125048-27e6095f230d/go.mod h1:2htx6lmL0NGLHlO8ZCf+lQBGBHIbEujyywxJArf+2Yc= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.5.1 h1:VHu76Lk0LSP1x254maIu2bplkWpfBWI+B+6fdoZprcg= github.com/spf13/afero v1.5.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/fsync v0.9.0 h1:f9CEt3DOB2mnHxZaftmEOFWjABEvKM/xpf3cUwJrGOY= github.com/spf13/fsync v0.9.0/go.mod h1:fNtJEfG3HiltN3y4cPOz6MLjos9+2pIEqLIgszqhp/0= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tdewolff/minify/v2 v2.6.2 h1:Jaod6aSABWmhftvnxvXogxcEoQt6yogfFeZgIQEMPOw= github.com/tdewolff/minify/v2 v2.6.2/go.mod h1:BkDSm8aMMT0ALGmpt7j3Ra7nLUgZL0qhyrAHXwxcy5w= github.com/tdewolff/parse/v2 v2.4.2 h1:Bu2Qv6wepkc+Ou7iB/qHjAhEImlAP5vedzlQRUdj3BI= github.com/tdewolff/parse/v2 v2.4.2/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho= github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4= github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.1.22/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1 h1:ruQGxdhGHe7FWOJPT0mKs5+pD2Xs1Bm/kdGlHO04FmM= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691 h1:VWSxtAiQNh3zgHJpdpkpVYjTPqRE3P6UZCOPa1nRDio= github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691/go.mod h1:YLF3kDffRfUH/bTxOxHhV6lxwIB3Vfj91rEwNMS9MXo= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= gocloud.dev v0.20.0 h1:mbEKMfnyPV7W1Rj35R1xXfjszs9dXkwSOq2KoFr25g8= gocloud.dev v0.20.0/go.mod h1:+Y/RpSXrJthIOM8uFNzWp6MRu9pFPNFEEZrQMxpkfIc= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20191214001246-9130b4cfad52 h1:2fktqPPvDiVEEVT/vSTeoUPXfmRxRaGy6GU8jypvEn0= golang.org/x/image v0.0.0-20191214001246-9130b4cfad52/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190619014844-b5b0513f8c1b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181031143558-9b800f95dbbc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191112214154-59a1497f0cea/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200317113312-5766fd39f98d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200317043434-63da46f3035e/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200601175630-2caf76543d99/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200606014950-c42cb6316fb6/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200608174601-1b747fd94509 h1:MI14dOfl3OG6Zd32w3ugsrvcUO810fDZdWakTq39dH4= golang.org/x/tools v0.0.0-20200608174601-1b747fd94509/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.5.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.26.0 h1:VJZ8h6E8ip82FRpQl848c5vAadxlTXrUh8RzQzSRm08= google.golang.org/api v0.26.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190508193815-b515fa19cec8/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200317114155-1f3552e48f24/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200325114520-5b2d0af7952b/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200603110839-e855014d5736/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200608115520-7c474a2e3482 h1:i+Aiej6cta/Frzp13/swvwz5O00kYcSe0A/C5Wd7zX8= google.golang.org/genproto v0.0.0-20200608115520-7c474a2e3482/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.1 h1:GyboHr4UqMiLUybYjd22ZjQIKEJEpgtLXtuGbR21Oho= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/neurosnap/sentences.v1 v1.0.6/go.mod h1:YlK+SN+fLQZj+kY3r8DkGDhDr91+S3JmTb5LSxFRQo0= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./hugofs/filter_fs.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugofs import ( "fmt" "io" "os" "path/filepath" "sort" "strings" "syscall" "time" "github.com/gohugoio/hugo/hugofs/files" "github.com/spf13/afero" ) var ( _ afero.Fs = (*FilterFs)(nil) _ afero.Lstater = (*FilterFs)(nil) _ afero.File = (*filterDir)(nil) ) func NewLanguageFs(langs map[string]int, fs afero.Fs) (afero.Fs, error) { applyMeta := func(fs *FilterFs, name string, fis []os.FileInfo) { for i, fi := range fis { if fi.IsDir() { filename := filepath.Join(name, fi.Name()) fis[i] = decorateFileInfo(fi, fs, fs.getOpener(filename), "", "", nil) continue } meta := fi.(FileMetaInfo).Meta() lang := meta.Lang() fileLang, translationBaseName, translationBaseNameWithExt := langInfoFrom(langs, fi.Name()) weight := 0 if fileLang != "" { weight = 1 if fileLang == lang { // Give priority to myfile.sv.txt inside the sv filesystem. weight++ } lang = fileLang } fim := NewFileMetaInfo(fi, FileMeta{ metaKeyLang: lang, metaKeyWeight: weight, metaKeyOrdinal: langs[lang], metaKeyTranslationBaseName: translationBaseName, metaKeyTranslationBaseNameWithExt: translationBaseNameWithExt, metaKeyClassifier: files.ClassifyContentFile(fi.Name(), meta.GetOpener()), }) fis[i] = fim } } all := func(fis []os.FileInfo) { // Maps translation base name to a list of language codes. translations := make(map[string][]string) trackTranslation := func(meta FileMeta) { name := meta.TranslationBaseNameWithExt() translations[name] = append(translations[name], meta.Lang()) } for _, fi := range fis { if fi.IsDir() { continue } meta := fi.(FileMetaInfo).Meta() trackTranslation(meta) } for _, fi := range fis { fim := fi.(FileMetaInfo) langs := translations[fim.Meta().TranslationBaseNameWithExt()] if len(langs) > 0 { fim.Meta()["translations"] = sortAndremoveStringDuplicates(langs) } } } return &FilterFs{ fs: fs, applyPerSource: applyMeta, applyAll: all, }, nil } func NewFilterFs(fs afero.Fs) (afero.Fs, error) { applyMeta := func(fs *FilterFs, name string, fis []os.FileInfo) { for i, fi := range fis { if fi.IsDir() { fis[i] = decorateFileInfo(fi, fs, fs.getOpener(fi.(FileMetaInfo).Meta().Filename()), "", "", nil) } } } ffs := &FilterFs{ fs: fs, applyPerSource: applyMeta, } return ffs, nil } // FilterFs is an ordered composite filesystem. type FilterFs struct { fs afero.Fs applyPerSource func(fs *FilterFs, name string, fis []os.FileInfo) applyAll func(fis []os.FileInfo) } func (fs *FilterFs) Chmod(n string, m os.FileMode) error { return syscall.EPERM } func (fs *FilterFs) Chtimes(n string, a, m time.Time) error { return syscall.EPERM } func (fs *FilterFs) LstatIfPossible(name string) (os.FileInfo, bool, error) { fi, b, err := lstatIfPossible(fs.fs, name) if err != nil { return nil, false, err } if fi.IsDir() { return decorateFileInfo(fi, fs, fs.getOpener(name), "", "", nil), false, nil } parent := filepath.Dir(name) fs.applyFilters(parent, -1, fi) return fi, b, nil } func (fs *FilterFs) Mkdir(n string, p os.FileMode) error { return syscall.EPERM } func (fs *FilterFs) MkdirAll(n string, p os.FileMode) error { return syscall.EPERM } func (fs *FilterFs) Name() string { return "WeightedFileSystem" } func (fs *FilterFs) Open(name string) (afero.File, error) { f, err := fs.fs.Open(name) if err != nil { return nil, err } return &filterDir{ File: f, ffs: fs, }, nil } func (fs *FilterFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error) { return fs.fs.Open(name) } func (fs *FilterFs) ReadDir(name string) ([]os.FileInfo, error) { panic("not implemented") } func (fs *FilterFs) Remove(n string) error { return syscall.EPERM } func (fs *FilterFs) RemoveAll(p string) error { return syscall.EPERM } func (fs *FilterFs) Rename(o, n string) error { return syscall.EPERM } func (fs *FilterFs) Stat(name string) (os.FileInfo, error) { fi, _, err := fs.LstatIfPossible(name) return fi, err } func (fs *FilterFs) Create(n string) (afero.File, error) { return nil, syscall.EPERM } func (fs *FilterFs) getOpener(name string) func() (afero.File, error) { return func() (afero.File, error) { return fs.Open(name) } } func (fs *FilterFs) applyFilters(name string, count int, fis ...os.FileInfo) ([]os.FileInfo, error) { if fs.applyPerSource != nil { fs.applyPerSource(fs, name, fis) } seen := make(map[string]bool) var duplicates []int for i, dir := range fis { if !dir.IsDir() { continue } if seen[dir.Name()] { duplicates = append(duplicates, i) } else { seen[dir.Name()] = true } } // Remove duplicate directories, keep first. if len(duplicates) > 0 { for i := len(duplicates) - 1; i >= 0; i-- { idx := duplicates[i] fis = append(fis[:idx], fis[idx+1:]...) } } if fs.applyAll != nil { fs.applyAll(fis) } if count > 0 && len(fis) >= count { return fis[:count], nil } return fis, nil } type filterDir struct { afero.File ffs *FilterFs } func (f *filterDir) Readdir(count int) ([]os.FileInfo, error) { fis, err := f.File.Readdir(-1) if err != nil { return nil, err } return f.ffs.applyFilters(f.Name(), count, fis...) } func (f *filterDir) Readdirnames(count int) ([]string, error) { dirsi, err := f.Readdir(count) if err != nil { return nil, err } dirs := make([]string, len(dirsi)) for i, d := range dirsi { dirs[i] = d.Name() } return dirs, nil } // Try to extract the language from the given filename. // Any valid language identifier in the name will win over the // language set on the file system, e.g. "mypost.en.md". func langInfoFrom(languages map[string]int, name string) (string, string, string) { var lang string baseName := filepath.Base(name) ext := filepath.Ext(baseName) translationBaseName := baseName if ext != "" { translationBaseName = strings.TrimSuffix(translationBaseName, ext) } fileLangExt := filepath.Ext(translationBaseName) fileLang := strings.TrimPrefix(fileLangExt, ".") if _, found := languages[fileLang]; found { lang = fileLang translationBaseName = strings.TrimSuffix(translationBaseName, fileLangExt) } translationBaseNameWithExt := translationBaseName if ext != "" { translationBaseNameWithExt += ext } return lang, translationBaseName, translationBaseNameWithExt } func printFs(fs afero.Fs, path string, w io.Writer) { if fs == nil { return } afero.Walk(fs, path, func(path string, info os.FileInfo, err error) error { fmt.Println("p:::", path) return nil }) } func sortAndremoveStringDuplicates(s []string) []string { ss := sort.StringSlice(s) ss.Sort() i := 0 for j := 1; j < len(s); j++ { if !ss.Less(i, j) { continue } i++ s[i] = s[j] } return s[:i+1] }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugofs import ( "fmt" "io" "os" "path/filepath" "sort" "strings" "syscall" "time" "github.com/gohugoio/hugo/hugofs/files" "github.com/spf13/afero" ) var ( _ afero.Fs = (*FilterFs)(nil) _ afero.Lstater = (*FilterFs)(nil) _ afero.File = (*filterDir)(nil) ) func NewLanguageFs(langs map[string]int, fs afero.Fs) (afero.Fs, error) { applyMeta := func(fs *FilterFs, name string, fis []os.FileInfo) { for i, fi := range fis { if fi.IsDir() { filename := filepath.Join(name, fi.Name()) fis[i] = decorateFileInfo(fi, fs, fs.getOpener(filename), "", "", nil) continue } meta := fi.(FileMetaInfo).Meta() lang := meta.Lang() fileLang, translationBaseName, translationBaseNameWithExt := langInfoFrom(langs, fi.Name()) weight := 0 if fileLang != "" { weight = 1 if fileLang == lang { // Give priority to myfile.sv.txt inside the sv filesystem. weight++ } lang = fileLang } fim := NewFileMetaInfo(fi, FileMeta{ metaKeyLang: lang, metaKeyWeight: weight, metaKeyOrdinal: langs[lang], metaKeyTranslationBaseName: translationBaseName, metaKeyTranslationBaseNameWithExt: translationBaseNameWithExt, metaKeyClassifier: files.ClassifyContentFile(fi.Name(), meta.GetOpener()), }) fis[i] = fim } } all := func(fis []os.FileInfo) { // Maps translation base name to a list of language codes. translations := make(map[string][]string) trackTranslation := func(meta FileMeta) { name := meta.TranslationBaseNameWithExt() translations[name] = append(translations[name], meta.Lang()) } for _, fi := range fis { if fi.IsDir() { continue } meta := fi.(FileMetaInfo).Meta() trackTranslation(meta) } for _, fi := range fis { fim := fi.(FileMetaInfo) langs := translations[fim.Meta().TranslationBaseNameWithExt()] if len(langs) > 0 { fim.Meta()["translations"] = sortAndremoveStringDuplicates(langs) } } } return &FilterFs{ fs: fs, applyPerSource: applyMeta, applyAll: all, }, nil } func NewFilterFs(fs afero.Fs) (afero.Fs, error) { applyMeta := func(fs *FilterFs, name string, fis []os.FileInfo) { for i, fi := range fis { if fi.IsDir() { fis[i] = decorateFileInfo(fi, fs, fs.getOpener(fi.(FileMetaInfo).Meta().Filename()), "", "", nil) } } } ffs := &FilterFs{ fs: fs, applyPerSource: applyMeta, } return ffs, nil } // FilterFs is an ordered composite filesystem. type FilterFs struct { fs afero.Fs applyPerSource func(fs *FilterFs, name string, fis []os.FileInfo) applyAll func(fis []os.FileInfo) } func (fs *FilterFs) Chmod(n string, m os.FileMode) error { return syscall.EPERM } func (fs *FilterFs) Chtimes(n string, a, m time.Time) error { return syscall.EPERM } func (fs *FilterFs) Chown(n string, uid, gid int) error { return syscall.EPERM } func (fs *FilterFs) LstatIfPossible(name string) (os.FileInfo, bool, error) { fi, b, err := lstatIfPossible(fs.fs, name) if err != nil { return nil, false, err } if fi.IsDir() { return decorateFileInfo(fi, fs, fs.getOpener(name), "", "", nil), false, nil } parent := filepath.Dir(name) fs.applyFilters(parent, -1, fi) return fi, b, nil } func (fs *FilterFs) Mkdir(n string, p os.FileMode) error { return syscall.EPERM } func (fs *FilterFs) MkdirAll(n string, p os.FileMode) error { return syscall.EPERM } func (fs *FilterFs) Name() string { return "WeightedFileSystem" } func (fs *FilterFs) Open(name string) (afero.File, error) { f, err := fs.fs.Open(name) if err != nil { return nil, err } return &filterDir{ File: f, ffs: fs, }, nil } func (fs *FilterFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error) { return fs.fs.Open(name) } func (fs *FilterFs) ReadDir(name string) ([]os.FileInfo, error) { panic("not implemented") } func (fs *FilterFs) Remove(n string) error { return syscall.EPERM } func (fs *FilterFs) RemoveAll(p string) error { return syscall.EPERM } func (fs *FilterFs) Rename(o, n string) error { return syscall.EPERM } func (fs *FilterFs) Stat(name string) (os.FileInfo, error) { fi, _, err := fs.LstatIfPossible(name) return fi, err } func (fs *FilterFs) Create(n string) (afero.File, error) { return nil, syscall.EPERM } func (fs *FilterFs) getOpener(name string) func() (afero.File, error) { return func() (afero.File, error) { return fs.Open(name) } } func (fs *FilterFs) applyFilters(name string, count int, fis ...os.FileInfo) ([]os.FileInfo, error) { if fs.applyPerSource != nil { fs.applyPerSource(fs, name, fis) } seen := make(map[string]bool) var duplicates []int for i, dir := range fis { if !dir.IsDir() { continue } if seen[dir.Name()] { duplicates = append(duplicates, i) } else { seen[dir.Name()] = true } } // Remove duplicate directories, keep first. if len(duplicates) > 0 { for i := len(duplicates) - 1; i >= 0; i-- { idx := duplicates[i] fis = append(fis[:idx], fis[idx+1:]...) } } if fs.applyAll != nil { fs.applyAll(fis) } if count > 0 && len(fis) >= count { return fis[:count], nil } return fis, nil } type filterDir struct { afero.File ffs *FilterFs } func (f *filterDir) Readdir(count int) ([]os.FileInfo, error) { fis, err := f.File.Readdir(-1) if err != nil { return nil, err } return f.ffs.applyFilters(f.Name(), count, fis...) } func (f *filterDir) Readdirnames(count int) ([]string, error) { dirsi, err := f.Readdir(count) if err != nil { return nil, err } dirs := make([]string, len(dirsi)) for i, d := range dirsi { dirs[i] = d.Name() } return dirs, nil } // Try to extract the language from the given filename. // Any valid language identifier in the name will win over the // language set on the file system, e.g. "mypost.en.md". func langInfoFrom(languages map[string]int, name string) (string, string, string) { var lang string baseName := filepath.Base(name) ext := filepath.Ext(baseName) translationBaseName := baseName if ext != "" { translationBaseName = strings.TrimSuffix(translationBaseName, ext) } fileLangExt := filepath.Ext(translationBaseName) fileLang := strings.TrimPrefix(fileLangExt, ".") if _, found := languages[fileLang]; found { lang = fileLang translationBaseName = strings.TrimSuffix(translationBaseName, fileLangExt) } translationBaseNameWithExt := translationBaseName if ext != "" { translationBaseNameWithExt += ext } return lang, translationBaseName, translationBaseNameWithExt } func printFs(fs afero.Fs, path string, w io.Writer) { if fs == nil { return } afero.Walk(fs, path, func(path string, info os.FileInfo, err error) error { fmt.Println("p:::", path) return nil }) } func sortAndremoveStringDuplicates(s []string) []string { ss := sort.StringSlice(s) ss.Sort() i := 0 for j := 1; j < len(s); j++ { if !ss.Less(i, j) { continue } i++ s[i] = s[j] } return s[:i+1] }
1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./hugofs/noop_fs.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugofs import ( "errors" "os" "time" "github.com/spf13/afero" ) var ( errNoOp = errors.New("this is a filesystem that does nothing and this operation is not supported") _ afero.Fs = (*noOpFs)(nil) // NoOpFs provides a no-op filesystem that implements the afero.Fs // interface. NoOpFs = &noOpFs{} ) type noOpFs struct { } func (fs noOpFs) Create(name string) (afero.File, error) { return nil, errNoOp } func (fs noOpFs) Mkdir(name string, perm os.FileMode) error { return errNoOp } func (fs noOpFs) MkdirAll(path string, perm os.FileMode) error { return errNoOp } func (fs noOpFs) Open(name string) (afero.File, error) { return nil, os.ErrNotExist } func (fs noOpFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error) { return nil, os.ErrNotExist } func (fs noOpFs) Remove(name string) error { return errNoOp } func (fs noOpFs) RemoveAll(path string) error { return errNoOp } func (fs noOpFs) Rename(oldname string, newname string) error { return errNoOp } func (fs noOpFs) Stat(name string) (os.FileInfo, error) { return nil, os.ErrNotExist } func (fs noOpFs) Name() string { return "noOpFs" } func (fs noOpFs) Chmod(name string, mode os.FileMode) error { return errNoOp } func (fs noOpFs) Chtimes(name string, atime time.Time, mtime time.Time) error { return errNoOp }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugofs import ( "errors" "os" "time" "github.com/spf13/afero" ) var ( errNoOp = errors.New("this is a filesystem that does nothing and this operation is not supported") _ afero.Fs = (*noOpFs)(nil) // NoOpFs provides a no-op filesystem that implements the afero.Fs // interface. NoOpFs = &noOpFs{} ) type noOpFs struct { } func (fs noOpFs) Create(name string) (afero.File, error) { return nil, errNoOp } func (fs noOpFs) Mkdir(name string, perm os.FileMode) error { return errNoOp } func (fs noOpFs) MkdirAll(path string, perm os.FileMode) error { return errNoOp } func (fs noOpFs) Open(name string) (afero.File, error) { return nil, os.ErrNotExist } func (fs noOpFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error) { return nil, os.ErrNotExist } func (fs noOpFs) Remove(name string) error { return errNoOp } func (fs noOpFs) RemoveAll(path string) error { return errNoOp } func (fs noOpFs) Rename(oldname string, newname string) error { return errNoOp } func (fs noOpFs) Stat(name string) (os.FileInfo, error) { return nil, os.ErrNotExist } func (fs noOpFs) Name() string { return "noOpFs" } func (fs noOpFs) Chmod(name string, mode os.FileMode) error { return errNoOp } func (fs noOpFs) Chtimes(name string, atime time.Time, mtime time.Time) error { return errNoOp } func (fs *noOpFs) Chown(name string, uid int, gid int) error { return errNoOp }
1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./hugofs/slice_fs.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugofs import ( "os" "syscall" "time" "github.com/pkg/errors" "github.com/spf13/afero" ) var ( _ afero.Fs = (*SliceFs)(nil) _ afero.Lstater = (*SliceFs)(nil) _ afero.File = (*sliceDir)(nil) ) func NewSliceFs(dirs ...FileMetaInfo) (afero.Fs, error) { if len(dirs) == 0 { return NoOpFs, nil } for _, dir := range dirs { if !dir.IsDir() { return nil, errors.New("this fs supports directories only") } } fs := &SliceFs{ dirs: dirs, } return fs, nil } // SliceFs is an ordered composite filesystem. type SliceFs struct { dirs []FileMetaInfo } func (fs *SliceFs) Chmod(n string, m os.FileMode) error { return syscall.EPERM } func (fs *SliceFs) Chtimes(n string, a, m time.Time) error { return syscall.EPERM } func (fs *SliceFs) LstatIfPossible(name string) (os.FileInfo, bool, error) { fi, _, err := fs.pickFirst(name) if err != nil { return nil, false, err } if fi.IsDir() { return decorateFileInfo(fi, fs, fs.getOpener(name), "", "", nil), false, nil } return nil, false, errors.Errorf("lstat: files not supported: %q", name) } func (fs *SliceFs) Mkdir(n string, p os.FileMode) error { return syscall.EPERM } func (fs *SliceFs) MkdirAll(n string, p os.FileMode) error { return syscall.EPERM } func (fs *SliceFs) Name() string { return "SliceFs" } func (fs *SliceFs) Open(name string) (afero.File, error) { fi, idx, err := fs.pickFirst(name) if err != nil { return nil, err } if !fi.IsDir() { panic("currently only dirs in here") } return &sliceDir{ lfs: fs, idx: idx, dirname: name, }, nil } func (fs *SliceFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error) { panic("not implemented") } func (fs *SliceFs) ReadDir(name string) ([]os.FileInfo, error) { panic("not implemented") } func (fs *SliceFs) Remove(n string) error { return syscall.EPERM } func (fs *SliceFs) RemoveAll(p string) error { return syscall.EPERM } func (fs *SliceFs) Rename(o, n string) error { return syscall.EPERM } func (fs *SliceFs) Stat(name string) (os.FileInfo, error) { fi, _, err := fs.LstatIfPossible(name) return fi, err } func (fs *SliceFs) Create(n string) (afero.File, error) { return nil, syscall.EPERM } func (fs *SliceFs) getOpener(name string) func() (afero.File, error) { return func() (afero.File, error) { return fs.Open(name) } } func (fs *SliceFs) pickFirst(name string) (os.FileInfo, int, error) { for i, mfs := range fs.dirs { meta := mfs.Meta() fs := meta.Fs() fi, _, err := lstatIfPossible(fs, name) if err == nil { // Gotta match! return fi, i, nil } if !os.IsNotExist(err) { // Real error return nil, -1, err } } // Not found return nil, -1, os.ErrNotExist } func (fs *SliceFs) readDirs(name string, startIdx, count int) ([]os.FileInfo, error) { collect := func(lfs FileMeta) ([]os.FileInfo, error) { d, err := lfs.Fs().Open(name) if err != nil { if !os.IsNotExist(err) { return nil, err } return nil, nil } else { defer d.Close() dirs, err := d.Readdir(-1) if err != nil { return nil, err } return dirs, nil } } var dirs []os.FileInfo for i := startIdx; i < len(fs.dirs); i++ { mfs := fs.dirs[i] fis, err := collect(mfs.Meta()) if err != nil { return nil, err } dirs = append(dirs, fis...) } seen := make(map[string]bool) var duplicates []int for i, fi := range dirs { if !fi.IsDir() { continue } if seen[fi.Name()] { duplicates = append(duplicates, i) } else { // Make sure it's opened by this filesystem. dirs[i] = decorateFileInfo(fi, fs, fs.getOpener(fi.(FileMetaInfo).Meta().Filename()), "", "", nil) seen[fi.Name()] = true } } // Remove duplicate directories, keep first. if len(duplicates) > 0 { for i := len(duplicates) - 1; i >= 0; i-- { idx := duplicates[i] dirs = append(dirs[:idx], dirs[idx+1:]...) } } if count > 0 && len(dirs) >= count { return dirs[:count], nil } return dirs, nil } type sliceDir struct { lfs *SliceFs idx int dirname string } func (f *sliceDir) Close() error { return nil } func (f *sliceDir) Name() string { return f.dirname } func (f *sliceDir) Read(p []byte) (n int, err error) { panic("not implemented") } func (f *sliceDir) ReadAt(p []byte, off int64) (n int, err error) { panic("not implemented") } func (f *sliceDir) Readdir(count int) ([]os.FileInfo, error) { return f.lfs.readDirs(f.dirname, f.idx, count) } func (f *sliceDir) Readdirnames(count int) ([]string, error) { dirsi, err := f.Readdir(count) if err != nil { return nil, err } dirs := make([]string, len(dirsi)) for i, d := range dirsi { dirs[i] = d.Name() } return dirs, nil } func (f *sliceDir) Seek(offset int64, whence int) (int64, error) { panic("not implemented") } func (f *sliceDir) Stat() (os.FileInfo, error) { panic("not implemented") } func (f *sliceDir) Sync() error { panic("not implemented") } func (f *sliceDir) Truncate(size int64) error { panic("not implemented") } func (f *sliceDir) Write(p []byte) (n int, err error) { panic("not implemented") } func (f *sliceDir) WriteAt(p []byte, off int64) (n int, err error) { panic("not implemented") } func (f *sliceDir) WriteString(s string) (ret int, err error) { panic("not implemented") }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugofs import ( "os" "syscall" "time" "github.com/pkg/errors" "github.com/spf13/afero" ) var ( _ afero.Fs = (*SliceFs)(nil) _ afero.Lstater = (*SliceFs)(nil) _ afero.File = (*sliceDir)(nil) ) func NewSliceFs(dirs ...FileMetaInfo) (afero.Fs, error) { if len(dirs) == 0 { return NoOpFs, nil } for _, dir := range dirs { if !dir.IsDir() { return nil, errors.New("this fs supports directories only") } } fs := &SliceFs{ dirs: dirs, } return fs, nil } // SliceFs is an ordered composite filesystem. type SliceFs struct { dirs []FileMetaInfo } func (fs *SliceFs) Chmod(n string, m os.FileMode) error { return syscall.EPERM } func (fs *SliceFs) Chtimes(n string, a, m time.Time) error { return syscall.EPERM } func (fs *SliceFs) Chown(n string, uid, gid int) error { return syscall.EPERM } func (fs *SliceFs) LstatIfPossible(name string) (os.FileInfo, bool, error) { fi, _, err := fs.pickFirst(name) if err != nil { return nil, false, err } if fi.IsDir() { return decorateFileInfo(fi, fs, fs.getOpener(name), "", "", nil), false, nil } return nil, false, errors.Errorf("lstat: files not supported: %q", name) } func (fs *SliceFs) Mkdir(n string, p os.FileMode) error { return syscall.EPERM } func (fs *SliceFs) MkdirAll(n string, p os.FileMode) error { return syscall.EPERM } func (fs *SliceFs) Name() string { return "SliceFs" } func (fs *SliceFs) Open(name string) (afero.File, error) { fi, idx, err := fs.pickFirst(name) if err != nil { return nil, err } if !fi.IsDir() { panic("currently only dirs in here") } return &sliceDir{ lfs: fs, idx: idx, dirname: name, }, nil } func (fs *SliceFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error) { panic("not implemented") } func (fs *SliceFs) ReadDir(name string) ([]os.FileInfo, error) { panic("not implemented") } func (fs *SliceFs) Remove(n string) error { return syscall.EPERM } func (fs *SliceFs) RemoveAll(p string) error { return syscall.EPERM } func (fs *SliceFs) Rename(o, n string) error { return syscall.EPERM } func (fs *SliceFs) Stat(name string) (os.FileInfo, error) { fi, _, err := fs.LstatIfPossible(name) return fi, err } func (fs *SliceFs) Create(n string) (afero.File, error) { return nil, syscall.EPERM } func (fs *SliceFs) getOpener(name string) func() (afero.File, error) { return func() (afero.File, error) { return fs.Open(name) } } func (fs *SliceFs) pickFirst(name string) (os.FileInfo, int, error) { for i, mfs := range fs.dirs { meta := mfs.Meta() fs := meta.Fs() fi, _, err := lstatIfPossible(fs, name) if err == nil { // Gotta match! return fi, i, nil } if !os.IsNotExist(err) { // Real error return nil, -1, err } } // Not found return nil, -1, os.ErrNotExist } func (fs *SliceFs) readDirs(name string, startIdx, count int) ([]os.FileInfo, error) { collect := func(lfs FileMeta) ([]os.FileInfo, error) { d, err := lfs.Fs().Open(name) if err != nil { if !os.IsNotExist(err) { return nil, err } return nil, nil } else { defer d.Close() dirs, err := d.Readdir(-1) if err != nil { return nil, err } return dirs, nil } } var dirs []os.FileInfo for i := startIdx; i < len(fs.dirs); i++ { mfs := fs.dirs[i] fis, err := collect(mfs.Meta()) if err != nil { return nil, err } dirs = append(dirs, fis...) } seen := make(map[string]bool) var duplicates []int for i, fi := range dirs { if !fi.IsDir() { continue } if seen[fi.Name()] { duplicates = append(duplicates, i) } else { // Make sure it's opened by this filesystem. dirs[i] = decorateFileInfo(fi, fs, fs.getOpener(fi.(FileMetaInfo).Meta().Filename()), "", "", nil) seen[fi.Name()] = true } } // Remove duplicate directories, keep first. if len(duplicates) > 0 { for i := len(duplicates) - 1; i >= 0; i-- { idx := duplicates[i] dirs = append(dirs[:idx], dirs[idx+1:]...) } } if count > 0 && len(dirs) >= count { return dirs[:count], nil } return dirs, nil } type sliceDir struct { lfs *SliceFs idx int dirname string } func (f *sliceDir) Close() error { return nil } func (f *sliceDir) Name() string { return f.dirname } func (f *sliceDir) Read(p []byte) (n int, err error) { panic("not implemented") } func (f *sliceDir) ReadAt(p []byte, off int64) (n int, err error) { panic("not implemented") } func (f *sliceDir) Readdir(count int) ([]os.FileInfo, error) { return f.lfs.readDirs(f.dirname, f.idx, count) } func (f *sliceDir) Readdirnames(count int) ([]string, error) { dirsi, err := f.Readdir(count) if err != nil { return nil, err } dirs := make([]string, len(dirsi)) for i, d := range dirsi { dirs[i] = d.Name() } return dirs, nil } func (f *sliceDir) Seek(offset int64, whence int) (int64, error) { panic("not implemented") } func (f *sliceDir) Stat() (os.FileInfo, error) { panic("not implemented") } func (f *sliceDir) Sync() error { panic("not implemented") } func (f *sliceDir) Truncate(size int64) error { panic("not implemented") } func (f *sliceDir) Write(p []byte) (n int, err error) { panic("not implemented") } func (f *sliceDir) WriteAt(p []byte, off int64) (n int, err error) { panic("not implemented") } func (f *sliceDir) WriteString(s string) (ret int, err error) { panic("not implemented") }
1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/time/time.go
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package time provides template functions for measuring and displaying time. package time import ( "fmt" _time "time" "github.com/spf13/cast" ) var timeFormats = []string{ _time.RFC3339, "2006-01-02T15:04:05", // iso8601 without timezone _time.RFC1123Z, _time.RFC1123, _time.RFC822Z, _time.RFC822, _time.RFC850, _time.ANSIC, _time.UnixDate, _time.RubyDate, "2006-01-02 15:04:05.999999999 -0700 MST", // Time.String() "2006-01-02", "02 Jan 2006", "2006-01-02T15:04:05-0700", // RFC3339 without timezone hh:mm colon "2006-01-02 15:04:05 -07:00", "2006-01-02 15:04:05 -0700", "2006-01-02 15:04:05Z07:00", // RFC3339 without T "2006-01-02 15:04:05Z0700", // RFC3339 without T or timezone hh:mm colon "2006-01-02 15:04:05", _time.Kitchen, _time.Stamp, _time.StampMilli, _time.StampMicro, _time.StampNano, } // New returns a new instance of the time-namespaced template functions. func New() *Namespace { return &Namespace{} } // Namespace provides template functions for the "time" namespace. type Namespace struct{} // AsTime converts the textual representation of the datetime string into // a time.Time interface. func (ns *Namespace) AsTime(v interface{}, args ...interface{}) (interface{}, error) { if len(args) == 0 { t, err := cast.ToTimeE(v) if err != nil { return nil, err } return t, nil } timeStr, err := cast.ToStringE(v) if err != nil { return nil, err } locStr, err := cast.ToStringE(args[0]) if err != nil { return nil, err } loc, err := _time.LoadLocation(locStr) if err != nil { return nil, err } // Note: Cast currently doesn't support time with non-default locations. For now, just inlining this. // Reference: https://github.com/spf13/cast/pull/80 for _, dateType := range timeFormats { t, err2 := _time.ParseInLocation(dateType, timeStr, loc) if err2 == nil { return t, nil } } return nil, fmt.Errorf("Unable to ParseInLocation using date %q with timezone %q", v, loc) } // Format converts the textual representation of the datetime string into // the other form or returns it of the time.Time value. These are formatted // with the layout string func (ns *Namespace) Format(layout string, v interface{}) (string, error) { t, err := cast.ToTimeE(v) if err != nil { return "", err } return t.Format(layout), nil } // Now returns the current local time. func (ns *Namespace) Now() _time.Time { return _time.Now() } // ParseDuration parses a duration string. // A duration string is a possibly signed sequence of // decimal numbers, each with optional fraction and a unit suffix, // such as "300ms", "-1.5h" or "2h45m". // Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". // See https://golang.org/pkg/time/#ParseDuration func (ns *Namespace) ParseDuration(in interface{}) (_time.Duration, error) { s, err := cast.ToStringE(in) if err != nil { return 0, err } return _time.ParseDuration(s) } var durationUnits = map[string]_time.Duration{ "nanosecond": _time.Nanosecond, "ns": _time.Nanosecond, "microsecond": _time.Microsecond, "us": _time.Microsecond, "µs": _time.Microsecond, "millisecond": _time.Millisecond, "ms": _time.Millisecond, "second": _time.Second, "s": _time.Second, "minute": _time.Minute, "m": _time.Minute, "hour": _time.Hour, "h": _time.Hour, } // Duration converts the given number to a time.Duration. // Unit is one of nanosecond/ns, microsecond/us/µs, millisecond/ms, second/s, minute/m or hour/h. func (ns *Namespace) Duration(unit interface{}, number interface{}) (_time.Duration, error) { unitStr, err := cast.ToStringE(unit) if err != nil { return 0, err } unitDuration, found := durationUnits[unitStr] if !found { return 0, fmt.Errorf("%q is not a valid duration unit", unit) } n, err := cast.ToInt64E(number) if err != nil { return 0, err } return _time.Duration(n) * unitDuration, nil }
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package time provides template functions for measuring and displaying time. package time import ( "fmt" _time "time" "github.com/spf13/cast" ) var timeFormats = []string{ _time.RFC3339, "2006-01-02T15:04:05", // iso8601 without timezone _time.RFC1123Z, _time.RFC1123, _time.RFC822Z, _time.RFC822, _time.RFC850, _time.ANSIC, _time.UnixDate, _time.RubyDate, "2006-01-02 15:04:05.999999999 -0700 MST", // Time.String() "2006-01-02", "02 Jan 2006", "2006-01-02T15:04:05-0700", // RFC3339 without timezone hh:mm colon "2006-01-02 15:04:05 -07:00", "2006-01-02 15:04:05 -0700", "2006-01-02 15:04:05Z07:00", // RFC3339 without T "2006-01-02 15:04:05Z0700", // RFC3339 without T or timezone hh:mm colon "2006-01-02 15:04:05", _time.Kitchen, _time.Stamp, _time.StampMilli, _time.StampMicro, _time.StampNano, } // New returns a new instance of the time-namespaced template functions. func New() *Namespace { return &Namespace{} } // Namespace provides template functions for the "time" namespace. type Namespace struct{} // AsTime converts the textual representation of the datetime string into // a time.Time interface. func (ns *Namespace) AsTime(v interface{}, args ...interface{}) (interface{}, error) { if len(args) == 0 { t, err := cast.ToTimeE(v) if err != nil { return nil, err } return t, nil } timeStr, err := cast.ToStringE(v) if err != nil { return nil, err } locStr, err := cast.ToStringE(args[0]) if err != nil { return nil, err } loc, err := _time.LoadLocation(locStr) if err != nil { return nil, err } // Note: Cast currently doesn't support time with non-default locations. For now, just inlining this. // Reference: https://github.com/spf13/cast/pull/80 for _, dateType := range timeFormats { t, err2 := _time.ParseInLocation(dateType, timeStr, loc) if err2 == nil { return t, nil } } return nil, fmt.Errorf("Unable to ParseInLocation using date %q with timezone %q", v, loc) } // Format converts the textual representation of the datetime string into // the other form or returns it of the time.Time value. These are formatted // with the layout string func (ns *Namespace) Format(layout string, v interface{}) (string, error) { t, err := cast.ToTimeE(v) if err != nil { return "", err } return t.Format(layout), nil } // Now returns the current local time. func (ns *Namespace) Now() _time.Time { return _time.Now() } // ParseDuration parses a duration string. // A duration string is a possibly signed sequence of // decimal numbers, each with optional fraction and a unit suffix, // such as "300ms", "-1.5h" or "2h45m". // Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". // See https://golang.org/pkg/time/#ParseDuration func (ns *Namespace) ParseDuration(in interface{}) (_time.Duration, error) { s, err := cast.ToStringE(in) if err != nil { return 0, err } return _time.ParseDuration(s) } var durationUnits = map[string]_time.Duration{ "nanosecond": _time.Nanosecond, "ns": _time.Nanosecond, "microsecond": _time.Microsecond, "us": _time.Microsecond, "µs": _time.Microsecond, "millisecond": _time.Millisecond, "ms": _time.Millisecond, "second": _time.Second, "s": _time.Second, "minute": _time.Minute, "m": _time.Minute, "hour": _time.Hour, "h": _time.Hour, } // Duration converts the given number to a time.Duration. // Unit is one of nanosecond/ns, microsecond/us/µs, millisecond/ms, second/s, minute/m or hour/h. func (ns *Namespace) Duration(unit interface{}, number interface{}) (_time.Duration, error) { unitStr, err := cast.ToStringE(unit) if err != nil { return 0, err } unitDuration, found := durationUnits[unitStr] if !found { return 0, fmt.Errorf("%q is not a valid duration unit", unit) } n, err := cast.ToInt64E(number) if err != nil { return 0, err } return _time.Duration(n) * unitDuration, nil }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./cache/filecache/filecache_config_test.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package filecache import ( "path/filepath" "runtime" "strings" "testing" "time" "github.com/spf13/afero" "github.com/gohugoio/hugo/config" qt "github.com/frankban/quicktest" "github.com/spf13/viper" ) func TestDecodeConfig(t *testing.T) { t.Parallel() c := qt.New(t) configStr := ` resourceDir = "myresources" contentDir = "content" dataDir = "data" i18nDir = "i18n" layoutDir = "layouts" assetDir = "assets" archetypeDir = "archetypes" [caches] [caches.getJSON] maxAge = "10m" dir = "/path/to/c1" [caches.getCSV] maxAge = "11h" dir = "/path/to/c2" [caches.images] dir = "/path/to/c3" ` cfg, err := config.FromConfigString(configStr, "toml") c.Assert(err, qt.IsNil) fs := afero.NewMemMapFs() decoded, err := DecodeConfig(fs, cfg) c.Assert(err, qt.IsNil) c.Assert(len(decoded), qt.Equals, 5) c2 := decoded["getcsv"] c.Assert(c2.MaxAge.String(), qt.Equals, "11h0m0s") c.Assert(c2.Dir, qt.Equals, filepath.FromSlash("/path/to/c2/filecache/getcsv")) c3 := decoded["images"] c.Assert(c3.MaxAge, qt.Equals, time.Duration(-1)) c.Assert(c3.Dir, qt.Equals, filepath.FromSlash("/path/to/c3/filecache/images")) } func TestDecodeConfigIgnoreCache(t *testing.T) { t.Parallel() c := qt.New(t) configStr := ` resourceDir = "myresources" contentDir = "content" dataDir = "data" i18nDir = "i18n" layoutDir = "layouts" assetDir = "assets" archeTypedir = "archetypes" ignoreCache = true [caches] [caches.getJSON] maxAge = 1234 dir = "/path/to/c1" [caches.getCSV] maxAge = 3456 dir = "/path/to/c2" [caches.images] dir = "/path/to/c3" ` cfg, err := config.FromConfigString(configStr, "toml") c.Assert(err, qt.IsNil) fs := afero.NewMemMapFs() decoded, err := DecodeConfig(fs, cfg) c.Assert(err, qt.IsNil) c.Assert(len(decoded), qt.Equals, 5) for _, v := range decoded { c.Assert(v.MaxAge, qt.Equals, time.Duration(0)) } } func TestDecodeConfigDefault(t *testing.T) { c := qt.New(t) cfg := newTestConfig() if runtime.GOOS == "windows" { cfg.Set("resourceDir", "c:\\cache\\resources") cfg.Set("cacheDir", "c:\\cache\\thecache") } else { cfg.Set("resourceDir", "/cache/resources") cfg.Set("cacheDir", "/cache/thecache") } fs := afero.NewMemMapFs() decoded, err := DecodeConfig(fs, cfg) c.Assert(err, qt.IsNil) c.Assert(len(decoded), qt.Equals, 5) imgConfig := decoded[cacheKeyImages] jsonConfig := decoded[cacheKeyGetJSON] if runtime.GOOS == "windows" { c.Assert(imgConfig.Dir, qt.Equals, filepath.FromSlash("_gen/images")) } else { c.Assert(imgConfig.Dir, qt.Equals, "_gen/images") c.Assert(jsonConfig.Dir, qt.Equals, "/cache/thecache/hugoproject/filecache/getjson") } c.Assert(imgConfig.isResourceDir, qt.Equals, true) c.Assert(jsonConfig.isResourceDir, qt.Equals, false) } func TestDecodeConfigInvalidDir(t *testing.T) { t.Parallel() c := qt.New(t) configStr := ` resourceDir = "myresources" contentDir = "content" dataDir = "data" i18nDir = "i18n" layoutDir = "layouts" assetDir = "assets" archeTypedir = "archetypes" [caches] [caches.getJSON] maxAge = "10m" dir = "/" ` if runtime.GOOS == "windows" { configStr = strings.Replace(configStr, "/", "c:\\\\", 1) } cfg, err := config.FromConfigString(configStr, "toml") c.Assert(err, qt.IsNil) fs := afero.NewMemMapFs() _, err = DecodeConfig(fs, cfg) c.Assert(err, qt.Not(qt.IsNil)) } func newTestConfig() *viper.Viper { cfg := viper.New() cfg.Set("workingDir", filepath.FromSlash("/my/cool/hugoproject")) cfg.Set("contentDir", "content") cfg.Set("dataDir", "data") cfg.Set("resourceDir", "resources") cfg.Set("i18nDir", "i18n") cfg.Set("layoutDir", "layouts") cfg.Set("archetypeDir", "archetypes") cfg.Set("assetDir", "assets") return cfg }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package filecache import ( "path/filepath" "runtime" "strings" "testing" "time" "github.com/spf13/afero" "github.com/gohugoio/hugo/config" qt "github.com/frankban/quicktest" "github.com/spf13/viper" ) func TestDecodeConfig(t *testing.T) { t.Parallel() c := qt.New(t) configStr := ` resourceDir = "myresources" contentDir = "content" dataDir = "data" i18nDir = "i18n" layoutDir = "layouts" assetDir = "assets" archetypeDir = "archetypes" [caches] [caches.getJSON] maxAge = "10m" dir = "/path/to/c1" [caches.getCSV] maxAge = "11h" dir = "/path/to/c2" [caches.images] dir = "/path/to/c3" ` cfg, err := config.FromConfigString(configStr, "toml") c.Assert(err, qt.IsNil) fs := afero.NewMemMapFs() decoded, err := DecodeConfig(fs, cfg) c.Assert(err, qt.IsNil) c.Assert(len(decoded), qt.Equals, 5) c2 := decoded["getcsv"] c.Assert(c2.MaxAge.String(), qt.Equals, "11h0m0s") c.Assert(c2.Dir, qt.Equals, filepath.FromSlash("/path/to/c2/filecache/getcsv")) c3 := decoded["images"] c.Assert(c3.MaxAge, qt.Equals, time.Duration(-1)) c.Assert(c3.Dir, qt.Equals, filepath.FromSlash("/path/to/c3/filecache/images")) } func TestDecodeConfigIgnoreCache(t *testing.T) { t.Parallel() c := qt.New(t) configStr := ` resourceDir = "myresources" contentDir = "content" dataDir = "data" i18nDir = "i18n" layoutDir = "layouts" assetDir = "assets" archeTypedir = "archetypes" ignoreCache = true [caches] [caches.getJSON] maxAge = 1234 dir = "/path/to/c1" [caches.getCSV] maxAge = 3456 dir = "/path/to/c2" [caches.images] dir = "/path/to/c3" ` cfg, err := config.FromConfigString(configStr, "toml") c.Assert(err, qt.IsNil) fs := afero.NewMemMapFs() decoded, err := DecodeConfig(fs, cfg) c.Assert(err, qt.IsNil) c.Assert(len(decoded), qt.Equals, 5) for _, v := range decoded { c.Assert(v.MaxAge, qt.Equals, time.Duration(0)) } } func TestDecodeConfigDefault(t *testing.T) { c := qt.New(t) cfg := newTestConfig() if runtime.GOOS == "windows" { cfg.Set("resourceDir", "c:\\cache\\resources") cfg.Set("cacheDir", "c:\\cache\\thecache") } else { cfg.Set("resourceDir", "/cache/resources") cfg.Set("cacheDir", "/cache/thecache") } fs := afero.NewMemMapFs() decoded, err := DecodeConfig(fs, cfg) c.Assert(err, qt.IsNil) c.Assert(len(decoded), qt.Equals, 5) imgConfig := decoded[cacheKeyImages] jsonConfig := decoded[cacheKeyGetJSON] if runtime.GOOS == "windows" { c.Assert(imgConfig.Dir, qt.Equals, filepath.FromSlash("_gen/images")) } else { c.Assert(imgConfig.Dir, qt.Equals, "_gen/images") c.Assert(jsonConfig.Dir, qt.Equals, "/cache/thecache/hugoproject/filecache/getjson") } c.Assert(imgConfig.isResourceDir, qt.Equals, true) c.Assert(jsonConfig.isResourceDir, qt.Equals, false) } func TestDecodeConfigInvalidDir(t *testing.T) { t.Parallel() c := qt.New(t) configStr := ` resourceDir = "myresources" contentDir = "content" dataDir = "data" i18nDir = "i18n" layoutDir = "layouts" assetDir = "assets" archeTypedir = "archetypes" [caches] [caches.getJSON] maxAge = "10m" dir = "/" ` if runtime.GOOS == "windows" { configStr = strings.Replace(configStr, "/", "c:\\\\", 1) } cfg, err := config.FromConfigString(configStr, "toml") c.Assert(err, qt.IsNil) fs := afero.NewMemMapFs() _, err = DecodeConfig(fs, cfg) c.Assert(err, qt.Not(qt.IsNil)) } func newTestConfig() *viper.Viper { cfg := viper.New() cfg.Set("workingDir", filepath.FromSlash("/my/cool/hugoproject")) cfg.Set("contentDir", "content") cfg.Set("dataDir", "data") cfg.Set("resourceDir", "resources") cfg.Set("i18nDir", "i18n") cfg.Set("layoutDir", "layouts") cfg.Set("archetypeDir", "archetypes") cfg.Set("assetDir", "assets") return cfg }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/os/init.go
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package os import ( "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/tpl/internal" ) const name = "os" func init() { f := func(d *deps.Deps) *internal.TemplateFuncsNamespace { ctx := New(d) ns := &internal.TemplateFuncsNamespace{ Name: name, Context: func(args ...interface{}) interface{} { return ctx }, } ns.AddMethodMapping(ctx.Getenv, []string{"getenv"}, [][2]string{}, ) ns.AddMethodMapping(ctx.ReadDir, []string{"readDir"}, [][2]string{ {`{{ range (readDir "files") }}{{ .Name }}{{ end }}`, "README.txt"}, }, ) ns.AddMethodMapping(ctx.ReadFile, []string{"readFile"}, [][2]string{ {`{{ readFile "files/README.txt" }}`, `Hugo Rocks!`}, }, ) ns.AddMethodMapping(ctx.FileExists, []string{"fileExists"}, [][2]string{ {`{{ fileExists "foo.txt" }}`, `false`}, }, ) return ns } internal.AddTemplateFuncsNamespace(f) }
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package os import ( "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/tpl/internal" ) const name = "os" func init() { f := func(d *deps.Deps) *internal.TemplateFuncsNamespace { ctx := New(d) ns := &internal.TemplateFuncsNamespace{ Name: name, Context: func(args ...interface{}) interface{} { return ctx }, } ns.AddMethodMapping(ctx.Getenv, []string{"getenv"}, [][2]string{}, ) ns.AddMethodMapping(ctx.ReadDir, []string{"readDir"}, [][2]string{ {`{{ range (readDir "files") }}{{ .Name }}{{ end }}`, "README.txt"}, }, ) ns.AddMethodMapping(ctx.ReadFile, []string{"readFile"}, [][2]string{ {`{{ readFile "files/README.txt" }}`, `Hugo Rocks!`}, }, ) ns.AddMethodMapping(ctx.FileExists, []string{"fileExists"}, [][2]string{ {`{{ fileExists "foo.txt" }}`, `false`}, }, ) return ns } internal.AddTemplateFuncsNamespace(f) }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/inflect/inflect_test.go
package inflect import ( "testing" qt "github.com/frankban/quicktest" ) func TestInflect(t *testing.T) { t.Parallel() c := qt.New(t) ns := New() for _, test := range []struct { fn func(i interface{}) (string, error) in interface{} expect interface{} }{ {ns.Humanize, "MyCamel", "My camel"}, {ns.Humanize, "óbito", "Óbito"}, {ns.Humanize, "", ""}, {ns.Humanize, "103", "103rd"}, {ns.Humanize, "41", "41st"}, {ns.Humanize, 103, "103rd"}, {ns.Humanize, int64(92), "92nd"}, {ns.Humanize, "5.5", "5.5"}, {ns.Humanize, t, false}, {ns.Pluralize, "cat", "cats"}, {ns.Pluralize, "", ""}, {ns.Pluralize, t, false}, {ns.Singularize, "cats", "cat"}, {ns.Singularize, "", ""}, {ns.Singularize, t, false}, } { result, err := test.fn(test.in) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil)) continue } c.Assert(err, qt.IsNil) c.Assert(result, qt.Equals, test.expect) } }
package inflect import ( "testing" qt "github.com/frankban/quicktest" ) func TestInflect(t *testing.T) { t.Parallel() c := qt.New(t) ns := New() for _, test := range []struct { fn func(i interface{}) (string, error) in interface{} expect interface{} }{ {ns.Humanize, "MyCamel", "My camel"}, {ns.Humanize, "óbito", "Óbito"}, {ns.Humanize, "", ""}, {ns.Humanize, "103", "103rd"}, {ns.Humanize, "41", "41st"}, {ns.Humanize, 103, "103rd"}, {ns.Humanize, int64(92), "92nd"}, {ns.Humanize, "5.5", "5.5"}, {ns.Humanize, t, false}, {ns.Pluralize, "cat", "cats"}, {ns.Pluralize, "", ""}, {ns.Pluralize, t, false}, {ns.Singularize, "cats", "cat"}, {ns.Singularize, "", ""}, {ns.Singularize, t, false}, } { result, err := test.fn(test.in) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil)) continue } c.Assert(err, qt.IsNil) c.Assert(result, qt.Equals, test.expect) } }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./common/types/evictingqueue.go
// Copyright 2017-present The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package types contains types shared between packages in Hugo. package types import ( "sync" ) // EvictingStringQueue is a queue which automatically evicts elements from the head of // the queue when attempting to add new elements onto the queue and it is full. // This queue orders elements LIFO (last-in-first-out). It throws away duplicates. // Note: This queue currently does not contain any remove (poll etc.) methods. type EvictingStringQueue struct { size int vals []string set map[string]bool mu sync.Mutex } // NewEvictingStringQueue creates a new queue with the given size. func NewEvictingStringQueue(size int) *EvictingStringQueue { return &EvictingStringQueue{size: size, set: make(map[string]bool)} } // Add adds a new string to the tail of the queue if it's not already there. func (q *EvictingStringQueue) Add(v string) { q.mu.Lock() if q.set[v] { q.mu.Unlock() return } if len(q.set) == q.size { // Full delete(q.set, q.vals[0]) q.vals = append(q.vals[:0], q.vals[1:]...) } q.set[v] = true q.vals = append(q.vals, v) q.mu.Unlock() } // Contains returns whether the queue contains v. func (q *EvictingStringQueue) Contains(v string) bool { q.mu.Lock() defer q.mu.Unlock() return q.set[v] } // Peek looks at the last element added to the queue. func (q *EvictingStringQueue) Peek() string { q.mu.Lock() l := len(q.vals) if l == 0 { q.mu.Unlock() return "" } elem := q.vals[l-1] q.mu.Unlock() return elem } // PeekAll looks at all the elements in the queue, with the newest first. func (q *EvictingStringQueue) PeekAll() []string { q.mu.Lock() vals := make([]string, len(q.vals)) copy(vals, q.vals) q.mu.Unlock() for i, j := 0, len(vals)-1; i < j; i, j = i+1, j-1 { vals[i], vals[j] = vals[j], vals[i] } return vals } // PeekAllSet returns PeekAll as a set. func (q *EvictingStringQueue) PeekAllSet() map[string]bool { all := q.PeekAll() set := make(map[string]bool) for _, v := range all { set[v] = true } return set }
// Copyright 2017-present The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package types contains types shared between packages in Hugo. package types import ( "sync" ) // EvictingStringQueue is a queue which automatically evicts elements from the head of // the queue when attempting to add new elements onto the queue and it is full. // This queue orders elements LIFO (last-in-first-out). It throws away duplicates. // Note: This queue currently does not contain any remove (poll etc.) methods. type EvictingStringQueue struct { size int vals []string set map[string]bool mu sync.Mutex } // NewEvictingStringQueue creates a new queue with the given size. func NewEvictingStringQueue(size int) *EvictingStringQueue { return &EvictingStringQueue{size: size, set: make(map[string]bool)} } // Add adds a new string to the tail of the queue if it's not already there. func (q *EvictingStringQueue) Add(v string) { q.mu.Lock() if q.set[v] { q.mu.Unlock() return } if len(q.set) == q.size { // Full delete(q.set, q.vals[0]) q.vals = append(q.vals[:0], q.vals[1:]...) } q.set[v] = true q.vals = append(q.vals, v) q.mu.Unlock() } // Contains returns whether the queue contains v. func (q *EvictingStringQueue) Contains(v string) bool { q.mu.Lock() defer q.mu.Unlock() return q.set[v] } // Peek looks at the last element added to the queue. func (q *EvictingStringQueue) Peek() string { q.mu.Lock() l := len(q.vals) if l == 0 { q.mu.Unlock() return "" } elem := q.vals[l-1] q.mu.Unlock() return elem } // PeekAll looks at all the elements in the queue, with the newest first. func (q *EvictingStringQueue) PeekAll() []string { q.mu.Lock() vals := make([]string, len(q.vals)) copy(vals, q.vals) q.mu.Unlock() for i, j := 0, len(vals)-1; i < j; i, j = i+1, j-1 { vals[i], vals[j] = vals[j], vals[i] } return vals } // PeekAllSet returns PeekAll as a set. func (q *EvictingStringQueue) PeekAllSet() map[string]bool { all := q.PeekAll() set := make(map[string]bool) for _, v := range all { set[v] = true } return set }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/internal/go_templates/texttemplate/parse/parse.go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package parse builds parse trees for templates as defined by text/template // and html/template. Clients should use those packages to construct templates // rather than this one, which provides shared internal data structures not // intended for general use. package parse import ( "bytes" "fmt" "runtime" "strconv" "strings" ) // Tree is the representation of a single parsed template. type Tree struct { Name string // name of the template represented by the tree. ParseName string // name of the top-level template during parsing, for error messages. Root *ListNode // top-level root of the tree. text string // text parsed to create the template (or its parent) // Parsing only; cleared after parse. funcs []map[string]interface{} lex *lexer token [3]item // three-token lookahead for parser. peekCount int vars []string // variables defined at the moment. treeSet map[string]*Tree } // Copy returns a copy of the Tree. Any parsing state is discarded. func (t *Tree) Copy() *Tree { if t == nil { return nil } return &Tree{ Name: t.Name, ParseName: t.ParseName, Root: t.Root.CopyList(), text: t.text, } } // Parse returns a map from template name to parse.Tree, created by parsing the // templates described in the argument string. The top-level template will be // given the specified name. If an error is encountered, parsing stops and an // empty map is returned with the error. func Parse(name, text, leftDelim, rightDelim string, funcs ...map[string]interface{}) (map[string]*Tree, error) { treeSet := make(map[string]*Tree) t := New(name) t.text = text _, err := t.Parse(text, leftDelim, rightDelim, treeSet, funcs...) return treeSet, err } // next returns the next token. func (t *Tree) next() item { if t.peekCount > 0 { t.peekCount-- } else { t.token[0] = t.lex.nextItem() } return t.token[t.peekCount] } // backup backs the input stream up one token. func (t *Tree) backup() { t.peekCount++ } // backup2 backs the input stream up two tokens. // The zeroth token is already there. func (t *Tree) backup2(t1 item) { t.token[1] = t1 t.peekCount = 2 } // backup3 backs the input stream up three tokens // The zeroth token is already there. func (t *Tree) backup3(t2, t1 item) { // Reverse order: we're pushing back. t.token[1] = t1 t.token[2] = t2 t.peekCount = 3 } // peek returns but does not consume the next token. func (t *Tree) peek() item { if t.peekCount > 0 { return t.token[t.peekCount-1] } t.peekCount = 1 t.token[0] = t.lex.nextItem() return t.token[0] } // nextNonSpace returns the next non-space token. func (t *Tree) nextNonSpace() (token item) { for { token = t.next() if token.typ != itemSpace { break } } return token } // peekNonSpace returns but does not consume the next non-space token. func (t *Tree) peekNonSpace() item { token := t.nextNonSpace() t.backup() return token } // Parsing. // New allocates a new parse tree with the given name. func New(name string, funcs ...map[string]interface{}) *Tree { return &Tree{ Name: name, funcs: funcs, } } // ErrorContext returns a textual representation of the location of the node in the input text. // The receiver is only used when the node does not have a pointer to the tree inside, // which can occur in old code. func (t *Tree) ErrorContext(n Node) (location, context string) { pos := int(n.Position()) tree := n.tree() if tree == nil { tree = t } text := tree.text[:pos] byteNum := strings.LastIndex(text, "\n") if byteNum == -1 { byteNum = pos // On first line. } else { byteNum++ // After the newline. byteNum = pos - byteNum } lineNum := 1 + strings.Count(text, "\n") context = n.String() return fmt.Sprintf("%s:%d:%d", tree.ParseName, lineNum, byteNum), context } // errorf formats the error and terminates processing. func (t *Tree) errorf(format string, args ...interface{}) { t.Root = nil format = fmt.Sprintf("template: %s:%d: %s", t.ParseName, t.token[0].line, format) panic(fmt.Errorf(format, args...)) } // error terminates processing. func (t *Tree) error(err error) { t.errorf("%s", err) } // expect consumes the next token and guarantees it has the required type. func (t *Tree) expect(expected itemType, context string) item { token := t.nextNonSpace() if token.typ != expected { t.unexpected(token, context) } return token } // expectOneOf consumes the next token and guarantees it has one of the required types. func (t *Tree) expectOneOf(expected1, expected2 itemType, context string) item { token := t.nextNonSpace() if token.typ != expected1 && token.typ != expected2 { t.unexpected(token, context) } return token } // unexpected complains about the token and terminates processing. func (t *Tree) unexpected(token item, context string) { t.errorf("unexpected %s in %s", token, context) } // recover is the handler that turns panics into returns from the top level of Parse. func (t *Tree) recover(errp *error) { e := recover() if e != nil { if _, ok := e.(runtime.Error); ok { panic(e) } if t != nil { t.lex.drain() t.stopParse() } *errp = e.(error) } } // startParse initializes the parser, using the lexer. func (t *Tree) startParse(funcs []map[string]interface{}, lex *lexer, treeSet map[string]*Tree) { t.Root = nil t.lex = lex t.vars = []string{"$"} t.funcs = funcs t.treeSet = treeSet } // stopParse terminates parsing. func (t *Tree) stopParse() { t.lex = nil t.vars = nil t.funcs = nil t.treeSet = nil } // Parse parses the template definition string to construct a representation of // the template for execution. If either action delimiter string is empty, the // default ("{{" or "}}") is used. Embedded template definitions are added to // the treeSet map. func (t *Tree) Parse(text, leftDelim, rightDelim string, treeSet map[string]*Tree, funcs ...map[string]interface{}) (tree *Tree, err error) { defer t.recover(&err) t.ParseName = t.Name t.startParse(funcs, lex(t.Name, text, leftDelim, rightDelim), treeSet) t.text = text t.parse() t.add() t.stopParse() return t, nil } // add adds tree to t.treeSet. func (t *Tree) add() { tree := t.treeSet[t.Name] if tree == nil || IsEmptyTree(tree.Root) { t.treeSet[t.Name] = t return } if !IsEmptyTree(t.Root) { t.errorf("template: multiple definition of template %q", t.Name) } } // IsEmptyTree reports whether this tree (node) is empty of everything but space. func IsEmptyTree(n Node) bool { switch n := n.(type) { case nil: return true case *ActionNode: case *IfNode: case *ListNode: for _, node := range n.Nodes { if !IsEmptyTree(node) { return false } } return true case *RangeNode: case *TemplateNode: case *TextNode: return len(bytes.TrimSpace(n.Text)) == 0 case *WithNode: default: panic("unknown node: " + n.String()) } return false } // parse is the top-level parser for a template, essentially the same // as itemList except it also parses {{define}} actions. // It runs to EOF. func (t *Tree) parse() { t.Root = t.newList(t.peek().pos) for t.peek().typ != itemEOF { if t.peek().typ == itemLeftDelim { delim := t.next() if t.nextNonSpace().typ == itemDefine { newT := New("definition") // name will be updated once we know it. newT.text = t.text newT.ParseName = t.ParseName newT.startParse(t.funcs, t.lex, t.treeSet) newT.parseDefinition() continue } t.backup2(delim) } switch n := t.textOrAction(); n.Type() { case nodeEnd, nodeElse: t.errorf("unexpected %s", n) default: t.Root.append(n) } } } // parseDefinition parses a {{define}} ... {{end}} template definition and // installs the definition in t.treeSet. The "define" keyword has already // been scanned. func (t *Tree) parseDefinition() { const context = "define clause" name := t.expectOneOf(itemString, itemRawString, context) var err error t.Name, err = strconv.Unquote(name.val) if err != nil { t.error(err) } t.expect(itemRightDelim, context) var end Node t.Root, end = t.itemList() if end.Type() != nodeEnd { t.errorf("unexpected %s in %s", end, context) } t.add() t.stopParse() } // itemList: // textOrAction* // Terminates at {{end}} or {{else}}, returned separately. func (t *Tree) itemList() (list *ListNode, next Node) { list = t.newList(t.peekNonSpace().pos) for t.peekNonSpace().typ != itemEOF { n := t.textOrAction() switch n.Type() { case nodeEnd, nodeElse: return list, n } list.append(n) } t.errorf("unexpected EOF") return } // textOrAction: // text | action func (t *Tree) textOrAction() Node { switch token := t.nextNonSpace(); token.typ { case itemText: return t.newText(token.pos, token.val) case itemLeftDelim: return t.action() default: t.unexpected(token, "input") } return nil } // Action: // control // command ("|" command)* // Left delim is past. Now get actions. // First word could be a keyword such as range. func (t *Tree) action() (n Node) { switch token := t.nextNonSpace(); token.typ { case itemBlock: return t.blockControl() case itemElse: return t.elseControl() case itemEnd: return t.endControl() case itemIf: return t.ifControl() case itemRange: return t.rangeControl() case itemTemplate: return t.templateControl() case itemWith: return t.withControl() } t.backup() token := t.peek() // Do not pop variables; they persist until "end". return t.newAction(token.pos, token.line, t.pipeline("command")) } // Pipeline: // declarations? command ('|' command)* func (t *Tree) pipeline(context string) (pipe *PipeNode) { token := t.peekNonSpace() pipe = t.newPipeline(token.pos, token.line, nil) // Are there declarations or assignments? decls: if v := t.peekNonSpace(); v.typ == itemVariable { t.next() // Since space is a token, we need 3-token look-ahead here in the worst case: // in "$x foo" we need to read "foo" (as opposed to ":=") to know that $x is an // argument variable rather than a declaration. So remember the token // adjacent to the variable so we can push it back if necessary. tokenAfterVariable := t.peek() next := t.peekNonSpace() switch { case next.typ == itemAssign, next.typ == itemDeclare: pipe.IsAssign = next.typ == itemAssign t.nextNonSpace() pipe.Decl = append(pipe.Decl, t.newVariable(v.pos, v.val)) t.vars = append(t.vars, v.val) case next.typ == itemChar && next.val == ",": t.nextNonSpace() pipe.Decl = append(pipe.Decl, t.newVariable(v.pos, v.val)) t.vars = append(t.vars, v.val) if context == "range" && len(pipe.Decl) < 2 { switch t.peekNonSpace().typ { case itemVariable, itemRightDelim, itemRightParen: // second initialized variable in a range pipeline goto decls default: t.errorf("range can only initialize variables") } } t.errorf("too many declarations in %s", context) case tokenAfterVariable.typ == itemSpace: t.backup3(v, tokenAfterVariable) default: t.backup2(v) } } for { switch token := t.nextNonSpace(); token.typ { case itemRightDelim, itemRightParen: // At this point, the pipeline is complete t.checkPipeline(pipe, context) if token.typ == itemRightParen { t.backup() } return case itemBool, itemCharConstant, itemComplex, itemDot, itemField, itemIdentifier, itemNumber, itemNil, itemRawString, itemString, itemVariable, itemLeftParen: t.backup() pipe.append(t.command()) default: t.unexpected(token, context) } } } func (t *Tree) checkPipeline(pipe *PipeNode, context string) { // Reject empty pipelines if len(pipe.Cmds) == 0 { t.errorf("missing value for %s", context) } // Only the first command of a pipeline can start with a non executable operand for i, c := range pipe.Cmds[1:] { switch c.Args[0].Type() { case NodeBool, NodeDot, NodeNil, NodeNumber, NodeString: // With A|B|C, pipeline stage 2 is B t.errorf("non executable command in pipeline stage %d", i+2) } } } func (t *Tree) parseControl(allowElseIf bool, context string) (pos Pos, line int, pipe *PipeNode, list, elseList *ListNode) { defer t.popVars(len(t.vars)) pipe = t.pipeline(context) var next Node list, next = t.itemList() switch next.Type() { case nodeEnd: //done case nodeElse: if allowElseIf { // Special case for "else if". If the "else" is followed immediately by an "if", // the elseControl will have left the "if" token pending. Treat // {{if a}}_{{else if b}}_{{end}} // as // {{if a}}_{{else}}{{if b}}_{{end}}{{end}}. // To do this, parse the if as usual and stop at it {{end}}; the subsequent{{end}} // is assumed. This technique works even for long if-else-if chains. // TODO: Should we allow else-if in with and range? if t.peek().typ == itemIf { t.next() // Consume the "if" token. elseList = t.newList(next.Position()) elseList.append(t.ifControl()) // Do not consume the next item - only one {{end}} required. break } } elseList, next = t.itemList() if next.Type() != nodeEnd { t.errorf("expected end; found %s", next) } } return pipe.Position(), pipe.Line, pipe, list, elseList } // If: // {{if pipeline}} itemList {{end}} // {{if pipeline}} itemList {{else}} itemList {{end}} // If keyword is past. func (t *Tree) ifControl() Node { return t.newIf(t.parseControl(true, "if")) } // Range: // {{range pipeline}} itemList {{end}} // {{range pipeline}} itemList {{else}} itemList {{end}} // Range keyword is past. func (t *Tree) rangeControl() Node { return t.newRange(t.parseControl(false, "range")) } // With: // {{with pipeline}} itemList {{end}} // {{with pipeline}} itemList {{else}} itemList {{end}} // If keyword is past. func (t *Tree) withControl() Node { return t.newWith(t.parseControl(false, "with")) } // End: // {{end}} // End keyword is past. func (t *Tree) endControl() Node { return t.newEnd(t.expect(itemRightDelim, "end").pos) } // Else: // {{else}} // Else keyword is past. func (t *Tree) elseControl() Node { // Special case for "else if". peek := t.peekNonSpace() if peek.typ == itemIf { // We see "{{else if ... " but in effect rewrite it to {{else}}{{if ... ". return t.newElse(peek.pos, peek.line) } token := t.expect(itemRightDelim, "else") return t.newElse(token.pos, token.line) } // Block: // {{block stringValue pipeline}} // Block keyword is past. // The name must be something that can evaluate to a string. // The pipeline is mandatory. func (t *Tree) blockControl() Node { const context = "block clause" token := t.nextNonSpace() name := t.parseTemplateName(token, context) pipe := t.pipeline(context) block := New(name) // name will be updated once we know it. block.text = t.text block.ParseName = t.ParseName block.startParse(t.funcs, t.lex, t.treeSet) var end Node block.Root, end = block.itemList() if end.Type() != nodeEnd { t.errorf("unexpected %s in %s", end, context) } block.add() block.stopParse() return t.newTemplate(token.pos, token.line, name, pipe) } // Template: // {{template stringValue pipeline}} // Template keyword is past. The name must be something that can evaluate // to a string. func (t *Tree) templateControl() Node { const context = "template clause" token := t.nextNonSpace() name := t.parseTemplateName(token, context) var pipe *PipeNode if t.nextNonSpace().typ != itemRightDelim { t.backup() // Do not pop variables; they persist until "end". pipe = t.pipeline(context) } return t.newTemplate(token.pos, token.line, name, pipe) } func (t *Tree) parseTemplateName(token item, context string) (name string) { switch token.typ { case itemString, itemRawString: s, err := strconv.Unquote(token.val) if err != nil { t.error(err) } name = s default: t.unexpected(token, context) } return } // command: // operand (space operand)* // space-separated arguments up to a pipeline character or right delimiter. // we consume the pipe character but leave the right delim to terminate the action. func (t *Tree) command() *CommandNode { cmd := t.newCommand(t.peekNonSpace().pos) for { t.peekNonSpace() // skip leading spaces. operand := t.operand() if operand != nil { cmd.append(operand) } switch token := t.next(); token.typ { case itemSpace: continue case itemError: t.errorf("%s", token.val) case itemRightDelim, itemRightParen: t.backup() case itemPipe: default: t.errorf("unexpected %s in operand", token) } break } if len(cmd.Args) == 0 { t.errorf("empty command") } return cmd } // operand: // term .Field* // An operand is a space-separated component of a command, // a term possibly followed by field accesses. // A nil return means the next item is not an operand. func (t *Tree) operand() Node { node := t.term() if node == nil { return nil } if t.peek().typ == itemField { chain := t.newChain(t.peek().pos, node) for t.peek().typ == itemField { chain.Add(t.next().val) } // Compatibility with original API: If the term is of type NodeField // or NodeVariable, just put more fields on the original. // Otherwise, keep the Chain node. // Obvious parsing errors involving literal values are detected here. // More complex error cases will have to be handled at execution time. switch node.Type() { case NodeField: node = t.newField(chain.Position(), chain.String()) case NodeVariable: node = t.newVariable(chain.Position(), chain.String()) case NodeBool, NodeString, NodeNumber, NodeNil, NodeDot: t.errorf("unexpected . after term %q", node.String()) default: node = chain } } return node } // term: // literal (number, string, nil, boolean) // function (identifier) // . // .Field // $ // '(' pipeline ')' // A term is a simple "expression". // A nil return means the next item is not a term. func (t *Tree) term() Node { switch token := t.nextNonSpace(); token.typ { case itemError: t.errorf("%s", token.val) case itemIdentifier: if !t.hasFunction(token.val) { t.errorf("function %q not defined", token.val) } return NewIdentifier(token.val).SetTree(t).SetPos(token.pos) case itemDot: return t.newDot(token.pos) case itemNil: return t.newNil(token.pos) case itemVariable: return t.useVar(token.pos, token.val) case itemField: return t.newField(token.pos, token.val) case itemBool: return t.newBool(token.pos, token.val == "true") case itemCharConstant, itemComplex, itemNumber: number, err := t.newNumber(token.pos, token.val, token.typ) if err != nil { t.error(err) } return number case itemLeftParen: pipe := t.pipeline("parenthesized pipeline") if token := t.next(); token.typ != itemRightParen { t.errorf("unclosed right paren: unexpected %s", token) } return pipe case itemString, itemRawString: s, err := strconv.Unquote(token.val) if err != nil { t.error(err) } return t.newString(token.pos, token.val, s) } t.backup() return nil } // hasFunction reports if a function name exists in the Tree's maps. func (t *Tree) hasFunction(name string) bool { for _, funcMap := range t.funcs { if funcMap == nil { continue } if funcMap[name] != nil { return true } } return false } // popVars trims the variable list to the specified length func (t *Tree) popVars(n int) { t.vars = t.vars[:n] } // useVar returns a node for a variable reference. It errors if the // variable is not defined. func (t *Tree) useVar(pos Pos, name string) Node { v := t.newVariable(pos, name) for _, varName := range t.vars { if varName == v.Ident[0] { return v } } t.errorf("undefined variable %q", v.Ident[0]) return nil }
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package parse builds parse trees for templates as defined by text/template // and html/template. Clients should use those packages to construct templates // rather than this one, which provides shared internal data structures not // intended for general use. package parse import ( "bytes" "fmt" "runtime" "strconv" "strings" ) // Tree is the representation of a single parsed template. type Tree struct { Name string // name of the template represented by the tree. ParseName string // name of the top-level template during parsing, for error messages. Root *ListNode // top-level root of the tree. text string // text parsed to create the template (or its parent) // Parsing only; cleared after parse. funcs []map[string]interface{} lex *lexer token [3]item // three-token lookahead for parser. peekCount int vars []string // variables defined at the moment. treeSet map[string]*Tree } // Copy returns a copy of the Tree. Any parsing state is discarded. func (t *Tree) Copy() *Tree { if t == nil { return nil } return &Tree{ Name: t.Name, ParseName: t.ParseName, Root: t.Root.CopyList(), text: t.text, } } // Parse returns a map from template name to parse.Tree, created by parsing the // templates described in the argument string. The top-level template will be // given the specified name. If an error is encountered, parsing stops and an // empty map is returned with the error. func Parse(name, text, leftDelim, rightDelim string, funcs ...map[string]interface{}) (map[string]*Tree, error) { treeSet := make(map[string]*Tree) t := New(name) t.text = text _, err := t.Parse(text, leftDelim, rightDelim, treeSet, funcs...) return treeSet, err } // next returns the next token. func (t *Tree) next() item { if t.peekCount > 0 { t.peekCount-- } else { t.token[0] = t.lex.nextItem() } return t.token[t.peekCount] } // backup backs the input stream up one token. func (t *Tree) backup() { t.peekCount++ } // backup2 backs the input stream up two tokens. // The zeroth token is already there. func (t *Tree) backup2(t1 item) { t.token[1] = t1 t.peekCount = 2 } // backup3 backs the input stream up three tokens // The zeroth token is already there. func (t *Tree) backup3(t2, t1 item) { // Reverse order: we're pushing back. t.token[1] = t1 t.token[2] = t2 t.peekCount = 3 } // peek returns but does not consume the next token. func (t *Tree) peek() item { if t.peekCount > 0 { return t.token[t.peekCount-1] } t.peekCount = 1 t.token[0] = t.lex.nextItem() return t.token[0] } // nextNonSpace returns the next non-space token. func (t *Tree) nextNonSpace() (token item) { for { token = t.next() if token.typ != itemSpace { break } } return token } // peekNonSpace returns but does not consume the next non-space token. func (t *Tree) peekNonSpace() item { token := t.nextNonSpace() t.backup() return token } // Parsing. // New allocates a new parse tree with the given name. func New(name string, funcs ...map[string]interface{}) *Tree { return &Tree{ Name: name, funcs: funcs, } } // ErrorContext returns a textual representation of the location of the node in the input text. // The receiver is only used when the node does not have a pointer to the tree inside, // which can occur in old code. func (t *Tree) ErrorContext(n Node) (location, context string) { pos := int(n.Position()) tree := n.tree() if tree == nil { tree = t } text := tree.text[:pos] byteNum := strings.LastIndex(text, "\n") if byteNum == -1 { byteNum = pos // On first line. } else { byteNum++ // After the newline. byteNum = pos - byteNum } lineNum := 1 + strings.Count(text, "\n") context = n.String() return fmt.Sprintf("%s:%d:%d", tree.ParseName, lineNum, byteNum), context } // errorf formats the error and terminates processing. func (t *Tree) errorf(format string, args ...interface{}) { t.Root = nil format = fmt.Sprintf("template: %s:%d: %s", t.ParseName, t.token[0].line, format) panic(fmt.Errorf(format, args...)) } // error terminates processing. func (t *Tree) error(err error) { t.errorf("%s", err) } // expect consumes the next token and guarantees it has the required type. func (t *Tree) expect(expected itemType, context string) item { token := t.nextNonSpace() if token.typ != expected { t.unexpected(token, context) } return token } // expectOneOf consumes the next token and guarantees it has one of the required types. func (t *Tree) expectOneOf(expected1, expected2 itemType, context string) item { token := t.nextNonSpace() if token.typ != expected1 && token.typ != expected2 { t.unexpected(token, context) } return token } // unexpected complains about the token and terminates processing. func (t *Tree) unexpected(token item, context string) { t.errorf("unexpected %s in %s", token, context) } // recover is the handler that turns panics into returns from the top level of Parse. func (t *Tree) recover(errp *error) { e := recover() if e != nil { if _, ok := e.(runtime.Error); ok { panic(e) } if t != nil { t.lex.drain() t.stopParse() } *errp = e.(error) } } // startParse initializes the parser, using the lexer. func (t *Tree) startParse(funcs []map[string]interface{}, lex *lexer, treeSet map[string]*Tree) { t.Root = nil t.lex = lex t.vars = []string{"$"} t.funcs = funcs t.treeSet = treeSet } // stopParse terminates parsing. func (t *Tree) stopParse() { t.lex = nil t.vars = nil t.funcs = nil t.treeSet = nil } // Parse parses the template definition string to construct a representation of // the template for execution. If either action delimiter string is empty, the // default ("{{" or "}}") is used. Embedded template definitions are added to // the treeSet map. func (t *Tree) Parse(text, leftDelim, rightDelim string, treeSet map[string]*Tree, funcs ...map[string]interface{}) (tree *Tree, err error) { defer t.recover(&err) t.ParseName = t.Name t.startParse(funcs, lex(t.Name, text, leftDelim, rightDelim), treeSet) t.text = text t.parse() t.add() t.stopParse() return t, nil } // add adds tree to t.treeSet. func (t *Tree) add() { tree := t.treeSet[t.Name] if tree == nil || IsEmptyTree(tree.Root) { t.treeSet[t.Name] = t return } if !IsEmptyTree(t.Root) { t.errorf("template: multiple definition of template %q", t.Name) } } // IsEmptyTree reports whether this tree (node) is empty of everything but space. func IsEmptyTree(n Node) bool { switch n := n.(type) { case nil: return true case *ActionNode: case *IfNode: case *ListNode: for _, node := range n.Nodes { if !IsEmptyTree(node) { return false } } return true case *RangeNode: case *TemplateNode: case *TextNode: return len(bytes.TrimSpace(n.Text)) == 0 case *WithNode: default: panic("unknown node: " + n.String()) } return false } // parse is the top-level parser for a template, essentially the same // as itemList except it also parses {{define}} actions. // It runs to EOF. func (t *Tree) parse() { t.Root = t.newList(t.peek().pos) for t.peek().typ != itemEOF { if t.peek().typ == itemLeftDelim { delim := t.next() if t.nextNonSpace().typ == itemDefine { newT := New("definition") // name will be updated once we know it. newT.text = t.text newT.ParseName = t.ParseName newT.startParse(t.funcs, t.lex, t.treeSet) newT.parseDefinition() continue } t.backup2(delim) } switch n := t.textOrAction(); n.Type() { case nodeEnd, nodeElse: t.errorf("unexpected %s", n) default: t.Root.append(n) } } } // parseDefinition parses a {{define}} ... {{end}} template definition and // installs the definition in t.treeSet. The "define" keyword has already // been scanned. func (t *Tree) parseDefinition() { const context = "define clause" name := t.expectOneOf(itemString, itemRawString, context) var err error t.Name, err = strconv.Unquote(name.val) if err != nil { t.error(err) } t.expect(itemRightDelim, context) var end Node t.Root, end = t.itemList() if end.Type() != nodeEnd { t.errorf("unexpected %s in %s", end, context) } t.add() t.stopParse() } // itemList: // textOrAction* // Terminates at {{end}} or {{else}}, returned separately. func (t *Tree) itemList() (list *ListNode, next Node) { list = t.newList(t.peekNonSpace().pos) for t.peekNonSpace().typ != itemEOF { n := t.textOrAction() switch n.Type() { case nodeEnd, nodeElse: return list, n } list.append(n) } t.errorf("unexpected EOF") return } // textOrAction: // text | action func (t *Tree) textOrAction() Node { switch token := t.nextNonSpace(); token.typ { case itemText: return t.newText(token.pos, token.val) case itemLeftDelim: return t.action() default: t.unexpected(token, "input") } return nil } // Action: // control // command ("|" command)* // Left delim is past. Now get actions. // First word could be a keyword such as range. func (t *Tree) action() (n Node) { switch token := t.nextNonSpace(); token.typ { case itemBlock: return t.blockControl() case itemElse: return t.elseControl() case itemEnd: return t.endControl() case itemIf: return t.ifControl() case itemRange: return t.rangeControl() case itemTemplate: return t.templateControl() case itemWith: return t.withControl() } t.backup() token := t.peek() // Do not pop variables; they persist until "end". return t.newAction(token.pos, token.line, t.pipeline("command")) } // Pipeline: // declarations? command ('|' command)* func (t *Tree) pipeline(context string) (pipe *PipeNode) { token := t.peekNonSpace() pipe = t.newPipeline(token.pos, token.line, nil) // Are there declarations or assignments? decls: if v := t.peekNonSpace(); v.typ == itemVariable { t.next() // Since space is a token, we need 3-token look-ahead here in the worst case: // in "$x foo" we need to read "foo" (as opposed to ":=") to know that $x is an // argument variable rather than a declaration. So remember the token // adjacent to the variable so we can push it back if necessary. tokenAfterVariable := t.peek() next := t.peekNonSpace() switch { case next.typ == itemAssign, next.typ == itemDeclare: pipe.IsAssign = next.typ == itemAssign t.nextNonSpace() pipe.Decl = append(pipe.Decl, t.newVariable(v.pos, v.val)) t.vars = append(t.vars, v.val) case next.typ == itemChar && next.val == ",": t.nextNonSpace() pipe.Decl = append(pipe.Decl, t.newVariable(v.pos, v.val)) t.vars = append(t.vars, v.val) if context == "range" && len(pipe.Decl) < 2 { switch t.peekNonSpace().typ { case itemVariable, itemRightDelim, itemRightParen: // second initialized variable in a range pipeline goto decls default: t.errorf("range can only initialize variables") } } t.errorf("too many declarations in %s", context) case tokenAfterVariable.typ == itemSpace: t.backup3(v, tokenAfterVariable) default: t.backup2(v) } } for { switch token := t.nextNonSpace(); token.typ { case itemRightDelim, itemRightParen: // At this point, the pipeline is complete t.checkPipeline(pipe, context) if token.typ == itemRightParen { t.backup() } return case itemBool, itemCharConstant, itemComplex, itemDot, itemField, itemIdentifier, itemNumber, itemNil, itemRawString, itemString, itemVariable, itemLeftParen: t.backup() pipe.append(t.command()) default: t.unexpected(token, context) } } } func (t *Tree) checkPipeline(pipe *PipeNode, context string) { // Reject empty pipelines if len(pipe.Cmds) == 0 { t.errorf("missing value for %s", context) } // Only the first command of a pipeline can start with a non executable operand for i, c := range pipe.Cmds[1:] { switch c.Args[0].Type() { case NodeBool, NodeDot, NodeNil, NodeNumber, NodeString: // With A|B|C, pipeline stage 2 is B t.errorf("non executable command in pipeline stage %d", i+2) } } } func (t *Tree) parseControl(allowElseIf bool, context string) (pos Pos, line int, pipe *PipeNode, list, elseList *ListNode) { defer t.popVars(len(t.vars)) pipe = t.pipeline(context) var next Node list, next = t.itemList() switch next.Type() { case nodeEnd: //done case nodeElse: if allowElseIf { // Special case for "else if". If the "else" is followed immediately by an "if", // the elseControl will have left the "if" token pending. Treat // {{if a}}_{{else if b}}_{{end}} // as // {{if a}}_{{else}}{{if b}}_{{end}}{{end}}. // To do this, parse the if as usual and stop at it {{end}}; the subsequent{{end}} // is assumed. This technique works even for long if-else-if chains. // TODO: Should we allow else-if in with and range? if t.peek().typ == itemIf { t.next() // Consume the "if" token. elseList = t.newList(next.Position()) elseList.append(t.ifControl()) // Do not consume the next item - only one {{end}} required. break } } elseList, next = t.itemList() if next.Type() != nodeEnd { t.errorf("expected end; found %s", next) } } return pipe.Position(), pipe.Line, pipe, list, elseList } // If: // {{if pipeline}} itemList {{end}} // {{if pipeline}} itemList {{else}} itemList {{end}} // If keyword is past. func (t *Tree) ifControl() Node { return t.newIf(t.parseControl(true, "if")) } // Range: // {{range pipeline}} itemList {{end}} // {{range pipeline}} itemList {{else}} itemList {{end}} // Range keyword is past. func (t *Tree) rangeControl() Node { return t.newRange(t.parseControl(false, "range")) } // With: // {{with pipeline}} itemList {{end}} // {{with pipeline}} itemList {{else}} itemList {{end}} // If keyword is past. func (t *Tree) withControl() Node { return t.newWith(t.parseControl(false, "with")) } // End: // {{end}} // End keyword is past. func (t *Tree) endControl() Node { return t.newEnd(t.expect(itemRightDelim, "end").pos) } // Else: // {{else}} // Else keyword is past. func (t *Tree) elseControl() Node { // Special case for "else if". peek := t.peekNonSpace() if peek.typ == itemIf { // We see "{{else if ... " but in effect rewrite it to {{else}}{{if ... ". return t.newElse(peek.pos, peek.line) } token := t.expect(itemRightDelim, "else") return t.newElse(token.pos, token.line) } // Block: // {{block stringValue pipeline}} // Block keyword is past. // The name must be something that can evaluate to a string. // The pipeline is mandatory. func (t *Tree) blockControl() Node { const context = "block clause" token := t.nextNonSpace() name := t.parseTemplateName(token, context) pipe := t.pipeline(context) block := New(name) // name will be updated once we know it. block.text = t.text block.ParseName = t.ParseName block.startParse(t.funcs, t.lex, t.treeSet) var end Node block.Root, end = block.itemList() if end.Type() != nodeEnd { t.errorf("unexpected %s in %s", end, context) } block.add() block.stopParse() return t.newTemplate(token.pos, token.line, name, pipe) } // Template: // {{template stringValue pipeline}} // Template keyword is past. The name must be something that can evaluate // to a string. func (t *Tree) templateControl() Node { const context = "template clause" token := t.nextNonSpace() name := t.parseTemplateName(token, context) var pipe *PipeNode if t.nextNonSpace().typ != itemRightDelim { t.backup() // Do not pop variables; they persist until "end". pipe = t.pipeline(context) } return t.newTemplate(token.pos, token.line, name, pipe) } func (t *Tree) parseTemplateName(token item, context string) (name string) { switch token.typ { case itemString, itemRawString: s, err := strconv.Unquote(token.val) if err != nil { t.error(err) } name = s default: t.unexpected(token, context) } return } // command: // operand (space operand)* // space-separated arguments up to a pipeline character or right delimiter. // we consume the pipe character but leave the right delim to terminate the action. func (t *Tree) command() *CommandNode { cmd := t.newCommand(t.peekNonSpace().pos) for { t.peekNonSpace() // skip leading spaces. operand := t.operand() if operand != nil { cmd.append(operand) } switch token := t.next(); token.typ { case itemSpace: continue case itemError: t.errorf("%s", token.val) case itemRightDelim, itemRightParen: t.backup() case itemPipe: default: t.errorf("unexpected %s in operand", token) } break } if len(cmd.Args) == 0 { t.errorf("empty command") } return cmd } // operand: // term .Field* // An operand is a space-separated component of a command, // a term possibly followed by field accesses. // A nil return means the next item is not an operand. func (t *Tree) operand() Node { node := t.term() if node == nil { return nil } if t.peek().typ == itemField { chain := t.newChain(t.peek().pos, node) for t.peek().typ == itemField { chain.Add(t.next().val) } // Compatibility with original API: If the term is of type NodeField // or NodeVariable, just put more fields on the original. // Otherwise, keep the Chain node. // Obvious parsing errors involving literal values are detected here. // More complex error cases will have to be handled at execution time. switch node.Type() { case NodeField: node = t.newField(chain.Position(), chain.String()) case NodeVariable: node = t.newVariable(chain.Position(), chain.String()) case NodeBool, NodeString, NodeNumber, NodeNil, NodeDot: t.errorf("unexpected . after term %q", node.String()) default: node = chain } } return node } // term: // literal (number, string, nil, boolean) // function (identifier) // . // .Field // $ // '(' pipeline ')' // A term is a simple "expression". // A nil return means the next item is not a term. func (t *Tree) term() Node { switch token := t.nextNonSpace(); token.typ { case itemError: t.errorf("%s", token.val) case itemIdentifier: if !t.hasFunction(token.val) { t.errorf("function %q not defined", token.val) } return NewIdentifier(token.val).SetTree(t).SetPos(token.pos) case itemDot: return t.newDot(token.pos) case itemNil: return t.newNil(token.pos) case itemVariable: return t.useVar(token.pos, token.val) case itemField: return t.newField(token.pos, token.val) case itemBool: return t.newBool(token.pos, token.val == "true") case itemCharConstant, itemComplex, itemNumber: number, err := t.newNumber(token.pos, token.val, token.typ) if err != nil { t.error(err) } return number case itemLeftParen: pipe := t.pipeline("parenthesized pipeline") if token := t.next(); token.typ != itemRightParen { t.errorf("unclosed right paren: unexpected %s", token) } return pipe case itemString, itemRawString: s, err := strconv.Unquote(token.val) if err != nil { t.error(err) } return t.newString(token.pos, token.val, s) } t.backup() return nil } // hasFunction reports if a function name exists in the Tree's maps. func (t *Tree) hasFunction(name string) bool { for _, funcMap := range t.funcs { if funcMap == nil { continue } if funcMap[name] != nil { return true } } return false } // popVars trims the variable list to the specified length func (t *Tree) popVars(n int) { t.vars = t.vars[:n] } // useVar returns a node for a variable reference. It errors if the // variable is not defined. func (t *Tree) useVar(pos Pos, name string) Node { v := t.newVariable(pos, name) for _, varName := range t.vars { if varName == v.Ident[0] { return v } } t.errorf("undefined variable %q", v.Ident[0]) return nil }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/strings/regexp_test.go
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package strings import ( "testing" qt "github.com/frankban/quicktest" ) func TestFindRE(t *testing.T) { t.Parallel() c := qt.New(t) for _, test := range []struct { expr string content interface{} limit interface{} expect interface{} }{ {"[G|g]o", "Hugo is a static site generator written in Go.", 2, []string{"go", "Go"}}, {"[G|g]o", "Hugo is a static site generator written in Go.", -1, []string{"go", "Go"}}, {"[G|g]o", "Hugo is a static site generator written in Go.", 1, []string{"go"}}, {"[G|g]o", "Hugo is a static site generator written in Go.", "1", []string{"go"}}, {"[G|g]o", "Hugo is a static site generator written in Go.", nil, []string(nil)}, // errors {"[G|go", "Hugo is a static site generator written in Go.", nil, false}, {"[G|g]o", t, nil, false}, } { result, err := ns.FindRE(test.expr, test.content, test.limit) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil)) continue } c.Assert(err, qt.IsNil) c.Check(result, qt.DeepEquals, test.expect) } } func TestReplaceRE(t *testing.T) { t.Parallel() c := qt.New(t) for _, test := range []struct { pattern interface{} repl interface{} s interface{} n []interface{} expect interface{} }{ {"^https?://([^/]+).*", "$1", "http://gohugo.io/docs", nil, "gohugo.io"}, {"^https?://([^/]+).*", "$2", "http://gohugo.io/docs", nil, ""}, {"(ab)", "AB", "aabbaab", nil, "aABbaAB"}, {"(ab)", "AB", "aabbaab", []interface{}{1}, "aABbaab"}, // errors {"(ab", "AB", "aabb", nil, false}, // invalid re {tstNoStringer{}, "$2", "http://gohugo.io/docs", nil, false}, {"^https?://([^/]+).*", tstNoStringer{}, "http://gohugo.io/docs", nil, false}, {"^https?://([^/]+).*", "$2", tstNoStringer{}, nil, false}, } { var ( result string err error ) if len(test.n) > 0 { result, err = ns.ReplaceRE(test.pattern, test.repl, test.s, test.n...) } else { result, err = ns.ReplaceRE(test.pattern, test.repl, test.s) } if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil)) continue } c.Assert(err, qt.IsNil) c.Check(result, qt.Equals, test.expect) } }
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package strings import ( "testing" qt "github.com/frankban/quicktest" ) func TestFindRE(t *testing.T) { t.Parallel() c := qt.New(t) for _, test := range []struct { expr string content interface{} limit interface{} expect interface{} }{ {"[G|g]o", "Hugo is a static site generator written in Go.", 2, []string{"go", "Go"}}, {"[G|g]o", "Hugo is a static site generator written in Go.", -1, []string{"go", "Go"}}, {"[G|g]o", "Hugo is a static site generator written in Go.", 1, []string{"go"}}, {"[G|g]o", "Hugo is a static site generator written in Go.", "1", []string{"go"}}, {"[G|g]o", "Hugo is a static site generator written in Go.", nil, []string(nil)}, // errors {"[G|go", "Hugo is a static site generator written in Go.", nil, false}, {"[G|g]o", t, nil, false}, } { result, err := ns.FindRE(test.expr, test.content, test.limit) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil)) continue } c.Assert(err, qt.IsNil) c.Check(result, qt.DeepEquals, test.expect) } } func TestReplaceRE(t *testing.T) { t.Parallel() c := qt.New(t) for _, test := range []struct { pattern interface{} repl interface{} s interface{} n []interface{} expect interface{} }{ {"^https?://([^/]+).*", "$1", "http://gohugo.io/docs", nil, "gohugo.io"}, {"^https?://([^/]+).*", "$2", "http://gohugo.io/docs", nil, ""}, {"(ab)", "AB", "aabbaab", nil, "aABbaAB"}, {"(ab)", "AB", "aabbaab", []interface{}{1}, "aABbaab"}, // errors {"(ab", "AB", "aabb", nil, false}, // invalid re {tstNoStringer{}, "$2", "http://gohugo.io/docs", nil, false}, {"^https?://([^/]+).*", tstNoStringer{}, "http://gohugo.io/docs", nil, false}, {"^https?://([^/]+).*", "$2", tstNoStringer{}, nil, false}, } { var ( result string err error ) if len(test.n) > 0 { result, err = ns.ReplaceRE(test.pattern, test.repl, test.s, test.n...) } else { result, err = ns.ReplaceRE(test.pattern, test.repl, test.s) } if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil)) continue } c.Assert(err, qt.IsNil) c.Check(result, qt.Equals, test.expect) } }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./hugofs/fileinfo.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package hugofs provides the file systems used by Hugo. package hugofs import ( "os" "path/filepath" "runtime" "sort" "strings" "time" "github.com/gohugoio/hugo/hugofs/files" "golang.org/x/text/unicode/norm" "github.com/pkg/errors" "github.com/spf13/cast" "github.com/gohugoio/hugo/common/hreflect" "github.com/spf13/afero" ) const ( metaKeyFilename = "filename" metaKeySourceRoot = "sourceRoot" metaKeyBaseDir = "baseDir" // Abs base directory of source file. metaKeyMountRoot = "mountRoot" metaKeyModule = "module" metaKeyOriginalFilename = "originalFilename" metaKeyName = "name" metaKeyPath = "path" metaKeyPathWalk = "pathWalk" metaKeyLang = "lang" metaKeyWeight = "weight" metaKeyOrdinal = "ordinal" metaKeyFs = "fs" metaKeyOpener = "opener" metaKeyIsOrdered = "isOrdered" metaKeyIsSymlink = "isSymlink" metaKeyJoinStat = "joinStat" metaKeySkipDir = "skipDir" metaKeyClassifier = "classifier" metaKeyTranslationBaseName = "translationBaseName" metaKeyTranslationBaseNameWithExt = "translationBaseNameWithExt" metaKeyTranslations = "translations" metaKeyDecoraterPath = "decoratorPath" ) type FileMeta map[string]interface{} func (f FileMeta) GetInt(key string) int { return cast.ToInt(f[key]) } func (f FileMeta) GetString(key string) string { return cast.ToString(f[key]) } func (f FileMeta) GetBool(key string) bool { return cast.ToBool(f[key]) } func (f FileMeta) Filename() string { return f.stringV(metaKeyFilename) } func (f FileMeta) OriginalFilename() string { return f.stringV(metaKeyOriginalFilename) } func (f FileMeta) SkipDir() bool { return f.GetBool(metaKeySkipDir) } func (f FileMeta) TranslationBaseName() string { return f.stringV(metaKeyTranslationBaseName) } func (f FileMeta) TranslationBaseNameWithExt() string { return f.stringV(metaKeyTranslationBaseNameWithExt) } func (f FileMeta) Translations() []string { return cast.ToStringSlice(f[metaKeyTranslations]) } func (f FileMeta) Name() string { return f.stringV(metaKeyName) } func (f FileMeta) Classifier() files.ContentClass { c, found := f[metaKeyClassifier] if found { return c.(files.ContentClass) } return files.ContentClassFile // For sorting } func (f FileMeta) Lang() string { return f.stringV(metaKeyLang) } // Path returns the relative file path to where this file is mounted. func (f FileMeta) Path() string { return f.stringV(metaKeyPath) } // PathFile returns the relative file path for the file source. func (f FileMeta) PathFile() string { base := f.stringV(metaKeyBaseDir) if base == "" { return "" } return strings.TrimPrefix(strings.TrimPrefix(f.Filename(), base), filepathSeparator) } func (f FileMeta) SourceRoot() string { return f.stringV(metaKeySourceRoot) } func (f FileMeta) MountRoot() string { return f.stringV(metaKeyMountRoot) } func (f FileMeta) Module() string { return f.stringV(metaKeyModule) } func (f FileMeta) Weight() int { return f.GetInt(metaKeyWeight) } func (f FileMeta) Ordinal() int { return f.GetInt(metaKeyOrdinal) } func (f FileMeta) IsOrdered() bool { return f.GetBool(metaKeyIsOrdered) } // IsSymlink returns whether this comes from a symlinked file or directory. func (f FileMeta) IsSymlink() bool { return f.GetBool(metaKeyIsSymlink) } func (f FileMeta) Watch() bool { if v, found := f["watch"]; found { return v.(bool) } return false } func (f FileMeta) Fs() afero.Fs { if v, found := f[metaKeyFs]; found { return v.(afero.Fs) } return nil } func (f FileMeta) GetOpener() func() (afero.File, error) { o, found := f[metaKeyOpener] if !found { return nil } return o.(func() (afero.File, error)) } func (f FileMeta) Open() (afero.File, error) { v, found := f[metaKeyOpener] if !found { return nil, errors.New("file opener not found") } return v.(func() (afero.File, error))() } func (f FileMeta) JoinStat(name string) (FileMetaInfo, error) { v, found := f[metaKeyJoinStat] if !found { return nil, os.ErrNotExist } return v.(func(name string) (FileMetaInfo, error))(name) } func (f FileMeta) stringV(key string) string { if v, found := f[key]; found { return v.(string) } return "" } func (f FileMeta) setIfNotZero(key string, val interface{}) { if !hreflect.IsTruthful(val) { return } f[key] = val } type FileMetaInfo interface { os.FileInfo Meta() FileMeta } type fileInfoMeta struct { os.FileInfo m FileMeta } // Name returns the file's name. Note that we follow symlinks, // if supported by the file system, and the Name given here will be the // name of the symlink, which is what Hugo needs in all situations. func (fi *fileInfoMeta) Name() string { if name := fi.m.Name(); name != "" { return name } return fi.FileInfo.Name() } func (fi *fileInfoMeta) Meta() FileMeta { return fi.m } func NewFileMetaInfo(fi os.FileInfo, m FileMeta) FileMetaInfo { if fim, ok := fi.(FileMetaInfo); ok { mergeFileMeta(fim.Meta(), m) } return &fileInfoMeta{FileInfo: fi, m: m} } func copyFileMeta(m FileMeta) FileMeta { c := make(FileMeta) for k, v := range m { c[k] = v } return c } // Merge metadata, last entry wins. func mergeFileMeta(from, to FileMeta) { if from == nil { return } for k, v := range from { if _, found := to[k]; !found { to[k] = v } } } type dirNameOnlyFileInfo struct { name string } func (fi *dirNameOnlyFileInfo) Name() string { return fi.name } func (fi *dirNameOnlyFileInfo) Size() int64 { panic("not implemented") } func (fi *dirNameOnlyFileInfo) Mode() os.FileMode { return os.ModeDir } func (fi *dirNameOnlyFileInfo) ModTime() time.Time { return time.Time{} } func (fi *dirNameOnlyFileInfo) IsDir() bool { return true } func (fi *dirNameOnlyFileInfo) Sys() interface{} { return nil } func newDirNameOnlyFileInfo(name string, meta FileMeta, fileOpener func() (afero.File, error)) FileMetaInfo { name = normalizeFilename(name) _, base := filepath.Split(name) m := copyFileMeta(meta) if _, found := m[metaKeyFilename]; !found { m.setIfNotZero(metaKeyFilename, name) } m[metaKeyOpener] = fileOpener m[metaKeyIsOrdered] = false return NewFileMetaInfo( &dirNameOnlyFileInfo{name: base}, m, ) } func decorateFileInfo( fi os.FileInfo, fs afero.Fs, opener func() (afero.File, error), filename, filepath string, inMeta FileMeta) FileMetaInfo { var meta FileMeta var fim FileMetaInfo filepath = strings.TrimPrefix(filepath, filepathSeparator) var ok bool if fim, ok = fi.(FileMetaInfo); ok { meta = fim.Meta() } else { meta = make(FileMeta) fim = NewFileMetaInfo(fi, meta) } meta.setIfNotZero(metaKeyOpener, opener) meta.setIfNotZero(metaKeyFs, fs) meta.setIfNotZero(metaKeyPath, normalizeFilename(filepath)) meta.setIfNotZero(metaKeyFilename, normalizeFilename(filename)) mergeFileMeta(inMeta, meta) return fim } func isSymlink(fi os.FileInfo) bool { return fi != nil && fi.Mode()&os.ModeSymlink == os.ModeSymlink } func fileInfosToFileMetaInfos(fis []os.FileInfo) []FileMetaInfo { fims := make([]FileMetaInfo, len(fis)) for i, v := range fis { fims[i] = v.(FileMetaInfo) } return fims } func normalizeFilename(filename string) string { if filename == "" { return "" } if runtime.GOOS == "darwin" { // When a file system is HFS+, its filepath is in NFD form. return norm.NFC.String(filename) } return filename } func fileInfosToNames(fis []os.FileInfo) []string { names := make([]string, len(fis)) for i, d := range fis { names[i] = d.Name() } return names } func fromSlash(filenames []string) []string { for i, name := range filenames { filenames[i] = filepath.FromSlash(name) } return filenames } func sortFileInfos(fis []os.FileInfo) { sort.Slice(fis, func(i, j int) bool { fimi, fimj := fis[i].(FileMetaInfo), fis[j].(FileMetaInfo) return fimi.Meta().Filename() < fimj.Meta().Filename() }) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package hugofs provides the file systems used by Hugo. package hugofs import ( "os" "path/filepath" "runtime" "sort" "strings" "time" "github.com/gohugoio/hugo/hugofs/files" "golang.org/x/text/unicode/norm" "github.com/pkg/errors" "github.com/spf13/cast" "github.com/gohugoio/hugo/common/hreflect" "github.com/spf13/afero" ) const ( metaKeyFilename = "filename" metaKeySourceRoot = "sourceRoot" metaKeyBaseDir = "baseDir" // Abs base directory of source file. metaKeyMountRoot = "mountRoot" metaKeyModule = "module" metaKeyOriginalFilename = "originalFilename" metaKeyName = "name" metaKeyPath = "path" metaKeyPathWalk = "pathWalk" metaKeyLang = "lang" metaKeyWeight = "weight" metaKeyOrdinal = "ordinal" metaKeyFs = "fs" metaKeyOpener = "opener" metaKeyIsOrdered = "isOrdered" metaKeyIsSymlink = "isSymlink" metaKeyJoinStat = "joinStat" metaKeySkipDir = "skipDir" metaKeyClassifier = "classifier" metaKeyTranslationBaseName = "translationBaseName" metaKeyTranslationBaseNameWithExt = "translationBaseNameWithExt" metaKeyTranslations = "translations" metaKeyDecoraterPath = "decoratorPath" ) type FileMeta map[string]interface{} func (f FileMeta) GetInt(key string) int { return cast.ToInt(f[key]) } func (f FileMeta) GetString(key string) string { return cast.ToString(f[key]) } func (f FileMeta) GetBool(key string) bool { return cast.ToBool(f[key]) } func (f FileMeta) Filename() string { return f.stringV(metaKeyFilename) } func (f FileMeta) OriginalFilename() string { return f.stringV(metaKeyOriginalFilename) } func (f FileMeta) SkipDir() bool { return f.GetBool(metaKeySkipDir) } func (f FileMeta) TranslationBaseName() string { return f.stringV(metaKeyTranslationBaseName) } func (f FileMeta) TranslationBaseNameWithExt() string { return f.stringV(metaKeyTranslationBaseNameWithExt) } func (f FileMeta) Translations() []string { return cast.ToStringSlice(f[metaKeyTranslations]) } func (f FileMeta) Name() string { return f.stringV(metaKeyName) } func (f FileMeta) Classifier() files.ContentClass { c, found := f[metaKeyClassifier] if found { return c.(files.ContentClass) } return files.ContentClassFile // For sorting } func (f FileMeta) Lang() string { return f.stringV(metaKeyLang) } // Path returns the relative file path to where this file is mounted. func (f FileMeta) Path() string { return f.stringV(metaKeyPath) } // PathFile returns the relative file path for the file source. func (f FileMeta) PathFile() string { base := f.stringV(metaKeyBaseDir) if base == "" { return "" } return strings.TrimPrefix(strings.TrimPrefix(f.Filename(), base), filepathSeparator) } func (f FileMeta) SourceRoot() string { return f.stringV(metaKeySourceRoot) } func (f FileMeta) MountRoot() string { return f.stringV(metaKeyMountRoot) } func (f FileMeta) Module() string { return f.stringV(metaKeyModule) } func (f FileMeta) Weight() int { return f.GetInt(metaKeyWeight) } func (f FileMeta) Ordinal() int { return f.GetInt(metaKeyOrdinal) } func (f FileMeta) IsOrdered() bool { return f.GetBool(metaKeyIsOrdered) } // IsSymlink returns whether this comes from a symlinked file or directory. func (f FileMeta) IsSymlink() bool { return f.GetBool(metaKeyIsSymlink) } func (f FileMeta) Watch() bool { if v, found := f["watch"]; found { return v.(bool) } return false } func (f FileMeta) Fs() afero.Fs { if v, found := f[metaKeyFs]; found { return v.(afero.Fs) } return nil } func (f FileMeta) GetOpener() func() (afero.File, error) { o, found := f[metaKeyOpener] if !found { return nil } return o.(func() (afero.File, error)) } func (f FileMeta) Open() (afero.File, error) { v, found := f[metaKeyOpener] if !found { return nil, errors.New("file opener not found") } return v.(func() (afero.File, error))() } func (f FileMeta) JoinStat(name string) (FileMetaInfo, error) { v, found := f[metaKeyJoinStat] if !found { return nil, os.ErrNotExist } return v.(func(name string) (FileMetaInfo, error))(name) } func (f FileMeta) stringV(key string) string { if v, found := f[key]; found { return v.(string) } return "" } func (f FileMeta) setIfNotZero(key string, val interface{}) { if !hreflect.IsTruthful(val) { return } f[key] = val } type FileMetaInfo interface { os.FileInfo Meta() FileMeta } type fileInfoMeta struct { os.FileInfo m FileMeta } // Name returns the file's name. Note that we follow symlinks, // if supported by the file system, and the Name given here will be the // name of the symlink, which is what Hugo needs in all situations. func (fi *fileInfoMeta) Name() string { if name := fi.m.Name(); name != "" { return name } return fi.FileInfo.Name() } func (fi *fileInfoMeta) Meta() FileMeta { return fi.m } func NewFileMetaInfo(fi os.FileInfo, m FileMeta) FileMetaInfo { if fim, ok := fi.(FileMetaInfo); ok { mergeFileMeta(fim.Meta(), m) } return &fileInfoMeta{FileInfo: fi, m: m} } func copyFileMeta(m FileMeta) FileMeta { c := make(FileMeta) for k, v := range m { c[k] = v } return c } // Merge metadata, last entry wins. func mergeFileMeta(from, to FileMeta) { if from == nil { return } for k, v := range from { if _, found := to[k]; !found { to[k] = v } } } type dirNameOnlyFileInfo struct { name string } func (fi *dirNameOnlyFileInfo) Name() string { return fi.name } func (fi *dirNameOnlyFileInfo) Size() int64 { panic("not implemented") } func (fi *dirNameOnlyFileInfo) Mode() os.FileMode { return os.ModeDir } func (fi *dirNameOnlyFileInfo) ModTime() time.Time { return time.Time{} } func (fi *dirNameOnlyFileInfo) IsDir() bool { return true } func (fi *dirNameOnlyFileInfo) Sys() interface{} { return nil } func newDirNameOnlyFileInfo(name string, meta FileMeta, fileOpener func() (afero.File, error)) FileMetaInfo { name = normalizeFilename(name) _, base := filepath.Split(name) m := copyFileMeta(meta) if _, found := m[metaKeyFilename]; !found { m.setIfNotZero(metaKeyFilename, name) } m[metaKeyOpener] = fileOpener m[metaKeyIsOrdered] = false return NewFileMetaInfo( &dirNameOnlyFileInfo{name: base}, m, ) } func decorateFileInfo( fi os.FileInfo, fs afero.Fs, opener func() (afero.File, error), filename, filepath string, inMeta FileMeta) FileMetaInfo { var meta FileMeta var fim FileMetaInfo filepath = strings.TrimPrefix(filepath, filepathSeparator) var ok bool if fim, ok = fi.(FileMetaInfo); ok { meta = fim.Meta() } else { meta = make(FileMeta) fim = NewFileMetaInfo(fi, meta) } meta.setIfNotZero(metaKeyOpener, opener) meta.setIfNotZero(metaKeyFs, fs) meta.setIfNotZero(metaKeyPath, normalizeFilename(filepath)) meta.setIfNotZero(metaKeyFilename, normalizeFilename(filename)) mergeFileMeta(inMeta, meta) return fim } func isSymlink(fi os.FileInfo) bool { return fi != nil && fi.Mode()&os.ModeSymlink == os.ModeSymlink } func fileInfosToFileMetaInfos(fis []os.FileInfo) []FileMetaInfo { fims := make([]FileMetaInfo, len(fis)) for i, v := range fis { fims[i] = v.(FileMetaInfo) } return fims } func normalizeFilename(filename string) string { if filename == "" { return "" } if runtime.GOOS == "darwin" { // When a file system is HFS+, its filepath is in NFD form. return norm.NFC.String(filename) } return filename } func fileInfosToNames(fis []os.FileInfo) []string { names := make([]string, len(fis)) for i, d := range fis { names[i] = d.Name() } return names } func fromSlash(filenames []string) []string { for i, name := range filenames { filenames[i] = filepath.FromSlash(name) } return filenames } func sortFileInfos(fis []os.FileInfo) { sort.Slice(fis, func(i, j int) bool { fimi, fimj := fis[i].(FileMetaInfo), fis[j].(FileMetaInfo) return fimi.Meta().Filename() < fimj.Meta().Filename() }) }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./hugolib/content_map.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "fmt" "path" "path/filepath" "strings" "sync" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/resources/page" "github.com/pkg/errors" "github.com/gohugoio/hugo/hugofs/files" "github.com/gohugoio/hugo/hugofs" radix "github.com/armon/go-radix" ) // We store the branch nodes in either the `sections` or `taxonomies` tree // with their path as a key; Unix style slashes, a leading and trailing slash. // // E.g. "/blog/" or "/categories/funny/" // // Pages that belongs to a section are stored in the `pages` tree below // the section name and a branch separator, e.g. "/blog/__hb_". A page is // given a key using the path below the section and the base filename with no extension // with a leaf separator added. // // For bundled pages (/mybundle/index.md), we use the folder name. // // An exmple of a full page key would be "/blog/__hb_page1__hl_" // // Bundled resources are stored in the `resources` having their path prefixed // with the bundle they belong to, e.g. // "/blog/__hb_bundle__hl_data.json". // // The weighted taxonomy entries extracted from page front matter are stored in // the `taxonomyEntries` tree below /plural/term/page-key, e.g. // "/categories/funny/blog/__hb_bundle__hl_". const ( cmBranchSeparator = "__hb_" cmLeafSeparator = "__hl_" ) // Used to mark ambiguous keys in reverse index lookups. var ambiguousContentNode = &contentNode{} func newContentMap(cfg contentMapConfig) *contentMap { m := &contentMap{ cfg: &cfg, pages: &contentTree{Name: "pages", Tree: radix.New()}, sections: &contentTree{Name: "sections", Tree: radix.New()}, taxonomies: &contentTree{Name: "taxonomies", Tree: radix.New()}, taxonomyEntries: &contentTree{Name: "taxonomyEntries", Tree: radix.New()}, resources: &contentTree{Name: "resources", Tree: radix.New()}, } m.pageTrees = []*contentTree{ m.pages, m.sections, m.taxonomies, } m.bundleTrees = []*contentTree{ m.pages, m.sections, m.taxonomies, m.resources, } m.branchTrees = []*contentTree{ m.sections, m.taxonomies, } addToReverseMap := func(k string, n *contentNode, m map[interface{}]*contentNode) { k = strings.ToLower(k) existing, found := m[k] if found && existing != ambiguousContentNode { m[k] = ambiguousContentNode } else if !found { m[k] = n } } m.pageReverseIndex = &contentTreeReverseIndex{ t: []*contentTree{m.pages, m.sections, m.taxonomies}, contentTreeReverseIndexMap: &contentTreeReverseIndexMap{ initFn: func(t *contentTree, m map[interface{}]*contentNode) { t.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) if n.p != nil && !n.p.File().IsZero() { meta := n.p.File().FileInfo().Meta() if meta.Path() != meta.PathFile() { // Keep track of the original mount source. mountKey := filepath.ToSlash(filepath.Join(meta.Module(), meta.PathFile())) addToReverseMap(mountKey, n, m) } } k := strings.TrimPrefix(strings.TrimSuffix(path.Base(s), cmLeafSeparator), cmBranchSeparator) addToReverseMap(k, n, m) return false }) }, }, } return m } type cmInsertKeyBuilder struct { m *contentMap err error // Builder state tree *contentTree baseKey string // Section or page key key string } func (b cmInsertKeyBuilder) ForPage(s string) *cmInsertKeyBuilder { // fmt.Println("ForPage:", s, "baseKey:", b.baseKey, "key:", b.key) baseKey := b.baseKey b.baseKey = s if baseKey != "/" { // Don't repeat the section path in the key. s = strings.TrimPrefix(s, baseKey) } s = strings.TrimPrefix(s, "/") switch b.tree { case b.m.sections: b.tree = b.m.pages b.key = baseKey + cmBranchSeparator + s + cmLeafSeparator case b.m.taxonomies: b.key = path.Join(baseKey, s) default: panic("invalid state") } return &b } func (b cmInsertKeyBuilder) ForResource(s string) *cmInsertKeyBuilder { // fmt.Println("ForResource:", s, "baseKey:", b.baseKey, "key:", b.key) baseKey := helpers.AddTrailingSlash(b.baseKey) s = strings.TrimPrefix(s, baseKey) switch b.tree { case b.m.pages: b.key = b.key + s case b.m.sections, b.m.taxonomies: b.key = b.key + cmLeafSeparator + s default: panic(fmt.Sprintf("invalid state: %#v", b.tree)) } b.tree = b.m.resources return &b } func (b *cmInsertKeyBuilder) Insert(n *contentNode) *cmInsertKeyBuilder { if b.err == nil { b.tree.Insert(b.Key(), n) } return b } func (b *cmInsertKeyBuilder) Key() string { switch b.tree { case b.m.sections, b.m.taxonomies: return cleanSectionTreeKey(b.key) default: return cleanTreeKey(b.key) } } func (b *cmInsertKeyBuilder) DeleteAll() *cmInsertKeyBuilder { if b.err == nil { b.tree.DeletePrefix(b.Key()) } return b } func (b *cmInsertKeyBuilder) WithFile(fi hugofs.FileMetaInfo) *cmInsertKeyBuilder { b.newTopLevel() m := b.m meta := fi.Meta() p := cleanTreeKey(meta.Path()) bundlePath := m.getBundleDir(meta) isBundle := meta.Classifier().IsBundle() if isBundle { panic("not implemented") } p, k := b.getBundle(p) if k == "" { b.err = errors.Errorf("no bundle header found for %q", bundlePath) return b } id := k + m.reduceKeyPart(p, fi.Meta().Path()) b.tree = b.m.resources b.key = id b.baseKey = p return b } func (b *cmInsertKeyBuilder) WithSection(s string) *cmInsertKeyBuilder { s = cleanSectionTreeKey(s) b.newTopLevel() b.tree = b.m.sections b.baseKey = s b.key = s return b } func (b *cmInsertKeyBuilder) WithTaxonomy(s string) *cmInsertKeyBuilder { s = cleanSectionTreeKey(s) b.newTopLevel() b.tree = b.m.taxonomies b.baseKey = s b.key = s return b } // getBundle gets both the key to the section and the prefix to where to store // this page bundle and its resources. func (b *cmInsertKeyBuilder) getBundle(s string) (string, string) { m := b.m section, _ := m.getSection(s) p := strings.TrimPrefix(s, section) bundlePathParts := strings.Split(p, "/") basePath := section + cmBranchSeparator // Put it into an existing bundle if found. for i := len(bundlePathParts) - 2; i >= 0; i-- { bundlePath := path.Join(bundlePathParts[:i]...) searchKey := basePath + bundlePath + cmLeafSeparator if _, found := m.pages.Get(searchKey); found { return section + bundlePath, searchKey } } // Put it into the section bundle. return section, section + cmLeafSeparator } func (b *cmInsertKeyBuilder) newTopLevel() { b.key = "" } type contentBundleViewInfo struct { ordinal int name viewName termKey string termOrigin string weight int ref *contentNode } func (c *contentBundleViewInfo) kind() string { if c.termKey != "" { return page.KindTerm } return page.KindTaxonomy } func (c *contentBundleViewInfo) sections() []string { if c.kind() == page.KindTaxonomy { return []string{c.name.plural} } return []string{c.name.plural, c.termKey} } func (c *contentBundleViewInfo) term() string { if c.termOrigin != "" { return c.termOrigin } return c.termKey } type contentMap struct { cfg *contentMapConfig // View of regular pages, sections, and taxonomies. pageTrees contentTrees // View of pages, sections, taxonomies, and resources. bundleTrees contentTrees // View of sections and taxonomies. branchTrees contentTrees // Stores page bundles keyed by its path's directory or the base filename, // e.g. "blog/post.md" => "/blog/post", "blog/post/index.md" => "/blog/post" // These are the "regular pages" and all of them are bundles. pages *contentTree // A reverse index used as a fallback in GetPage. // There are currently two cases where this is used: // 1. Short name lookups in ref/relRef, e.g. using only "mypage.md" without a path. // 2. Links resolved from a remounted content directory. These are restricted to the same module. // Both of the above cases can result in ambigous lookup errors. pageReverseIndex *contentTreeReverseIndex // Section nodes. sections *contentTree // Taxonomy nodes. taxonomies *contentTree // Pages in a taxonomy. taxonomyEntries *contentTree // Resources stored per bundle below a common prefix, e.g. "/blog/post__hb_". resources *contentTree } func (m *contentMap) AddFiles(fis ...hugofs.FileMetaInfo) error { for _, fi := range fis { if err := m.addFile(fi); err != nil { return err } } return nil } func (m *contentMap) AddFilesBundle(header hugofs.FileMetaInfo, resources ...hugofs.FileMetaInfo) error { var ( meta = header.Meta() classifier = meta.Classifier() isBranch = classifier == files.ContentClassBranch bundlePath = m.getBundleDir(meta) n = m.newContentNodeFromFi(header) b = m.newKeyBuilder() section string ) if isBranch { // Either a section or a taxonomy node. section = bundlePath if tc := m.cfg.getTaxonomyConfig(section); !tc.IsZero() { term := strings.TrimPrefix(strings.TrimPrefix(section, "/"+tc.plural), "/") n.viewInfo = &contentBundleViewInfo{ name: tc, termKey: term, termOrigin: term, } n.viewInfo.ref = n b.WithTaxonomy(section).Insert(n) } else { b.WithSection(section).Insert(n) } } else { // A regular page. Attach it to its section. section, _ = m.getOrCreateSection(n, bundlePath) b = b.WithSection(section).ForPage(bundlePath).Insert(n) } if m.cfg.isRebuild { // The resource owner will be either deleted or overwritten on rebuilds, // but make sure we handle deletion of resources (images etc.) as well. b.ForResource("").DeleteAll() } for _, r := range resources { rb := b.ForResource(cleanTreeKey(r.Meta().Path())) rb.Insert(&contentNode{fi: r}) } return nil } func (m *contentMap) CreateMissingNodes() error { // Create missing home and root sections rootSections := make(map[string]interface{}) trackRootSection := func(s string, b *contentNode) { parts := strings.Split(s, "/") if len(parts) > 2 { root := strings.TrimSuffix(parts[1], cmBranchSeparator) if root != "" { if _, found := rootSections[root]; !found { rootSections[root] = b } } } } m.sections.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) if s == "/" { return false } trackRootSection(s, n) return false }) m.pages.Walk(func(s string, v interface{}) bool { trackRootSection(s, v.(*contentNode)) return false }) if _, found := rootSections["/"]; !found { rootSections["/"] = true } for sect, v := range rootSections { var sectionPath string if n, ok := v.(*contentNode); ok && n.path != "" { sectionPath = n.path firstSlash := strings.Index(sectionPath, "/") if firstSlash != -1 { sectionPath = sectionPath[:firstSlash] } } sect = cleanSectionTreeKey(sect) _, found := m.sections.Get(sect) if !found { m.sections.Insert(sect, &contentNode{path: sectionPath}) } } for _, view := range m.cfg.taxonomyConfig { s := cleanSectionTreeKey(view.plural) _, found := m.taxonomies.Get(s) if !found { b := &contentNode{ viewInfo: &contentBundleViewInfo{ name: view, }, } b.viewInfo.ref = b m.taxonomies.Insert(s, b) } } return nil } func (m *contentMap) getBundleDir(meta hugofs.FileMeta) string { dir := cleanTreeKey(filepath.Dir(meta.Path())) switch meta.Classifier() { case files.ContentClassContent: return path.Join(dir, meta.TranslationBaseName()) default: return dir } } func (m *contentMap) newContentNodeFromFi(fi hugofs.FileMetaInfo) *contentNode { return &contentNode{ fi: fi, path: strings.TrimPrefix(filepath.ToSlash(fi.Meta().Path()), "/"), } } func (m *contentMap) getFirstSection(s string) (string, *contentNode) { s = helpers.AddTrailingSlash(s) for { k, v, found := m.sections.LongestPrefix(s) if !found { return "", nil } if strings.Count(k, "/") <= 2 { return k, v.(*contentNode) } s = helpers.AddTrailingSlash(path.Dir(strings.TrimSuffix(s, "/"))) } } func (m *contentMap) newKeyBuilder() *cmInsertKeyBuilder { return &cmInsertKeyBuilder{m: m} } func (m *contentMap) getOrCreateSection(n *contentNode, s string) (string, *contentNode) { level := strings.Count(s, "/") k, b := m.getSection(s) mustCreate := false if k == "" { mustCreate = true } else if level > 1 && k == "/" { // We found the home section, but this page needs to be placed in // the root, e.g. "/blog", section. mustCreate = true } if mustCreate { k = cleanSectionTreeKey(s[:strings.Index(s[1:], "/")+1]) b = &contentNode{ path: n.rootSection(), } m.sections.Insert(k, b) } return k, b } func (m *contentMap) getPage(section, name string) *contentNode { section = helpers.AddTrailingSlash(section) key := section + cmBranchSeparator + name + cmLeafSeparator v, found := m.pages.Get(key) if found { return v.(*contentNode) } return nil } func (m *contentMap) getSection(s string) (string, *contentNode) { s = helpers.AddTrailingSlash(path.Dir(strings.TrimSuffix(s, "/"))) k, v, found := m.sections.LongestPrefix(s) if found { return k, v.(*contentNode) } return "", nil } func (m *contentMap) getTaxonomyParent(s string) (string, *contentNode) { s = helpers.AddTrailingSlash(path.Dir(strings.TrimSuffix(s, "/"))) k, v, found := m.taxonomies.LongestPrefix(s) if found { return k, v.(*contentNode) } v, found = m.sections.Get("/") if found { return s, v.(*contentNode) } return "", nil } func (m *contentMap) addFile(fi hugofs.FileMetaInfo) error { b := m.newKeyBuilder() return b.WithFile(fi).Insert(m.newContentNodeFromFi(fi)).err } func cleanTreeKey(k string) string { k = "/" + strings.ToLower(strings.Trim(path.Clean(filepath.ToSlash(k)), "./")) return k } func cleanSectionTreeKey(k string) string { k = cleanTreeKey(k) if k != "/" { k += "/" } return k } func (m *contentMap) onSameLevel(s1, s2 string) bool { return strings.Count(s1, "/") == strings.Count(s2, "/") } func (m *contentMap) deleteBundleMatching(matches func(b *contentNode) bool) { // Check sections first s := m.sections.getMatch(matches) if s != "" { m.deleteSectionByPath(s) return } s = m.pages.getMatch(matches) if s != "" { m.deletePage(s) return } s = m.resources.getMatch(matches) if s != "" { m.resources.Delete(s) } } // Deletes any empty root section that's not backed by a content file. func (m *contentMap) deleteOrphanSections() { var sectionsToDelete []string m.sections.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) if n.fi != nil { // Section may be empty, but is backed by a content file. return false } if s == "/" || strings.Count(s, "/") > 2 { return false } prefixBundle := s + cmBranchSeparator if !(m.sections.hasBelow(s) || m.pages.hasBelow(prefixBundle) || m.resources.hasBelow(prefixBundle)) { sectionsToDelete = append(sectionsToDelete, s) } return false }) for _, s := range sectionsToDelete { m.sections.Delete(s) } } func (m *contentMap) deletePage(s string) { m.pages.DeletePrefix(s) m.resources.DeletePrefix(s) } func (m *contentMap) deleteSectionByPath(s string) { if !strings.HasSuffix(s, "/") { panic("section must end with a slash") } if !strings.HasPrefix(s, "/") { panic("section must start with a slash") } m.sections.DeletePrefix(s) m.pages.DeletePrefix(s) m.resources.DeletePrefix(s) } func (m *contentMap) deletePageByPath(s string) { m.pages.Walk(func(s string, v interface{}) bool { fmt.Println("S", s) return false }) } func (m *contentMap) deleteTaxonomy(s string) { m.taxonomies.DeletePrefix(s) } func (m *contentMap) reduceKeyPart(dir, filename string) string { dir, filename = filepath.ToSlash(dir), filepath.ToSlash(filename) dir, filename = strings.TrimPrefix(dir, "/"), strings.TrimPrefix(filename, "/") return strings.TrimPrefix(strings.TrimPrefix(filename, dir), "/") } func (m *contentMap) splitKey(k string) []string { if k == "" || k == "/" { return nil } return strings.Split(k, "/")[1:] } func (m *contentMap) testDump() string { var sb strings.Builder for i, r := range []*contentTree{m.pages, m.sections, m.resources} { sb.WriteString(fmt.Sprintf("Tree %d:\n", i)) r.Walk(func(s string, v interface{}) bool { sb.WriteString("\t" + s + "\n") return false }) } for i, r := range []*contentTree{m.pages, m.sections} { r.Walk(func(s string, v interface{}) bool { c := v.(*contentNode) cpToString := func(c *contentNode) string { var sb strings.Builder if c.p != nil { sb.WriteString("|p:" + c.p.Title()) } if c.fi != nil { sb.WriteString("|f:" + filepath.ToSlash(c.fi.Meta().Path())) } return sb.String() } sb.WriteString(path.Join(m.cfg.lang, r.Name) + s + cpToString(c) + "\n") resourcesPrefix := s if i == 1 { resourcesPrefix += cmLeafSeparator m.pages.WalkPrefix(s+cmBranchSeparator, func(s string, v interface{}) bool { sb.WriteString("\t - P: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename()) + "\n") return false }) } m.resources.WalkPrefix(resourcesPrefix, func(s string, v interface{}) bool { sb.WriteString("\t - R: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename()) + "\n") return false }) return false }) } return sb.String() } type contentMapConfig struct { lang string taxonomyConfig []viewName taxonomyDisabled bool taxonomyTermDisabled bool pageDisabled bool isRebuild bool } func (cfg contentMapConfig) getTaxonomyConfig(s string) (v viewName) { s = strings.TrimPrefix(s, "/") if s == "" { return } for _, n := range cfg.taxonomyConfig { if strings.HasPrefix(s, n.plural) { return n } } return } type contentNode struct { p *pageState // Set for taxonomy nodes. viewInfo *contentBundleViewInfo // Set if source is a file. // We will soon get other sources. fi hugofs.FileMetaInfo // The source path. Unix slashes. No leading slash. path string } func (b *contentNode) rootSection() string { if b.path == "" { return "" } firstSlash := strings.Index(b.path, "/") if firstSlash == -1 { return b.path } return b.path[:firstSlash] } type contentTree struct { Name string *radix.Tree } type contentTrees []*contentTree func (t contentTrees) DeletePrefix(prefix string) int { var count int for _, tree := range t { tree.Walk(func(s string, v interface{}) bool { return false }) count += tree.DeletePrefix(prefix) } return count } type contentTreeNodeCallback func(s string, n *contentNode) bool func newContentTreeFilter(fn func(n *contentNode) bool) contentTreeNodeCallback { return func(s string, n *contentNode) bool { return fn(n) } } var ( contentTreeNoListAlwaysFilter = func(s string, n *contentNode) bool { if n.p == nil { return true } return n.p.m.noListAlways() } contentTreeNoRenderFilter = func(s string, n *contentNode) bool { if n.p == nil { return true } return n.p.m.noRender() } contentTreeNoLinkFilter = func(s string, n *contentNode) bool { if n.p == nil { return true } return n.p.m.noLink() } ) func (c *contentTree) WalkQuery(query pageMapQuery, walkFn contentTreeNodeCallback) { filter := query.Filter if filter == nil { filter = contentTreeNoListAlwaysFilter } if query.Prefix != "" { c.WalkBelow(query.Prefix, func(s string, v interface{}) bool { n := v.(*contentNode) if filter != nil && filter(s, n) { return false } return walkFn(s, n) }) return } c.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) if filter != nil && filter(s, n) { return false } return walkFn(s, n) }) } func (c contentTrees) WalkRenderable(fn contentTreeNodeCallback) { query := pageMapQuery{Filter: contentTreeNoRenderFilter} for _, tree := range c { tree.WalkQuery(query, fn) } } func (c contentTrees) WalkLinkable(fn contentTreeNodeCallback) { query := pageMapQuery{Filter: contentTreeNoLinkFilter} for _, tree := range c { tree.WalkQuery(query, fn) } } func (c contentTrees) Walk(fn contentTreeNodeCallback) { for _, tree := range c { tree.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) return fn(s, n) }) } } func (c contentTrees) WalkPrefix(prefix string, fn contentTreeNodeCallback) { for _, tree := range c { tree.WalkPrefix(prefix, func(s string, v interface{}) bool { n := v.(*contentNode) return fn(s, n) }) } } // WalkBelow walks the tree below the given prefix, i.e. it skips the // node with the given prefix as key. func (c *contentTree) WalkBelow(prefix string, fn radix.WalkFn) { c.Tree.WalkPrefix(prefix, func(s string, v interface{}) bool { if s == prefix { return false } return fn(s, v) }) } func (c *contentTree) getMatch(matches func(b *contentNode) bool) string { var match string c.Walk(func(s string, v interface{}) bool { n, ok := v.(*contentNode) if !ok { return false } if matches(n) { match = s return true } return false }) return match } func (c *contentTree) hasBelow(s1 string) bool { var t bool c.WalkBelow(s1, func(s2 string, v interface{}) bool { t = true return true }) return t } func (c *contentTree) printKeys() { c.Walk(func(s string, v interface{}) bool { fmt.Println(s) return false }) } func (c *contentTree) printKeysPrefix(prefix string) { c.WalkPrefix(prefix, func(s string, v interface{}) bool { fmt.Println(s) return false }) } // contentTreeRef points to a node in the given tree. type contentTreeRef struct { m *pageMap t *contentTree n *contentNode key string } func (c *contentTreeRef) getCurrentSection() (string, *contentNode) { if c.isSection() { return c.key, c.n } return c.getSection() } func (c *contentTreeRef) isSection() bool { return c.t == c.m.sections } func (c *contentTreeRef) getSection() (string, *contentNode) { if c.t == c.m.taxonomies { return c.m.getTaxonomyParent(c.key) } return c.m.getSection(c.key) } func (c *contentTreeRef) getPages() page.Pages { var pas page.Pages c.m.collectPages( pageMapQuery{ Prefix: c.key + cmBranchSeparator, Filter: c.n.p.m.getListFilter(true), }, func(c *contentNode) { pas = append(pas, c.p) }, ) page.SortByDefault(pas) return pas } func (c *contentTreeRef) getPagesRecursive() page.Pages { var pas page.Pages query := pageMapQuery{ Filter: c.n.p.m.getListFilter(true), } query.Prefix = c.key c.m.collectPages(query, func(c *contentNode) { pas = append(pas, c.p) }) page.SortByDefault(pas) return pas } func (c *contentTreeRef) getPagesAndSections() page.Pages { var pas page.Pages query := pageMapQuery{ Filter: c.n.p.m.getListFilter(true), Prefix: c.key, } c.m.collectPagesAndSections(query, func(c *contentNode) { pas = append(pas, c.p) }) page.SortByDefault(pas) return pas } func (c *contentTreeRef) getSections() page.Pages { var pas page.Pages query := pageMapQuery{ Filter: c.n.p.m.getListFilter(true), Prefix: c.key, } c.m.collectSections(query, func(c *contentNode) { pas = append(pas, c.p) }) page.SortByDefault(pas) return pas } type contentTreeReverseIndex struct { t []*contentTree *contentTreeReverseIndexMap } type contentTreeReverseIndexMap struct { m map[interface{}]*contentNode init sync.Once initFn func(*contentTree, map[interface{}]*contentNode) } func (c *contentTreeReverseIndex) Reset() { c.contentTreeReverseIndexMap = &contentTreeReverseIndexMap{ initFn: c.initFn, } } func (c *contentTreeReverseIndex) Get(key interface{}) *contentNode { c.init.Do(func() { c.m = make(map[interface{}]*contentNode) for _, tree := range c.t { c.initFn(tree, c.m) } }) return c.m[key] }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "fmt" "path" "path/filepath" "strings" "sync" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/resources/page" "github.com/pkg/errors" "github.com/gohugoio/hugo/hugofs/files" "github.com/gohugoio/hugo/hugofs" radix "github.com/armon/go-radix" ) // We store the branch nodes in either the `sections` or `taxonomies` tree // with their path as a key; Unix style slashes, a leading and trailing slash. // // E.g. "/blog/" or "/categories/funny/" // // Pages that belongs to a section are stored in the `pages` tree below // the section name and a branch separator, e.g. "/blog/__hb_". A page is // given a key using the path below the section and the base filename with no extension // with a leaf separator added. // // For bundled pages (/mybundle/index.md), we use the folder name. // // An exmple of a full page key would be "/blog/__hb_page1__hl_" // // Bundled resources are stored in the `resources` having their path prefixed // with the bundle they belong to, e.g. // "/blog/__hb_bundle__hl_data.json". // // The weighted taxonomy entries extracted from page front matter are stored in // the `taxonomyEntries` tree below /plural/term/page-key, e.g. // "/categories/funny/blog/__hb_bundle__hl_". const ( cmBranchSeparator = "__hb_" cmLeafSeparator = "__hl_" ) // Used to mark ambiguous keys in reverse index lookups. var ambiguousContentNode = &contentNode{} func newContentMap(cfg contentMapConfig) *contentMap { m := &contentMap{ cfg: &cfg, pages: &contentTree{Name: "pages", Tree: radix.New()}, sections: &contentTree{Name: "sections", Tree: radix.New()}, taxonomies: &contentTree{Name: "taxonomies", Tree: radix.New()}, taxonomyEntries: &contentTree{Name: "taxonomyEntries", Tree: radix.New()}, resources: &contentTree{Name: "resources", Tree: radix.New()}, } m.pageTrees = []*contentTree{ m.pages, m.sections, m.taxonomies, } m.bundleTrees = []*contentTree{ m.pages, m.sections, m.taxonomies, m.resources, } m.branchTrees = []*contentTree{ m.sections, m.taxonomies, } addToReverseMap := func(k string, n *contentNode, m map[interface{}]*contentNode) { k = strings.ToLower(k) existing, found := m[k] if found && existing != ambiguousContentNode { m[k] = ambiguousContentNode } else if !found { m[k] = n } } m.pageReverseIndex = &contentTreeReverseIndex{ t: []*contentTree{m.pages, m.sections, m.taxonomies}, contentTreeReverseIndexMap: &contentTreeReverseIndexMap{ initFn: func(t *contentTree, m map[interface{}]*contentNode) { t.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) if n.p != nil && !n.p.File().IsZero() { meta := n.p.File().FileInfo().Meta() if meta.Path() != meta.PathFile() { // Keep track of the original mount source. mountKey := filepath.ToSlash(filepath.Join(meta.Module(), meta.PathFile())) addToReverseMap(mountKey, n, m) } } k := strings.TrimPrefix(strings.TrimSuffix(path.Base(s), cmLeafSeparator), cmBranchSeparator) addToReverseMap(k, n, m) return false }) }, }, } return m } type cmInsertKeyBuilder struct { m *contentMap err error // Builder state tree *contentTree baseKey string // Section or page key key string } func (b cmInsertKeyBuilder) ForPage(s string) *cmInsertKeyBuilder { // fmt.Println("ForPage:", s, "baseKey:", b.baseKey, "key:", b.key) baseKey := b.baseKey b.baseKey = s if baseKey != "/" { // Don't repeat the section path in the key. s = strings.TrimPrefix(s, baseKey) } s = strings.TrimPrefix(s, "/") switch b.tree { case b.m.sections: b.tree = b.m.pages b.key = baseKey + cmBranchSeparator + s + cmLeafSeparator case b.m.taxonomies: b.key = path.Join(baseKey, s) default: panic("invalid state") } return &b } func (b cmInsertKeyBuilder) ForResource(s string) *cmInsertKeyBuilder { // fmt.Println("ForResource:", s, "baseKey:", b.baseKey, "key:", b.key) baseKey := helpers.AddTrailingSlash(b.baseKey) s = strings.TrimPrefix(s, baseKey) switch b.tree { case b.m.pages: b.key = b.key + s case b.m.sections, b.m.taxonomies: b.key = b.key + cmLeafSeparator + s default: panic(fmt.Sprintf("invalid state: %#v", b.tree)) } b.tree = b.m.resources return &b } func (b *cmInsertKeyBuilder) Insert(n *contentNode) *cmInsertKeyBuilder { if b.err == nil { b.tree.Insert(b.Key(), n) } return b } func (b *cmInsertKeyBuilder) Key() string { switch b.tree { case b.m.sections, b.m.taxonomies: return cleanSectionTreeKey(b.key) default: return cleanTreeKey(b.key) } } func (b *cmInsertKeyBuilder) DeleteAll() *cmInsertKeyBuilder { if b.err == nil { b.tree.DeletePrefix(b.Key()) } return b } func (b *cmInsertKeyBuilder) WithFile(fi hugofs.FileMetaInfo) *cmInsertKeyBuilder { b.newTopLevel() m := b.m meta := fi.Meta() p := cleanTreeKey(meta.Path()) bundlePath := m.getBundleDir(meta) isBundle := meta.Classifier().IsBundle() if isBundle { panic("not implemented") } p, k := b.getBundle(p) if k == "" { b.err = errors.Errorf("no bundle header found for %q", bundlePath) return b } id := k + m.reduceKeyPart(p, fi.Meta().Path()) b.tree = b.m.resources b.key = id b.baseKey = p return b } func (b *cmInsertKeyBuilder) WithSection(s string) *cmInsertKeyBuilder { s = cleanSectionTreeKey(s) b.newTopLevel() b.tree = b.m.sections b.baseKey = s b.key = s return b } func (b *cmInsertKeyBuilder) WithTaxonomy(s string) *cmInsertKeyBuilder { s = cleanSectionTreeKey(s) b.newTopLevel() b.tree = b.m.taxonomies b.baseKey = s b.key = s return b } // getBundle gets both the key to the section and the prefix to where to store // this page bundle and its resources. func (b *cmInsertKeyBuilder) getBundle(s string) (string, string) { m := b.m section, _ := m.getSection(s) p := strings.TrimPrefix(s, section) bundlePathParts := strings.Split(p, "/") basePath := section + cmBranchSeparator // Put it into an existing bundle if found. for i := len(bundlePathParts) - 2; i >= 0; i-- { bundlePath := path.Join(bundlePathParts[:i]...) searchKey := basePath + bundlePath + cmLeafSeparator if _, found := m.pages.Get(searchKey); found { return section + bundlePath, searchKey } } // Put it into the section bundle. return section, section + cmLeafSeparator } func (b *cmInsertKeyBuilder) newTopLevel() { b.key = "" } type contentBundleViewInfo struct { ordinal int name viewName termKey string termOrigin string weight int ref *contentNode } func (c *contentBundleViewInfo) kind() string { if c.termKey != "" { return page.KindTerm } return page.KindTaxonomy } func (c *contentBundleViewInfo) sections() []string { if c.kind() == page.KindTaxonomy { return []string{c.name.plural} } return []string{c.name.plural, c.termKey} } func (c *contentBundleViewInfo) term() string { if c.termOrigin != "" { return c.termOrigin } return c.termKey } type contentMap struct { cfg *contentMapConfig // View of regular pages, sections, and taxonomies. pageTrees contentTrees // View of pages, sections, taxonomies, and resources. bundleTrees contentTrees // View of sections and taxonomies. branchTrees contentTrees // Stores page bundles keyed by its path's directory or the base filename, // e.g. "blog/post.md" => "/blog/post", "blog/post/index.md" => "/blog/post" // These are the "regular pages" and all of them are bundles. pages *contentTree // A reverse index used as a fallback in GetPage. // There are currently two cases where this is used: // 1. Short name lookups in ref/relRef, e.g. using only "mypage.md" without a path. // 2. Links resolved from a remounted content directory. These are restricted to the same module. // Both of the above cases can result in ambigous lookup errors. pageReverseIndex *contentTreeReverseIndex // Section nodes. sections *contentTree // Taxonomy nodes. taxonomies *contentTree // Pages in a taxonomy. taxonomyEntries *contentTree // Resources stored per bundle below a common prefix, e.g. "/blog/post__hb_". resources *contentTree } func (m *contentMap) AddFiles(fis ...hugofs.FileMetaInfo) error { for _, fi := range fis { if err := m.addFile(fi); err != nil { return err } } return nil } func (m *contentMap) AddFilesBundle(header hugofs.FileMetaInfo, resources ...hugofs.FileMetaInfo) error { var ( meta = header.Meta() classifier = meta.Classifier() isBranch = classifier == files.ContentClassBranch bundlePath = m.getBundleDir(meta) n = m.newContentNodeFromFi(header) b = m.newKeyBuilder() section string ) if isBranch { // Either a section or a taxonomy node. section = bundlePath if tc := m.cfg.getTaxonomyConfig(section); !tc.IsZero() { term := strings.TrimPrefix(strings.TrimPrefix(section, "/"+tc.plural), "/") n.viewInfo = &contentBundleViewInfo{ name: tc, termKey: term, termOrigin: term, } n.viewInfo.ref = n b.WithTaxonomy(section).Insert(n) } else { b.WithSection(section).Insert(n) } } else { // A regular page. Attach it to its section. section, _ = m.getOrCreateSection(n, bundlePath) b = b.WithSection(section).ForPage(bundlePath).Insert(n) } if m.cfg.isRebuild { // The resource owner will be either deleted or overwritten on rebuilds, // but make sure we handle deletion of resources (images etc.) as well. b.ForResource("").DeleteAll() } for _, r := range resources { rb := b.ForResource(cleanTreeKey(r.Meta().Path())) rb.Insert(&contentNode{fi: r}) } return nil } func (m *contentMap) CreateMissingNodes() error { // Create missing home and root sections rootSections := make(map[string]interface{}) trackRootSection := func(s string, b *contentNode) { parts := strings.Split(s, "/") if len(parts) > 2 { root := strings.TrimSuffix(parts[1], cmBranchSeparator) if root != "" { if _, found := rootSections[root]; !found { rootSections[root] = b } } } } m.sections.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) if s == "/" { return false } trackRootSection(s, n) return false }) m.pages.Walk(func(s string, v interface{}) bool { trackRootSection(s, v.(*contentNode)) return false }) if _, found := rootSections["/"]; !found { rootSections["/"] = true } for sect, v := range rootSections { var sectionPath string if n, ok := v.(*contentNode); ok && n.path != "" { sectionPath = n.path firstSlash := strings.Index(sectionPath, "/") if firstSlash != -1 { sectionPath = sectionPath[:firstSlash] } } sect = cleanSectionTreeKey(sect) _, found := m.sections.Get(sect) if !found { m.sections.Insert(sect, &contentNode{path: sectionPath}) } } for _, view := range m.cfg.taxonomyConfig { s := cleanSectionTreeKey(view.plural) _, found := m.taxonomies.Get(s) if !found { b := &contentNode{ viewInfo: &contentBundleViewInfo{ name: view, }, } b.viewInfo.ref = b m.taxonomies.Insert(s, b) } } return nil } func (m *contentMap) getBundleDir(meta hugofs.FileMeta) string { dir := cleanTreeKey(filepath.Dir(meta.Path())) switch meta.Classifier() { case files.ContentClassContent: return path.Join(dir, meta.TranslationBaseName()) default: return dir } } func (m *contentMap) newContentNodeFromFi(fi hugofs.FileMetaInfo) *contentNode { return &contentNode{ fi: fi, path: strings.TrimPrefix(filepath.ToSlash(fi.Meta().Path()), "/"), } } func (m *contentMap) getFirstSection(s string) (string, *contentNode) { s = helpers.AddTrailingSlash(s) for { k, v, found := m.sections.LongestPrefix(s) if !found { return "", nil } if strings.Count(k, "/") <= 2 { return k, v.(*contentNode) } s = helpers.AddTrailingSlash(path.Dir(strings.TrimSuffix(s, "/"))) } } func (m *contentMap) newKeyBuilder() *cmInsertKeyBuilder { return &cmInsertKeyBuilder{m: m} } func (m *contentMap) getOrCreateSection(n *contentNode, s string) (string, *contentNode) { level := strings.Count(s, "/") k, b := m.getSection(s) mustCreate := false if k == "" { mustCreate = true } else if level > 1 && k == "/" { // We found the home section, but this page needs to be placed in // the root, e.g. "/blog", section. mustCreate = true } if mustCreate { k = cleanSectionTreeKey(s[:strings.Index(s[1:], "/")+1]) b = &contentNode{ path: n.rootSection(), } m.sections.Insert(k, b) } return k, b } func (m *contentMap) getPage(section, name string) *contentNode { section = helpers.AddTrailingSlash(section) key := section + cmBranchSeparator + name + cmLeafSeparator v, found := m.pages.Get(key) if found { return v.(*contentNode) } return nil } func (m *contentMap) getSection(s string) (string, *contentNode) { s = helpers.AddTrailingSlash(path.Dir(strings.TrimSuffix(s, "/"))) k, v, found := m.sections.LongestPrefix(s) if found { return k, v.(*contentNode) } return "", nil } func (m *contentMap) getTaxonomyParent(s string) (string, *contentNode) { s = helpers.AddTrailingSlash(path.Dir(strings.TrimSuffix(s, "/"))) k, v, found := m.taxonomies.LongestPrefix(s) if found { return k, v.(*contentNode) } v, found = m.sections.Get("/") if found { return s, v.(*contentNode) } return "", nil } func (m *contentMap) addFile(fi hugofs.FileMetaInfo) error { b := m.newKeyBuilder() return b.WithFile(fi).Insert(m.newContentNodeFromFi(fi)).err } func cleanTreeKey(k string) string { k = "/" + strings.ToLower(strings.Trim(path.Clean(filepath.ToSlash(k)), "./")) return k } func cleanSectionTreeKey(k string) string { k = cleanTreeKey(k) if k != "/" { k += "/" } return k } func (m *contentMap) onSameLevel(s1, s2 string) bool { return strings.Count(s1, "/") == strings.Count(s2, "/") } func (m *contentMap) deleteBundleMatching(matches func(b *contentNode) bool) { // Check sections first s := m.sections.getMatch(matches) if s != "" { m.deleteSectionByPath(s) return } s = m.pages.getMatch(matches) if s != "" { m.deletePage(s) return } s = m.resources.getMatch(matches) if s != "" { m.resources.Delete(s) } } // Deletes any empty root section that's not backed by a content file. func (m *contentMap) deleteOrphanSections() { var sectionsToDelete []string m.sections.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) if n.fi != nil { // Section may be empty, but is backed by a content file. return false } if s == "/" || strings.Count(s, "/") > 2 { return false } prefixBundle := s + cmBranchSeparator if !(m.sections.hasBelow(s) || m.pages.hasBelow(prefixBundle) || m.resources.hasBelow(prefixBundle)) { sectionsToDelete = append(sectionsToDelete, s) } return false }) for _, s := range sectionsToDelete { m.sections.Delete(s) } } func (m *contentMap) deletePage(s string) { m.pages.DeletePrefix(s) m.resources.DeletePrefix(s) } func (m *contentMap) deleteSectionByPath(s string) { if !strings.HasSuffix(s, "/") { panic("section must end with a slash") } if !strings.HasPrefix(s, "/") { panic("section must start with a slash") } m.sections.DeletePrefix(s) m.pages.DeletePrefix(s) m.resources.DeletePrefix(s) } func (m *contentMap) deletePageByPath(s string) { m.pages.Walk(func(s string, v interface{}) bool { fmt.Println("S", s) return false }) } func (m *contentMap) deleteTaxonomy(s string) { m.taxonomies.DeletePrefix(s) } func (m *contentMap) reduceKeyPart(dir, filename string) string { dir, filename = filepath.ToSlash(dir), filepath.ToSlash(filename) dir, filename = strings.TrimPrefix(dir, "/"), strings.TrimPrefix(filename, "/") return strings.TrimPrefix(strings.TrimPrefix(filename, dir), "/") } func (m *contentMap) splitKey(k string) []string { if k == "" || k == "/" { return nil } return strings.Split(k, "/")[1:] } func (m *contentMap) testDump() string { var sb strings.Builder for i, r := range []*contentTree{m.pages, m.sections, m.resources} { sb.WriteString(fmt.Sprintf("Tree %d:\n", i)) r.Walk(func(s string, v interface{}) bool { sb.WriteString("\t" + s + "\n") return false }) } for i, r := range []*contentTree{m.pages, m.sections} { r.Walk(func(s string, v interface{}) bool { c := v.(*contentNode) cpToString := func(c *contentNode) string { var sb strings.Builder if c.p != nil { sb.WriteString("|p:" + c.p.Title()) } if c.fi != nil { sb.WriteString("|f:" + filepath.ToSlash(c.fi.Meta().Path())) } return sb.String() } sb.WriteString(path.Join(m.cfg.lang, r.Name) + s + cpToString(c) + "\n") resourcesPrefix := s if i == 1 { resourcesPrefix += cmLeafSeparator m.pages.WalkPrefix(s+cmBranchSeparator, func(s string, v interface{}) bool { sb.WriteString("\t - P: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename()) + "\n") return false }) } m.resources.WalkPrefix(resourcesPrefix, func(s string, v interface{}) bool { sb.WriteString("\t - R: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename()) + "\n") return false }) return false }) } return sb.String() } type contentMapConfig struct { lang string taxonomyConfig []viewName taxonomyDisabled bool taxonomyTermDisabled bool pageDisabled bool isRebuild bool } func (cfg contentMapConfig) getTaxonomyConfig(s string) (v viewName) { s = strings.TrimPrefix(s, "/") if s == "" { return } for _, n := range cfg.taxonomyConfig { if strings.HasPrefix(s, n.plural) { return n } } return } type contentNode struct { p *pageState // Set for taxonomy nodes. viewInfo *contentBundleViewInfo // Set if source is a file. // We will soon get other sources. fi hugofs.FileMetaInfo // The source path. Unix slashes. No leading slash. path string } func (b *contentNode) rootSection() string { if b.path == "" { return "" } firstSlash := strings.Index(b.path, "/") if firstSlash == -1 { return b.path } return b.path[:firstSlash] } type contentTree struct { Name string *radix.Tree } type contentTrees []*contentTree func (t contentTrees) DeletePrefix(prefix string) int { var count int for _, tree := range t { tree.Walk(func(s string, v interface{}) bool { return false }) count += tree.DeletePrefix(prefix) } return count } type contentTreeNodeCallback func(s string, n *contentNode) bool func newContentTreeFilter(fn func(n *contentNode) bool) contentTreeNodeCallback { return func(s string, n *contentNode) bool { return fn(n) } } var ( contentTreeNoListAlwaysFilter = func(s string, n *contentNode) bool { if n.p == nil { return true } return n.p.m.noListAlways() } contentTreeNoRenderFilter = func(s string, n *contentNode) bool { if n.p == nil { return true } return n.p.m.noRender() } contentTreeNoLinkFilter = func(s string, n *contentNode) bool { if n.p == nil { return true } return n.p.m.noLink() } ) func (c *contentTree) WalkQuery(query pageMapQuery, walkFn contentTreeNodeCallback) { filter := query.Filter if filter == nil { filter = contentTreeNoListAlwaysFilter } if query.Prefix != "" { c.WalkBelow(query.Prefix, func(s string, v interface{}) bool { n := v.(*contentNode) if filter != nil && filter(s, n) { return false } return walkFn(s, n) }) return } c.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) if filter != nil && filter(s, n) { return false } return walkFn(s, n) }) } func (c contentTrees) WalkRenderable(fn contentTreeNodeCallback) { query := pageMapQuery{Filter: contentTreeNoRenderFilter} for _, tree := range c { tree.WalkQuery(query, fn) } } func (c contentTrees) WalkLinkable(fn contentTreeNodeCallback) { query := pageMapQuery{Filter: contentTreeNoLinkFilter} for _, tree := range c { tree.WalkQuery(query, fn) } } func (c contentTrees) Walk(fn contentTreeNodeCallback) { for _, tree := range c { tree.Walk(func(s string, v interface{}) bool { n := v.(*contentNode) return fn(s, n) }) } } func (c contentTrees) WalkPrefix(prefix string, fn contentTreeNodeCallback) { for _, tree := range c { tree.WalkPrefix(prefix, func(s string, v interface{}) bool { n := v.(*contentNode) return fn(s, n) }) } } // WalkBelow walks the tree below the given prefix, i.e. it skips the // node with the given prefix as key. func (c *contentTree) WalkBelow(prefix string, fn radix.WalkFn) { c.Tree.WalkPrefix(prefix, func(s string, v interface{}) bool { if s == prefix { return false } return fn(s, v) }) } func (c *contentTree) getMatch(matches func(b *contentNode) bool) string { var match string c.Walk(func(s string, v interface{}) bool { n, ok := v.(*contentNode) if !ok { return false } if matches(n) { match = s return true } return false }) return match } func (c *contentTree) hasBelow(s1 string) bool { var t bool c.WalkBelow(s1, func(s2 string, v interface{}) bool { t = true return true }) return t } func (c *contentTree) printKeys() { c.Walk(func(s string, v interface{}) bool { fmt.Println(s) return false }) } func (c *contentTree) printKeysPrefix(prefix string) { c.WalkPrefix(prefix, func(s string, v interface{}) bool { fmt.Println(s) return false }) } // contentTreeRef points to a node in the given tree. type contentTreeRef struct { m *pageMap t *contentTree n *contentNode key string } func (c *contentTreeRef) getCurrentSection() (string, *contentNode) { if c.isSection() { return c.key, c.n } return c.getSection() } func (c *contentTreeRef) isSection() bool { return c.t == c.m.sections } func (c *contentTreeRef) getSection() (string, *contentNode) { if c.t == c.m.taxonomies { return c.m.getTaxonomyParent(c.key) } return c.m.getSection(c.key) } func (c *contentTreeRef) getPages() page.Pages { var pas page.Pages c.m.collectPages( pageMapQuery{ Prefix: c.key + cmBranchSeparator, Filter: c.n.p.m.getListFilter(true), }, func(c *contentNode) { pas = append(pas, c.p) }, ) page.SortByDefault(pas) return pas } func (c *contentTreeRef) getPagesRecursive() page.Pages { var pas page.Pages query := pageMapQuery{ Filter: c.n.p.m.getListFilter(true), } query.Prefix = c.key c.m.collectPages(query, func(c *contentNode) { pas = append(pas, c.p) }) page.SortByDefault(pas) return pas } func (c *contentTreeRef) getPagesAndSections() page.Pages { var pas page.Pages query := pageMapQuery{ Filter: c.n.p.m.getListFilter(true), Prefix: c.key, } c.m.collectPagesAndSections(query, func(c *contentNode) { pas = append(pas, c.p) }) page.SortByDefault(pas) return pas } func (c *contentTreeRef) getSections() page.Pages { var pas page.Pages query := pageMapQuery{ Filter: c.n.p.m.getListFilter(true), Prefix: c.key, } c.m.collectSections(query, func(c *contentNode) { pas = append(pas, c.p) }) page.SortByDefault(pas) return pas } type contentTreeReverseIndex struct { t []*contentTree *contentTreeReverseIndexMap } type contentTreeReverseIndexMap struct { m map[interface{}]*contentNode init sync.Once initFn func(*contentTree, map[interface{}]*contentNode) } func (c *contentTreeReverseIndex) Reset() { c.contentTreeReverseIndexMap = &contentTreeReverseIndexMap{ initFn: c.initFn, } } func (c *contentTreeReverseIndex) Get(key interface{}) *contentNode { c.init.Do(func() { c.m = make(map[interface{}]*contentNode) for _, tree := range c.t { c.initFn(tree, c.m) } }) return c.m[key] }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./hugolib/pagecollections.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "fmt" "path" "path/filepath" "strings" "sync" "github.com/gohugoio/hugo/hugofs/files" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/resources/page" ) // PageCollections contains the page collections for a site. type PageCollections struct { pageMap *pageMap // Lazy initialized page collections pages *lazyPagesFactory regularPages *lazyPagesFactory allPages *lazyPagesFactory allRegularPages *lazyPagesFactory } // Pages returns all pages. // This is for the current language only. func (c *PageCollections) Pages() page.Pages { return c.pages.get() } // RegularPages returns all the regular pages. // This is for the current language only. func (c *PageCollections) RegularPages() page.Pages { return c.regularPages.get() } // AllPages returns all pages for all languages. func (c *PageCollections) AllPages() page.Pages { return c.allPages.get() } // AllPages returns all regular pages for all languages. func (c *PageCollections) AllRegularPages() page.Pages { return c.allRegularPages.get() } type lazyPagesFactory struct { pages page.Pages init sync.Once factory page.PagesFactory } func (l *lazyPagesFactory) get() page.Pages { l.init.Do(func() { l.pages = l.factory() }) return l.pages } func newLazyPagesFactory(factory page.PagesFactory) *lazyPagesFactory { return &lazyPagesFactory{factory: factory} } func newPageCollections(m *pageMap) *PageCollections { if m == nil { panic("must provide a pageMap") } c := &PageCollections{pageMap: m} c.pages = newLazyPagesFactory(func() page.Pages { return m.createListAllPages() }) c.regularPages = newLazyPagesFactory(func() page.Pages { return c.findPagesByKindIn(page.KindPage, c.pages.get()) }) return c } // This is an adapter func for the old API with Kind as first argument. // This is invoked when you do .Site.GetPage. We drop the Kind and fails // if there are more than 2 arguments, which would be ambiguous. func (c *PageCollections) getPageOldVersion(ref ...string) (page.Page, error) { var refs []string for _, r := range ref { // A common construct in the wild is // .Site.GetPage "home" "" or // .Site.GetPage "home" "/" if r != "" && r != "/" { refs = append(refs, r) } } var key string if len(refs) > 2 { // This was allowed in Hugo <= 0.44, but we cannot support this with the // new API. This should be the most unusual case. return nil, fmt.Errorf(`too many arguments to .Site.GetPage: %v. Use lookups on the form {{ .Site.GetPage "/posts/mypage-md" }}`, ref) } if len(refs) == 0 || refs[0] == page.KindHome { key = "/" } else if len(refs) == 1 { if len(ref) == 2 && refs[0] == page.KindSection { // This is an old style reference to the "Home Page section". // Typically fetched via {{ .Site.GetPage "section" .Section }} // See https://github.com/gohugoio/hugo/issues/4989 key = "/" } else { key = refs[0] } } else { key = refs[1] } key = filepath.ToSlash(key) if !strings.HasPrefix(key, "/") { key = "/" + key } return c.getPageNew(nil, key) } // Only used in tests. func (c *PageCollections) getPage(typ string, sections ...string) page.Page { refs := append([]string{typ}, path.Join(sections...)) p, _ := c.getPageOldVersion(refs...) return p } // getPageRef resolves a Page from ref/relRef, with a slightly more comprehensive // search path than getPageNew. func (c *PageCollections) getPageRef(context page.Page, ref string) (page.Page, error) { n, err := c.getContentNode(context, true, ref) if err != nil || n == nil || n.p == nil { return nil, err } return n.p, nil } func (c *PageCollections) getPageNew(context page.Page, ref string) (page.Page, error) { n, err := c.getContentNode(context, false, ref) if err != nil || n == nil || n.p == nil { return nil, err } return n.p, nil } func (c *PageCollections) getSectionOrPage(ref string) (*contentNode, string) { var n *contentNode pref := helpers.AddTrailingSlash(ref) s, v, found := c.pageMap.sections.LongestPrefix(pref) if found { n = v.(*contentNode) } if found && s == pref { // A section return n, "" } m := c.pageMap filename := strings.TrimPrefix(strings.TrimPrefix(ref, s), "/") langSuffix := "." + m.s.Lang() // Trim both extension and any language code. name := helpers.PathNoExt(filename) name = strings.TrimSuffix(name, langSuffix) // These are reserved bundle names and will always be stored by their owning // folder name. name = strings.TrimSuffix(name, "/index") name = strings.TrimSuffix(name, "/_index") if !found { return nil, name } // Check if it's a section with filename provided. if !n.p.File().IsZero() && n.p.File().LogicalName() == filename { return n, name } return m.getPage(s, name), name } // For Ref/Reflink and .Site.GetPage do simple name lookups for the potentially ambigous myarticle.md and /myarticle.md, // but not when we get ./myarticle*, section/myarticle. func shouldDoSimpleLookup(ref string) bool { if ref[0] == '.' { return false } slashCount := strings.Count(ref, "/") if slashCount > 1 { return false } return slashCount == 0 || ref[0] == '/' } func (c *PageCollections) getContentNode(context page.Page, isReflink bool, ref string) (*contentNode, error) { ref = filepath.ToSlash(strings.ToLower(strings.TrimSpace(ref))) if ref == "" { ref = "/" } inRef := ref navUp := strings.HasPrefix(ref, "..") var doSimpleLookup bool if isReflink || context == nil { doSimpleLookup = shouldDoSimpleLookup(ref) } if context != nil && !strings.HasPrefix(ref, "/") { // Try the page-relative path. var base string if context.File().IsZero() { base = context.SectionsPath() } else { meta := context.File().FileInfo().Meta() base = filepath.ToSlash(filepath.Dir(meta.Path())) if meta.Classifier() == files.ContentClassLeaf { // Bundles are stored in subfolders e.g. blog/mybundle/index.md, // so if the user has not explicitly asked to go up, // look on the "blog" level. if !navUp { base = path.Dir(base) } } } ref = path.Join("/", strings.ToLower(base), ref) } if !strings.HasPrefix(ref, "/") { ref = "/" + ref } m := c.pageMap // It's either a section, a page in a section or a taxonomy node. // Start with the most likely: n, name := c.getSectionOrPage(ref) if n != nil { return n, nil } if !strings.HasPrefix(inRef, "/") { // Many people will have "post/foo.md" in their content files. if n, _ := c.getSectionOrPage("/" + inRef); n != nil { return n, nil } } // Check if it's a taxonomy node pref := helpers.AddTrailingSlash(ref) s, v, found := m.taxonomies.LongestPrefix(pref) if found { if !m.onSameLevel(pref, s) { return nil, nil } return v.(*contentNode), nil } getByName := func(s string) (*contentNode, error) { n := m.pageReverseIndex.Get(s) if n != nil { if n == ambiguousContentNode { return nil, fmt.Errorf("page reference %q is ambiguous", ref) } return n, nil } return nil, nil } var module string if context != nil && !context.File().IsZero() { module = context.File().FileInfo().Meta().Module() } if module == "" && !c.pageMap.s.home.File().IsZero() { module = c.pageMap.s.home.File().FileInfo().Meta().Module() } if module != "" { n, err := getByName(module + ref) if err != nil { return nil, err } if n != nil { return n, nil } } if !doSimpleLookup { return nil, nil } // Ref/relref supports this potentially ambigous lookup. return getByName(path.Base(name)) } func (*PageCollections) findPagesByKindIn(kind string, inPages page.Pages) page.Pages { var pages page.Pages for _, p := range inPages { if p.Kind() == kind { pages = append(pages, p) } } return pages }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "fmt" "path" "path/filepath" "strings" "sync" "github.com/gohugoio/hugo/hugofs/files" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/resources/page" ) // PageCollections contains the page collections for a site. type PageCollections struct { pageMap *pageMap // Lazy initialized page collections pages *lazyPagesFactory regularPages *lazyPagesFactory allPages *lazyPagesFactory allRegularPages *lazyPagesFactory } // Pages returns all pages. // This is for the current language only. func (c *PageCollections) Pages() page.Pages { return c.pages.get() } // RegularPages returns all the regular pages. // This is for the current language only. func (c *PageCollections) RegularPages() page.Pages { return c.regularPages.get() } // AllPages returns all pages for all languages. func (c *PageCollections) AllPages() page.Pages { return c.allPages.get() } // AllPages returns all regular pages for all languages. func (c *PageCollections) AllRegularPages() page.Pages { return c.allRegularPages.get() } type lazyPagesFactory struct { pages page.Pages init sync.Once factory page.PagesFactory } func (l *lazyPagesFactory) get() page.Pages { l.init.Do(func() { l.pages = l.factory() }) return l.pages } func newLazyPagesFactory(factory page.PagesFactory) *lazyPagesFactory { return &lazyPagesFactory{factory: factory} } func newPageCollections(m *pageMap) *PageCollections { if m == nil { panic("must provide a pageMap") } c := &PageCollections{pageMap: m} c.pages = newLazyPagesFactory(func() page.Pages { return m.createListAllPages() }) c.regularPages = newLazyPagesFactory(func() page.Pages { return c.findPagesByKindIn(page.KindPage, c.pages.get()) }) return c } // This is an adapter func for the old API with Kind as first argument. // This is invoked when you do .Site.GetPage. We drop the Kind and fails // if there are more than 2 arguments, which would be ambiguous. func (c *PageCollections) getPageOldVersion(ref ...string) (page.Page, error) { var refs []string for _, r := range ref { // A common construct in the wild is // .Site.GetPage "home" "" or // .Site.GetPage "home" "/" if r != "" && r != "/" { refs = append(refs, r) } } var key string if len(refs) > 2 { // This was allowed in Hugo <= 0.44, but we cannot support this with the // new API. This should be the most unusual case. return nil, fmt.Errorf(`too many arguments to .Site.GetPage: %v. Use lookups on the form {{ .Site.GetPage "/posts/mypage-md" }}`, ref) } if len(refs) == 0 || refs[0] == page.KindHome { key = "/" } else if len(refs) == 1 { if len(ref) == 2 && refs[0] == page.KindSection { // This is an old style reference to the "Home Page section". // Typically fetched via {{ .Site.GetPage "section" .Section }} // See https://github.com/gohugoio/hugo/issues/4989 key = "/" } else { key = refs[0] } } else { key = refs[1] } key = filepath.ToSlash(key) if !strings.HasPrefix(key, "/") { key = "/" + key } return c.getPageNew(nil, key) } // Only used in tests. func (c *PageCollections) getPage(typ string, sections ...string) page.Page { refs := append([]string{typ}, path.Join(sections...)) p, _ := c.getPageOldVersion(refs...) return p } // getPageRef resolves a Page from ref/relRef, with a slightly more comprehensive // search path than getPageNew. func (c *PageCollections) getPageRef(context page.Page, ref string) (page.Page, error) { n, err := c.getContentNode(context, true, ref) if err != nil || n == nil || n.p == nil { return nil, err } return n.p, nil } func (c *PageCollections) getPageNew(context page.Page, ref string) (page.Page, error) { n, err := c.getContentNode(context, false, ref) if err != nil || n == nil || n.p == nil { return nil, err } return n.p, nil } func (c *PageCollections) getSectionOrPage(ref string) (*contentNode, string) { var n *contentNode pref := helpers.AddTrailingSlash(ref) s, v, found := c.pageMap.sections.LongestPrefix(pref) if found { n = v.(*contentNode) } if found && s == pref { // A section return n, "" } m := c.pageMap filename := strings.TrimPrefix(strings.TrimPrefix(ref, s), "/") langSuffix := "." + m.s.Lang() // Trim both extension and any language code. name := helpers.PathNoExt(filename) name = strings.TrimSuffix(name, langSuffix) // These are reserved bundle names and will always be stored by their owning // folder name. name = strings.TrimSuffix(name, "/index") name = strings.TrimSuffix(name, "/_index") if !found { return nil, name } // Check if it's a section with filename provided. if !n.p.File().IsZero() && n.p.File().LogicalName() == filename { return n, name } return m.getPage(s, name), name } // For Ref/Reflink and .Site.GetPage do simple name lookups for the potentially ambigous myarticle.md and /myarticle.md, // but not when we get ./myarticle*, section/myarticle. func shouldDoSimpleLookup(ref string) bool { if ref[0] == '.' { return false } slashCount := strings.Count(ref, "/") if slashCount > 1 { return false } return slashCount == 0 || ref[0] == '/' } func (c *PageCollections) getContentNode(context page.Page, isReflink bool, ref string) (*contentNode, error) { ref = filepath.ToSlash(strings.ToLower(strings.TrimSpace(ref))) if ref == "" { ref = "/" } inRef := ref navUp := strings.HasPrefix(ref, "..") var doSimpleLookup bool if isReflink || context == nil { doSimpleLookup = shouldDoSimpleLookup(ref) } if context != nil && !strings.HasPrefix(ref, "/") { // Try the page-relative path. var base string if context.File().IsZero() { base = context.SectionsPath() } else { meta := context.File().FileInfo().Meta() base = filepath.ToSlash(filepath.Dir(meta.Path())) if meta.Classifier() == files.ContentClassLeaf { // Bundles are stored in subfolders e.g. blog/mybundle/index.md, // so if the user has not explicitly asked to go up, // look on the "blog" level. if !navUp { base = path.Dir(base) } } } ref = path.Join("/", strings.ToLower(base), ref) } if !strings.HasPrefix(ref, "/") { ref = "/" + ref } m := c.pageMap // It's either a section, a page in a section or a taxonomy node. // Start with the most likely: n, name := c.getSectionOrPage(ref) if n != nil { return n, nil } if !strings.HasPrefix(inRef, "/") { // Many people will have "post/foo.md" in their content files. if n, _ := c.getSectionOrPage("/" + inRef); n != nil { return n, nil } } // Check if it's a taxonomy node pref := helpers.AddTrailingSlash(ref) s, v, found := m.taxonomies.LongestPrefix(pref) if found { if !m.onSameLevel(pref, s) { return nil, nil } return v.(*contentNode), nil } getByName := func(s string) (*contentNode, error) { n := m.pageReverseIndex.Get(s) if n != nil { if n == ambiguousContentNode { return nil, fmt.Errorf("page reference %q is ambiguous", ref) } return n, nil } return nil, nil } var module string if context != nil && !context.File().IsZero() { module = context.File().FileInfo().Meta().Module() } if module == "" && !c.pageMap.s.home.File().IsZero() { module = c.pageMap.s.home.File().FileInfo().Meta().Module() } if module != "" { n, err := getByName(module + ref) if err != nil { return nil, err } if n != nil { return n, nil } } if !doSimpleLookup { return nil, nil } // Ref/relref supports this potentially ambigous lookup. return getByName(path.Base(name)) } func (*PageCollections) findPagesByKindIn(kind string, inPages page.Pages) page.Pages { var pages page.Pages for _, p := range inPages { if p.Kind() == kind { pages = append(pages, p) } } return pages }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./langs/i18n/i18n_test.go
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package i18n import ( "fmt" "path/filepath" "testing" "github.com/gohugoio/hugo/modules" "github.com/gohugoio/hugo/tpl/tplimpl" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/langs" "github.com/gohugoio/hugo/resources/page" "github.com/spf13/afero" "github.com/spf13/viper" "github.com/gohugoio/hugo/deps" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/hugofs" ) var logger = loggers.NewErrorLogger() type i18nTest struct { name string data map[string][]byte args interface{} lang, id, expected, expectedFlag string } var i18nTests = []i18nTest{ // All translations present { name: "all-present", data: map[string][]byte{ "en.toml": []byte("[hello]\nother = \"Hello, World!\""), "es.toml": []byte("[hello]\nother = \"¡Hola, Mundo!\""), }, args: nil, lang: "es", id: "hello", expected: "¡Hola, Mundo!", expectedFlag: "¡Hola, Mundo!", }, // Translation missing in current language but present in default { name: "present-in-default", data: map[string][]byte{ "en.toml": []byte("[hello]\nother = \"Hello, World!\""), "es.toml": []byte("[goodbye]\nother = \"¡Adiós, Mundo!\""), }, args: nil, lang: "es", id: "hello", expected: "Hello, World!", expectedFlag: "[i18n] hello", }, // Translation missing in default language but present in current { name: "present-in-current", data: map[string][]byte{ "en.toml": []byte("[goodbye]\nother = \"Goodbye, World!\""), "es.toml": []byte("[hello]\nother = \"¡Hola, Mundo!\""), }, args: nil, lang: "es", id: "hello", expected: "¡Hola, Mundo!", expectedFlag: "¡Hola, Mundo!", }, // Translation missing in both default and current language { name: "missing", data: map[string][]byte{ "en.toml": []byte("[goodbye]\nother = \"Goodbye, World!\""), "es.toml": []byte("[goodbye]\nother = \"¡Adiós, Mundo!\""), }, args: nil, lang: "es", id: "hello", expected: "", expectedFlag: "[i18n] hello", }, // Default translation file missing or empty { name: "file-missing", data: map[string][]byte{ "en.toml": []byte(""), }, args: nil, lang: "es", id: "hello", expected: "", expectedFlag: "[i18n] hello", }, // Context provided { name: "context-provided", data: map[string][]byte{ "en.toml": []byte("[wordCount]\nother = \"Hello, {{.WordCount}} people!\""), "es.toml": []byte("[wordCount]\nother = \"¡Hola, {{.WordCount}} gente!\""), }, args: struct { WordCount int }{ 50, }, lang: "es", id: "wordCount", expected: "¡Hola, 50 gente!", expectedFlag: "¡Hola, 50 gente!", }, // https://github.com/gohugoio/hugo/issues/7787 { name: "readingTime-one", data: map[string][]byte{ "en.toml": []byte(`[readingTime] one = "One minute to read" other = "{{ .Count }} minutes to read" `), }, args: 1, lang: "en", id: "readingTime", expected: "One minute to read", expectedFlag: "One minute to read", }, { name: "readingTime-many", data: map[string][]byte{ "en.toml": []byte(`[readingTime] one = "One minute to read" other = "{{ .Count }} minutes to read" `), }, args: 21, lang: "en", id: "readingTime", expected: "21 minutes to read", expectedFlag: "21 minutes to read", }, // Same id and translation in current language // https://github.com/gohugoio/hugo/issues/2607 { name: "same-id-and-translation", data: map[string][]byte{ "es.toml": []byte("[hello]\nother = \"hello\""), "en.toml": []byte("[hello]\nother = \"hi\""), }, args: nil, lang: "es", id: "hello", expected: "hello", expectedFlag: "hello", }, // Translation missing in current language, but same id and translation in default { name: "same-id-and-translation-default", data: map[string][]byte{ "es.toml": []byte("[bye]\nother = \"bye\""), "en.toml": []byte("[hello]\nother = \"hello\""), }, args: nil, lang: "es", id: "hello", expected: "hello", expectedFlag: "[i18n] hello", }, // Unknown language code should get its plural spec from en { name: "unknown-language-code", data: map[string][]byte{ "en.toml": []byte(`[readingTime] one ="one minute read" other = "{{.Count}} minutes read"`), "klingon.toml": []byte(`[readingTime] one = "eitt minutt med lesing" other = "{{ .Count }} minuttar lesing"`), }, args: 3, lang: "klingon", id: "readingTime", expected: "3 minuttar lesing", expectedFlag: "3 minuttar lesing", }, // https://github.com/gohugoio/hugo/issues/7798 { name: "known-language-missing-plural", data: map[string][]byte{ "oc.toml": []byte(`[oc] one = "abc"`), }, args: 1, lang: "oc", id: "oc", expected: "abc", expectedFlag: "abc", }, // https://github.com/gohugoio/hugo/issues/7794 { name: "dotted-bare-key", data: map[string][]byte{ "en.toml": []byte(`"shop_nextPage.one" = "Show Me The Money" `), }, args: nil, lang: "en", id: "shop_nextPage.one", expected: "Show Me The Money", expectedFlag: "Show Me The Money", }, // https: //github.com/gohugoio/hugo/issues/7804 { name: "lang-with-hyphen", data: map[string][]byte{ "pt-br.toml": []byte(`foo.one = "abc"`), }, args: 1, lang: "pt-br", id: "foo", expected: "abc", expectedFlag: "abc", }, } func doTestI18nTranslate(t testing.TB, test i18nTest, cfg config.Provider) string { tp := prepareTranslationProvider(t, test, cfg) f := tp.t.Func(test.lang) return f(test.id, test.args) } func prepareTranslationProvider(t testing.TB, test i18nTest, cfg config.Provider) *TranslationProvider { c := qt.New(t) fs := hugofs.NewMem(cfg) for file, content := range test.data { err := afero.WriteFile(fs.Source, filepath.Join("i18n", file), []byte(content), 0755) c.Assert(err, qt.IsNil) } tp := NewTranslationProvider() depsCfg := newDepsConfig(tp, cfg, fs) d, err := deps.New(depsCfg) c.Assert(err, qt.IsNil) c.Assert(d.LoadResources(), qt.IsNil) return tp } func newDepsConfig(tp *TranslationProvider, cfg config.Provider, fs *hugofs.Fs) deps.DepsCfg { l := langs.NewLanguage("en", cfg) l.Set("i18nDir", "i18n") return deps.DepsCfg{ Language: l, Site: page.NewDummyHugoSite(cfg), Cfg: cfg, Fs: fs, Logger: logger, TemplateProvider: tplimpl.DefaultTemplateProvider, TranslationProvider: tp, } } func getConfig() *viper.Viper { v := viper.New() v.SetDefault("defaultContentLanguage", "en") v.Set("contentDir", "content") v.Set("dataDir", "data") v.Set("i18nDir", "i18n") v.Set("layoutDir", "layouts") v.Set("archetypeDir", "archetypes") v.Set("assetDir", "assets") v.Set("resourceDir", "resources") v.Set("publishDir", "public") langs.LoadLanguageSettings(v, nil) mod, err := modules.CreateProjectModule(v) if err != nil { panic(err) } v.Set("allModules", modules.Modules{mod}) return v } func TestI18nTranslate(t *testing.T) { c := qt.New(t) var actual, expected string v := getConfig() // Test without and with placeholders for _, enablePlaceholders := range []bool{false, true} { v.Set("enableMissingTranslationPlaceholders", enablePlaceholders) for _, test := range i18nTests { c.Run(fmt.Sprintf("%s-%t", test.name, enablePlaceholders), func(c *qt.C) { if enablePlaceholders { expected = test.expectedFlag } else { expected = test.expected } actual = doTestI18nTranslate(c, test, v) c.Assert(actual, qt.Equals, expected) }) } } } func BenchmarkI18nTranslate(b *testing.B) { v := getConfig() for _, test := range i18nTests { b.Run(test.name, func(b *testing.B) { tp := prepareTranslationProvider(b, test, v) b.ResetTimer() for i := 0; i < b.N; i++ { f := tp.t.Func(test.lang) actual := f(test.id, test.args) if actual != test.expected { b.Fatalf("expected %v got %v", test.expected, actual) } } }) } }
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package i18n import ( "fmt" "path/filepath" "testing" "github.com/gohugoio/hugo/modules" "github.com/gohugoio/hugo/tpl/tplimpl" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/langs" "github.com/gohugoio/hugo/resources/page" "github.com/spf13/afero" "github.com/spf13/viper" "github.com/gohugoio/hugo/deps" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/hugofs" ) var logger = loggers.NewErrorLogger() type i18nTest struct { name string data map[string][]byte args interface{} lang, id, expected, expectedFlag string } var i18nTests = []i18nTest{ // All translations present { name: "all-present", data: map[string][]byte{ "en.toml": []byte("[hello]\nother = \"Hello, World!\""), "es.toml": []byte("[hello]\nother = \"¡Hola, Mundo!\""), }, args: nil, lang: "es", id: "hello", expected: "¡Hola, Mundo!", expectedFlag: "¡Hola, Mundo!", }, // Translation missing in current language but present in default { name: "present-in-default", data: map[string][]byte{ "en.toml": []byte("[hello]\nother = \"Hello, World!\""), "es.toml": []byte("[goodbye]\nother = \"¡Adiós, Mundo!\""), }, args: nil, lang: "es", id: "hello", expected: "Hello, World!", expectedFlag: "[i18n] hello", }, // Translation missing in default language but present in current { name: "present-in-current", data: map[string][]byte{ "en.toml": []byte("[goodbye]\nother = \"Goodbye, World!\""), "es.toml": []byte("[hello]\nother = \"¡Hola, Mundo!\""), }, args: nil, lang: "es", id: "hello", expected: "¡Hola, Mundo!", expectedFlag: "¡Hola, Mundo!", }, // Translation missing in both default and current language { name: "missing", data: map[string][]byte{ "en.toml": []byte("[goodbye]\nother = \"Goodbye, World!\""), "es.toml": []byte("[goodbye]\nother = \"¡Adiós, Mundo!\""), }, args: nil, lang: "es", id: "hello", expected: "", expectedFlag: "[i18n] hello", }, // Default translation file missing or empty { name: "file-missing", data: map[string][]byte{ "en.toml": []byte(""), }, args: nil, lang: "es", id: "hello", expected: "", expectedFlag: "[i18n] hello", }, // Context provided { name: "context-provided", data: map[string][]byte{ "en.toml": []byte("[wordCount]\nother = \"Hello, {{.WordCount}} people!\""), "es.toml": []byte("[wordCount]\nother = \"¡Hola, {{.WordCount}} gente!\""), }, args: struct { WordCount int }{ 50, }, lang: "es", id: "wordCount", expected: "¡Hola, 50 gente!", expectedFlag: "¡Hola, 50 gente!", }, // https://github.com/gohugoio/hugo/issues/7787 { name: "readingTime-one", data: map[string][]byte{ "en.toml": []byte(`[readingTime] one = "One minute to read" other = "{{ .Count }} minutes to read" `), }, args: 1, lang: "en", id: "readingTime", expected: "One minute to read", expectedFlag: "One minute to read", }, { name: "readingTime-many", data: map[string][]byte{ "en.toml": []byte(`[readingTime] one = "One minute to read" other = "{{ .Count }} minutes to read" `), }, args: 21, lang: "en", id: "readingTime", expected: "21 minutes to read", expectedFlag: "21 minutes to read", }, // Same id and translation in current language // https://github.com/gohugoio/hugo/issues/2607 { name: "same-id-and-translation", data: map[string][]byte{ "es.toml": []byte("[hello]\nother = \"hello\""), "en.toml": []byte("[hello]\nother = \"hi\""), }, args: nil, lang: "es", id: "hello", expected: "hello", expectedFlag: "hello", }, // Translation missing in current language, but same id and translation in default { name: "same-id-and-translation-default", data: map[string][]byte{ "es.toml": []byte("[bye]\nother = \"bye\""), "en.toml": []byte("[hello]\nother = \"hello\""), }, args: nil, lang: "es", id: "hello", expected: "hello", expectedFlag: "[i18n] hello", }, // Unknown language code should get its plural spec from en { name: "unknown-language-code", data: map[string][]byte{ "en.toml": []byte(`[readingTime] one ="one minute read" other = "{{.Count}} minutes read"`), "klingon.toml": []byte(`[readingTime] one = "eitt minutt med lesing" other = "{{ .Count }} minuttar lesing"`), }, args: 3, lang: "klingon", id: "readingTime", expected: "3 minuttar lesing", expectedFlag: "3 minuttar lesing", }, // https://github.com/gohugoio/hugo/issues/7798 { name: "known-language-missing-plural", data: map[string][]byte{ "oc.toml": []byte(`[oc] one = "abc"`), }, args: 1, lang: "oc", id: "oc", expected: "abc", expectedFlag: "abc", }, // https://github.com/gohugoio/hugo/issues/7794 { name: "dotted-bare-key", data: map[string][]byte{ "en.toml": []byte(`"shop_nextPage.one" = "Show Me The Money" `), }, args: nil, lang: "en", id: "shop_nextPage.one", expected: "Show Me The Money", expectedFlag: "Show Me The Money", }, // https: //github.com/gohugoio/hugo/issues/7804 { name: "lang-with-hyphen", data: map[string][]byte{ "pt-br.toml": []byte(`foo.one = "abc"`), }, args: 1, lang: "pt-br", id: "foo", expected: "abc", expectedFlag: "abc", }, } func doTestI18nTranslate(t testing.TB, test i18nTest, cfg config.Provider) string { tp := prepareTranslationProvider(t, test, cfg) f := tp.t.Func(test.lang) return f(test.id, test.args) } func prepareTranslationProvider(t testing.TB, test i18nTest, cfg config.Provider) *TranslationProvider { c := qt.New(t) fs := hugofs.NewMem(cfg) for file, content := range test.data { err := afero.WriteFile(fs.Source, filepath.Join("i18n", file), []byte(content), 0755) c.Assert(err, qt.IsNil) } tp := NewTranslationProvider() depsCfg := newDepsConfig(tp, cfg, fs) d, err := deps.New(depsCfg) c.Assert(err, qt.IsNil) c.Assert(d.LoadResources(), qt.IsNil) return tp } func newDepsConfig(tp *TranslationProvider, cfg config.Provider, fs *hugofs.Fs) deps.DepsCfg { l := langs.NewLanguage("en", cfg) l.Set("i18nDir", "i18n") return deps.DepsCfg{ Language: l, Site: page.NewDummyHugoSite(cfg), Cfg: cfg, Fs: fs, Logger: logger, TemplateProvider: tplimpl.DefaultTemplateProvider, TranslationProvider: tp, } } func getConfig() *viper.Viper { v := viper.New() v.SetDefault("defaultContentLanguage", "en") v.Set("contentDir", "content") v.Set("dataDir", "data") v.Set("i18nDir", "i18n") v.Set("layoutDir", "layouts") v.Set("archetypeDir", "archetypes") v.Set("assetDir", "assets") v.Set("resourceDir", "resources") v.Set("publishDir", "public") langs.LoadLanguageSettings(v, nil) mod, err := modules.CreateProjectModule(v) if err != nil { panic(err) } v.Set("allModules", modules.Modules{mod}) return v } func TestI18nTranslate(t *testing.T) { c := qt.New(t) var actual, expected string v := getConfig() // Test without and with placeholders for _, enablePlaceholders := range []bool{false, true} { v.Set("enableMissingTranslationPlaceholders", enablePlaceholders) for _, test := range i18nTests { c.Run(fmt.Sprintf("%s-%t", test.name, enablePlaceholders), func(c *qt.C) { if enablePlaceholders { expected = test.expectedFlag } else { expected = test.expected } actual = doTestI18nTranslate(c, test, v) c.Assert(actual, qt.Equals, expected) }) } } } func BenchmarkI18nTranslate(b *testing.B) { v := getConfig() for _, test := range i18nTests { b.Run(test.name, func(b *testing.B) { tp := prepareTranslationProvider(b, test, v) b.ResetTimer() for i := 0; i < b.N; i++ { f := tp.t.Func(test.lang) actual := f(test.id, test.args) if actual != test.expected { b.Fatalf("expected %v got %v", test.expected, actual) } } }) } }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./resources/page/pagemeta/pagemeta_test.go
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package pagemeta import ( "fmt" "testing" "github.com/gohugoio/hugo/htesting/hqt" "github.com/gohugoio/hugo/config" qt "github.com/frankban/quicktest" ) func TestDecodeBuildConfig(t *testing.T) { t.Parallel() c := qt.New(t) configTempl := ` [_build] render = %s list = %s publishResources = true` for _, test := range []struct { args []interface{} expect BuildConfig }{ { []interface{}{"true", "true"}, BuildConfig{ Render: Always, List: Always, PublishResources: true, set: true, }, }, {[]interface{}{"true", "false"}, BuildConfig{ Render: Always, List: Never, PublishResources: true, set: true, }}, {[]interface{}{`"always"`, `"always"`}, BuildConfig{ Render: Always, List: Always, PublishResources: true, set: true, }}, {[]interface{}{`"never"`, `"never"`}, BuildConfig{ Render: Never, List: Never, PublishResources: true, set: true, }}, {[]interface{}{`"link"`, `"local"`}, BuildConfig{ Render: Link, List: ListLocally, PublishResources: true, set: true, }}, {[]interface{}{`"always"`, `"asdfadf"`}, BuildConfig{ Render: Always, List: Always, PublishResources: true, set: true, }}, } { cfg, err := config.FromConfigString(fmt.Sprintf(configTempl, test.args...), "toml") c.Assert(err, qt.IsNil) bcfg, err := DecodeBuildConfig(cfg.Get("_build")) c.Assert(err, qt.IsNil) eq := qt.CmpEquals(hqt.DeepAllowUnexported(BuildConfig{})) c.Assert(bcfg, eq, test.expect) } }
// Copyright 2020 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package pagemeta import ( "fmt" "testing" "github.com/gohugoio/hugo/htesting/hqt" "github.com/gohugoio/hugo/config" qt "github.com/frankban/quicktest" ) func TestDecodeBuildConfig(t *testing.T) { t.Parallel() c := qt.New(t) configTempl := ` [_build] render = %s list = %s publishResources = true` for _, test := range []struct { args []interface{} expect BuildConfig }{ { []interface{}{"true", "true"}, BuildConfig{ Render: Always, List: Always, PublishResources: true, set: true, }, }, {[]interface{}{"true", "false"}, BuildConfig{ Render: Always, List: Never, PublishResources: true, set: true, }}, {[]interface{}{`"always"`, `"always"`}, BuildConfig{ Render: Always, List: Always, PublishResources: true, set: true, }}, {[]interface{}{`"never"`, `"never"`}, BuildConfig{ Render: Never, List: Never, PublishResources: true, set: true, }}, {[]interface{}{`"link"`, `"local"`}, BuildConfig{ Render: Link, List: ListLocally, PublishResources: true, set: true, }}, {[]interface{}{`"always"`, `"asdfadf"`}, BuildConfig{ Render: Always, List: Always, PublishResources: true, set: true, }}, } { cfg, err := config.FromConfigString(fmt.Sprintf(configTempl, test.args...), "toml") c.Assert(err, qt.IsNil) bcfg, err := DecodeBuildConfig(cfg.Get("_build")) c.Assert(err, qt.IsNil) eq := qt.CmpEquals(hqt.DeepAllowUnexported(BuildConfig{})) c.Assert(bcfg, eq, test.expect) } }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/collections/complement_test.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package collections import ( "reflect" "testing" "github.com/gohugoio/hugo/deps" qt "github.com/frankban/quicktest" ) type StructWithSlice struct { A string B []string } type StructWithSlicePointers []*StructWithSlice func TestComplement(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) s1 := []TstX{{A: "a"}, {A: "b"}, {A: "d"}, {A: "e"}} s2 := []TstX{{A: "b"}, {A: "e"}} xa, xb, xd, xe := &StructWithSlice{A: "a"}, &StructWithSlice{A: "b"}, &StructWithSlice{A: "d"}, &StructWithSlice{A: "e"} sp1 := []*StructWithSlice{xa, xb, xd, xe} sp2 := []*StructWithSlice{xb, xe} sp1_2 := StructWithSlicePointers{xa, xb, xd, xe} sp2_2 := StructWithSlicePointers{xb, xe} for i, test := range []struct { s interface{} t []interface{} expected interface{} }{ {[]string{"a", "b", "c"}, []interface{}{[]string{"c", "d"}}, []string{"a", "b"}}, {[]string{"a", "b", "c"}, []interface{}{[]string{"c", "d"}, []string{"a", "b"}}, []string{}}, {[]interface{}{"a", "b", nil}, []interface{}{[]string{"a", "d"}}, []interface{}{"b", nil}}, {[]int{1, 2, 3, 4, 5}, []interface{}{[]int{1, 3}, []string{"a", "b"}, []int{1, 2}}, []int{4, 5}}, {[]int{1, 2, 3, 4, 5}, []interface{}{[]int64{1, 3}}, []int{2, 4, 5}}, {s1, []interface{}{s2}, []TstX{{A: "a"}, {A: "d"}}}, {sp1, []interface{}{sp2}, []*StructWithSlice{xa, xd}}, {sp1_2, []interface{}{sp2_2}, StructWithSlicePointers{xa, xd}}, // Errors {[]string{"a", "b", "c"}, []interface{}{"error"}, false}, {"error", []interface{}{[]string{"c", "d"}, []string{"a", "b"}}, false}, {[]string{"a", "b", "c"}, []interface{}{[][]string{{"c", "d"}}}, false}, { []interface{}{[][]string{{"c", "d"}}}, []interface{}{[]string{"c", "d"}, []string{"a", "b"}}, []interface{}{[][]string{{"c", "d"}}}, }, } { errMsg := qt.Commentf("[%d]", i) args := append(test.t, test.s) result, err := ns.Complement(args...) if b, ok := test.expected.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) if !reflect.DeepEqual(test.expected, result) { t.Fatalf("%s got\n%T: %v\nexpected\n%T: %v", errMsg, result, result, test.expected, test.expected) } } _, err := ns.Complement() c.Assert(err, qt.Not(qt.IsNil)) _, err = ns.Complement([]string{"a", "b"}) c.Assert(err, qt.Not(qt.IsNil)) }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package collections import ( "reflect" "testing" "github.com/gohugoio/hugo/deps" qt "github.com/frankban/quicktest" ) type StructWithSlice struct { A string B []string } type StructWithSlicePointers []*StructWithSlice func TestComplement(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) s1 := []TstX{{A: "a"}, {A: "b"}, {A: "d"}, {A: "e"}} s2 := []TstX{{A: "b"}, {A: "e"}} xa, xb, xd, xe := &StructWithSlice{A: "a"}, &StructWithSlice{A: "b"}, &StructWithSlice{A: "d"}, &StructWithSlice{A: "e"} sp1 := []*StructWithSlice{xa, xb, xd, xe} sp2 := []*StructWithSlice{xb, xe} sp1_2 := StructWithSlicePointers{xa, xb, xd, xe} sp2_2 := StructWithSlicePointers{xb, xe} for i, test := range []struct { s interface{} t []interface{} expected interface{} }{ {[]string{"a", "b", "c"}, []interface{}{[]string{"c", "d"}}, []string{"a", "b"}}, {[]string{"a", "b", "c"}, []interface{}{[]string{"c", "d"}, []string{"a", "b"}}, []string{}}, {[]interface{}{"a", "b", nil}, []interface{}{[]string{"a", "d"}}, []interface{}{"b", nil}}, {[]int{1, 2, 3, 4, 5}, []interface{}{[]int{1, 3}, []string{"a", "b"}, []int{1, 2}}, []int{4, 5}}, {[]int{1, 2, 3, 4, 5}, []interface{}{[]int64{1, 3}}, []int{2, 4, 5}}, {s1, []interface{}{s2}, []TstX{{A: "a"}, {A: "d"}}}, {sp1, []interface{}{sp2}, []*StructWithSlice{xa, xd}}, {sp1_2, []interface{}{sp2_2}, StructWithSlicePointers{xa, xd}}, // Errors {[]string{"a", "b", "c"}, []interface{}{"error"}, false}, {"error", []interface{}{[]string{"c", "d"}, []string{"a", "b"}}, false}, {[]string{"a", "b", "c"}, []interface{}{[][]string{{"c", "d"}}}, false}, { []interface{}{[][]string{{"c", "d"}}}, []interface{}{[]string{"c", "d"}, []string{"a", "b"}}, []interface{}{[][]string{{"c", "d"}}}, }, } { errMsg := qt.Commentf("[%d]", i) args := append(test.t, test.s) result, err := ns.Complement(args...) if b, ok := test.expected.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) if !reflect.DeepEqual(test.expected, result) { t.Fatalf("%s got\n%T: %v\nexpected\n%T: %v", errMsg, result, result, test.expected, test.expected) } } _, err := ns.Complement() c.Assert(err, qt.Not(qt.IsNil)) _, err = ns.Complement([]string{"a", "b"}) c.Assert(err, qt.Not(qt.IsNil)) }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/data/resources.go
// Copyright 2016 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package data import ( "io/ioutil" "net/http" "net/url" "path/filepath" "time" "github.com/pkg/errors" "github.com/gohugoio/hugo/cache/filecache" "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/helpers" "github.com/spf13/afero" ) var ( resSleep = time.Second * 2 // if JSON decoding failed sleep for n seconds before retrying resRetries = 1 // number of retries to load the JSON from URL ) // getRemote loads the content of a remote file. This method is thread safe. func (ns *Namespace) getRemote(cache *filecache.Cache, unmarshal func([]byte) (bool, error), req *http.Request) error { url := req.URL.String() id := helpers.MD5String(url) var handled bool var retry bool _, b, err := cache.GetOrCreateBytes(id, func() ([]byte, error) { var err error handled = true for i := 0; i <= resRetries; i++ { ns.deps.Log.Infof("Downloading: %s ...", url) var res *http.Response res, err = ns.client.Do(req) if err != nil { return nil, err } if isHTTPError(res) { return nil, errors.Errorf("Failed to retrieve remote file: %s", http.StatusText(res.StatusCode)) } var b []byte b, err = ioutil.ReadAll(res.Body) if err != nil { return nil, err } res.Body.Close() retry, err = unmarshal(b) if err == nil { // Return it so it can be cached. return b, nil } if !retry { return nil, err } ns.deps.Log.Infof("Cannot read remote resource %s: %s", url, err) ns.deps.Log.Infof("Retry #%d for %s and sleeping for %s", i+1, url, resSleep) time.Sleep(resSleep) } return nil, err }) if !handled { // This is cached content and should be correct. _, err = unmarshal(b) } return err } // getLocal loads the content of a local file func getLocal(url string, fs afero.Fs, cfg config.Provider) ([]byte, error) { filename := filepath.Join(cfg.GetString("workingDir"), url) if e, err := helpers.Exists(filename, fs); !e { return nil, err } return afero.ReadFile(fs, filename) } // getResource loads the content of a local or remote file and returns its content and the // cache ID used, if relevant. func (ns *Namespace) getResource(cache *filecache.Cache, unmarshal func(b []byte) (bool, error), req *http.Request) error { switch req.URL.Scheme { case "": url, err := url.QueryUnescape(req.URL.String()) if err != nil { return err } b, err := getLocal(url, ns.deps.Fs.Source, ns.deps.Cfg) if err != nil { return err } _, err = unmarshal(b) return err default: return ns.getRemote(cache, unmarshal, req) } } func isHTTPError(res *http.Response) bool { return res.StatusCode < 200 || res.StatusCode > 299 }
// Copyright 2016 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package data import ( "io/ioutil" "net/http" "net/url" "path/filepath" "time" "github.com/pkg/errors" "github.com/gohugoio/hugo/cache/filecache" "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/helpers" "github.com/spf13/afero" ) var ( resSleep = time.Second * 2 // if JSON decoding failed sleep for n seconds before retrying resRetries = 1 // number of retries to load the JSON from URL ) // getRemote loads the content of a remote file. This method is thread safe. func (ns *Namespace) getRemote(cache *filecache.Cache, unmarshal func([]byte) (bool, error), req *http.Request) error { url := req.URL.String() id := helpers.MD5String(url) var handled bool var retry bool _, b, err := cache.GetOrCreateBytes(id, func() ([]byte, error) { var err error handled = true for i := 0; i <= resRetries; i++ { ns.deps.Log.Infof("Downloading: %s ...", url) var res *http.Response res, err = ns.client.Do(req) if err != nil { return nil, err } if isHTTPError(res) { return nil, errors.Errorf("Failed to retrieve remote file: %s", http.StatusText(res.StatusCode)) } var b []byte b, err = ioutil.ReadAll(res.Body) if err != nil { return nil, err } res.Body.Close() retry, err = unmarshal(b) if err == nil { // Return it so it can be cached. return b, nil } if !retry { return nil, err } ns.deps.Log.Infof("Cannot read remote resource %s: %s", url, err) ns.deps.Log.Infof("Retry #%d for %s and sleeping for %s", i+1, url, resSleep) time.Sleep(resSleep) } return nil, err }) if !handled { // This is cached content and should be correct. _, err = unmarshal(b) } return err } // getLocal loads the content of a local file func getLocal(url string, fs afero.Fs, cfg config.Provider) ([]byte, error) { filename := filepath.Join(cfg.GetString("workingDir"), url) if e, err := helpers.Exists(filename, fs); !e { return nil, err } return afero.ReadFile(fs, filename) } // getResource loads the content of a local or remote file and returns its content and the // cache ID used, if relevant. func (ns *Namespace) getResource(cache *filecache.Cache, unmarshal func(b []byte) (bool, error), req *http.Request) error { switch req.URL.Scheme { case "": url, err := url.QueryUnescape(req.URL.String()) if err != nil { return err } b, err := getLocal(url, ns.deps.Fs.Source, ns.deps.Cfg) if err != nil { return err } _, err = unmarshal(b) return err default: return ns.getRemote(cache, unmarshal, req) } } func isHTTPError(res *http.Response) bool { return res.StatusCode < 200 || res.StatusCode > 299 }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./output/layout_test.go
// Copyright 2017-present The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package output import ( "fmt" "reflect" "strings" "testing" "github.com/gohugoio/hugo/media" qt "github.com/frankban/quicktest" "github.com/kylelemons/godebug/diff" ) func TestLayout(t *testing.T) { c := qt.New(t) noExtNoDelimMediaType := media.TextType noExtNoDelimMediaType.Suffixes = nil noExtNoDelimMediaType.Delimiter = "" noExtMediaType := media.TextType noExtMediaType.Suffixes = nil var ( ampType = Format{ Name: "AMP", MediaType: media.HTMLType, BaseName: "index", } htmlFormat = HTMLFormat noExtDelimFormat = Format{ Name: "NEM", MediaType: noExtNoDelimMediaType, BaseName: "_redirects", } noExt = Format{ Name: "NEX", MediaType: noExtMediaType, BaseName: "next", } ) for _, this := range []struct { name string layoutDescriptor LayoutDescriptor layoutOverride string format Format expect []string }{ { "Home", LayoutDescriptor{Kind: "home"}, "", ampType, []string{ "index.amp.html", "home.amp.html", "list.amp.html", "index.html", "home.html", "list.html", "_default/index.amp.html", "_default/home.amp.html", "_default/list.amp.html", "_default/index.html", "_default/home.html", "_default/list.html", }, }, { "Home baseof", LayoutDescriptor{Kind: "home", Baseof: true}, "", ampType, []string{ "index-baseof.amp.html", "home-baseof.amp.html", "list-baseof.amp.html", "baseof.amp.html", "index-baseof.html", "home-baseof.html", "list-baseof.html", "baseof.html", "_default/index-baseof.amp.html", "_default/home-baseof.amp.html", "_default/list-baseof.amp.html", "_default/baseof.amp.html", "_default/index-baseof.html", "_default/home-baseof.html", "_default/list-baseof.html", "_default/baseof.html", }, }, { "Home, HTML", LayoutDescriptor{Kind: "home"}, "", htmlFormat, // We will eventually get to index.html. This looks stuttery, but makes the lookup logic easy to understand. []string{ "index.html.html", "home.html.html", "list.html.html", "index.html", "home.html", "list.html", "_default/index.html.html", "_default/home.html.html", "_default/list.html.html", "_default/index.html", "_default/home.html", "_default/list.html", }, }, { "Home, HTML, baseof", LayoutDescriptor{Kind: "home", Baseof: true}, "", htmlFormat, []string{ "index-baseof.html.html", "home-baseof.html.html", "list-baseof.html.html", "baseof.html.html", "index-baseof.html", "home-baseof.html", "list-baseof.html", "baseof.html", "_default/index-baseof.html.html", "_default/home-baseof.html.html", "_default/list-baseof.html.html", "_default/baseof.html.html", "_default/index-baseof.html", "_default/home-baseof.html", "_default/list-baseof.html", "_default/baseof.html", }, }, { "Home, french language", LayoutDescriptor{Kind: "home", Lang: "fr"}, "", ampType, []string{ "index.fr.amp.html", "home.fr.amp.html", "list.fr.amp.html", "index.amp.html", "home.amp.html", "list.amp.html", "index.fr.html", "home.fr.html", "list.fr.html", "index.html", "home.html", "list.html", "_default/index.fr.amp.html", "_default/home.fr.amp.html", "_default/list.fr.amp.html", "_default/index.amp.html", "_default/home.amp.html", "_default/list.amp.html", "_default/index.fr.html", "_default/home.fr.html", "_default/list.fr.html", "_default/index.html", "_default/home.html", "_default/list.html", }, }, { "Home, no ext or delim", LayoutDescriptor{Kind: "home"}, "", noExtDelimFormat, []string{ "index.nem", "home.nem", "list.nem", "_default/index.nem", "_default/home.nem", "_default/list.nem", }, }, { "Home, no ext", LayoutDescriptor{Kind: "home"}, "", noExt, []string{ "index.nex", "home.nex", "list.nex", "_default/index.nex", "_default/home.nex", "_default/list.nex", }, }, { "Page, no ext or delim", LayoutDescriptor{Kind: "page"}, "", noExtDelimFormat, []string{"_default/single.nem"}, }, { "Section", LayoutDescriptor{Kind: "section", Section: "sect1"}, "", ampType, []string{ "sect1/sect1.amp.html", "sect1/section.amp.html", "sect1/list.amp.html", "sect1/sect1.html", "sect1/section.html", "sect1/list.html", "section/sect1.amp.html", "section/section.amp.html", "section/list.amp.html", "section/sect1.html", "section/section.html", "section/list.html", "_default/sect1.amp.html", "_default/section.amp.html", "_default/list.amp.html", "_default/sect1.html", "_default/section.html", "_default/list.html", }, }, { "Section, baseof", LayoutDescriptor{Kind: "section", Section: "sect1", Baseof: true}, "", ampType, []string{ "sect1/sect1-baseof.amp.html", "sect1/section-baseof.amp.html", "sect1/list-baseof.amp.html", "sect1/baseof.amp.html", "sect1/sect1-baseof.html", "sect1/section-baseof.html", "sect1/list-baseof.html", "sect1/baseof.html", "section/sect1-baseof.amp.html", "section/section-baseof.amp.html", "section/list-baseof.amp.html", "section/baseof.amp.html", "section/sect1-baseof.html", "section/section-baseof.html", "section/list-baseof.html", "section/baseof.html", "_default/sect1-baseof.amp.html", "_default/section-baseof.amp.html", "_default/list-baseof.amp.html", "_default/baseof.amp.html", "_default/sect1-baseof.html", "_default/section-baseof.html", "_default/list-baseof.html", "_default/baseof.html", }, }, { "Section, baseof, French, AMP", LayoutDescriptor{Kind: "section", Section: "sect1", Lang: "fr", Baseof: true}, "", ampType, []string{ "sect1/sect1-baseof.fr.amp.html", "sect1/section-baseof.fr.amp.html", "sect1/list-baseof.fr.amp.html", "sect1/baseof.fr.amp.html", "sect1/sect1-baseof.amp.html", "sect1/section-baseof.amp.html", "sect1/list-baseof.amp.html", "sect1/baseof.amp.html", "sect1/sect1-baseof.fr.html", "sect1/section-baseof.fr.html", "sect1/list-baseof.fr.html", "sect1/baseof.fr.html", "sect1/sect1-baseof.html", "sect1/section-baseof.html", "sect1/list-baseof.html", "sect1/baseof.html", "section/sect1-baseof.fr.amp.html", "section/section-baseof.fr.amp.html", "section/list-baseof.fr.amp.html", "section/baseof.fr.amp.html", "section/sect1-baseof.amp.html", "section/section-baseof.amp.html", "section/list-baseof.amp.html", "section/baseof.amp.html", "section/sect1-baseof.fr.html", "section/section-baseof.fr.html", "section/list-baseof.fr.html", "section/baseof.fr.html", "section/sect1-baseof.html", "section/section-baseof.html", "section/list-baseof.html", "section/baseof.html", "_default/sect1-baseof.fr.amp.html", "_default/section-baseof.fr.amp.html", "_default/list-baseof.fr.amp.html", "_default/baseof.fr.amp.html", "_default/sect1-baseof.amp.html", "_default/section-baseof.amp.html", "_default/list-baseof.amp.html", "_default/baseof.amp.html", "_default/sect1-baseof.fr.html", "_default/section-baseof.fr.html", "_default/list-baseof.fr.html", "_default/baseof.fr.html", "_default/sect1-baseof.html", "_default/section-baseof.html", "_default/list-baseof.html", "_default/baseof.html", }, }, { "Section with layout", LayoutDescriptor{Kind: "section", Section: "sect1", Layout: "mylayout"}, "", ampType, []string{ "sect1/mylayout.amp.html", "sect1/sect1.amp.html", "sect1/section.amp.html", "sect1/list.amp.html", "sect1/mylayout.html", "sect1/sect1.html", "sect1/section.html", "sect1/list.html", "section/mylayout.amp.html", "section/sect1.amp.html", "section/section.amp.html", "section/list.amp.html", "section/mylayout.html", "section/sect1.html", "section/section.html", "section/list.html", "_default/mylayout.amp.html", "_default/sect1.amp.html", "_default/section.amp.html", "_default/list.amp.html", "_default/mylayout.html", "_default/sect1.html", "_default/section.html", "_default/list.html", }, }, { "Term, French, AMP", LayoutDescriptor{Kind: "term", Section: "tags", Lang: "fr"}, "", ampType, []string{ "term/term.fr.amp.html", "term/tags.fr.amp.html", "term/taxonomy.fr.amp.html", "term/list.fr.amp.html", "term/term.amp.html", "term/tags.amp.html", "term/taxonomy.amp.html", "term/list.amp.html", "term/term.fr.html", "term/tags.fr.html", "term/taxonomy.fr.html", "term/list.fr.html", "term/term.html", "term/tags.html", "term/taxonomy.html", "term/list.html", "taxonomy/term.fr.amp.html", "taxonomy/tags.fr.amp.html", "taxonomy/taxonomy.fr.amp.html", "taxonomy/list.fr.amp.html", "taxonomy/term.amp.html", "taxonomy/tags.amp.html", "taxonomy/taxonomy.amp.html", "taxonomy/list.amp.html", "taxonomy/term.fr.html", "taxonomy/tags.fr.html", "taxonomy/taxonomy.fr.html", "taxonomy/list.fr.html", "taxonomy/term.html", "taxonomy/tags.html", "taxonomy/taxonomy.html", "taxonomy/list.html", "tags/term.fr.amp.html", "tags/tags.fr.amp.html", "tags/taxonomy.fr.amp.html", "tags/list.fr.amp.html", "tags/term.amp.html", "tags/tags.amp.html", "tags/taxonomy.amp.html", "tags/list.amp.html", "tags/term.fr.html", "tags/tags.fr.html", "tags/taxonomy.fr.html", "tags/list.fr.html", "tags/term.html", "tags/tags.html", "tags/taxonomy.html", "tags/list.html", "_default/term.fr.amp.html", "_default/tags.fr.amp.html", "_default/taxonomy.fr.amp.html", "_default/list.fr.amp.html", "_default/term.amp.html", "_default/tags.amp.html", "_default/taxonomy.amp.html", "_default/list.amp.html", "_default/term.fr.html", "_default/tags.fr.html", "_default/taxonomy.fr.html", "_default/list.fr.html", "_default/term.html", "_default/tags.html", "_default/taxonomy.html", "_default/list.html", }, }, { "Term, baseof, French, AMP", LayoutDescriptor{Kind: "term", Section: "tags", Lang: "fr", Baseof: true}, "", ampType, []string{ "term/term-baseof.fr.amp.html", "term/tags-baseof.fr.amp.html", "term/taxonomy-baseof.fr.amp.html", "term/list-baseof.fr.amp.html", "term/baseof.fr.amp.html", "term/term-baseof.amp.html", "term/tags-baseof.amp.html", "term/taxonomy-baseof.amp.html", "term/list-baseof.amp.html", "term/baseof.amp.html", "term/term-baseof.fr.html", "term/tags-baseof.fr.html", "term/taxonomy-baseof.fr.html", "term/list-baseof.fr.html", "term/baseof.fr.html", "term/term-baseof.html", "term/tags-baseof.html", "term/taxonomy-baseof.html", "term/list-baseof.html", "term/baseof.html", "taxonomy/term-baseof.fr.amp.html", "taxonomy/tags-baseof.fr.amp.html", "taxonomy/taxonomy-baseof.fr.amp.html", "taxonomy/list-baseof.fr.amp.html", "taxonomy/baseof.fr.amp.html", "taxonomy/term-baseof.amp.html", "taxonomy/tags-baseof.amp.html", "taxonomy/taxonomy-baseof.amp.html", "taxonomy/list-baseof.amp.html", "taxonomy/baseof.amp.html", "taxonomy/term-baseof.fr.html", "taxonomy/tags-baseof.fr.html", "taxonomy/taxonomy-baseof.fr.html", "taxonomy/list-baseof.fr.html", "taxonomy/baseof.fr.html", "taxonomy/term-baseof.html", "taxonomy/tags-baseof.html", "taxonomy/taxonomy-baseof.html", "taxonomy/list-baseof.html", "taxonomy/baseof.html", "tags/term-baseof.fr.amp.html", "tags/tags-baseof.fr.amp.html", "tags/taxonomy-baseof.fr.amp.html", "tags/list-baseof.fr.amp.html", "tags/baseof.fr.amp.html", "tags/term-baseof.amp.html", "tags/tags-baseof.amp.html", "tags/taxonomy-baseof.amp.html", "tags/list-baseof.amp.html", "tags/baseof.amp.html", "tags/term-baseof.fr.html", "tags/tags-baseof.fr.html", "tags/taxonomy-baseof.fr.html", "tags/list-baseof.fr.html", "tags/baseof.fr.html", "tags/term-baseof.html", "tags/tags-baseof.html", "tags/taxonomy-baseof.html", "tags/list-baseof.html", "tags/baseof.html", "_default/term-baseof.fr.amp.html", "_default/tags-baseof.fr.amp.html", "_default/taxonomy-baseof.fr.amp.html", "_default/list-baseof.fr.amp.html", "_default/baseof.fr.amp.html", "_default/term-baseof.amp.html", "_default/tags-baseof.amp.html", "_default/taxonomy-baseof.amp.html", "_default/list-baseof.amp.html", "_default/baseof.amp.html", "_default/term-baseof.fr.html", "_default/tags-baseof.fr.html", "_default/taxonomy-baseof.fr.html", "_default/list-baseof.fr.html", "_default/baseof.fr.html", "_default/term-baseof.html", "_default/tags-baseof.html", "_default/taxonomy-baseof.html", "_default/list-baseof.html", "_default/baseof.html", }, }, { "Term", LayoutDescriptor{Kind: "term", Section: "tags"}, "", ampType, []string{ "term/term.amp.html", "term/tags.amp.html", "term/taxonomy.amp.html", "term/list.amp.html", "term/term.html", "term/tags.html", "term/taxonomy.html", "term/list.html", "taxonomy/term.amp.html", "taxonomy/tags.amp.html", "taxonomy/taxonomy.amp.html", "taxonomy/list.amp.html", "taxonomy/term.html", "taxonomy/tags.html", "taxonomy/taxonomy.html", "taxonomy/list.html", "tags/term.amp.html", "tags/tags.amp.html", "tags/taxonomy.amp.html", "tags/list.amp.html", "tags/term.html", "tags/tags.html", "tags/taxonomy.html", "tags/list.html", "_default/term.amp.html", "_default/tags.amp.html", "_default/taxonomy.amp.html", "_default/list.amp.html", "_default/term.html", "_default/tags.html", "_default/taxonomy.html", "_default/list.html", }, }, { "Taxonomy", LayoutDescriptor{Kind: "taxonomy", Section: "categories"}, "", ampType, []string{ "categories/categories.terms.amp.html", "categories/terms.amp.html", "categories/taxonomy.amp.html", "categories/list.amp.html", "categories/categories.terms.html", "categories/terms.html", "categories/taxonomy.html", "categories/list.html", "taxonomy/categories.terms.amp.html", "taxonomy/terms.amp.html", "taxonomy/taxonomy.amp.html", "taxonomy/list.amp.html", "taxonomy/categories.terms.html", "taxonomy/terms.html", "taxonomy/taxonomy.html", "taxonomy/list.html", "_default/categories.terms.amp.html", "_default/terms.amp.html", "_default/taxonomy.amp.html", "_default/list.amp.html", "_default/categories.terms.html", "_default/terms.html", "_default/taxonomy.html", "_default/list.html", }, }, { "Page", LayoutDescriptor{Kind: "page"}, "", ampType, []string{ "_default/single.amp.html", "_default/single.html", }, }, { "Page, baseof", LayoutDescriptor{Kind: "page", Baseof: true}, "", ampType, []string{ "_default/single-baseof.amp.html", "_default/baseof.amp.html", "_default/single-baseof.html", "_default/baseof.html", }, }, { "Page with layout", LayoutDescriptor{Kind: "page", Layout: "mylayout"}, "", ampType, []string{ "_default/mylayout.amp.html", "_default/single.amp.html", "_default/mylayout.html", "_default/single.html", }, }, { "Page with layout, baseof", LayoutDescriptor{Kind: "page", Layout: "mylayout", Baseof: true}, "", ampType, []string{ "_default/mylayout-baseof.amp.html", "_default/single-baseof.amp.html", "_default/baseof.amp.html", "_default/mylayout-baseof.html", "_default/single-baseof.html", "_default/baseof.html", }, }, { "Page with layout and type", LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype"}, "", ampType, []string{ "myttype/mylayout.amp.html", "myttype/single.amp.html", "myttype/mylayout.html", "myttype/single.html", "_default/mylayout.amp.html", "_default/single.amp.html", "_default/mylayout.html", "_default/single.html", }, }, { "Page baseof with layout and type", LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype", Baseof: true}, "", ampType, []string{ "myttype/mylayout-baseof.amp.html", "myttype/single-baseof.amp.html", "myttype/baseof.amp.html", "myttype/mylayout-baseof.html", "myttype/single-baseof.html", "myttype/baseof.html", "_default/mylayout-baseof.amp.html", "_default/single-baseof.amp.html", "_default/baseof.amp.html", "_default/mylayout-baseof.html", "_default/single-baseof.html", "_default/baseof.html", }, }, { "Page baseof with layout and type in French", LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype", Lang: "fr", Baseof: true}, "", ampType, []string{ "myttype/mylayout-baseof.fr.amp.html", "myttype/single-baseof.fr.amp.html", "myttype/baseof.fr.amp.html", "myttype/mylayout-baseof.amp.html", "myttype/single-baseof.amp.html", "myttype/baseof.amp.html", "myttype/mylayout-baseof.fr.html", "myttype/single-baseof.fr.html", "myttype/baseof.fr.html", "myttype/mylayout-baseof.html", "myttype/single-baseof.html", "myttype/baseof.html", "_default/mylayout-baseof.fr.amp.html", "_default/single-baseof.fr.amp.html", "_default/baseof.fr.amp.html", "_default/mylayout-baseof.amp.html", "_default/single-baseof.amp.html", "_default/baseof.amp.html", "_default/mylayout-baseof.fr.html", "_default/single-baseof.fr.html", "_default/baseof.fr.html", "_default/mylayout-baseof.html", "_default/single-baseof.html", "_default/baseof.html", }, }, { "Page with layout and type with subtype", LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype/mysubtype"}, "", ampType, []string{ "myttype/mysubtype/mylayout.amp.html", "myttype/mysubtype/single.amp.html", "myttype/mysubtype/mylayout.html", "myttype/mysubtype/single.html", "_default/mylayout.amp.html", "_default/single.amp.html", "_default/mylayout.html", "_default/single.html", }, }, // RSS { "RSS Home", LayoutDescriptor{Kind: "home"}, "", RSSFormat, []string{ "index.rss.xml", "home.rss.xml", "rss.xml", "list.rss.xml", "index.xml", "home.xml", "list.xml", "_default/index.rss.xml", "_default/home.rss.xml", "_default/rss.xml", "_default/list.rss.xml", "_default/index.xml", "_default/home.xml", "_default/list.xml", "_internal/_default/rss.xml", }, }, { "RSS Home, baseof", LayoutDescriptor{Kind: "home", Baseof: true}, "", RSSFormat, []string{ "index-baseof.rss.xml", "home-baseof.rss.xml", "list-baseof.rss.xml", "baseof.rss.xml", "index-baseof.xml", "home-baseof.xml", "list-baseof.xml", "baseof.xml", "_default/index-baseof.rss.xml", "_default/home-baseof.rss.xml", "_default/list-baseof.rss.xml", "_default/baseof.rss.xml", "_default/index-baseof.xml", "_default/home-baseof.xml", "_default/list-baseof.xml", "_default/baseof.xml", }, }, { "RSS Section", LayoutDescriptor{Kind: "section", Section: "sect1"}, "", RSSFormat, []string{ "sect1/sect1.rss.xml", "sect1/section.rss.xml", "sect1/rss.xml", "sect1/list.rss.xml", "sect1/sect1.xml", "sect1/section.xml", "sect1/list.xml", "section/sect1.rss.xml", "section/section.rss.xml", "section/rss.xml", "section/list.rss.xml", "section/sect1.xml", "section/section.xml", "section/list.xml", "_default/sect1.rss.xml", "_default/section.rss.xml", "_default/rss.xml", "_default/list.rss.xml", "_default/sect1.xml", "_default/section.xml", "_default/list.xml", "_internal/_default/rss.xml", }, }, { "RSS Term", LayoutDescriptor{Kind: "term", Section: "tag"}, "", RSSFormat, []string{ "term/term.rss.xml", "term/tag.rss.xml", "term/taxonomy.rss.xml", "term/rss.xml", "term/list.rss.xml", "term/term.xml", "term/tag.xml", "term/taxonomy.xml", "term/list.xml", "taxonomy/term.rss.xml", "taxonomy/tag.rss.xml", "taxonomy/taxonomy.rss.xml", "taxonomy/rss.xml", "taxonomy/list.rss.xml", "taxonomy/term.xml", "taxonomy/tag.xml", "taxonomy/taxonomy.xml", "taxonomy/list.xml", "tag/term.rss.xml", "tag/tag.rss.xml", "tag/taxonomy.rss.xml", "tag/rss.xml", "tag/list.rss.xml", "tag/term.xml", "tag/tag.xml", "tag/taxonomy.xml", "tag/list.xml", "_default/term.rss.xml", "_default/tag.rss.xml", "_default/taxonomy.rss.xml", "_default/rss.xml", "_default/list.rss.xml", "_default/term.xml", "_default/tag.xml", "_default/taxonomy.xml", "_default/list.xml", "_internal/_default/rss.xml", }, }, { "RSS Taxonomy", LayoutDescriptor{Kind: "taxonomy", Section: "tag"}, "", RSSFormat, []string{ "tag/tag.terms.rss.xml", "tag/terms.rss.xml", "tag/taxonomy.rss.xml", "tag/rss.xml", "tag/list.rss.xml", "tag/tag.terms.xml", "tag/terms.xml", "tag/taxonomy.xml", "tag/list.xml", "taxonomy/tag.terms.rss.xml", "taxonomy/terms.rss.xml", "taxonomy/taxonomy.rss.xml", "taxonomy/rss.xml", "taxonomy/list.rss.xml", "taxonomy/tag.terms.xml", "taxonomy/terms.xml", "taxonomy/taxonomy.xml", "taxonomy/list.xml", "_default/tag.terms.rss.xml", "_default/terms.rss.xml", "_default/taxonomy.rss.xml", "_default/rss.xml", "_default/list.rss.xml", "_default/tag.terms.xml", "_default/terms.xml", "_default/taxonomy.xml", "_default/list.xml", "_internal/_default/rss.xml", }, }, { "Home plain text", LayoutDescriptor{Kind: "home"}, "", JSONFormat, []string{ "index.json.json", "home.json.json", "list.json.json", "index.json", "home.json", "list.json", "_default/index.json.json", "_default/home.json.json", "_default/list.json.json", "_default/index.json", "_default/home.json", "_default/list.json", }, }, { "Page plain text", LayoutDescriptor{Kind: "page"}, "", JSONFormat, []string{ "_default/single.json.json", "_default/single.json", }, }, { "Reserved section, shortcodes", LayoutDescriptor{Kind: "section", Section: "shortcodes", Type: "shortcodes"}, "", ampType, []string{ "section/shortcodes.amp.html", "section/section.amp.html", "section/list.amp.html", "section/shortcodes.html", "section/section.html", "section/list.html", "_default/shortcodes.amp.html", "_default/section.amp.html", "_default/list.amp.html", "_default/shortcodes.html", "_default/section.html", "_default/list.html", }, }, { "Reserved section, partials", LayoutDescriptor{Kind: "section", Section: "partials", Type: "partials"}, "", ampType, []string{ "section/partials.amp.html", "section/section.amp.html", "section/list.amp.html", "section/partials.html", "section/section.html", "section/list.html", "_default/partials.amp.html", "_default/section.amp.html", "_default/list.amp.html", "_default/partials.html", "_default/section.html", "_default/list.html", }, }, // This is currently always HTML only { "404, HTML", LayoutDescriptor{Kind: "404"}, "", htmlFormat, []string{ "404.html.html", "404.html", }, }, { "404, HTML baseof", LayoutDescriptor{Kind: "404", Baseof: true}, "", htmlFormat, []string{ "404-baseof.html.html", "baseof.html.html", "404-baseof.html", "baseof.html", "_default/404-baseof.html.html", "_default/baseof.html.html", "_default/404-baseof.html", "_default/baseof.html", }, }, { "Content hook", LayoutDescriptor{Kind: "render-link", RenderingHook: true, Layout: "mylayout", Section: "blog"}, "", ampType, []string{ "blog/_markup/render-link.amp.html", "blog/_markup/render-link.html", "_default/_markup/render-link.amp.html", "_default/_markup/render-link.html", }, }, } { c.Run(this.name, func(c *qt.C) { l := NewLayoutHandler() layouts, err := l.For(this.layoutDescriptor, this.format) c.Assert(err, qt.IsNil) c.Assert(layouts, qt.Not(qt.IsNil), qt.Commentf(this.layoutDescriptor.Kind)) if !reflect.DeepEqual(layouts, this.expect) { r := strings.NewReplacer( "[", "\t\"", "]", "\",", " ", "\",\n\t\"", ) fmtGot := r.Replace(fmt.Sprintf("%v", layouts)) fmtExp := r.Replace(fmt.Sprintf("%v", this.expect)) c.Fatalf("got %d items, expected %d:\nGot:\n\t%v\nExpected:\n\t%v\nDiff:\n%s", len(layouts), len(this.expect), layouts, this.expect, diff.Diff(fmtExp, fmtGot)) } }) } } func BenchmarkLayout(b *testing.B) { descriptor := LayoutDescriptor{Kind: "taxonomy", Section: "categories"} l := NewLayoutHandler() for i := 0; i < b.N; i++ { _, err := l.For(descriptor, HTMLFormat) if err != nil { panic(err) } } } func BenchmarkLayoutUncached(b *testing.B) { for i := 0; i < b.N; i++ { descriptor := LayoutDescriptor{Kind: "taxonomy", Section: "categories"} l := NewLayoutHandler() _, err := l.For(descriptor, HTMLFormat) if err != nil { panic(err) } } }
// Copyright 2017-present The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package output import ( "fmt" "reflect" "strings" "testing" "github.com/gohugoio/hugo/media" qt "github.com/frankban/quicktest" "github.com/kylelemons/godebug/diff" ) func TestLayout(t *testing.T) { c := qt.New(t) noExtNoDelimMediaType := media.TextType noExtNoDelimMediaType.Suffixes = nil noExtNoDelimMediaType.Delimiter = "" noExtMediaType := media.TextType noExtMediaType.Suffixes = nil var ( ampType = Format{ Name: "AMP", MediaType: media.HTMLType, BaseName: "index", } htmlFormat = HTMLFormat noExtDelimFormat = Format{ Name: "NEM", MediaType: noExtNoDelimMediaType, BaseName: "_redirects", } noExt = Format{ Name: "NEX", MediaType: noExtMediaType, BaseName: "next", } ) for _, this := range []struct { name string layoutDescriptor LayoutDescriptor layoutOverride string format Format expect []string }{ { "Home", LayoutDescriptor{Kind: "home"}, "", ampType, []string{ "index.amp.html", "home.amp.html", "list.amp.html", "index.html", "home.html", "list.html", "_default/index.amp.html", "_default/home.amp.html", "_default/list.amp.html", "_default/index.html", "_default/home.html", "_default/list.html", }, }, { "Home baseof", LayoutDescriptor{Kind: "home", Baseof: true}, "", ampType, []string{ "index-baseof.amp.html", "home-baseof.amp.html", "list-baseof.amp.html", "baseof.amp.html", "index-baseof.html", "home-baseof.html", "list-baseof.html", "baseof.html", "_default/index-baseof.amp.html", "_default/home-baseof.amp.html", "_default/list-baseof.amp.html", "_default/baseof.amp.html", "_default/index-baseof.html", "_default/home-baseof.html", "_default/list-baseof.html", "_default/baseof.html", }, }, { "Home, HTML", LayoutDescriptor{Kind: "home"}, "", htmlFormat, // We will eventually get to index.html. This looks stuttery, but makes the lookup logic easy to understand. []string{ "index.html.html", "home.html.html", "list.html.html", "index.html", "home.html", "list.html", "_default/index.html.html", "_default/home.html.html", "_default/list.html.html", "_default/index.html", "_default/home.html", "_default/list.html", }, }, { "Home, HTML, baseof", LayoutDescriptor{Kind: "home", Baseof: true}, "", htmlFormat, []string{ "index-baseof.html.html", "home-baseof.html.html", "list-baseof.html.html", "baseof.html.html", "index-baseof.html", "home-baseof.html", "list-baseof.html", "baseof.html", "_default/index-baseof.html.html", "_default/home-baseof.html.html", "_default/list-baseof.html.html", "_default/baseof.html.html", "_default/index-baseof.html", "_default/home-baseof.html", "_default/list-baseof.html", "_default/baseof.html", }, }, { "Home, french language", LayoutDescriptor{Kind: "home", Lang: "fr"}, "", ampType, []string{ "index.fr.amp.html", "home.fr.amp.html", "list.fr.amp.html", "index.amp.html", "home.amp.html", "list.amp.html", "index.fr.html", "home.fr.html", "list.fr.html", "index.html", "home.html", "list.html", "_default/index.fr.amp.html", "_default/home.fr.amp.html", "_default/list.fr.amp.html", "_default/index.amp.html", "_default/home.amp.html", "_default/list.amp.html", "_default/index.fr.html", "_default/home.fr.html", "_default/list.fr.html", "_default/index.html", "_default/home.html", "_default/list.html", }, }, { "Home, no ext or delim", LayoutDescriptor{Kind: "home"}, "", noExtDelimFormat, []string{ "index.nem", "home.nem", "list.nem", "_default/index.nem", "_default/home.nem", "_default/list.nem", }, }, { "Home, no ext", LayoutDescriptor{Kind: "home"}, "", noExt, []string{ "index.nex", "home.nex", "list.nex", "_default/index.nex", "_default/home.nex", "_default/list.nex", }, }, { "Page, no ext or delim", LayoutDescriptor{Kind: "page"}, "", noExtDelimFormat, []string{"_default/single.nem"}, }, { "Section", LayoutDescriptor{Kind: "section", Section: "sect1"}, "", ampType, []string{ "sect1/sect1.amp.html", "sect1/section.amp.html", "sect1/list.amp.html", "sect1/sect1.html", "sect1/section.html", "sect1/list.html", "section/sect1.amp.html", "section/section.amp.html", "section/list.amp.html", "section/sect1.html", "section/section.html", "section/list.html", "_default/sect1.amp.html", "_default/section.amp.html", "_default/list.amp.html", "_default/sect1.html", "_default/section.html", "_default/list.html", }, }, { "Section, baseof", LayoutDescriptor{Kind: "section", Section: "sect1", Baseof: true}, "", ampType, []string{ "sect1/sect1-baseof.amp.html", "sect1/section-baseof.amp.html", "sect1/list-baseof.amp.html", "sect1/baseof.amp.html", "sect1/sect1-baseof.html", "sect1/section-baseof.html", "sect1/list-baseof.html", "sect1/baseof.html", "section/sect1-baseof.amp.html", "section/section-baseof.amp.html", "section/list-baseof.amp.html", "section/baseof.amp.html", "section/sect1-baseof.html", "section/section-baseof.html", "section/list-baseof.html", "section/baseof.html", "_default/sect1-baseof.amp.html", "_default/section-baseof.amp.html", "_default/list-baseof.amp.html", "_default/baseof.amp.html", "_default/sect1-baseof.html", "_default/section-baseof.html", "_default/list-baseof.html", "_default/baseof.html", }, }, { "Section, baseof, French, AMP", LayoutDescriptor{Kind: "section", Section: "sect1", Lang: "fr", Baseof: true}, "", ampType, []string{ "sect1/sect1-baseof.fr.amp.html", "sect1/section-baseof.fr.amp.html", "sect1/list-baseof.fr.amp.html", "sect1/baseof.fr.amp.html", "sect1/sect1-baseof.amp.html", "sect1/section-baseof.amp.html", "sect1/list-baseof.amp.html", "sect1/baseof.amp.html", "sect1/sect1-baseof.fr.html", "sect1/section-baseof.fr.html", "sect1/list-baseof.fr.html", "sect1/baseof.fr.html", "sect1/sect1-baseof.html", "sect1/section-baseof.html", "sect1/list-baseof.html", "sect1/baseof.html", "section/sect1-baseof.fr.amp.html", "section/section-baseof.fr.amp.html", "section/list-baseof.fr.amp.html", "section/baseof.fr.amp.html", "section/sect1-baseof.amp.html", "section/section-baseof.amp.html", "section/list-baseof.amp.html", "section/baseof.amp.html", "section/sect1-baseof.fr.html", "section/section-baseof.fr.html", "section/list-baseof.fr.html", "section/baseof.fr.html", "section/sect1-baseof.html", "section/section-baseof.html", "section/list-baseof.html", "section/baseof.html", "_default/sect1-baseof.fr.amp.html", "_default/section-baseof.fr.amp.html", "_default/list-baseof.fr.amp.html", "_default/baseof.fr.amp.html", "_default/sect1-baseof.amp.html", "_default/section-baseof.amp.html", "_default/list-baseof.amp.html", "_default/baseof.amp.html", "_default/sect1-baseof.fr.html", "_default/section-baseof.fr.html", "_default/list-baseof.fr.html", "_default/baseof.fr.html", "_default/sect1-baseof.html", "_default/section-baseof.html", "_default/list-baseof.html", "_default/baseof.html", }, }, { "Section with layout", LayoutDescriptor{Kind: "section", Section: "sect1", Layout: "mylayout"}, "", ampType, []string{ "sect1/mylayout.amp.html", "sect1/sect1.amp.html", "sect1/section.amp.html", "sect1/list.amp.html", "sect1/mylayout.html", "sect1/sect1.html", "sect1/section.html", "sect1/list.html", "section/mylayout.amp.html", "section/sect1.amp.html", "section/section.amp.html", "section/list.amp.html", "section/mylayout.html", "section/sect1.html", "section/section.html", "section/list.html", "_default/mylayout.amp.html", "_default/sect1.amp.html", "_default/section.amp.html", "_default/list.amp.html", "_default/mylayout.html", "_default/sect1.html", "_default/section.html", "_default/list.html", }, }, { "Term, French, AMP", LayoutDescriptor{Kind: "term", Section: "tags", Lang: "fr"}, "", ampType, []string{ "term/term.fr.amp.html", "term/tags.fr.amp.html", "term/taxonomy.fr.amp.html", "term/list.fr.amp.html", "term/term.amp.html", "term/tags.amp.html", "term/taxonomy.amp.html", "term/list.amp.html", "term/term.fr.html", "term/tags.fr.html", "term/taxonomy.fr.html", "term/list.fr.html", "term/term.html", "term/tags.html", "term/taxonomy.html", "term/list.html", "taxonomy/term.fr.amp.html", "taxonomy/tags.fr.amp.html", "taxonomy/taxonomy.fr.amp.html", "taxonomy/list.fr.amp.html", "taxonomy/term.amp.html", "taxonomy/tags.amp.html", "taxonomy/taxonomy.amp.html", "taxonomy/list.amp.html", "taxonomy/term.fr.html", "taxonomy/tags.fr.html", "taxonomy/taxonomy.fr.html", "taxonomy/list.fr.html", "taxonomy/term.html", "taxonomy/tags.html", "taxonomy/taxonomy.html", "taxonomy/list.html", "tags/term.fr.amp.html", "tags/tags.fr.amp.html", "tags/taxonomy.fr.amp.html", "tags/list.fr.amp.html", "tags/term.amp.html", "tags/tags.amp.html", "tags/taxonomy.amp.html", "tags/list.amp.html", "tags/term.fr.html", "tags/tags.fr.html", "tags/taxonomy.fr.html", "tags/list.fr.html", "tags/term.html", "tags/tags.html", "tags/taxonomy.html", "tags/list.html", "_default/term.fr.amp.html", "_default/tags.fr.amp.html", "_default/taxonomy.fr.amp.html", "_default/list.fr.amp.html", "_default/term.amp.html", "_default/tags.amp.html", "_default/taxonomy.amp.html", "_default/list.amp.html", "_default/term.fr.html", "_default/tags.fr.html", "_default/taxonomy.fr.html", "_default/list.fr.html", "_default/term.html", "_default/tags.html", "_default/taxonomy.html", "_default/list.html", }, }, { "Term, baseof, French, AMP", LayoutDescriptor{Kind: "term", Section: "tags", Lang: "fr", Baseof: true}, "", ampType, []string{ "term/term-baseof.fr.amp.html", "term/tags-baseof.fr.amp.html", "term/taxonomy-baseof.fr.amp.html", "term/list-baseof.fr.amp.html", "term/baseof.fr.amp.html", "term/term-baseof.amp.html", "term/tags-baseof.amp.html", "term/taxonomy-baseof.amp.html", "term/list-baseof.amp.html", "term/baseof.amp.html", "term/term-baseof.fr.html", "term/tags-baseof.fr.html", "term/taxonomy-baseof.fr.html", "term/list-baseof.fr.html", "term/baseof.fr.html", "term/term-baseof.html", "term/tags-baseof.html", "term/taxonomy-baseof.html", "term/list-baseof.html", "term/baseof.html", "taxonomy/term-baseof.fr.amp.html", "taxonomy/tags-baseof.fr.amp.html", "taxonomy/taxonomy-baseof.fr.amp.html", "taxonomy/list-baseof.fr.amp.html", "taxonomy/baseof.fr.amp.html", "taxonomy/term-baseof.amp.html", "taxonomy/tags-baseof.amp.html", "taxonomy/taxonomy-baseof.amp.html", "taxonomy/list-baseof.amp.html", "taxonomy/baseof.amp.html", "taxonomy/term-baseof.fr.html", "taxonomy/tags-baseof.fr.html", "taxonomy/taxonomy-baseof.fr.html", "taxonomy/list-baseof.fr.html", "taxonomy/baseof.fr.html", "taxonomy/term-baseof.html", "taxonomy/tags-baseof.html", "taxonomy/taxonomy-baseof.html", "taxonomy/list-baseof.html", "taxonomy/baseof.html", "tags/term-baseof.fr.amp.html", "tags/tags-baseof.fr.amp.html", "tags/taxonomy-baseof.fr.amp.html", "tags/list-baseof.fr.amp.html", "tags/baseof.fr.amp.html", "tags/term-baseof.amp.html", "tags/tags-baseof.amp.html", "tags/taxonomy-baseof.amp.html", "tags/list-baseof.amp.html", "tags/baseof.amp.html", "tags/term-baseof.fr.html", "tags/tags-baseof.fr.html", "tags/taxonomy-baseof.fr.html", "tags/list-baseof.fr.html", "tags/baseof.fr.html", "tags/term-baseof.html", "tags/tags-baseof.html", "tags/taxonomy-baseof.html", "tags/list-baseof.html", "tags/baseof.html", "_default/term-baseof.fr.amp.html", "_default/tags-baseof.fr.amp.html", "_default/taxonomy-baseof.fr.amp.html", "_default/list-baseof.fr.amp.html", "_default/baseof.fr.amp.html", "_default/term-baseof.amp.html", "_default/tags-baseof.amp.html", "_default/taxonomy-baseof.amp.html", "_default/list-baseof.amp.html", "_default/baseof.amp.html", "_default/term-baseof.fr.html", "_default/tags-baseof.fr.html", "_default/taxonomy-baseof.fr.html", "_default/list-baseof.fr.html", "_default/baseof.fr.html", "_default/term-baseof.html", "_default/tags-baseof.html", "_default/taxonomy-baseof.html", "_default/list-baseof.html", "_default/baseof.html", }, }, { "Term", LayoutDescriptor{Kind: "term", Section: "tags"}, "", ampType, []string{ "term/term.amp.html", "term/tags.amp.html", "term/taxonomy.amp.html", "term/list.amp.html", "term/term.html", "term/tags.html", "term/taxonomy.html", "term/list.html", "taxonomy/term.amp.html", "taxonomy/tags.amp.html", "taxonomy/taxonomy.amp.html", "taxonomy/list.amp.html", "taxonomy/term.html", "taxonomy/tags.html", "taxonomy/taxonomy.html", "taxonomy/list.html", "tags/term.amp.html", "tags/tags.amp.html", "tags/taxonomy.amp.html", "tags/list.amp.html", "tags/term.html", "tags/tags.html", "tags/taxonomy.html", "tags/list.html", "_default/term.amp.html", "_default/tags.amp.html", "_default/taxonomy.amp.html", "_default/list.amp.html", "_default/term.html", "_default/tags.html", "_default/taxonomy.html", "_default/list.html", }, }, { "Taxonomy", LayoutDescriptor{Kind: "taxonomy", Section: "categories"}, "", ampType, []string{ "categories/categories.terms.amp.html", "categories/terms.amp.html", "categories/taxonomy.amp.html", "categories/list.amp.html", "categories/categories.terms.html", "categories/terms.html", "categories/taxonomy.html", "categories/list.html", "taxonomy/categories.terms.amp.html", "taxonomy/terms.amp.html", "taxonomy/taxonomy.amp.html", "taxonomy/list.amp.html", "taxonomy/categories.terms.html", "taxonomy/terms.html", "taxonomy/taxonomy.html", "taxonomy/list.html", "_default/categories.terms.amp.html", "_default/terms.amp.html", "_default/taxonomy.amp.html", "_default/list.amp.html", "_default/categories.terms.html", "_default/terms.html", "_default/taxonomy.html", "_default/list.html", }, }, { "Page", LayoutDescriptor{Kind: "page"}, "", ampType, []string{ "_default/single.amp.html", "_default/single.html", }, }, { "Page, baseof", LayoutDescriptor{Kind: "page", Baseof: true}, "", ampType, []string{ "_default/single-baseof.amp.html", "_default/baseof.amp.html", "_default/single-baseof.html", "_default/baseof.html", }, }, { "Page with layout", LayoutDescriptor{Kind: "page", Layout: "mylayout"}, "", ampType, []string{ "_default/mylayout.amp.html", "_default/single.amp.html", "_default/mylayout.html", "_default/single.html", }, }, { "Page with layout, baseof", LayoutDescriptor{Kind: "page", Layout: "mylayout", Baseof: true}, "", ampType, []string{ "_default/mylayout-baseof.amp.html", "_default/single-baseof.amp.html", "_default/baseof.amp.html", "_default/mylayout-baseof.html", "_default/single-baseof.html", "_default/baseof.html", }, }, { "Page with layout and type", LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype"}, "", ampType, []string{ "myttype/mylayout.amp.html", "myttype/single.amp.html", "myttype/mylayout.html", "myttype/single.html", "_default/mylayout.amp.html", "_default/single.amp.html", "_default/mylayout.html", "_default/single.html", }, }, { "Page baseof with layout and type", LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype", Baseof: true}, "", ampType, []string{ "myttype/mylayout-baseof.amp.html", "myttype/single-baseof.amp.html", "myttype/baseof.amp.html", "myttype/mylayout-baseof.html", "myttype/single-baseof.html", "myttype/baseof.html", "_default/mylayout-baseof.amp.html", "_default/single-baseof.amp.html", "_default/baseof.amp.html", "_default/mylayout-baseof.html", "_default/single-baseof.html", "_default/baseof.html", }, }, { "Page baseof with layout and type in French", LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype", Lang: "fr", Baseof: true}, "", ampType, []string{ "myttype/mylayout-baseof.fr.amp.html", "myttype/single-baseof.fr.amp.html", "myttype/baseof.fr.amp.html", "myttype/mylayout-baseof.amp.html", "myttype/single-baseof.amp.html", "myttype/baseof.amp.html", "myttype/mylayout-baseof.fr.html", "myttype/single-baseof.fr.html", "myttype/baseof.fr.html", "myttype/mylayout-baseof.html", "myttype/single-baseof.html", "myttype/baseof.html", "_default/mylayout-baseof.fr.amp.html", "_default/single-baseof.fr.amp.html", "_default/baseof.fr.amp.html", "_default/mylayout-baseof.amp.html", "_default/single-baseof.amp.html", "_default/baseof.amp.html", "_default/mylayout-baseof.fr.html", "_default/single-baseof.fr.html", "_default/baseof.fr.html", "_default/mylayout-baseof.html", "_default/single-baseof.html", "_default/baseof.html", }, }, { "Page with layout and type with subtype", LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype/mysubtype"}, "", ampType, []string{ "myttype/mysubtype/mylayout.amp.html", "myttype/mysubtype/single.amp.html", "myttype/mysubtype/mylayout.html", "myttype/mysubtype/single.html", "_default/mylayout.amp.html", "_default/single.amp.html", "_default/mylayout.html", "_default/single.html", }, }, // RSS { "RSS Home", LayoutDescriptor{Kind: "home"}, "", RSSFormat, []string{ "index.rss.xml", "home.rss.xml", "rss.xml", "list.rss.xml", "index.xml", "home.xml", "list.xml", "_default/index.rss.xml", "_default/home.rss.xml", "_default/rss.xml", "_default/list.rss.xml", "_default/index.xml", "_default/home.xml", "_default/list.xml", "_internal/_default/rss.xml", }, }, { "RSS Home, baseof", LayoutDescriptor{Kind: "home", Baseof: true}, "", RSSFormat, []string{ "index-baseof.rss.xml", "home-baseof.rss.xml", "list-baseof.rss.xml", "baseof.rss.xml", "index-baseof.xml", "home-baseof.xml", "list-baseof.xml", "baseof.xml", "_default/index-baseof.rss.xml", "_default/home-baseof.rss.xml", "_default/list-baseof.rss.xml", "_default/baseof.rss.xml", "_default/index-baseof.xml", "_default/home-baseof.xml", "_default/list-baseof.xml", "_default/baseof.xml", }, }, { "RSS Section", LayoutDescriptor{Kind: "section", Section: "sect1"}, "", RSSFormat, []string{ "sect1/sect1.rss.xml", "sect1/section.rss.xml", "sect1/rss.xml", "sect1/list.rss.xml", "sect1/sect1.xml", "sect1/section.xml", "sect1/list.xml", "section/sect1.rss.xml", "section/section.rss.xml", "section/rss.xml", "section/list.rss.xml", "section/sect1.xml", "section/section.xml", "section/list.xml", "_default/sect1.rss.xml", "_default/section.rss.xml", "_default/rss.xml", "_default/list.rss.xml", "_default/sect1.xml", "_default/section.xml", "_default/list.xml", "_internal/_default/rss.xml", }, }, { "RSS Term", LayoutDescriptor{Kind: "term", Section: "tag"}, "", RSSFormat, []string{ "term/term.rss.xml", "term/tag.rss.xml", "term/taxonomy.rss.xml", "term/rss.xml", "term/list.rss.xml", "term/term.xml", "term/tag.xml", "term/taxonomy.xml", "term/list.xml", "taxonomy/term.rss.xml", "taxonomy/tag.rss.xml", "taxonomy/taxonomy.rss.xml", "taxonomy/rss.xml", "taxonomy/list.rss.xml", "taxonomy/term.xml", "taxonomy/tag.xml", "taxonomy/taxonomy.xml", "taxonomy/list.xml", "tag/term.rss.xml", "tag/tag.rss.xml", "tag/taxonomy.rss.xml", "tag/rss.xml", "tag/list.rss.xml", "tag/term.xml", "tag/tag.xml", "tag/taxonomy.xml", "tag/list.xml", "_default/term.rss.xml", "_default/tag.rss.xml", "_default/taxonomy.rss.xml", "_default/rss.xml", "_default/list.rss.xml", "_default/term.xml", "_default/tag.xml", "_default/taxonomy.xml", "_default/list.xml", "_internal/_default/rss.xml", }, }, { "RSS Taxonomy", LayoutDescriptor{Kind: "taxonomy", Section: "tag"}, "", RSSFormat, []string{ "tag/tag.terms.rss.xml", "tag/terms.rss.xml", "tag/taxonomy.rss.xml", "tag/rss.xml", "tag/list.rss.xml", "tag/tag.terms.xml", "tag/terms.xml", "tag/taxonomy.xml", "tag/list.xml", "taxonomy/tag.terms.rss.xml", "taxonomy/terms.rss.xml", "taxonomy/taxonomy.rss.xml", "taxonomy/rss.xml", "taxonomy/list.rss.xml", "taxonomy/tag.terms.xml", "taxonomy/terms.xml", "taxonomy/taxonomy.xml", "taxonomy/list.xml", "_default/tag.terms.rss.xml", "_default/terms.rss.xml", "_default/taxonomy.rss.xml", "_default/rss.xml", "_default/list.rss.xml", "_default/tag.terms.xml", "_default/terms.xml", "_default/taxonomy.xml", "_default/list.xml", "_internal/_default/rss.xml", }, }, { "Home plain text", LayoutDescriptor{Kind: "home"}, "", JSONFormat, []string{ "index.json.json", "home.json.json", "list.json.json", "index.json", "home.json", "list.json", "_default/index.json.json", "_default/home.json.json", "_default/list.json.json", "_default/index.json", "_default/home.json", "_default/list.json", }, }, { "Page plain text", LayoutDescriptor{Kind: "page"}, "", JSONFormat, []string{ "_default/single.json.json", "_default/single.json", }, }, { "Reserved section, shortcodes", LayoutDescriptor{Kind: "section", Section: "shortcodes", Type: "shortcodes"}, "", ampType, []string{ "section/shortcodes.amp.html", "section/section.amp.html", "section/list.amp.html", "section/shortcodes.html", "section/section.html", "section/list.html", "_default/shortcodes.amp.html", "_default/section.amp.html", "_default/list.amp.html", "_default/shortcodes.html", "_default/section.html", "_default/list.html", }, }, { "Reserved section, partials", LayoutDescriptor{Kind: "section", Section: "partials", Type: "partials"}, "", ampType, []string{ "section/partials.amp.html", "section/section.amp.html", "section/list.amp.html", "section/partials.html", "section/section.html", "section/list.html", "_default/partials.amp.html", "_default/section.amp.html", "_default/list.amp.html", "_default/partials.html", "_default/section.html", "_default/list.html", }, }, // This is currently always HTML only { "404, HTML", LayoutDescriptor{Kind: "404"}, "", htmlFormat, []string{ "404.html.html", "404.html", }, }, { "404, HTML baseof", LayoutDescriptor{Kind: "404", Baseof: true}, "", htmlFormat, []string{ "404-baseof.html.html", "baseof.html.html", "404-baseof.html", "baseof.html", "_default/404-baseof.html.html", "_default/baseof.html.html", "_default/404-baseof.html", "_default/baseof.html", }, }, { "Content hook", LayoutDescriptor{Kind: "render-link", RenderingHook: true, Layout: "mylayout", Section: "blog"}, "", ampType, []string{ "blog/_markup/render-link.amp.html", "blog/_markup/render-link.html", "_default/_markup/render-link.amp.html", "_default/_markup/render-link.html", }, }, } { c.Run(this.name, func(c *qt.C) { l := NewLayoutHandler() layouts, err := l.For(this.layoutDescriptor, this.format) c.Assert(err, qt.IsNil) c.Assert(layouts, qt.Not(qt.IsNil), qt.Commentf(this.layoutDescriptor.Kind)) if !reflect.DeepEqual(layouts, this.expect) { r := strings.NewReplacer( "[", "\t\"", "]", "\",", " ", "\",\n\t\"", ) fmtGot := r.Replace(fmt.Sprintf("%v", layouts)) fmtExp := r.Replace(fmt.Sprintf("%v", this.expect)) c.Fatalf("got %d items, expected %d:\nGot:\n\t%v\nExpected:\n\t%v\nDiff:\n%s", len(layouts), len(this.expect), layouts, this.expect, diff.Diff(fmtExp, fmtGot)) } }) } } func BenchmarkLayout(b *testing.B) { descriptor := LayoutDescriptor{Kind: "taxonomy", Section: "categories"} l := NewLayoutHandler() for i := 0; i < b.N; i++ { _, err := l.For(descriptor, HTMLFormat) if err != nil { panic(err) } } } func BenchmarkLayoutUncached(b *testing.B) { for i := 0; i < b.N; i++ { descriptor := LayoutDescriptor{Kind: "taxonomy", Section: "categories"} l := NewLayoutHandler() _, err := l.For(descriptor, HTMLFormat) if err != nil { panic(err) } } }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./hugolib/disableKinds_test.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "fmt" "testing" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/resources/page" ) func TestDisable(t *testing.T) { c := qt.New(t) newSitesBuilder := func(c *qt.C, disableKind string) *sitesBuilder { config := fmt.Sprintf(` baseURL = "http://example.com/blog" enableRobotsTXT = true ignoreErrors = ["error-disable-taxonomy"] disableKinds = [%q] `, disableKind) b := newTestSitesBuilder(c) b.WithTemplatesAdded("_default/single.html", `single`) b.WithConfigFile("toml", config).WithContent("sect/page.md", ` --- title: Page categories: ["mycat"] tags: ["mytag"] --- `, "sect/no-list.md", ` --- title: No List _build: list: false --- `, "sect/no-render.md", ` --- title: No List _build: render: false --- `, "sect/no-render-link.md", ` --- title: No Render Link aliases: ["/link-alias"] _build: render: link --- `, "sect/no-publishresources/index.md", ` --- title: No Publish Resources _build: publishResources: false --- `, "sect/headlessbundle/index.md", ` --- title: Headless headless: true --- `, "headless-local/_index.md", ` --- title: Headless Local Lists cascade: _build: render: false list: local publishResources: false --- `, "headless-local/headless-local-page.md", "---\ntitle: Headless Local Page\n---", "headless-local/sub/_index.md", ` --- title: Headless Local Lists Sub --- `, "headless-local/sub/headless-local-sub-page.md", "---\ntitle: Headless Local Sub Page\n---", ) b.WithSourceFile("content/sect/headlessbundle/data.json", "DATA") b.WithSourceFile("content/sect/no-publishresources/data.json", "DATA") return b } getPage := func(b *sitesBuilder, ref string) page.Page { b.Helper() p, err := b.H.Sites[0].getPageNew(nil, ref) b.Assert(err, qt.IsNil) return p } getPageInSitePages := func(b *sitesBuilder, ref string) page.Page { b.Helper() for _, pages := range []page.Pages{b.H.Sites[0].Pages(), b.H.Sites[0].RegularPages()} { for _, p := range pages { if ref == p.(*pageState).sourceRef() { return p } } } return nil } getPageInPagePages := func(p page.Page, ref string, pageCollections ...page.Pages) page.Page { if len(pageCollections) == 0 { pageCollections = []page.Pages{p.Pages(), p.RegularPages(), p.RegularPagesRecursive(), p.Sections()} } for _, pages := range pageCollections { for _, p := range pages { if ref == p.(*pageState).sourceRef() { return p } } } return nil } disableKind := page.KindPage c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) s := b.H.Sites[0] b.Assert(getPage(b, "/sect/page.md"), qt.IsNil) b.Assert(b.CheckExists("public/sect/page/index.html"), qt.Equals, false) b.Assert(getPageInSitePages(b, "/sect/page.md"), qt.IsNil) b.Assert(getPageInPagePages(getPage(b, "/"), "/sect/page.md"), qt.IsNil) // Also check the side effects b.Assert(b.CheckExists("public/categories/mycat/index.html"), qt.Equals, false) b.Assert(len(s.Taxonomies()["categories"]), qt.Equals, 0) }) disableKind = page.KindTerm c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) s := b.H.Sites[0] b.Assert(b.CheckExists("public/categories/index.html"), qt.Equals, true) b.Assert(b.CheckExists("public/categories/mycat/index.html"), qt.Equals, false) b.Assert(len(s.Taxonomies()["categories"]), qt.Equals, 0) b.Assert(getPage(b, "/categories"), qt.Not(qt.IsNil)) b.Assert(getPage(b, "/categories/mycat"), qt.IsNil) }) disableKind = page.KindTaxonomy c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) s := b.H.Sites[0] b.Assert(b.CheckExists("public/categories/mycat/index.html"), qt.Equals, true) b.Assert(b.CheckExists("public/categories/index.html"), qt.Equals, false) b.Assert(len(s.Taxonomies()["categories"]), qt.Equals, 1) b.Assert(getPage(b, "/categories/mycat"), qt.Not(qt.IsNil)) categories := getPage(b, "/categories") b.Assert(categories, qt.Not(qt.IsNil)) b.Assert(categories.RelPermalink(), qt.Equals, "") b.Assert(getPageInSitePages(b, "/categories"), qt.IsNil) b.Assert(getPageInPagePages(getPage(b, "/"), "/categories"), qt.IsNil) }) disableKind = page.KindHome c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/index.html"), qt.Equals, false) home := getPage(b, "/") b.Assert(home, qt.Not(qt.IsNil)) b.Assert(home.RelPermalink(), qt.Equals, "") b.Assert(getPageInSitePages(b, "/"), qt.IsNil) b.Assert(getPageInPagePages(home, "/"), qt.IsNil) b.Assert(getPage(b, "/sect/page.md"), qt.Not(qt.IsNil)) }) disableKind = page.KindSection c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/sect/index.html"), qt.Equals, false) sect := getPage(b, "/sect") b.Assert(sect, qt.Not(qt.IsNil)) b.Assert(sect.RelPermalink(), qt.Equals, "") b.Assert(getPageInSitePages(b, "/sect"), qt.IsNil) home := getPage(b, "/") b.Assert(getPageInPagePages(home, "/sect"), qt.IsNil) b.Assert(home.OutputFormats(), qt.HasLen, 2) page := getPage(b, "/sect/page.md") b.Assert(page, qt.Not(qt.IsNil)) b.Assert(page.CurrentSection(), qt.Equals, sect) b.Assert(getPageInPagePages(sect, "/sect/page.md"), qt.Not(qt.IsNil)) b.AssertFileContent("public/sitemap.xml", "sitemap") b.AssertFileContent("public/index.xml", "rss") }) disableKind = kindRSS c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/index.xml"), qt.Equals, false) home := getPage(b, "/") b.Assert(home.OutputFormats(), qt.HasLen, 1) }) disableKind = kindSitemap c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/sitemap.xml"), qt.Equals, false) }) disableKind = kind404 c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/404.html"), qt.Equals, false) }) disableKind = kindRobotsTXT c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.WithTemplatesAdded("robots.txt", "myrobots") b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/robots.txt"), qt.Equals, false) }) c.Run("Headless bundle", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/sect/headlessbundle/index.html"), qt.Equals, false) b.Assert(b.CheckExists("public/sect/headlessbundle/data.json"), qt.Equals, true) bundle := getPage(b, "/sect/headlessbundle/index.md") b.Assert(bundle, qt.Not(qt.IsNil)) b.Assert(bundle.RelPermalink(), qt.Equals, "") resource := bundle.Resources()[0] b.Assert(resource.RelPermalink(), qt.Equals, "/blog/sect/headlessbundle/data.json") b.Assert(bundle.OutputFormats(), qt.HasLen, 0) b.Assert(bundle.AlternativeOutputFormats(), qt.HasLen, 0) }) c.Run("Build config, no list", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) ref := "/sect/no-list.md" b.Assert(b.CheckExists("public/sect/no-list/index.html"), qt.Equals, true) p := getPage(b, ref) b.Assert(p, qt.Not(qt.IsNil)) b.Assert(p.RelPermalink(), qt.Equals, "/blog/sect/no-list/") b.Assert(getPageInSitePages(b, ref), qt.IsNil) sect := getPage(b, "/sect") b.Assert(getPageInPagePages(sect, ref), qt.IsNil) }) c.Run("Build config, local list", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) ref := "/headless-local" sect := getPage(b, ref) b.Assert(sect, qt.Not(qt.IsNil)) b.Assert(getPageInSitePages(b, ref), qt.IsNil) b.Assert(getPageInSitePages(b, "/headless-local/_index.md"), qt.IsNil) b.Assert(getPageInSitePages(b, "/headless-local/headless-local-page.md"), qt.IsNil) localPageRef := ref + "/headless-local-page.md" b.Assert(getPageInPagePages(sect, localPageRef, sect.RegularPages()), qt.Not(qt.IsNil)) b.Assert(getPageInPagePages(sect, localPageRef, sect.RegularPagesRecursive()), qt.Not(qt.IsNil)) b.Assert(getPageInPagePages(sect, localPageRef, sect.Pages()), qt.Not(qt.IsNil)) ref = "/headless-local/sub" sect = getPage(b, ref) b.Assert(sect, qt.Not(qt.IsNil)) localPageRef = ref + "/headless-local-sub-page.md" b.Assert(getPageInPagePages(sect, localPageRef), qt.Not(qt.IsNil)) }) c.Run("Build config, no render", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) ref := "/sect/no-render.md" b.Assert(b.CheckExists("public/sect/no-render/index.html"), qt.Equals, false) p := getPage(b, ref) b.Assert(p, qt.Not(qt.IsNil)) b.Assert(p.RelPermalink(), qt.Equals, "") b.Assert(p.OutputFormats(), qt.HasLen, 0) b.Assert(getPageInSitePages(b, ref), qt.Not(qt.IsNil)) sect := getPage(b, "/sect") b.Assert(getPageInPagePages(sect, ref), qt.Not(qt.IsNil)) }) c.Run("Build config, no render link", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) ref := "/sect/no-render-link.md" b.Assert(b.CheckExists("public/sect/no-render/index.html"), qt.Equals, false) p := getPage(b, ref) b.Assert(p, qt.Not(qt.IsNil)) b.Assert(p.RelPermalink(), qt.Equals, "/blog/sect/no-render-link/") b.Assert(p.OutputFormats(), qt.HasLen, 1) b.Assert(getPageInSitePages(b, ref), qt.Not(qt.IsNil)) sect := getPage(b, "/sect") b.Assert(getPageInPagePages(sect, ref), qt.Not(qt.IsNil)) // https://github.com/gohugoio/hugo/issues/7832 // It should still render any aliases. b.AssertFileContent("public/link-alias/index.html", "refresh") }) c.Run("Build config, no publish resources", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/sect/no-publishresources/index.html"), qt.Equals, true) b.Assert(b.CheckExists("public/sect/no-publishresources/data.json"), qt.Equals, false) bundle := getPage(b, "/sect/no-publishresources/index.md") b.Assert(bundle, qt.Not(qt.IsNil)) b.Assert(bundle.RelPermalink(), qt.Equals, "/blog/sect/no-publishresources/") b.Assert(bundle.Resources(), qt.HasLen, 1) resource := bundle.Resources()[0] b.Assert(resource.RelPermalink(), qt.Equals, "/blog/sect/no-publishresources/data.json") }) } // https://github.com/gohugoio/hugo/issues/6897#issuecomment-587947078 func TestDisableRSSWithRSSInCustomOutputs(t *testing.T) { b := newTestSitesBuilder(t).WithConfigFile("toml", ` disableKinds = ["term", "taxonomy", "RSS"] [outputs] home = [ "HTML", "RSS" ] `).Build(BuildCfg{}) // The config above is a little conflicting, but it exists in the real world. // In Hugo 0.65 we consolidated the code paths and made RSS a pure output format, // but we should make sure to not break existing sites. b.Assert(b.CheckExists("public/index.xml"), qt.Equals, false) } func TestBundleNoPublishResources(t *testing.T) { b := newTestSitesBuilder(t) b.WithTemplates("index.html", ` {{ $bundle := site.GetPage "section/bundle-false" }} {{ $data1 := $bundle.Resources.GetMatch "data1*" }} Data1: {{ $data1.RelPermalink }} `) b.WithContent("section/bundle-false/index.md", `---\ntitle: BundleFalse _build: publishResources: false ---`, "section/bundle-false/data1.json", "Some data1", "section/bundle-false/data2.json", "Some data2", ) b.WithContent("section/bundle-true/index.md", `---\ntitle: BundleTrue ---`, "section/bundle-true/data3.json", "Some data 3", ) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", `Data1: /section/bundle-false/data1.json`) b.AssertFileContent("public/section/bundle-false/data1.json", `Some data1`) b.Assert(b.CheckExists("public/section/bundle-false/data2.json"), qt.Equals, false) b.AssertFileContent("public/section/bundle-true/data3.json", `Some data 3`) } func TestNoRenderAndNoPublishResources(t *testing.T) { noRenderPage := ` --- title: %s _build: render: false publishResources: false --- ` b := newTestSitesBuilder(t) b.WithTemplatesAdded("index.html", ` {{ $page := site.GetPage "sect/no-render" }} {{ $sect := site.GetPage "sect-no-render" }} Page: {{ $page.Title }}|RelPermalink: {{ $page.RelPermalink }}|Outputs: {{ len $page.OutputFormats }} Section: {{ $sect.Title }}|RelPermalink: {{ $sect.RelPermalink }}|Outputs: {{ len $sect.OutputFormats }} `) b.WithContent("sect-no-render/_index.md", fmt.Sprintf(noRenderPage, "MySection")) b.WithContent("sect/no-render.md", fmt.Sprintf(noRenderPage, "MyPage")) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Page: MyPage|RelPermalink: |Outputs: 0 Section: MySection|RelPermalink: |Outputs: 0 `) b.Assert(b.CheckExists("public/sect/no-render/index.html"), qt.Equals, false) b.Assert(b.CheckExists("public/sect-no-render/index.html"), qt.Equals, false) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "fmt" "testing" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/resources/page" ) func TestDisable(t *testing.T) { c := qt.New(t) newSitesBuilder := func(c *qt.C, disableKind string) *sitesBuilder { config := fmt.Sprintf(` baseURL = "http://example.com/blog" enableRobotsTXT = true ignoreErrors = ["error-disable-taxonomy"] disableKinds = [%q] `, disableKind) b := newTestSitesBuilder(c) b.WithTemplatesAdded("_default/single.html", `single`) b.WithConfigFile("toml", config).WithContent("sect/page.md", ` --- title: Page categories: ["mycat"] tags: ["mytag"] --- `, "sect/no-list.md", ` --- title: No List _build: list: false --- `, "sect/no-render.md", ` --- title: No List _build: render: false --- `, "sect/no-render-link.md", ` --- title: No Render Link aliases: ["/link-alias"] _build: render: link --- `, "sect/no-publishresources/index.md", ` --- title: No Publish Resources _build: publishResources: false --- `, "sect/headlessbundle/index.md", ` --- title: Headless headless: true --- `, "headless-local/_index.md", ` --- title: Headless Local Lists cascade: _build: render: false list: local publishResources: false --- `, "headless-local/headless-local-page.md", "---\ntitle: Headless Local Page\n---", "headless-local/sub/_index.md", ` --- title: Headless Local Lists Sub --- `, "headless-local/sub/headless-local-sub-page.md", "---\ntitle: Headless Local Sub Page\n---", ) b.WithSourceFile("content/sect/headlessbundle/data.json", "DATA") b.WithSourceFile("content/sect/no-publishresources/data.json", "DATA") return b } getPage := func(b *sitesBuilder, ref string) page.Page { b.Helper() p, err := b.H.Sites[0].getPageNew(nil, ref) b.Assert(err, qt.IsNil) return p } getPageInSitePages := func(b *sitesBuilder, ref string) page.Page { b.Helper() for _, pages := range []page.Pages{b.H.Sites[0].Pages(), b.H.Sites[0].RegularPages()} { for _, p := range pages { if ref == p.(*pageState).sourceRef() { return p } } } return nil } getPageInPagePages := func(p page.Page, ref string, pageCollections ...page.Pages) page.Page { if len(pageCollections) == 0 { pageCollections = []page.Pages{p.Pages(), p.RegularPages(), p.RegularPagesRecursive(), p.Sections()} } for _, pages := range pageCollections { for _, p := range pages { if ref == p.(*pageState).sourceRef() { return p } } } return nil } disableKind := page.KindPage c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) s := b.H.Sites[0] b.Assert(getPage(b, "/sect/page.md"), qt.IsNil) b.Assert(b.CheckExists("public/sect/page/index.html"), qt.Equals, false) b.Assert(getPageInSitePages(b, "/sect/page.md"), qt.IsNil) b.Assert(getPageInPagePages(getPage(b, "/"), "/sect/page.md"), qt.IsNil) // Also check the side effects b.Assert(b.CheckExists("public/categories/mycat/index.html"), qt.Equals, false) b.Assert(len(s.Taxonomies()["categories"]), qt.Equals, 0) }) disableKind = page.KindTerm c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) s := b.H.Sites[0] b.Assert(b.CheckExists("public/categories/index.html"), qt.Equals, true) b.Assert(b.CheckExists("public/categories/mycat/index.html"), qt.Equals, false) b.Assert(len(s.Taxonomies()["categories"]), qt.Equals, 0) b.Assert(getPage(b, "/categories"), qt.Not(qt.IsNil)) b.Assert(getPage(b, "/categories/mycat"), qt.IsNil) }) disableKind = page.KindTaxonomy c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) s := b.H.Sites[0] b.Assert(b.CheckExists("public/categories/mycat/index.html"), qt.Equals, true) b.Assert(b.CheckExists("public/categories/index.html"), qt.Equals, false) b.Assert(len(s.Taxonomies()["categories"]), qt.Equals, 1) b.Assert(getPage(b, "/categories/mycat"), qt.Not(qt.IsNil)) categories := getPage(b, "/categories") b.Assert(categories, qt.Not(qt.IsNil)) b.Assert(categories.RelPermalink(), qt.Equals, "") b.Assert(getPageInSitePages(b, "/categories"), qt.IsNil) b.Assert(getPageInPagePages(getPage(b, "/"), "/categories"), qt.IsNil) }) disableKind = page.KindHome c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/index.html"), qt.Equals, false) home := getPage(b, "/") b.Assert(home, qt.Not(qt.IsNil)) b.Assert(home.RelPermalink(), qt.Equals, "") b.Assert(getPageInSitePages(b, "/"), qt.IsNil) b.Assert(getPageInPagePages(home, "/"), qt.IsNil) b.Assert(getPage(b, "/sect/page.md"), qt.Not(qt.IsNil)) }) disableKind = page.KindSection c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/sect/index.html"), qt.Equals, false) sect := getPage(b, "/sect") b.Assert(sect, qt.Not(qt.IsNil)) b.Assert(sect.RelPermalink(), qt.Equals, "") b.Assert(getPageInSitePages(b, "/sect"), qt.IsNil) home := getPage(b, "/") b.Assert(getPageInPagePages(home, "/sect"), qt.IsNil) b.Assert(home.OutputFormats(), qt.HasLen, 2) page := getPage(b, "/sect/page.md") b.Assert(page, qt.Not(qt.IsNil)) b.Assert(page.CurrentSection(), qt.Equals, sect) b.Assert(getPageInPagePages(sect, "/sect/page.md"), qt.Not(qt.IsNil)) b.AssertFileContent("public/sitemap.xml", "sitemap") b.AssertFileContent("public/index.xml", "rss") }) disableKind = kindRSS c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/index.xml"), qt.Equals, false) home := getPage(b, "/") b.Assert(home.OutputFormats(), qt.HasLen, 1) }) disableKind = kindSitemap c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/sitemap.xml"), qt.Equals, false) }) disableKind = kind404 c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/404.html"), qt.Equals, false) }) disableKind = kindRobotsTXT c.Run("Disable "+disableKind, func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.WithTemplatesAdded("robots.txt", "myrobots") b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/robots.txt"), qt.Equals, false) }) c.Run("Headless bundle", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/sect/headlessbundle/index.html"), qt.Equals, false) b.Assert(b.CheckExists("public/sect/headlessbundle/data.json"), qt.Equals, true) bundle := getPage(b, "/sect/headlessbundle/index.md") b.Assert(bundle, qt.Not(qt.IsNil)) b.Assert(bundle.RelPermalink(), qt.Equals, "") resource := bundle.Resources()[0] b.Assert(resource.RelPermalink(), qt.Equals, "/blog/sect/headlessbundle/data.json") b.Assert(bundle.OutputFormats(), qt.HasLen, 0) b.Assert(bundle.AlternativeOutputFormats(), qt.HasLen, 0) }) c.Run("Build config, no list", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) ref := "/sect/no-list.md" b.Assert(b.CheckExists("public/sect/no-list/index.html"), qt.Equals, true) p := getPage(b, ref) b.Assert(p, qt.Not(qt.IsNil)) b.Assert(p.RelPermalink(), qt.Equals, "/blog/sect/no-list/") b.Assert(getPageInSitePages(b, ref), qt.IsNil) sect := getPage(b, "/sect") b.Assert(getPageInPagePages(sect, ref), qt.IsNil) }) c.Run("Build config, local list", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) ref := "/headless-local" sect := getPage(b, ref) b.Assert(sect, qt.Not(qt.IsNil)) b.Assert(getPageInSitePages(b, ref), qt.IsNil) b.Assert(getPageInSitePages(b, "/headless-local/_index.md"), qt.IsNil) b.Assert(getPageInSitePages(b, "/headless-local/headless-local-page.md"), qt.IsNil) localPageRef := ref + "/headless-local-page.md" b.Assert(getPageInPagePages(sect, localPageRef, sect.RegularPages()), qt.Not(qt.IsNil)) b.Assert(getPageInPagePages(sect, localPageRef, sect.RegularPagesRecursive()), qt.Not(qt.IsNil)) b.Assert(getPageInPagePages(sect, localPageRef, sect.Pages()), qt.Not(qt.IsNil)) ref = "/headless-local/sub" sect = getPage(b, ref) b.Assert(sect, qt.Not(qt.IsNil)) localPageRef = ref + "/headless-local-sub-page.md" b.Assert(getPageInPagePages(sect, localPageRef), qt.Not(qt.IsNil)) }) c.Run("Build config, no render", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) ref := "/sect/no-render.md" b.Assert(b.CheckExists("public/sect/no-render/index.html"), qt.Equals, false) p := getPage(b, ref) b.Assert(p, qt.Not(qt.IsNil)) b.Assert(p.RelPermalink(), qt.Equals, "") b.Assert(p.OutputFormats(), qt.HasLen, 0) b.Assert(getPageInSitePages(b, ref), qt.Not(qt.IsNil)) sect := getPage(b, "/sect") b.Assert(getPageInPagePages(sect, ref), qt.Not(qt.IsNil)) }) c.Run("Build config, no render link", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) ref := "/sect/no-render-link.md" b.Assert(b.CheckExists("public/sect/no-render/index.html"), qt.Equals, false) p := getPage(b, ref) b.Assert(p, qt.Not(qt.IsNil)) b.Assert(p.RelPermalink(), qt.Equals, "/blog/sect/no-render-link/") b.Assert(p.OutputFormats(), qt.HasLen, 1) b.Assert(getPageInSitePages(b, ref), qt.Not(qt.IsNil)) sect := getPage(b, "/sect") b.Assert(getPageInPagePages(sect, ref), qt.Not(qt.IsNil)) // https://github.com/gohugoio/hugo/issues/7832 // It should still render any aliases. b.AssertFileContent("public/link-alias/index.html", "refresh") }) c.Run("Build config, no publish resources", func(c *qt.C) { b := newSitesBuilder(c, disableKind) b.Build(BuildCfg{}) b.Assert(b.CheckExists("public/sect/no-publishresources/index.html"), qt.Equals, true) b.Assert(b.CheckExists("public/sect/no-publishresources/data.json"), qt.Equals, false) bundle := getPage(b, "/sect/no-publishresources/index.md") b.Assert(bundle, qt.Not(qt.IsNil)) b.Assert(bundle.RelPermalink(), qt.Equals, "/blog/sect/no-publishresources/") b.Assert(bundle.Resources(), qt.HasLen, 1) resource := bundle.Resources()[0] b.Assert(resource.RelPermalink(), qt.Equals, "/blog/sect/no-publishresources/data.json") }) } // https://github.com/gohugoio/hugo/issues/6897#issuecomment-587947078 func TestDisableRSSWithRSSInCustomOutputs(t *testing.T) { b := newTestSitesBuilder(t).WithConfigFile("toml", ` disableKinds = ["term", "taxonomy", "RSS"] [outputs] home = [ "HTML", "RSS" ] `).Build(BuildCfg{}) // The config above is a little conflicting, but it exists in the real world. // In Hugo 0.65 we consolidated the code paths and made RSS a pure output format, // but we should make sure to not break existing sites. b.Assert(b.CheckExists("public/index.xml"), qt.Equals, false) } func TestBundleNoPublishResources(t *testing.T) { b := newTestSitesBuilder(t) b.WithTemplates("index.html", ` {{ $bundle := site.GetPage "section/bundle-false" }} {{ $data1 := $bundle.Resources.GetMatch "data1*" }} Data1: {{ $data1.RelPermalink }} `) b.WithContent("section/bundle-false/index.md", `---\ntitle: BundleFalse _build: publishResources: false ---`, "section/bundle-false/data1.json", "Some data1", "section/bundle-false/data2.json", "Some data2", ) b.WithContent("section/bundle-true/index.md", `---\ntitle: BundleTrue ---`, "section/bundle-true/data3.json", "Some data 3", ) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", `Data1: /section/bundle-false/data1.json`) b.AssertFileContent("public/section/bundle-false/data1.json", `Some data1`) b.Assert(b.CheckExists("public/section/bundle-false/data2.json"), qt.Equals, false) b.AssertFileContent("public/section/bundle-true/data3.json", `Some data 3`) } func TestNoRenderAndNoPublishResources(t *testing.T) { noRenderPage := ` --- title: %s _build: render: false publishResources: false --- ` b := newTestSitesBuilder(t) b.WithTemplatesAdded("index.html", ` {{ $page := site.GetPage "sect/no-render" }} {{ $sect := site.GetPage "sect-no-render" }} Page: {{ $page.Title }}|RelPermalink: {{ $page.RelPermalink }}|Outputs: {{ len $page.OutputFormats }} Section: {{ $sect.Title }}|RelPermalink: {{ $sect.RelPermalink }}|Outputs: {{ len $sect.OutputFormats }} `) b.WithContent("sect-no-render/_index.md", fmt.Sprintf(noRenderPage, "MySection")) b.WithContent("sect/no-render.md", fmt.Sprintf(noRenderPage, "MyPage")) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Page: MyPage|RelPermalink: |Outputs: 0 Section: MySection|RelPermalink: |Outputs: 0 `) b.Assert(b.CheckExists("public/sect/no-render/index.html"), qt.Equals, false) b.Assert(b.CheckExists("public/sect-no-render/index.html"), qt.Equals, false) }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/urls/urls_test.go
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package urls import ( "net/url" "testing" "github.com/gohugoio/hugo/htesting/hqt" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" "github.com/spf13/viper" ) var ns = New(&deps.Deps{Cfg: viper.New()}) type tstNoStringer struct{} func TestParse(t *testing.T) { t.Parallel() c := qt.New(t) for _, test := range []struct { rawurl interface{} expect interface{} }{ { "http://www.google.com", &url.URL{ Scheme: "http", Host: "www.google.com", }, }, { "http://j@ne:[email protected]", &url.URL{ Scheme: "http", User: url.UserPassword("j@ne", "password"), Host: "google.com", }, }, // errors {tstNoStringer{}, false}, } { result, err := ns.Parse(test.rawurl) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil)) continue } c.Assert(err, qt.IsNil) c.Assert(result, qt.CmpEquals(hqt.DeepAllowUnexported(&url.URL{}, url.Userinfo{})), test.expect) } }
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package urls import ( "net/url" "testing" "github.com/gohugoio/hugo/htesting/hqt" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" "github.com/spf13/viper" ) var ns = New(&deps.Deps{Cfg: viper.New()}) type tstNoStringer struct{} func TestParse(t *testing.T) { t.Parallel() c := qt.New(t) for _, test := range []struct { rawurl interface{} expect interface{} }{ { "http://www.google.com", &url.URL{ Scheme: "http", Host: "www.google.com", }, }, { "http://j@ne:[email protected]", &url.URL{ Scheme: "http", User: url.UserPassword("j@ne", "password"), Host: "google.com", }, }, // errors {tstNoStringer{}, false}, } { result, err := ns.Parse(test.rawurl) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil)) continue } c.Assert(err, qt.IsNil) c.Assert(result, qt.CmpEquals(hqt.DeepAllowUnexported(&url.URL{}, url.Userinfo{})), test.expect) } }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./commands/check_darwin.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package commands import ( "github.com/spf13/cobra" ) var _ cmder = (*checkCmd)(nil) type checkCmd struct { *baseCmd } func newCheckCmd() *checkCmd { cc := &checkCmd{baseCmd: &baseCmd{ cmd: &cobra.Command{ Use: "check", Short: "Contains some verification checks", }, }} cc.cmd.AddCommand(newLimitCmd().getCommand()) return cc }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package commands import ( "github.com/spf13/cobra" ) var _ cmder = (*checkCmd)(nil) type checkCmd struct { *baseCmd } func newCheckCmd() *checkCmd { cc := &checkCmd{baseCmd: &baseCmd{ cmd: &cobra.Command{ Use: "check", Short: "Contains some verification checks", }, }} cc.cmd.AddCommand(newLimitCmd().getCommand()) return cc }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./hugolib/hugo_sites_rebuild_test.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "testing" qt "github.com/frankban/quicktest" ) func TestSitesRebuild(t *testing.T) { configFile := ` baseURL = "https://example.com" title = "Rebuild this" contentDir = "content" enableInlineShortcodes = true timeout = "5s" ` var ( contentFilename = "content/blog/page1.md" dataFilename = "data/mydata.toml" ) createSiteBuilder := func(t testing.TB) *sitesBuilder { b := newTestSitesBuilder(t).WithConfigFile("toml", configFile).Running() b.WithSourceFile(dataFilename, `hugo = "Rocks!"`) b.WithContent("content/_index.md", `--- title: Home, Sweet Home! --- `) b.WithContent(contentFilename, ` --- title: "Page 1" summary: "Initial summary" paginate: 3 --- Content. {{< badge.inline >}} Data Inline: {{ site.Data.mydata.hugo }} {{< /badge.inline >}} `) // For .Page.Render tests b.WithContent("prender.md", `--- title: Page 1 --- Content for Page 1. {{< dorender >}} `) b.WithTemplatesAdded( "layouts/shortcodes/dorender.html", ` {{ $p := .Page }} Render {{ $p.RelPermalink }}: {{ $p.Render "single" }} `) b.WithTemplatesAdded("index.html", ` {{ range (.Paginate .Site.RegularPages).Pages }} * Page Paginate: {{ .Title }}|Summary: {{ .Summary }}|Content: {{ .Content }} {{ end }} {{ range .Site.RegularPages }} * Page Pages: {{ .Title }}|Summary: {{ .Summary }}|Content: {{ .Content }} {{ end }} Content: {{ .Content }} Data: {{ site.Data.mydata.hugo }} `) b.WithTemplatesAdded("layouts/partials/mypartial1.html", `Mypartial1`) b.WithTemplatesAdded("layouts/partials/mypartial2.html", `Mypartial2`) b.WithTemplatesAdded("layouts/partials/mypartial3.html", `Mypartial3`) b.WithTemplatesAdded("_default/single.html", `{{ define "main" }}Single Main: {{ .Title }}|Mypartial1: {{ partial "mypartial1.html" }}{{ end }}`) b.WithTemplatesAdded("_default/list.html", `{{ define "main" }}List Main: {{ .Title }}{{ end }}`) b.WithTemplatesAdded("_default/baseof.html", `Baseof:{{ block "main" . }}Baseof Main{{ end }}|Mypartial3: {{ partial "mypartial3.html" }}:END`) return b } t.Run("Refresh paginator on edit", func(t *testing.T) { b := createSiteBuilder(t) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", "* Page Paginate: Page 1|Summary: Initial summary|Content: <p>Content.</p>") b.EditFiles(contentFilename, ` --- title: "Page 1 edit" summary: "Edited summary" --- Edited content. `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", "* Page Paginate: Page 1 edit|Summary: Edited summary|Content: <p>Edited content.</p>") // https://github.com/gohugoio/hugo/issues/5833 b.AssertFileContent("public/index.html", "* Page Pages: Page 1 edit|Summary: Edited summary|Content: <p>Edited content.</p>") }) // https://github.com/gohugoio/hugo/issues/6768 t.Run("Edit data", func(t *testing.T) { b := createSiteBuilder(t) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Data: Rocks! Data Inline: Rocks! `) b.EditFiles(dataFilename, `hugo = "Rules!"`) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Data: Rules! Data Inline: Rules!`) }) // https://github.com/gohugoio/hugo/issues/6968 t.Run("Edit single.html with base", func(t *testing.T) { b := newTestSitesBuilder(t).Running() b.WithTemplates( "_default/single.html", `{{ define "main" }}Single{{ end }}`, "_default/baseof.html", `Base: {{ block "main" .}}Block{{ end }}`, ) b.WithContent("p1.md", "---\ntitle: Page\n---") b.Build(BuildCfg{}) b.EditFiles("layouts/_default/single.html", `Single Edit: {{ define "main" }}Single{{ end }}`) counters := &testCounters{} b.Build(BuildCfg{testCounters: counters}) b.Assert(int(counters.contentRenderCounter), qt.Equals, 0) }) t.Run("Page.Render, edit baseof", func(t *testing.T) { b := createSiteBuilder(t) b.WithTemplatesAdded("index.html", ` {{ $p := site.GetPage "prender.md" }} prender: {{ $p.Title }}|{{ $p.Content }} `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Render /prender/: Baseof:Single Main: Page 1|Mypartial1: Mypartial1|Mypartial3: Mypartial3:END `) b.EditFiles("layouts/_default/baseof.html", `Baseof Edited:{{ block "main" . }}Baseof Main{{ end }}:END`) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Render /prender/: Baseof Edited:Single Main: Page 1|Mypartial1: Mypartial1:END `) }) t.Run("Page.Render, edit partial in baseof", func(t *testing.T) { b := createSiteBuilder(t) b.WithTemplatesAdded("index.html", ` {{ $p := site.GetPage "prender.md" }} prender: {{ $p.Title }}|{{ $p.Content }} `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Render /prender/: Baseof:Single Main: Page 1|Mypartial1: Mypartial1|Mypartial3: Mypartial3:END `) b.EditFiles("layouts/partials/mypartial3.html", `Mypartial3 Edited`) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Render /prender/: Baseof:Single Main: Page 1|Mypartial1: Mypartial1|Mypartial3: Mypartial3 Edited:END `) }) t.Run("Edit RSS shortcode", func(t *testing.T) { b := createSiteBuilder(t) b.WithContent("output.md", `--- title: Output outputs: ["HTML", "AMP"] layout: output --- Content for Output. {{< output >}} `) b.WithTemplates( "layouts/_default/output.html", `Output HTML: {{ .RelPermalink }}|{{ .Content }}`, "layouts/_default/output.amp.html", `Output AMP: {{ .RelPermalink }}|{{ .Content }}`, "layouts/shortcodes/output.html", `Output Shortcode HTML`, "layouts/shortcodes/output.amp.html", `Output Shortcode AMP`) b.Build(BuildCfg{}) b.AssertFileContent("public/output/index.html", ` Output Shortcode HTML `) b.AssertFileContent("public/amp/output/index.html", ` Output Shortcode AMP `) b.EditFiles("layouts/shortcodes/output.amp.html", `Output Shortcode AMP Edited`) b.Build(BuildCfg{}) b.AssertFileContent("public/amp/output/index.html", ` Output Shortcode AMP Edited `) }) } // Issues #7623 #7625 func TestSitesRebuildOnFilesIncludedWithGetPage(t *testing.T) { b := newTestSitesBuilder(t).Running() b.WithContent("pages/p1.md", `--- title: p1 --- P3: {{< GetPage "pages/p3" >}} `) b.WithContent("pages/p2.md", `--- title: p2 --- P4: {{< site_GetPage "pages/p4" >}} P5: {{< site_GetPage "p5" >}} P6: {{< dot_site_GetPage "p6" >}} `) b.WithContent("pages/p3/index.md", "---\ntitle: p3\nheadless: true\n---\nP3 content") b.WithContent("pages/p4/index.md", "---\ntitle: p4\nheadless: true\n---\nP4 content") b.WithContent("pages/p5.md", "---\ntitle: p5\n---\nP5 content") b.WithContent("pages/p6.md", "---\ntitle: p6\n---\nP6 content") b.WithTemplates( "_default/single.html", `{{ .Content }}`, "shortcodes/GetPage.html", ` {{ $arg := .Get 0 }} {{ $p := .Page.GetPage $arg }} {{ $p.Content }} `, "shortcodes/site_GetPage.html", ` {{ $arg := .Get 0 }} {{ $p := site.GetPage $arg }} {{ $p.Content }} `, "shortcodes/dot_site_GetPage.html", ` {{ $arg := .Get 0 }} {{ $p := .Site.GetPage $arg }} {{ $p.Content }} `, ) b.Build(BuildCfg{}) b.AssertFileContent("public/pages/p1/index.html", "P3 content") b.AssertFileContent("public/pages/p2/index.html", `P4 content P5 content P6 content `) b.EditFiles("content/pages/p3/index.md", "---\ntitle: p3\n---\nP3 changed content") b.EditFiles("content/pages/p4/index.md", "---\ntitle: p4\n---\nP4 changed content") b.EditFiles("content/pages/p5.md", "---\ntitle: p5\n---\nP5 changed content") b.EditFiles("content/pages/p6.md", "---\ntitle: p6\n---\nP6 changed content") b.Build(BuildCfg{}) b.AssertFileContent("public/pages/p1/index.html", "P3 changed content") b.AssertFileContent("public/pages/p2/index.html", `P4 changed content P5 changed content P6 changed content `) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package hugolib import ( "testing" qt "github.com/frankban/quicktest" ) func TestSitesRebuild(t *testing.T) { configFile := ` baseURL = "https://example.com" title = "Rebuild this" contentDir = "content" enableInlineShortcodes = true timeout = "5s" ` var ( contentFilename = "content/blog/page1.md" dataFilename = "data/mydata.toml" ) createSiteBuilder := func(t testing.TB) *sitesBuilder { b := newTestSitesBuilder(t).WithConfigFile("toml", configFile).Running() b.WithSourceFile(dataFilename, `hugo = "Rocks!"`) b.WithContent("content/_index.md", `--- title: Home, Sweet Home! --- `) b.WithContent(contentFilename, ` --- title: "Page 1" summary: "Initial summary" paginate: 3 --- Content. {{< badge.inline >}} Data Inline: {{ site.Data.mydata.hugo }} {{< /badge.inline >}} `) // For .Page.Render tests b.WithContent("prender.md", `--- title: Page 1 --- Content for Page 1. {{< dorender >}} `) b.WithTemplatesAdded( "layouts/shortcodes/dorender.html", ` {{ $p := .Page }} Render {{ $p.RelPermalink }}: {{ $p.Render "single" }} `) b.WithTemplatesAdded("index.html", ` {{ range (.Paginate .Site.RegularPages).Pages }} * Page Paginate: {{ .Title }}|Summary: {{ .Summary }}|Content: {{ .Content }} {{ end }} {{ range .Site.RegularPages }} * Page Pages: {{ .Title }}|Summary: {{ .Summary }}|Content: {{ .Content }} {{ end }} Content: {{ .Content }} Data: {{ site.Data.mydata.hugo }} `) b.WithTemplatesAdded("layouts/partials/mypartial1.html", `Mypartial1`) b.WithTemplatesAdded("layouts/partials/mypartial2.html", `Mypartial2`) b.WithTemplatesAdded("layouts/partials/mypartial3.html", `Mypartial3`) b.WithTemplatesAdded("_default/single.html", `{{ define "main" }}Single Main: {{ .Title }}|Mypartial1: {{ partial "mypartial1.html" }}{{ end }}`) b.WithTemplatesAdded("_default/list.html", `{{ define "main" }}List Main: {{ .Title }}{{ end }}`) b.WithTemplatesAdded("_default/baseof.html", `Baseof:{{ block "main" . }}Baseof Main{{ end }}|Mypartial3: {{ partial "mypartial3.html" }}:END`) return b } t.Run("Refresh paginator on edit", func(t *testing.T) { b := createSiteBuilder(t) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", "* Page Paginate: Page 1|Summary: Initial summary|Content: <p>Content.</p>") b.EditFiles(contentFilename, ` --- title: "Page 1 edit" summary: "Edited summary" --- Edited content. `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", "* Page Paginate: Page 1 edit|Summary: Edited summary|Content: <p>Edited content.</p>") // https://github.com/gohugoio/hugo/issues/5833 b.AssertFileContent("public/index.html", "* Page Pages: Page 1 edit|Summary: Edited summary|Content: <p>Edited content.</p>") }) // https://github.com/gohugoio/hugo/issues/6768 t.Run("Edit data", func(t *testing.T) { b := createSiteBuilder(t) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Data: Rocks! Data Inline: Rocks! `) b.EditFiles(dataFilename, `hugo = "Rules!"`) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Data: Rules! Data Inline: Rules!`) }) // https://github.com/gohugoio/hugo/issues/6968 t.Run("Edit single.html with base", func(t *testing.T) { b := newTestSitesBuilder(t).Running() b.WithTemplates( "_default/single.html", `{{ define "main" }}Single{{ end }}`, "_default/baseof.html", `Base: {{ block "main" .}}Block{{ end }}`, ) b.WithContent("p1.md", "---\ntitle: Page\n---") b.Build(BuildCfg{}) b.EditFiles("layouts/_default/single.html", `Single Edit: {{ define "main" }}Single{{ end }}`) counters := &testCounters{} b.Build(BuildCfg{testCounters: counters}) b.Assert(int(counters.contentRenderCounter), qt.Equals, 0) }) t.Run("Page.Render, edit baseof", func(t *testing.T) { b := createSiteBuilder(t) b.WithTemplatesAdded("index.html", ` {{ $p := site.GetPage "prender.md" }} prender: {{ $p.Title }}|{{ $p.Content }} `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Render /prender/: Baseof:Single Main: Page 1|Mypartial1: Mypartial1|Mypartial3: Mypartial3:END `) b.EditFiles("layouts/_default/baseof.html", `Baseof Edited:{{ block "main" . }}Baseof Main{{ end }}:END`) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Render /prender/: Baseof Edited:Single Main: Page 1|Mypartial1: Mypartial1:END `) }) t.Run("Page.Render, edit partial in baseof", func(t *testing.T) { b := createSiteBuilder(t) b.WithTemplatesAdded("index.html", ` {{ $p := site.GetPage "prender.md" }} prender: {{ $p.Title }}|{{ $p.Content }} `) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Render /prender/: Baseof:Single Main: Page 1|Mypartial1: Mypartial1|Mypartial3: Mypartial3:END `) b.EditFiles("layouts/partials/mypartial3.html", `Mypartial3 Edited`) b.Build(BuildCfg{}) b.AssertFileContent("public/index.html", ` Render /prender/: Baseof:Single Main: Page 1|Mypartial1: Mypartial1|Mypartial3: Mypartial3 Edited:END `) }) t.Run("Edit RSS shortcode", func(t *testing.T) { b := createSiteBuilder(t) b.WithContent("output.md", `--- title: Output outputs: ["HTML", "AMP"] layout: output --- Content for Output. {{< output >}} `) b.WithTemplates( "layouts/_default/output.html", `Output HTML: {{ .RelPermalink }}|{{ .Content }}`, "layouts/_default/output.amp.html", `Output AMP: {{ .RelPermalink }}|{{ .Content }}`, "layouts/shortcodes/output.html", `Output Shortcode HTML`, "layouts/shortcodes/output.amp.html", `Output Shortcode AMP`) b.Build(BuildCfg{}) b.AssertFileContent("public/output/index.html", ` Output Shortcode HTML `) b.AssertFileContent("public/amp/output/index.html", ` Output Shortcode AMP `) b.EditFiles("layouts/shortcodes/output.amp.html", `Output Shortcode AMP Edited`) b.Build(BuildCfg{}) b.AssertFileContent("public/amp/output/index.html", ` Output Shortcode AMP Edited `) }) } // Issues #7623 #7625 func TestSitesRebuildOnFilesIncludedWithGetPage(t *testing.T) { b := newTestSitesBuilder(t).Running() b.WithContent("pages/p1.md", `--- title: p1 --- P3: {{< GetPage "pages/p3" >}} `) b.WithContent("pages/p2.md", `--- title: p2 --- P4: {{< site_GetPage "pages/p4" >}} P5: {{< site_GetPage "p5" >}} P6: {{< dot_site_GetPage "p6" >}} `) b.WithContent("pages/p3/index.md", "---\ntitle: p3\nheadless: true\n---\nP3 content") b.WithContent("pages/p4/index.md", "---\ntitle: p4\nheadless: true\n---\nP4 content") b.WithContent("pages/p5.md", "---\ntitle: p5\n---\nP5 content") b.WithContent("pages/p6.md", "---\ntitle: p6\n---\nP6 content") b.WithTemplates( "_default/single.html", `{{ .Content }}`, "shortcodes/GetPage.html", ` {{ $arg := .Get 0 }} {{ $p := .Page.GetPage $arg }} {{ $p.Content }} `, "shortcodes/site_GetPage.html", ` {{ $arg := .Get 0 }} {{ $p := site.GetPage $arg }} {{ $p.Content }} `, "shortcodes/dot_site_GetPage.html", ` {{ $arg := .Get 0 }} {{ $p := .Site.GetPage $arg }} {{ $p.Content }} `, ) b.Build(BuildCfg{}) b.AssertFileContent("public/pages/p1/index.html", "P3 content") b.AssertFileContent("public/pages/p2/index.html", `P4 content P5 content P6 content `) b.EditFiles("content/pages/p3/index.md", "---\ntitle: p3\n---\nP3 changed content") b.EditFiles("content/pages/p4/index.md", "---\ntitle: p4\n---\nP4 changed content") b.EditFiles("content/pages/p5.md", "---\ntitle: p5\n---\nP5 changed content") b.EditFiles("content/pages/p6.md", "---\ntitle: p6\n---\nP6 changed content") b.Build(BuildCfg{}) b.AssertFileContent("public/pages/p1/index.html", "P3 changed content") b.AssertFileContent("public/pages/p2/index.html", `P4 changed content P5 changed content P6 changed content `) }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./resources/images/color.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package images import ( "encoding/hex" "image/color" "strings" "github.com/pkg/errors" ) // AddColorToPalette adds c as the first color in p if not already there. // Note that it does no additional checks, so callers must make sure // that the palette is valid for the relevant format. func AddColorToPalette(c color.Color, p color.Palette) color.Palette { var found bool for _, cc := range p { if c == cc { found = true break } } if !found { p = append(color.Palette{c}, p...) } return p } // ReplaceColorInPalette will replace the color in palette p closest to c in Euclidean // R,G,B,A space with c. func ReplaceColorInPalette(c color.Color, p color.Palette) { p[p.Index(c)] = c } func hexStringToColor(s string) (color.Color, error) { s = strings.TrimPrefix(s, "#") if len(s) != 3 && len(s) != 6 { return nil, errors.Errorf("invalid color code: %q", s) } s = strings.ToLower(s) if len(s) == 3 { var v string for _, r := range s { v += string(r) + string(r) } s = v } // Standard colors. if s == "ffffff" { return color.White, nil } if s == "000000" { return color.Black, nil } // Set Alfa to white. s += "ff" b, err := hex.DecodeString(s) if err != nil { return nil, err } return color.RGBA{b[0], b[1], b[2], b[3]}, nil }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package images import ( "encoding/hex" "image/color" "strings" "github.com/pkg/errors" ) // AddColorToPalette adds c as the first color in p if not already there. // Note that it does no additional checks, so callers must make sure // that the palette is valid for the relevant format. func AddColorToPalette(c color.Color, p color.Palette) color.Palette { var found bool for _, cc := range p { if c == cc { found = true break } } if !found { p = append(color.Palette{c}, p...) } return p } // ReplaceColorInPalette will replace the color in palette p closest to c in Euclidean // R,G,B,A space with c. func ReplaceColorInPalette(c color.Color, p color.Palette) { p[p.Index(c)] = c } func hexStringToColor(s string) (color.Color, error) { s = strings.TrimPrefix(s, "#") if len(s) != 3 && len(s) != 6 { return nil, errors.Errorf("invalid color code: %q", s) } s = strings.ToLower(s) if len(s) == 3 { var v string for _, r := range s { v += string(r) + string(r) } s = v } // Standard colors. if s == "ffffff" { return color.White, nil } if s == "000000" { return color.Black, nil } // Set Alfa to white. s += "ff" b, err := hex.DecodeString(s) if err != nil { return nil, err } return color.RGBA{b[0], b[1], b[2], b[3]}, nil }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./markup/highlight/highlight_test.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package highlight provides code highlighting. package highlight import ( "testing" qt "github.com/frankban/quicktest" ) func TestHighlight(t *testing.T) { c := qt.New(t) lines := `LINE1 LINE2 LINE3 LINE4 LINE5 ` coalesceNeeded := `GET /foo HTTP/1.1 Content-Type: application/json User-Agent: foo { "hello": "world" }` c.Run("Basic", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false h := New(cfg) result, _ := h.Highlight(`echo "Hugo Rocks!"`, "bash", "") c.Assert(result, qt.Equals, `<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">echo</span> <span class="s2">&#34;Hugo Rocks!&#34;</span></code></pre></div>`) result, _ = h.Highlight(`echo "Hugo Rocks!"`, "unknown", "") c.Assert(result, qt.Equals, `<pre><code class="language-unknown" data-lang="unknown">echo &#34;Hugo Rocks!&#34;</code></pre>`) }) c.Run("Highlight lines, default config", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false h := New(cfg) result, _ := h.Highlight(lines, "bash", "linenos=table,hl_lines=2 4-5,linenostart=3") c.Assert(result, qt.Contains, "<div class=\"highlight\"><div class=\"chroma\">\n<table class=\"lntable\"><tr><td class=\"lntd\">\n<pre class=\"chroma\"><code><span class") c.Assert(result, qt.Contains, "<span class=\"hl\"><span class=\"lnt\">4") result, _ = h.Highlight(lines, "bash", "linenos=inline,hl_lines=2") c.Assert(result, qt.Contains, "<span class=\"ln\">2</span>LINE2\n</span>") c.Assert(result, qt.Not(qt.Contains), "<table") result, _ = h.Highlight(lines, "bash", "linenos=true,hl_lines=2") c.Assert(result, qt.Contains, "<table") c.Assert(result, qt.Contains, "<span class=\"hl\"><span class=\"lnt\">2\n</span>") }) c.Run("Highlight lines, linenumbers default on", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false cfg.LineNos = true h := New(cfg) result, _ := h.Highlight(lines, "bash", "") c.Assert(result, qt.Contains, "<span class=\"lnt\">2\n</span>") result, _ = h.Highlight(lines, "bash", "linenos=false,hl_lines=2") c.Assert(result, qt.Not(qt.Contains), "class=\"lnt\"") }) c.Run("Highlight lines, linenumbers default on, anchorlinenumbers default on", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false cfg.LineNos = true cfg.AnchorLineNos = true h := New(cfg) result, _ := h.Highlight(lines, "bash", "") // From Chroma v0.8.2 this is linkable: https://github.com/alecthomas/chroma/commit/ab61726cdb54d5a98b6efe7ed76af6aa0698ab4a c.Assert(result, qt.Contains, "<span class=\"lnt\" id=\"2\"><a style=\"outline: none; text-decoration:none; color:inherit\" href=\"#2\">2</a>\n</span>") result, _ = h.Highlight(lines, "bash", "lineanchors=test") result, _ = h.Highlight(lines, "bash", "anchorlinenos=false,hl_lines=2") c.Assert(result, qt.Not(qt.Contains), "id=\"2\"") }) c.Run("Highlight lines, linenumbers default on, linenumbers in table default off", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false cfg.LineNos = true cfg.LineNumbersInTable = false h := New(cfg) result, _ := h.Highlight(lines, "bash", "") c.Assert(result, qt.Contains, "<span class=\"ln\">2</span>LINE2\n<") result, _ = h.Highlight(lines, "bash", "linenos=table") c.Assert(result, qt.Contains, "<span class=\"lnt\">1\n</span>") }) c.Run("No language", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false cfg.LineNos = true h := New(cfg) result, _ := h.Highlight(lines, "", "") c.Assert(result, qt.Equals, "<pre><code>LINE1\nLINE2\nLINE3\nLINE4\nLINE5\n</code></pre>") }) c.Run("No language, guess syntax", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false cfg.GuessSyntax = true cfg.LineNos = true cfg.LineNumbersInTable = false h := New(cfg) result, _ := h.Highlight(lines, "", "") c.Assert(result, qt.Contains, "<span class=\"ln\">2</span>LINE2\n<") }) c.Run("No language, Escape HTML string", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false h := New(cfg) result, _ := h.Highlight("Escaping less-than in code block? <fail>", "", "") c.Assert(result, qt.Contains, "&lt;fail&gt;") }) c.Run("Highlight lines, default config", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false h := New(cfg) result, _ := h.Highlight(coalesceNeeded, "http", "linenos=true,hl_lines=2") c.Assert(result, qt.Contains, "hello") c.Assert(result, qt.Contains, "}") }) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package highlight provides code highlighting. package highlight import ( "testing" qt "github.com/frankban/quicktest" ) func TestHighlight(t *testing.T) { c := qt.New(t) lines := `LINE1 LINE2 LINE3 LINE4 LINE5 ` coalesceNeeded := `GET /foo HTTP/1.1 Content-Type: application/json User-Agent: foo { "hello": "world" }` c.Run("Basic", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false h := New(cfg) result, _ := h.Highlight(`echo "Hugo Rocks!"`, "bash", "") c.Assert(result, qt.Equals, `<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">echo</span> <span class="s2">&#34;Hugo Rocks!&#34;</span></code></pre></div>`) result, _ = h.Highlight(`echo "Hugo Rocks!"`, "unknown", "") c.Assert(result, qt.Equals, `<pre><code class="language-unknown" data-lang="unknown">echo &#34;Hugo Rocks!&#34;</code></pre>`) }) c.Run("Highlight lines, default config", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false h := New(cfg) result, _ := h.Highlight(lines, "bash", "linenos=table,hl_lines=2 4-5,linenostart=3") c.Assert(result, qt.Contains, "<div class=\"highlight\"><div class=\"chroma\">\n<table class=\"lntable\"><tr><td class=\"lntd\">\n<pre class=\"chroma\"><code><span class") c.Assert(result, qt.Contains, "<span class=\"hl\"><span class=\"lnt\">4") result, _ = h.Highlight(lines, "bash", "linenos=inline,hl_lines=2") c.Assert(result, qt.Contains, "<span class=\"ln\">2</span>LINE2\n</span>") c.Assert(result, qt.Not(qt.Contains), "<table") result, _ = h.Highlight(lines, "bash", "linenos=true,hl_lines=2") c.Assert(result, qt.Contains, "<table") c.Assert(result, qt.Contains, "<span class=\"hl\"><span class=\"lnt\">2\n</span>") }) c.Run("Highlight lines, linenumbers default on", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false cfg.LineNos = true h := New(cfg) result, _ := h.Highlight(lines, "bash", "") c.Assert(result, qt.Contains, "<span class=\"lnt\">2\n</span>") result, _ = h.Highlight(lines, "bash", "linenos=false,hl_lines=2") c.Assert(result, qt.Not(qt.Contains), "class=\"lnt\"") }) c.Run("Highlight lines, linenumbers default on, anchorlinenumbers default on", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false cfg.LineNos = true cfg.AnchorLineNos = true h := New(cfg) result, _ := h.Highlight(lines, "bash", "") // From Chroma v0.8.2 this is linkable: https://github.com/alecthomas/chroma/commit/ab61726cdb54d5a98b6efe7ed76af6aa0698ab4a c.Assert(result, qt.Contains, "<span class=\"lnt\" id=\"2\"><a style=\"outline: none; text-decoration:none; color:inherit\" href=\"#2\">2</a>\n</span>") result, _ = h.Highlight(lines, "bash", "lineanchors=test") result, _ = h.Highlight(lines, "bash", "anchorlinenos=false,hl_lines=2") c.Assert(result, qt.Not(qt.Contains), "id=\"2\"") }) c.Run("Highlight lines, linenumbers default on, linenumbers in table default off", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false cfg.LineNos = true cfg.LineNumbersInTable = false h := New(cfg) result, _ := h.Highlight(lines, "bash", "") c.Assert(result, qt.Contains, "<span class=\"ln\">2</span>LINE2\n<") result, _ = h.Highlight(lines, "bash", "linenos=table") c.Assert(result, qt.Contains, "<span class=\"lnt\">1\n</span>") }) c.Run("No language", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false cfg.LineNos = true h := New(cfg) result, _ := h.Highlight(lines, "", "") c.Assert(result, qt.Equals, "<pre><code>LINE1\nLINE2\nLINE3\nLINE4\nLINE5\n</code></pre>") }) c.Run("No language, guess syntax", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false cfg.GuessSyntax = true cfg.LineNos = true cfg.LineNumbersInTable = false h := New(cfg) result, _ := h.Highlight(lines, "", "") c.Assert(result, qt.Contains, "<span class=\"ln\">2</span>LINE2\n<") }) c.Run("No language, Escape HTML string", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false h := New(cfg) result, _ := h.Highlight("Escaping less-than in code block? <fail>", "", "") c.Assert(result, qt.Contains, "&lt;fail&gt;") }) c.Run("Highlight lines, default config", func(c *qt.C) { cfg := DefaultConfig cfg.NoClasses = false h := New(cfg) result, _ := h.Highlight(coalesceNeeded, "http", "linenos=true,hl_lines=2") c.Assert(result, qt.Contains, "hello") c.Assert(result, qt.Contains, "}") }) }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./config/commonConfig.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package config import ( "sort" "strings" "sync" "github.com/pkg/errors" "github.com/gohugoio/hugo/common/types" "github.com/gobwas/glob" "github.com/gohugoio/hugo/common/herrors" "github.com/mitchellh/mapstructure" "github.com/spf13/cast" jww "github.com/spf13/jwalterweatherman" ) var DefaultBuild = Build{ UseResourceCacheWhen: "fallback", WriteStats: false, } // Build holds some build related configuration. type Build struct { UseResourceCacheWhen string // never, fallback, always. Default is fallback // When enabled, will collect and write a hugo_stats.json with some build // related aggregated data (e.g. CSS class names). WriteStats bool // Can be used to toggle off writing of the intellinsense /assets/jsconfig.js // file. NoJSConfigInAssets bool } func (b Build) UseResourceCache(err error) bool { if b.UseResourceCacheWhen == "never" { return false } if b.UseResourceCacheWhen == "fallback" { return err == herrors.ErrFeatureNotAvailable } return true } func DecodeBuild(cfg Provider) Build { m := cfg.GetStringMap("build") b := DefaultBuild if m == nil { return b } err := mapstructure.WeakDecode(m, &b) if err != nil { return DefaultBuild } b.UseResourceCacheWhen = strings.ToLower(b.UseResourceCacheWhen) when := b.UseResourceCacheWhen if when != "never" && when != "always" && when != "fallback" { b.UseResourceCacheWhen = "fallback" } return b } // Sitemap configures the sitemap to be generated. type Sitemap struct { ChangeFreq string Priority float64 Filename string } func DecodeSitemap(prototype Sitemap, input map[string]interface{}) Sitemap { for key, value := range input { switch key { case "changefreq": prototype.ChangeFreq = cast.ToString(value) case "priority": prototype.Priority = cast.ToFloat64(value) case "filename": prototype.Filename = cast.ToString(value) default: jww.WARN.Printf("Unknown Sitemap field: %s\n", key) } } return prototype } // Config for the dev server. type Server struct { Headers []Headers Redirects []Redirect compiledInit sync.Once compiledHeaders []glob.Glob compiledRedirects []glob.Glob } func (s *Server) init() { s.compiledInit.Do(func() { for _, h := range s.Headers { s.compiledHeaders = append(s.compiledHeaders, glob.MustCompile(h.For)) } for _, r := range s.Redirects { s.compiledRedirects = append(s.compiledRedirects, glob.MustCompile(r.From)) } }) } func (s *Server) MatchHeaders(pattern string) []types.KeyValueStr { s.init() if s.compiledHeaders == nil { return nil } var matches []types.KeyValueStr for i, g := range s.compiledHeaders { if g.Match(pattern) { h := s.Headers[i] for k, v := range h.Values { matches = append(matches, types.KeyValueStr{Key: k, Value: cast.ToString(v)}) } } } sort.Slice(matches, func(i, j int) bool { return matches[i].Key < matches[j].Key }) return matches } func (s *Server) MatchRedirect(pattern string) Redirect { s.init() if s.compiledRedirects == nil { return Redirect{} } pattern = strings.TrimSuffix(pattern, "index.html") for i, g := range s.compiledRedirects { redir := s.Redirects[i] // No redirect to self. if redir.To == pattern { return Redirect{} } if g.Match(pattern) { return redir } } return Redirect{} } type Headers struct { For string Values map[string]interface{} } type Redirect struct { From string To string Status int Force bool } func (r Redirect) IsZero() bool { return r.From == "" } func DecodeServer(cfg Provider) (*Server, error) { m := cfg.GetStringMap("server") s := &Server{} if m == nil { return s, nil } _ = mapstructure.WeakDecode(m, s) for i, redir := range s.Redirects { // Get it in line with the Hugo server. redir.To = strings.TrimSuffix(redir.To, "index.html") if !strings.HasPrefix(redir.To, "https") && !strings.HasSuffix(redir.To, "/") { // There are some tricky infinite loop situations when dealing // when the target does not have a trailing slash. // This can certainly be handled better, but not time for that now. return nil, errors.Errorf("unsupported redirect to value %q in server config; currently this must be either a remote destination or a local folder, e.g. \"/blog/\" or \"/blog/index.html\"", redir.To) } s.Redirects[i] = redir } return s, nil }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package config import ( "sort" "strings" "sync" "github.com/pkg/errors" "github.com/gohugoio/hugo/common/types" "github.com/gobwas/glob" "github.com/gohugoio/hugo/common/herrors" "github.com/mitchellh/mapstructure" "github.com/spf13/cast" jww "github.com/spf13/jwalterweatherman" ) var DefaultBuild = Build{ UseResourceCacheWhen: "fallback", WriteStats: false, } // Build holds some build related configuration. type Build struct { UseResourceCacheWhen string // never, fallback, always. Default is fallback // When enabled, will collect and write a hugo_stats.json with some build // related aggregated data (e.g. CSS class names). WriteStats bool // Can be used to toggle off writing of the intellinsense /assets/jsconfig.js // file. NoJSConfigInAssets bool } func (b Build) UseResourceCache(err error) bool { if b.UseResourceCacheWhen == "never" { return false } if b.UseResourceCacheWhen == "fallback" { return err == herrors.ErrFeatureNotAvailable } return true } func DecodeBuild(cfg Provider) Build { m := cfg.GetStringMap("build") b := DefaultBuild if m == nil { return b } err := mapstructure.WeakDecode(m, &b) if err != nil { return DefaultBuild } b.UseResourceCacheWhen = strings.ToLower(b.UseResourceCacheWhen) when := b.UseResourceCacheWhen if when != "never" && when != "always" && when != "fallback" { b.UseResourceCacheWhen = "fallback" } return b } // Sitemap configures the sitemap to be generated. type Sitemap struct { ChangeFreq string Priority float64 Filename string } func DecodeSitemap(prototype Sitemap, input map[string]interface{}) Sitemap { for key, value := range input { switch key { case "changefreq": prototype.ChangeFreq = cast.ToString(value) case "priority": prototype.Priority = cast.ToFloat64(value) case "filename": prototype.Filename = cast.ToString(value) default: jww.WARN.Printf("Unknown Sitemap field: %s\n", key) } } return prototype } // Config for the dev server. type Server struct { Headers []Headers Redirects []Redirect compiledInit sync.Once compiledHeaders []glob.Glob compiledRedirects []glob.Glob } func (s *Server) init() { s.compiledInit.Do(func() { for _, h := range s.Headers { s.compiledHeaders = append(s.compiledHeaders, glob.MustCompile(h.For)) } for _, r := range s.Redirects { s.compiledRedirects = append(s.compiledRedirects, glob.MustCompile(r.From)) } }) } func (s *Server) MatchHeaders(pattern string) []types.KeyValueStr { s.init() if s.compiledHeaders == nil { return nil } var matches []types.KeyValueStr for i, g := range s.compiledHeaders { if g.Match(pattern) { h := s.Headers[i] for k, v := range h.Values { matches = append(matches, types.KeyValueStr{Key: k, Value: cast.ToString(v)}) } } } sort.Slice(matches, func(i, j int) bool { return matches[i].Key < matches[j].Key }) return matches } func (s *Server) MatchRedirect(pattern string) Redirect { s.init() if s.compiledRedirects == nil { return Redirect{} } pattern = strings.TrimSuffix(pattern, "index.html") for i, g := range s.compiledRedirects { redir := s.Redirects[i] // No redirect to self. if redir.To == pattern { return Redirect{} } if g.Match(pattern) { return redir } } return Redirect{} } type Headers struct { For string Values map[string]interface{} } type Redirect struct { From string To string Status int Force bool } func (r Redirect) IsZero() bool { return r.From == "" } func DecodeServer(cfg Provider) (*Server, error) { m := cfg.GetStringMap("server") s := &Server{} if m == nil { return s, nil } _ = mapstructure.WeakDecode(m, s) for i, redir := range s.Redirects { // Get it in line with the Hugo server. redir.To = strings.TrimSuffix(redir.To, "index.html") if !strings.HasPrefix(redir.To, "https") && !strings.HasSuffix(redir.To, "/") { // There are some tricky infinite loop situations when dealing // when the target does not have a trailing slash. // This can certainly be handled better, but not time for that now. return nil, errors.Errorf("unsupported redirect to value %q in server config; currently this must be either a remote destination or a local folder, e.g. \"/blog/\" or \"/blog/index.html\"", redir.To) } s.Redirects[i] = redir } return s, nil }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/lang/init_test.go
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package lang import ( "testing" "github.com/gohugoio/hugo/htesting/hqt" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/tpl/internal" ) func TestInit(t *testing.T) { c := qt.New(t) var found bool var ns *internal.TemplateFuncsNamespace for _, nsf := range internal.TemplateFuncsNamespaceRegistry { ns = nsf(&deps.Deps{}) if ns.Name == name { found = true break } } c.Assert(found, qt.Equals, true) c.Assert(ns.Context(), hqt.IsSameType, &Namespace{}) }
// Copyright 2017 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package lang import ( "testing" "github.com/gohugoio/hugo/htesting/hqt" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/tpl/internal" ) func TestInit(t *testing.T) { c := qt.New(t) var found bool var ns *internal.TemplateFuncsNamespace for _, nsf := range internal.TemplateFuncsNamespaceRegistry { ns = nsf(&deps.Deps{}) if ns.Name == name { found = true break } } c.Assert(found, qt.Equals, true) c.Assert(ns.Context(), hqt.IsSameType, &Namespace{}) }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/internal/go_templates/htmltemplate/html_test.go
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build go1.13,!windows package template import ( "html" "strings" "testing" ) func TestHTMLNospaceEscaper(t *testing.T) { input := ("\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + ` !"#$%&'()*+,-./` + `0123456789:;<=>?` + `@ABCDEFGHIJKLMNO` + `PQRSTUVWXYZ[\]^_` + "`abcdefghijklmno" + "pqrstuvwxyz{|}~\x7f" + "\u00A0\u0100\u2028\u2029\ufeff\ufdec\U0001D11E" + "erroneous\x960") // keep at the end want := ("&#xfffd;\x01\x02\x03\x04\x05\x06\x07" + "\x08&#9;&#10;&#11;&#12;&#13;\x0E\x0F" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + `&#32;!&#34;#$%&amp;&#39;()*&#43;,-./` + `0123456789:;&lt;&#61;&gt;?` + `@ABCDEFGHIJKLMNO` + `PQRSTUVWXYZ[\]^_` + `&#96;abcdefghijklmno` + `pqrstuvwxyz{|}~` + "\u007f" + "\u00A0\u0100\u2028\u2029\ufeff&#xfdec;\U0001D11E" + "erroneous&#xfffd;0") // keep at the end got := htmlNospaceEscaper(input) if got != want { t.Errorf("encode: want\n\t%q\nbut got\n\t%q", want, got) } r := strings.NewReplacer("\x00", "\ufffd", "\x96", "\ufffd") got, want = html.UnescapeString(got), r.Replace(input) if want != got { t.Errorf("decode: want\n\t%q\nbut got\n\t%q", want, got) } } func TestStripTags(t *testing.T) { tests := []struct { input, want string }{ {"", ""}, {"Hello, World!", "Hello, World!"}, {"foo&amp;bar", "foo&amp;bar"}, {`Hello <a href="www.example.com/">World</a>!`, "Hello World!"}, {"Foo <textarea>Bar</textarea> Baz", "Foo Bar Baz"}, {"Foo <!-- Bar --> Baz", "Foo Baz"}, {"<", "<"}, {"foo < bar", "foo < bar"}, {`Foo<script type="text/javascript">alert(1337)</script>Bar`, "FooBar"}, {`Foo<div title="1>2">Bar`, "FooBar"}, {`I <3 Ponies!`, `I <3 Ponies!`}, {`<script>foo()</script>`, ``}, } for _, test := range tests { if got := stripTags(test.input); got != test.want { t.Errorf("%q: want %q, got %q", test.input, test.want, got) } } } func BenchmarkHTMLNospaceEscaper(b *testing.B) { for i := 0; i < b.N; i++ { htmlNospaceEscaper("The <i>quick</i>,\r\n<span style='color:brown'>brown</span> fox jumps\u2028over the <canine class=\"lazy\">dog</canine>") } } func BenchmarkHTMLNospaceEscaperNoSpecials(b *testing.B) { for i := 0; i < b.N; i++ { htmlNospaceEscaper("The_quick,_brown_fox_jumps_over_the_lazy_dog.") } } func BenchmarkStripTags(b *testing.B) { for i := 0; i < b.N; i++ { stripTags("The <i>quick</i>,\r\n<span style='color:brown'>brown</span> fox jumps\u2028over the <canine class=\"lazy\">dog</canine>") } } func BenchmarkStripTagsNoSpecials(b *testing.B) { for i := 0; i < b.N; i++ { stripTags("The quick, brown fox jumps over the lazy dog.") } }
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build go1.13,!windows package template import ( "html" "strings" "testing" ) func TestHTMLNospaceEscaper(t *testing.T) { input := ("\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + ` !"#$%&'()*+,-./` + `0123456789:;<=>?` + `@ABCDEFGHIJKLMNO` + `PQRSTUVWXYZ[\]^_` + "`abcdefghijklmno" + "pqrstuvwxyz{|}~\x7f" + "\u00A0\u0100\u2028\u2029\ufeff\ufdec\U0001D11E" + "erroneous\x960") // keep at the end want := ("&#xfffd;\x01\x02\x03\x04\x05\x06\x07" + "\x08&#9;&#10;&#11;&#12;&#13;\x0E\x0F" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + `&#32;!&#34;#$%&amp;&#39;()*&#43;,-./` + `0123456789:;&lt;&#61;&gt;?` + `@ABCDEFGHIJKLMNO` + `PQRSTUVWXYZ[\]^_` + `&#96;abcdefghijklmno` + `pqrstuvwxyz{|}~` + "\u007f" + "\u00A0\u0100\u2028\u2029\ufeff&#xfdec;\U0001D11E" + "erroneous&#xfffd;0") // keep at the end got := htmlNospaceEscaper(input) if got != want { t.Errorf("encode: want\n\t%q\nbut got\n\t%q", want, got) } r := strings.NewReplacer("\x00", "\ufffd", "\x96", "\ufffd") got, want = html.UnescapeString(got), r.Replace(input) if want != got { t.Errorf("decode: want\n\t%q\nbut got\n\t%q", want, got) } } func TestStripTags(t *testing.T) { tests := []struct { input, want string }{ {"", ""}, {"Hello, World!", "Hello, World!"}, {"foo&amp;bar", "foo&amp;bar"}, {`Hello <a href="www.example.com/">World</a>!`, "Hello World!"}, {"Foo <textarea>Bar</textarea> Baz", "Foo Bar Baz"}, {"Foo <!-- Bar --> Baz", "Foo Baz"}, {"<", "<"}, {"foo < bar", "foo < bar"}, {`Foo<script type="text/javascript">alert(1337)</script>Bar`, "FooBar"}, {`Foo<div title="1>2">Bar`, "FooBar"}, {`I <3 Ponies!`, `I <3 Ponies!`}, {`<script>foo()</script>`, ``}, } for _, test := range tests { if got := stripTags(test.input); got != test.want { t.Errorf("%q: want %q, got %q", test.input, test.want, got) } } } func BenchmarkHTMLNospaceEscaper(b *testing.B) { for i := 0; i < b.N; i++ { htmlNospaceEscaper("The <i>quick</i>,\r\n<span style='color:brown'>brown</span> fox jumps\u2028over the <canine class=\"lazy\">dog</canine>") } } func BenchmarkHTMLNospaceEscaperNoSpecials(b *testing.B) { for i := 0; i < b.N; i++ { htmlNospaceEscaper("The_quick,_brown_fox_jumps_over_the_lazy_dog.") } } func BenchmarkStripTags(b *testing.B) { for i := 0; i < b.N; i++ { stripTags("The <i>quick</i>,\r\n<span style='color:brown'>brown</span> fox jumps\u2028over the <canine class=\"lazy\">dog</canine>") } } func BenchmarkStripTagsNoSpecials(b *testing.B) { for i := 0; i < b.N; i++ { stripTags("The quick, brown fox jumps over the lazy dog.") } }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./releaser/github_test.go
// Copyright 2017-present The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package releaser import ( "fmt" "os" "testing" qt "github.com/frankban/quicktest" ) func TestGitHubLookupCommit(t *testing.T) { skipIfNoToken(t) c := qt.New(t) client := newGitHubAPI("hugo") commit, err := client.fetchCommit("793554108763c0984f1a1b1a6ee5744b560d78d0") c.Assert(err, qt.IsNil) fmt.Println(commit) } func TestFetchRepo(t *testing.T) { skipIfNoToken(t) c := qt.New(t) client := newGitHubAPI("hugo") repo, err := client.fetchRepo() c.Assert(err, qt.IsNil) fmt.Println(">>", len(repo.Contributors)) } func skipIfNoToken(t *testing.T) { if os.Getenv("GITHUB_TOKEN") == "" { t.Skip("Skip test against GitHub as no GITHUB_TOKEN set.") } }
// Copyright 2017-present The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package releaser import ( "fmt" "os" "testing" qt "github.com/frankban/quicktest" ) func TestGitHubLookupCommit(t *testing.T) { skipIfNoToken(t) c := qt.New(t) client := newGitHubAPI("hugo") commit, err := client.fetchCommit("793554108763c0984f1a1b1a6ee5744b560d78d0") c.Assert(err, qt.IsNil) fmt.Println(commit) } func TestFetchRepo(t *testing.T) { skipIfNoToken(t) c := qt.New(t) client := newGitHubAPI("hugo") repo, err := client.fetchRepo() c.Assert(err, qt.IsNil) fmt.Println(">>", len(repo.Contributors)) } func skipIfNoToken(t *testing.T) { if os.Getenv("GITHUB_TOKEN") == "" { t.Skip("Skip test against GitHub as no GITHUB_TOKEN set.") } }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/internal/templatefuncsRegistry.go
// Copyright 2017-present The Hugo Authors. All rights reserved. // // Portions Copyright The Go Authors. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package internal import ( "bytes" "encoding/json" "fmt" "go/doc" "go/parser" "go/token" "io/ioutil" "log" "os" "path/filepath" "reflect" "runtime" "strings" "sync" "github.com/gohugoio/hugo/deps" ) // TemplateFuncsNamespaceRegistry describes a registry of functions that provide // namespaces. var TemplateFuncsNamespaceRegistry []func(d *deps.Deps) *TemplateFuncsNamespace // AddTemplateFuncsNamespace adds a given function to a registry. func AddTemplateFuncsNamespace(ns func(d *deps.Deps) *TemplateFuncsNamespace) { TemplateFuncsNamespaceRegistry = append(TemplateFuncsNamespaceRegistry, ns) } // TemplateFuncsNamespace represents a template function namespace. type TemplateFuncsNamespace struct { // The namespace name, "strings", "lang", etc. Name string // This is the method receiver. Context func(v ...interface{}) interface{} // Additional info, aliases and examples, per method name. MethodMappings map[string]TemplateFuncMethodMapping } // TemplateFuncsNamespaces is a slice of TemplateFuncsNamespace. type TemplateFuncsNamespaces []*TemplateFuncsNamespace // AddMethodMapping adds a method to a template function namespace. func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []string, examples [][2]string) { if t.MethodMappings == nil { t.MethodMappings = make(map[string]TemplateFuncMethodMapping) } name := methodToName(m) // sanity check for _, e := range examples { if e[0] == "" { panic(t.Name + ": Empty example for " + name) } } for _, a := range aliases { if a == "" { panic(t.Name + ": Empty alias for " + name) } } t.MethodMappings[name] = TemplateFuncMethodMapping{ Method: m, Aliases: aliases, Examples: examples, } } // TemplateFuncMethodMapping represents a mapping of functions to methods for a // given namespace. type TemplateFuncMethodMapping struct { Method interface{} // Any template funcs aliases. This is mainly motivated by keeping // backwards compatibility, but some new template funcs may also make // sense to give short and snappy aliases. // Note that these aliases are global and will be merged, so the last // key will win. Aliases []string // A slice of input/expected examples. // We keep it a the namespace level for now, but may find a way to keep track // of the single template func, for documentation purposes. // Some of these, hopefully just a few, may depend on some test data to run. Examples [][2]string } func methodToName(m interface{}) string { name := runtime.FuncForPC(reflect.ValueOf(m).Pointer()).Name() name = filepath.Ext(name) name = strings.TrimPrefix(name, ".") name = strings.TrimSuffix(name, "-fm") return name } type goDocFunc struct { Name string Description string Args []string Aliases []string Examples [][2]string } func (t goDocFunc) toJSON() ([]byte, error) { args, err := json.Marshal(t.Args) if err != nil { return nil, err } aliases, err := json.Marshal(t.Aliases) if err != nil { return nil, err } examples, err := json.Marshal(t.Examples) if err != nil { return nil, err } var buf bytes.Buffer buf.WriteString(fmt.Sprintf(`%q: { "Description": %q, "Args": %s, "Aliases": %s, "Examples": %s } `, t.Name, t.Description, args, aliases, examples)) return buf.Bytes(), nil } // MarshalJSON returns the JSON encoding of namespaces. func (namespaces TemplateFuncsNamespaces) MarshalJSON() ([]byte, error) { var buf bytes.Buffer buf.WriteString("{") for i, ns := range namespaces { if i != 0 { buf.WriteString(",") } b, err := ns.toJSON() if err != nil { return nil, err } buf.Write(b) } buf.WriteString("}") return buf.Bytes(), nil } func (t *TemplateFuncsNamespace) toJSON() ([]byte, error) { var buf bytes.Buffer godoc := getGetTplPackagesGoDoc()[t.Name] var funcs []goDocFunc buf.WriteString(fmt.Sprintf(`%q: {`, t.Name)) ctx := t.Context() ctxType := reflect.TypeOf(ctx) for i := 0; i < ctxType.NumMethod(); i++ { method := ctxType.Method(i) f := goDocFunc{ Name: method.Name, } methodGoDoc := godoc[method.Name] if mapping, ok := t.MethodMappings[method.Name]; ok { f.Aliases = mapping.Aliases f.Examples = mapping.Examples f.Description = methodGoDoc.Description f.Args = methodGoDoc.Args } funcs = append(funcs, f) } for i, f := range funcs { if i != 0 { buf.WriteString(",") } funcStr, err := f.toJSON() if err != nil { return nil, err } buf.Write(funcStr) } buf.WriteString("}") return buf.Bytes(), nil } type methodGoDocInfo struct { Description string Args []string } var ( tplPackagesGoDoc map[string]map[string]methodGoDocInfo tplPackagesGoDocInit sync.Once ) func getGetTplPackagesGoDoc() map[string]map[string]methodGoDocInfo { tplPackagesGoDocInit.Do(func() { tplPackagesGoDoc = make(map[string]map[string]methodGoDocInfo) pwd, err := os.Getwd() if err != nil { log.Fatal(err) } fset := token.NewFileSet() // pwd will be inside one of the namespace packages during tests var basePath string if strings.Contains(pwd, "tpl") { basePath = filepath.Join(pwd, "..") } else { basePath = filepath.Join(pwd, "tpl") } files, err := ioutil.ReadDir(basePath) if err != nil { log.Fatal(err) } for _, fi := range files { if !fi.IsDir() { continue } namespaceDoc := make(map[string]methodGoDocInfo) packagePath := filepath.Join(basePath, fi.Name()) d, err := parser.ParseDir(fset, packagePath, nil, parser.ParseComments) if err != nil { log.Fatal(err) } for _, f := range d { p := doc.New(f, "./", 0) for _, t := range p.Types { if t.Name == "Namespace" { for _, tt := range t.Methods { var args []string for _, p := range tt.Decl.Type.Params.List { for _, pp := range p.Names { args = append(args, pp.Name) } } description := strings.TrimSpace(tt.Doc) di := methodGoDocInfo{Description: description, Args: args} namespaceDoc[tt.Name] = di } } } } tplPackagesGoDoc[fi.Name()] = namespaceDoc } }) return tplPackagesGoDoc }
// Copyright 2017-present The Hugo Authors. All rights reserved. // // Portions Copyright The Go Authors. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package internal import ( "bytes" "encoding/json" "fmt" "go/doc" "go/parser" "go/token" "io/ioutil" "log" "os" "path/filepath" "reflect" "runtime" "strings" "sync" "github.com/gohugoio/hugo/deps" ) // TemplateFuncsNamespaceRegistry describes a registry of functions that provide // namespaces. var TemplateFuncsNamespaceRegistry []func(d *deps.Deps) *TemplateFuncsNamespace // AddTemplateFuncsNamespace adds a given function to a registry. func AddTemplateFuncsNamespace(ns func(d *deps.Deps) *TemplateFuncsNamespace) { TemplateFuncsNamespaceRegistry = append(TemplateFuncsNamespaceRegistry, ns) } // TemplateFuncsNamespace represents a template function namespace. type TemplateFuncsNamespace struct { // The namespace name, "strings", "lang", etc. Name string // This is the method receiver. Context func(v ...interface{}) interface{} // Additional info, aliases and examples, per method name. MethodMappings map[string]TemplateFuncMethodMapping } // TemplateFuncsNamespaces is a slice of TemplateFuncsNamespace. type TemplateFuncsNamespaces []*TemplateFuncsNamespace // AddMethodMapping adds a method to a template function namespace. func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []string, examples [][2]string) { if t.MethodMappings == nil { t.MethodMappings = make(map[string]TemplateFuncMethodMapping) } name := methodToName(m) // sanity check for _, e := range examples { if e[0] == "" { panic(t.Name + ": Empty example for " + name) } } for _, a := range aliases { if a == "" { panic(t.Name + ": Empty alias for " + name) } } t.MethodMappings[name] = TemplateFuncMethodMapping{ Method: m, Aliases: aliases, Examples: examples, } } // TemplateFuncMethodMapping represents a mapping of functions to methods for a // given namespace. type TemplateFuncMethodMapping struct { Method interface{} // Any template funcs aliases. This is mainly motivated by keeping // backwards compatibility, but some new template funcs may also make // sense to give short and snappy aliases. // Note that these aliases are global and will be merged, so the last // key will win. Aliases []string // A slice of input/expected examples. // We keep it a the namespace level for now, but may find a way to keep track // of the single template func, for documentation purposes. // Some of these, hopefully just a few, may depend on some test data to run. Examples [][2]string } func methodToName(m interface{}) string { name := runtime.FuncForPC(reflect.ValueOf(m).Pointer()).Name() name = filepath.Ext(name) name = strings.TrimPrefix(name, ".") name = strings.TrimSuffix(name, "-fm") return name } type goDocFunc struct { Name string Description string Args []string Aliases []string Examples [][2]string } func (t goDocFunc) toJSON() ([]byte, error) { args, err := json.Marshal(t.Args) if err != nil { return nil, err } aliases, err := json.Marshal(t.Aliases) if err != nil { return nil, err } examples, err := json.Marshal(t.Examples) if err != nil { return nil, err } var buf bytes.Buffer buf.WriteString(fmt.Sprintf(`%q: { "Description": %q, "Args": %s, "Aliases": %s, "Examples": %s } `, t.Name, t.Description, args, aliases, examples)) return buf.Bytes(), nil } // MarshalJSON returns the JSON encoding of namespaces. func (namespaces TemplateFuncsNamespaces) MarshalJSON() ([]byte, error) { var buf bytes.Buffer buf.WriteString("{") for i, ns := range namespaces { if i != 0 { buf.WriteString(",") } b, err := ns.toJSON() if err != nil { return nil, err } buf.Write(b) } buf.WriteString("}") return buf.Bytes(), nil } func (t *TemplateFuncsNamespace) toJSON() ([]byte, error) { var buf bytes.Buffer godoc := getGetTplPackagesGoDoc()[t.Name] var funcs []goDocFunc buf.WriteString(fmt.Sprintf(`%q: {`, t.Name)) ctx := t.Context() ctxType := reflect.TypeOf(ctx) for i := 0; i < ctxType.NumMethod(); i++ { method := ctxType.Method(i) f := goDocFunc{ Name: method.Name, } methodGoDoc := godoc[method.Name] if mapping, ok := t.MethodMappings[method.Name]; ok { f.Aliases = mapping.Aliases f.Examples = mapping.Examples f.Description = methodGoDoc.Description f.Args = methodGoDoc.Args } funcs = append(funcs, f) } for i, f := range funcs { if i != 0 { buf.WriteString(",") } funcStr, err := f.toJSON() if err != nil { return nil, err } buf.Write(funcStr) } buf.WriteString("}") return buf.Bytes(), nil } type methodGoDocInfo struct { Description string Args []string } var ( tplPackagesGoDoc map[string]map[string]methodGoDocInfo tplPackagesGoDocInit sync.Once ) func getGetTplPackagesGoDoc() map[string]map[string]methodGoDocInfo { tplPackagesGoDocInit.Do(func() { tplPackagesGoDoc = make(map[string]map[string]methodGoDocInfo) pwd, err := os.Getwd() if err != nil { log.Fatal(err) } fset := token.NewFileSet() // pwd will be inside one of the namespace packages during tests var basePath string if strings.Contains(pwd, "tpl") { basePath = filepath.Join(pwd, "..") } else { basePath = filepath.Join(pwd, "tpl") } files, err := ioutil.ReadDir(basePath) if err != nil { log.Fatal(err) } for _, fi := range files { if !fi.IsDir() { continue } namespaceDoc := make(map[string]methodGoDocInfo) packagePath := filepath.Join(basePath, fi.Name()) d, err := parser.ParseDir(fset, packagePath, nil, parser.ParseComments) if err != nil { log.Fatal(err) } for _, f := range d { p := doc.New(f, "./", 0) for _, t := range p.Types { if t.Name == "Namespace" { for _, tt := range t.Methods { var args []string for _, p := range tt.Decl.Type.Params.List { for _, pp := range p.Names { args = append(args, pp.Name) } } description := strings.TrimSpace(tt.Doc) di := methodGoDocInfo{Description: description, Args: args} namespaceDoc[tt.Name] = di } } } } tplPackagesGoDoc[fi.Name()] = namespaceDoc } }) return tplPackagesGoDoc }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./tpl/collections/collections_test.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package collections import ( "errors" "fmt" "html/template" "math/rand" "reflect" "testing" "time" "github.com/gohugoio/hugo/common/maps" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/langs" "github.com/spf13/afero" "github.com/spf13/viper" ) type tstNoStringer struct{} func TestAfter(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { index interface{} seq interface{} expect interface{} }{ {int(2), []string{"a", "b", "c", "d"}, []string{"c", "d"}}, {int32(3), []string{"a", "b"}, []string{}}, {int64(2), []int{100, 200, 300}, []int{300}}, {100, []int{100, 200}, []int{}}, {"1", []int{100, 200, 300}, []int{200, 300}}, {0, []int{100, 200, 300, 400, 500}, []int{100, 200, 300, 400, 500}}, {0, []string{"a", "b", "c", "d", "e"}, []string{"a", "b", "c", "d", "e"}}, {int64(-1), []int{100, 200, 300}, false}, {"noint", []int{100, 200, 300}, false}, {2, []string{}, []string{}}, {1, nil, false}, {nil, []int{100}, false}, {1, t, false}, {1, (*string)(nil), false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.After(test.index, test.seq) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.DeepEquals, test.expect, errMsg) } } type tstGrouper struct { } type tstGroupers []*tstGrouper func (g tstGrouper) Group(key interface{}, items interface{}) (interface{}, error) { ilen := reflect.ValueOf(items).Len() return fmt.Sprintf("%v(%d)", key, ilen), nil } type tstGrouper2 struct { } func (g *tstGrouper2) Group(key interface{}, items interface{}) (interface{}, error) { ilen := reflect.ValueOf(items).Len() return fmt.Sprintf("%v(%d)", key, ilen), nil } func TestGroup(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { key interface{} items interface{} expect interface{} }{ {"a", []*tstGrouper{{}, {}}, "a(2)"}, {"b", tstGroupers{&tstGrouper{}, &tstGrouper{}}, "b(2)"}, {"a", []tstGrouper{{}, {}}, "a(2)"}, {"a", []*tstGrouper2{{}, {}}, "a(2)"}, {"b", []tstGrouper2{{}, {}}, "b(2)"}, {"a", []*tstGrouper{}, "a(0)"}, {"a", []string{"a", "b"}, false}, {"a", "asdf", false}, {"a", nil, false}, {nil, []*tstGrouper{{}, {}}, false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Group(test.key, test.items) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestDelimit(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { seq interface{} delimiter interface{} last interface{} expect template.HTML }{ {[]string{"class1", "class2", "class3"}, " ", nil, "class1 class2 class3"}, {[]int{1, 2, 3, 4, 5}, ",", nil, "1,2,3,4,5"}, {[]int{1, 2, 3, 4, 5}, ", ", nil, "1, 2, 3, 4, 5"}, {[]string{"class1", "class2", "class3"}, " ", " and ", "class1 class2 and class3"}, {[]int{1, 2, 3, 4, 5}, ",", ",", "1,2,3,4,5"}, {[]int{1, 2, 3, 4, 5}, ", ", ", and ", "1, 2, 3, 4, and 5"}, // test maps with and without sorting required {map[string]int{"1": 10, "2": 20, "3": 30, "4": 40, "5": 50}, "--", nil, "10--20--30--40--50"}, {map[string]int{"3": 10, "2": 20, "1": 30, "4": 40, "5": 50}, "--", nil, "30--20--10--40--50"}, {map[string]string{"1": "10", "2": "20", "3": "30", "4": "40", "5": "50"}, "--", nil, "10--20--30--40--50"}, {map[string]string{"3": "10", "2": "20", "1": "30", "4": "40", "5": "50"}, "--", nil, "30--20--10--40--50"}, {map[string]string{"one": "10", "two": "20", "three": "30", "four": "40", "five": "50"}, "--", nil, "50--40--10--30--20"}, {map[int]string{1: "10", 2: "20", 3: "30", 4: "40", 5: "50"}, "--", nil, "10--20--30--40--50"}, {map[int]string{3: "10", 2: "20", 1: "30", 4: "40", 5: "50"}, "--", nil, "30--20--10--40--50"}, {map[float64]string{3.3: "10", 2.3: "20", 1.3: "30", 4.3: "40", 5.3: "50"}, "--", nil, "30--20--10--40--50"}, // test maps with a last delimiter {map[string]int{"1": 10, "2": 20, "3": 30, "4": 40, "5": 50}, "--", "--and--", "10--20--30--40--and--50"}, {map[string]int{"3": 10, "2": 20, "1": 30, "4": 40, "5": 50}, "--", "--and--", "30--20--10--40--and--50"}, {map[string]string{"1": "10", "2": "20", "3": "30", "4": "40", "5": "50"}, "--", "--and--", "10--20--30--40--and--50"}, {map[string]string{"3": "10", "2": "20", "1": "30", "4": "40", "5": "50"}, "--", "--and--", "30--20--10--40--and--50"}, {map[string]string{"one": "10", "two": "20", "three": "30", "four": "40", "five": "50"}, "--", "--and--", "50--40--10--30--and--20"}, {map[int]string{1: "10", 2: "20", 3: "30", 4: "40", 5: "50"}, "--", "--and--", "10--20--30--40--and--50"}, {map[int]string{3: "10", 2: "20", 1: "30", 4: "40", 5: "50"}, "--", "--and--", "30--20--10--40--and--50"}, {map[float64]string{3.5: "10", 2.5: "20", 1.5: "30", 4.5: "40", 5.5: "50"}, "--", "--and--", "30--20--10--40--and--50"}, } { errMsg := qt.Commentf("[%d] %v", i, test) var result template.HTML var err error if test.last == nil { result, err = ns.Delimit(test.seq, test.delimiter) } else { result, err = ns.Delimit(test.seq, test.delimiter, test.last) } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestDictionary(t *testing.T) { c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { values []interface{} expect interface{} }{ {[]interface{}{"a", "b"}, map[string]interface{}{"a": "b"}}, {[]interface{}{[]string{"a", "b"}, "c"}, map[string]interface{}{"a": map[string]interface{}{"b": "c"}}}, { []interface{}{[]string{"a", "b"}, "c", []string{"a", "b2"}, "c2", "b", "c"}, map[string]interface{}{"a": map[string]interface{}{"b": "c", "b2": "c2"}, "b": "c"}, }, {[]interface{}{"a", 12, "b", []int{4}}, map[string]interface{}{"a": 12, "b": []int{4}}}, // errors {[]interface{}{5, "b"}, false}, {[]interface{}{"a", "b", "c"}, false}, } { i := i test := test c.Run(fmt.Sprint(i), func(c *qt.C) { c.Parallel() errMsg := qt.Commentf("[%d] %v", i, test.values) result, err := ns.Dictionary(test.values...) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) return } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.DeepEquals, test.expect, qt.Commentf(fmt.Sprint(result))) }) } } func TestReverse(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) s := []string{"a", "b", "c"} reversed, err := ns.Reverse(s) c.Assert(err, qt.IsNil) c.Assert(reversed, qt.DeepEquals, []string{"c", "b", "a"}, qt.Commentf(fmt.Sprint(reversed))) c.Assert(s, qt.DeepEquals, []string{"a", "b", "c"}) reversed, err = ns.Reverse(nil) c.Assert(err, qt.IsNil) c.Assert(reversed, qt.IsNil) _, err = ns.Reverse(43) c.Assert(err, qt.Not(qt.IsNil)) } func TestEchoParam(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { a interface{} key interface{} expect interface{} }{ {[]int{1, 2, 3}, 1, int64(2)}, {[]uint{1, 2, 3}, 1, uint64(2)}, {[]float64{1.1, 2.2, 3.3}, 1, float64(2.2)}, {[]string{"foo", "bar", "baz"}, 1, "bar"}, {[]TstX{{A: "a", B: "b"}, {A: "c", B: "d"}, {A: "e", B: "f"}}, 1, ""}, {map[string]int{"foo": 1, "bar": 2, "baz": 3}, "bar", int64(2)}, {map[string]uint{"foo": 1, "bar": 2, "baz": 3}, "bar", uint64(2)}, {map[string]float64{"foo": 1.1, "bar": 2.2, "baz": 3.3}, "bar", float64(2.2)}, {map[string]string{"foo": "FOO", "bar": "BAR", "baz": "BAZ"}, "bar", "BAR"}, {map[string]TstX{"foo": {A: "a", B: "b"}, "bar": {A: "c", B: "d"}, "baz": {A: "e", B: "f"}}, "bar", ""}, {map[string]interface{}{"foo": nil}, "foo", ""}, {(*[]string)(nil), "bar", ""}, } { errMsg := qt.Commentf("[%d] %v", i, test) result := ns.EchoParam(test.a, test.key) c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestFirst(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { limit interface{} seq interface{} expect interface{} }{ {int(2), []string{"a", "b", "c"}, []string{"a", "b"}}, {int32(3), []string{"a", "b"}, []string{"a", "b"}}, {int64(2), []int{100, 200, 300}, []int{100, 200}}, {100, []int{100, 200}, []int{100, 200}}, {"1", []int{100, 200, 300}, []int{100}}, {0, []string{"h", "u", "g", "o"}, []string{}}, {int64(-1), []int{100, 200, 300}, false}, {"noint", []int{100, 200, 300}, false}, {1, nil, false}, {nil, []int{100}, false}, {1, t, false}, {1, (*string)(nil), false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.First(test.limit, test.seq) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil) c.Assert(result, qt.DeepEquals, test.expect, errMsg) } } func TestIn(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { l1 interface{} l2 interface{} expect bool }{ {[]string{"a", "b", "c"}, "b", true}, {[]interface{}{"a", "b", "c"}, "b", true}, {[]interface{}{"a", "b", "c"}, "d", false}, {[]string{"a", "b", "c"}, "d", false}, {[]string{"a", "12", "c"}, 12, false}, {[]string{"a", "b", "c"}, nil, false}, {[]int{1, 2, 4}, 2, true}, {[]interface{}{1, 2, 4}, 2, true}, {[]interface{}{1, 2, 4}, nil, false}, {[]interface{}{nil}, nil, false}, {[]int{1, 2, 4}, 3, false}, {[]float64{1.23, 2.45, 4.67}, 1.23, true}, {[]float64{1.234567, 2.45, 4.67}, 1.234568, false}, {[]float64{1, 2, 3}, 1, true}, {[]float32{1, 2, 3}, 1, true}, {"this substring should be found", "substring", true}, {"this substring should not be found", "subseastring", false}, {nil, "foo", false}, // Pointers {pagesPtr{p1, p2, p3, p2}, p2, true}, {pagesPtr{p1, p2, p3, p2}, p4, false}, // Structs {pagesVals{p3v, p2v, p3v, p2v}, p2v, true}, {pagesVals{p3v, p2v, p3v, p2v}, p4v, false}, // template.HTML {template.HTML("this substring should be found"), "substring", true}, {template.HTML("this substring should not be found"), "subseastring", false}, // Uncomparable, use hashstructure {[]string{"a", "b"}, []string{"a", "b"}, false}, {[][]string{{"a", "b"}}, []string{"a", "b"}, true}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.In(test.l1, test.l2) c.Assert(err, qt.IsNil) c.Assert(result, qt.Equals, test.expect, errMsg) } } type testPage struct { Title string } func (p testPage) String() string { return "p-" + p.Title } type ( pagesPtr []*testPage pagesVals []testPage ) var ( p1 = &testPage{"A"} p2 = &testPage{"B"} p3 = &testPage{"C"} p4 = &testPage{"D"} p1v = testPage{"A"} p2v = testPage{"B"} p3v = testPage{"C"} p4v = testPage{"D"} ) func TestIntersect(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { l1, l2 interface{} expect interface{} }{ {[]string{"a", "b", "c", "c"}, []string{"a", "b", "b"}, []string{"a", "b"}}, {[]string{"a", "b"}, []string{"a", "b", "c"}, []string{"a", "b"}}, {[]string{"a", "b", "c"}, []string{"d", "e"}, []string{}}, {[]string{}, []string{}, []string{}}, {[]string{"a", "b"}, nil, []interface{}{}}, {nil, []string{"a", "b"}, []interface{}{}}, {nil, nil, []interface{}{}}, {[]string{"1", "2"}, []int{1, 2}, []string{}}, {[]int{1, 2}, []string{"1", "2"}, []int{}}, {[]int{1, 2, 4}, []int{2, 4}, []int{2, 4}}, {[]int{2, 4}, []int{1, 2, 4}, []int{2, 4}}, {[]int{1, 2, 4}, []int{3, 6}, []int{}}, {[]float64{2.2, 4.4}, []float64{1.1, 2.2, 4.4}, []float64{2.2, 4.4}}, // []interface{} ∩ []interface{} {[]interface{}{"a", "b", "c"}, []interface{}{"a", "b", "b"}, []interface{}{"a", "b"}}, {[]interface{}{1, 2, 3}, []interface{}{1, 2, 2}, []interface{}{1, 2}}, {[]interface{}{int8(1), int8(2), int8(3)}, []interface{}{int8(1), int8(2), int8(2)}, []interface{}{int8(1), int8(2)}}, {[]interface{}{int16(1), int16(2), int16(3)}, []interface{}{int16(1), int16(2), int16(2)}, []interface{}{int16(1), int16(2)}}, {[]interface{}{int32(1), int32(2), int32(3)}, []interface{}{int32(1), int32(2), int32(2)}, []interface{}{int32(1), int32(2)}}, {[]interface{}{int64(1), int64(2), int64(3)}, []interface{}{int64(1), int64(2), int64(2)}, []interface{}{int64(1), int64(2)}}, {[]interface{}{float32(1), float32(2), float32(3)}, []interface{}{float32(1), float32(2), float32(2)}, []interface{}{float32(1), float32(2)}}, {[]interface{}{float64(1), float64(2), float64(3)}, []interface{}{float64(1), float64(2), float64(2)}, []interface{}{float64(1), float64(2)}}, // []interface{} ∩ []T {[]interface{}{"a", "b", "c"}, []string{"a", "b", "b"}, []interface{}{"a", "b"}}, {[]interface{}{1, 2, 3}, []int{1, 2, 2}, []interface{}{1, 2}}, {[]interface{}{int8(1), int8(2), int8(3)}, []int8{1, 2, 2}, []interface{}{int8(1), int8(2)}}, {[]interface{}{int16(1), int16(2), int16(3)}, []int16{1, 2, 2}, []interface{}{int16(1), int16(2)}}, {[]interface{}{int32(1), int32(2), int32(3)}, []int32{1, 2, 2}, []interface{}{int32(1), int32(2)}}, {[]interface{}{int64(1), int64(2), int64(3)}, []int64{1, 2, 2}, []interface{}{int64(1), int64(2)}}, {[]interface{}{uint(1), uint(2), uint(3)}, []uint{1, 2, 2}, []interface{}{uint(1), uint(2)}}, {[]interface{}{float32(1), float32(2), float32(3)}, []float32{1, 2, 2}, []interface{}{float32(1), float32(2)}}, {[]interface{}{float64(1), float64(2), float64(3)}, []float64{1, 2, 2}, []interface{}{float64(1), float64(2)}}, // []T ∩ []interface{} {[]string{"a", "b", "c"}, []interface{}{"a", "b", "b"}, []string{"a", "b"}}, {[]int{1, 2, 3}, []interface{}{1, 2, 2}, []int{1, 2}}, {[]int8{1, 2, 3}, []interface{}{int8(1), int8(2), int8(2)}, []int8{1, 2}}, {[]int16{1, 2, 3}, []interface{}{int16(1), int16(2), int16(2)}, []int16{1, 2}}, {[]int32{1, 2, 3}, []interface{}{int32(1), int32(2), int32(2)}, []int32{1, 2}}, {[]int64{1, 2, 3}, []interface{}{int64(1), int64(2), int64(2)}, []int64{1, 2}}, {[]float32{1, 2, 3}, []interface{}{float32(1), float32(2), float32(2)}, []float32{1, 2}}, {[]float64{1, 2, 3}, []interface{}{float64(1), float64(2), float64(2)}, []float64{1, 2}}, // Structs {pagesPtr{p1, p4, p2, p3}, pagesPtr{p4, p2, p2}, pagesPtr{p4, p2}}, {pagesVals{p1v, p4v, p2v, p3v}, pagesVals{p1v, p3v, p3v}, pagesVals{p1v, p3v}}, {[]interface{}{p1, p4, p2, p3}, []interface{}{p4, p2, p2}, []interface{}{p4, p2}}, {[]interface{}{p1v, p4v, p2v, p3v}, []interface{}{p1v, p3v, p3v}, []interface{}{p1v, p3v}}, {pagesPtr{p1, p4, p2, p3}, pagesPtr{}, pagesPtr{}}, {pagesVals{}, pagesVals{p1v, p3v, p3v}, pagesVals{}}, {[]interface{}{p1, p4, p2, p3}, []interface{}{}, []interface{}{}}, {[]interface{}{}, []interface{}{p1v, p3v, p3v}, []interface{}{}}, // errors {"not array or slice", []string{"a"}, false}, {[]string{"a"}, "not array or slice", false}, // uncomparable types - #3820 {[]map[int]int{{1: 1}, {2: 2}}, []map[int]int{{2: 2}, {3: 3}}, false}, {[][]int{{1, 1}, {1, 2}}, [][]int{{1, 2}, {1, 2}, {1, 3}}, false}, {[]int{1, 1}, [][]int{{1, 2}, {1, 2}, {1, 3}}, false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Intersect(test.l1, test.l2) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) if !reflect.DeepEqual(result, test.expect) { t.Fatalf("[%d] Got\n%v expected\n%v", i, result, test.expect) } } } func TestIsSet(t *testing.T) { t.Parallel() c := qt.New(t) ns := newTestNs() for i, test := range []struct { a interface{} key interface{} expect bool isErr bool }{ {[]interface{}{1, 2, 3, 5}, 2, true, false}, {[]interface{}{1, 2, 3, 5}, "2", true, false}, {[]interface{}{1, 2, 3, 5}, 2.0, true, false}, {[]interface{}{1, 2, 3, 5}, 22, false, false}, {map[string]interface{}{"a": 1, "b": 2}, "b", true, false}, {map[string]interface{}{"a": 1, "b": 2}, "bc", false, false}, {time.Now(), "Day", false, false}, {nil, "nil", false, false}, {[]interface{}{1, 2, 3, 5}, TstX{}, false, true}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.IsSet(test.a, test.key) if test.isErr { continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestLast(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { limit interface{} seq interface{} expect interface{} }{ {int(2), []string{"a", "b", "c"}, []string{"b", "c"}}, {int32(3), []string{"a", "b"}, []string{"a", "b"}}, {int64(2), []int{100, 200, 300}, []int{200, 300}}, {100, []int{100, 200}, []int{100, 200}}, {"1", []int{100, 200, 300}, []int{300}}, {"0", []int{100, 200, 300}, []int{}}, {"0", []string{"a", "b", "c"}, []string{}}, // errors {int64(-1), []int{100, 200, 300}, false}, {"noint", []int{100, 200, 300}, false}, {1, nil, false}, {nil, []int{100}, false}, {1, t, false}, {1, (*string)(nil), false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Last(test.limit, test.seq) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.DeepEquals, test.expect, errMsg) } } func TestQuerify(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { params []interface{} expect interface{} }{ {[]interface{}{"a", "b"}, "a=b"}, {[]interface{}{"a", "b", "c", "d", "f", " &"}, `a=b&c=d&f=+%26`}, // errors {[]interface{}{5, "b"}, false}, {[]interface{}{"a", "b", "c"}, false}, } { errMsg := qt.Commentf("[%d] %v", i, test.params) result, err := ns.Querify(test.params...) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestSeq(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { args []interface{} expect interface{} }{ {[]interface{}{-2, 5}, []int{-2, -1, 0, 1, 2, 3, 4, 5}}, {[]interface{}{1, 2, 4}, []int{1, 3}}, {[]interface{}{1}, []int{1}}, {[]interface{}{3}, []int{1, 2, 3}}, {[]interface{}{3.2}, []int{1, 2, 3}}, {[]interface{}{0}, []int{}}, {[]interface{}{-1}, []int{-1}}, {[]interface{}{-3}, []int{-1, -2, -3}}, {[]interface{}{3, -2}, []int{3, 2, 1, 0, -1, -2}}, {[]interface{}{6, -2, 2}, []int{6, 4, 2}}, // errors {[]interface{}{1, 0, 2}, false}, {[]interface{}{1, -1, 2}, false}, {[]interface{}{2, 1, 1}, false}, {[]interface{}{2, 1, 1, 1}, false}, {[]interface{}{2001}, false}, {[]interface{}{}, false}, {[]interface{}{0, -1000000}, false}, {[]interface{}{tstNoStringer{}}, false}, {nil, false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Seq(test.args...) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.DeepEquals, test.expect, errMsg) } } func TestShuffle(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { seq interface{} success bool }{ {[]string{"a", "b", "c", "d"}, true}, {[]int{100, 200, 300}, true}, {[]int{100, 200, 300}, true}, {[]int{100, 200}, true}, {[]string{"a", "b"}, true}, {[]int{100, 200, 300}, true}, {[]int{100, 200, 300}, true}, {[]int{100}, true}, // errors {nil, false}, {t, false}, {(*string)(nil), false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Shuffle(test.seq) if !test.success { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) resultv := reflect.ValueOf(result) seqv := reflect.ValueOf(test.seq) c.Assert(seqv.Len(), qt.Equals, resultv.Len(), errMsg) } } func TestShuffleRandomising(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) // Note that this test can fail with false negative result if the shuffle // of the sequence happens to be the same as the original sequence. However // the probability of the event is 10^-158 which is negligible. seqLen := 100 rand.Seed(time.Now().UTC().UnixNano()) for _, test := range []struct { seq []int }{ {rand.Perm(seqLen)}, } { result, err := ns.Shuffle(test.seq) resultv := reflect.ValueOf(result) c.Assert(err, qt.IsNil) allSame := true for i, v := range test.seq { allSame = allSame && (resultv.Index(i).Interface() == v) } c.Assert(allSame, qt.Equals, false) } } // Also see tests in commons/collection. func TestSlice(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { args []interface{} expected interface{} }{ {[]interface{}{"a", "b"}, []string{"a", "b"}}, {[]interface{}{}, []interface{}{}}, {[]interface{}{nil}, []interface{}{nil}}, {[]interface{}{5, "b"}, []interface{}{5, "b"}}, {[]interface{}{tstNoStringer{}}, []tstNoStringer{{}}}, } { errMsg := qt.Commentf("[%d] %v", i, test.args) result := ns.Slice(test.args...) c.Assert(result, qt.DeepEquals, test.expected, errMsg) } } func TestUnion(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { l1 interface{} l2 interface{} expect interface{} isErr bool }{ {nil, nil, []interface{}{}, false}, {nil, []string{"a", "b"}, []string{"a", "b"}, false}, {[]string{"a", "b"}, nil, []string{"a", "b"}, false}, // []A ∪ []B {[]string{"1", "2"}, []int{3}, []string{}, false}, {[]int{1, 2}, []string{"1", "2"}, []int{}, false}, // []T ∪ []T {[]string{"a", "b", "c", "c"}, []string{"a", "b", "b"}, []string{"a", "b", "c"}, false}, {[]string{"a", "b"}, []string{"a", "b", "c"}, []string{"a", "b", "c"}, false}, {[]string{"a", "b", "c"}, []string{"d", "e"}, []string{"a", "b", "c", "d", "e"}, false}, {[]string{}, []string{}, []string{}, false}, {[]int{1, 2, 3}, []int{3, 4, 5}, []int{1, 2, 3, 4, 5}, false}, {[]int{1, 2, 3}, []int{1, 2, 3}, []int{1, 2, 3}, false}, {[]int{1, 2, 4}, []int{2, 4}, []int{1, 2, 4}, false}, {[]int{2, 4}, []int{1, 2, 4}, []int{2, 4, 1}, false}, {[]int{1, 2, 4}, []int{3, 6}, []int{1, 2, 4, 3, 6}, false}, {[]float64{2.2, 4.4}, []float64{1.1, 2.2, 4.4}, []float64{2.2, 4.4, 1.1}, false}, {[]interface{}{"a", "b", "c", "c"}, []interface{}{"a", "b", "b"}, []interface{}{"a", "b", "c"}, false}, // []T ∪ []interface{} {[]string{"1", "2"}, []interface{}{"9"}, []string{"1", "2", "9"}, false}, {[]int{2, 4}, []interface{}{1, 2, 4}, []int{2, 4, 1}, false}, {[]int8{2, 4}, []interface{}{int8(1), int8(2), int8(4)}, []int8{2, 4, 1}, false}, {[]int8{2, 4}, []interface{}{1, 2, 4}, []int8{2, 4, 1}, false}, {[]int16{2, 4}, []interface{}{1, 2, 4}, []int16{2, 4, 1}, false}, {[]int32{2, 4}, []interface{}{1, 2, 4}, []int32{2, 4, 1}, false}, {[]int64{2, 4}, []interface{}{1, 2, 4}, []int64{2, 4, 1}, false}, {[]float64{2.2, 4.4}, []interface{}{1.1, 2.2, 4.4}, []float64{2.2, 4.4, 1.1}, false}, {[]float32{2.2, 4.4}, []interface{}{1.1, 2.2, 4.4}, []float32{2.2, 4.4, 1.1}, false}, // []interface{} ∪ []T {[]interface{}{"a", "b", "c", "c"}, []string{"a", "b", "d"}, []interface{}{"a", "b", "c", "d"}, false}, {[]interface{}{}, []string{}, []interface{}{}, false}, {[]interface{}{1, 2}, []int{2, 3}, []interface{}{1, 2, 3}, false}, {[]interface{}{1, 2}, []int8{2, 3}, []interface{}{1, 2, 3}, false}, // 28 {[]interface{}{uint(1), uint(2)}, []uint{2, 3}, []interface{}{uint(1), uint(2), uint(3)}, false}, {[]interface{}{1.1, 2.2}, []float64{2.2, 3.3}, []interface{}{1.1, 2.2, 3.3}, false}, // Structs {pagesPtr{p1, p4}, pagesPtr{p4, p2, p2}, pagesPtr{p1, p4, p2}, false}, {pagesVals{p1v}, pagesVals{p3v, p3v}, pagesVals{p1v, p3v}, false}, {[]interface{}{p1, p4}, []interface{}{p4, p2, p2}, []interface{}{p1, p4, p2}, false}, {[]interface{}{p1v}, []interface{}{p3v, p3v}, []interface{}{p1v, p3v}, false}, // #3686 {[]interface{}{p1v}, []interface{}{}, []interface{}{p1v}, false}, {[]interface{}{}, []interface{}{p1v}, []interface{}{p1v}, false}, {pagesPtr{p1}, pagesPtr{}, pagesPtr{p1}, false}, {pagesVals{p1v}, pagesVals{}, pagesVals{p1v}, false}, {pagesPtr{}, pagesPtr{p1}, pagesPtr{p1}, false}, {pagesVals{}, pagesVals{p1v}, pagesVals{p1v}, false}, // errors {"not array or slice", []string{"a"}, false, true}, {[]string{"a"}, "not array or slice", false, true}, // uncomparable types - #3820 {[]map[string]int{{"K1": 1}}, []map[string]int{{"K2": 2}, {"K2": 2}}, false, true}, {[][]int{{1, 1}, {1, 2}}, [][]int{{2, 1}, {2, 2}}, false, true}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Union(test.l1, test.l2) if test.isErr { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) if !reflect.DeepEqual(result, test.expect) { t.Fatalf("[%d] Got\n%v expected\n%v", i, result, test.expect) } } } func TestUniq(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { l interface{} expect interface{} isErr bool }{ {[]string{"a", "b", "c"}, []string{"a", "b", "c"}, false}, {[]string{"a", "b", "c", "c"}, []string{"a", "b", "c"}, false}, {[]string{"a", "b", "b", "c"}, []string{"a", "b", "c"}, false}, {[]string{"a", "b", "c", "b"}, []string{"a", "b", "c"}, false}, {[]int{1, 2, 3}, []int{1, 2, 3}, false}, {[]int{1, 2, 3, 3}, []int{1, 2, 3}, false}, {[]int{1, 2, 2, 3}, []int{1, 2, 3}, false}, {[]int{1, 2, 3, 2}, []int{1, 2, 3}, false}, {[4]int{1, 2, 3, 2}, []int{1, 2, 3}, false}, {nil, make([]interface{}, 0), false}, // Pointers {pagesPtr{p1, p2, p3, p2}, pagesPtr{p1, p2, p3}, false}, {pagesPtr{}, pagesPtr{}, false}, // Structs {pagesVals{p3v, p2v, p3v, p2v}, pagesVals{p3v, p2v}, false}, // not Comparable(), use hashstructure {[]map[string]int{ {"K1": 1}, {"K2": 2}, {"K1": 1}, {"K2": 1}, }, []map[string]int{ {"K1": 1}, {"K2": 2}, {"K2": 1}, }, false}, // should fail {1, 1, true}, {"foo", "fo", true}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Uniq(test.l) if test.isErr { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.DeepEquals, test.expect, errMsg) } } func (x *TstX) TstRp() string { return "r" + x.A } func (x TstX) TstRv() string { return "r" + x.B } func (x TstX) TstRv2() string { return "r" + x.B } func (x TstX) unexportedMethod() string { return x.unexported } func (x TstX) MethodWithArg(s string) string { return s } func (x TstX) MethodReturnNothing() {} func (x TstX) MethodReturnErrorOnly() error { return errors.New("some error occurred") } func (x TstX) MethodReturnTwoValues() (string, string) { return "foo", "bar" } func (x TstX) MethodReturnValueWithError() (string, error) { return "", errors.New("some error occurred") } func (x TstX) String() string { return fmt.Sprintf("A: %s, B: %s", x.A, x.B) } type TstX struct { A, B string unexported string } type TstParams struct { params maps.Params } func (x TstParams) Params() maps.Params { return x.params } type TstXIHolder struct { XI TstXI } // Partially implemented by the TstX struct. type TstXI interface { TstRv2() string } func ToTstXIs(slice interface{}) []TstXI { s := reflect.ValueOf(slice) if s.Kind() != reflect.Slice { return nil } tis := make([]TstXI, s.Len()) for i := 0; i < s.Len(); i++ { tsti, ok := s.Index(i).Interface().(TstXI) if !ok { return nil } tis[i] = tsti } return tis } func newDeps(cfg config.Provider) *deps.Deps { l := langs.NewLanguage("en", cfg) l.Set("i18nDir", "i18n") cs, err := helpers.NewContentSpec(l, loggers.NewErrorLogger(), afero.NewMemMapFs()) if err != nil { panic(err) } return &deps.Deps{ Cfg: cfg, Fs: hugofs.NewMem(l), ContentSpec: cs, Log: loggers.NewErrorLogger(), } } func newTestNs() *Namespace { v := viper.New() v.Set("contentDir", "content") return New(newDeps(v)) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package collections import ( "errors" "fmt" "html/template" "math/rand" "reflect" "testing" "time" "github.com/gohugoio/hugo/common/maps" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/common/loggers" "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/deps" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/langs" "github.com/spf13/afero" "github.com/spf13/viper" ) type tstNoStringer struct{} func TestAfter(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { index interface{} seq interface{} expect interface{} }{ {int(2), []string{"a", "b", "c", "d"}, []string{"c", "d"}}, {int32(3), []string{"a", "b"}, []string{}}, {int64(2), []int{100, 200, 300}, []int{300}}, {100, []int{100, 200}, []int{}}, {"1", []int{100, 200, 300}, []int{200, 300}}, {0, []int{100, 200, 300, 400, 500}, []int{100, 200, 300, 400, 500}}, {0, []string{"a", "b", "c", "d", "e"}, []string{"a", "b", "c", "d", "e"}}, {int64(-1), []int{100, 200, 300}, false}, {"noint", []int{100, 200, 300}, false}, {2, []string{}, []string{}}, {1, nil, false}, {nil, []int{100}, false}, {1, t, false}, {1, (*string)(nil), false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.After(test.index, test.seq) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.DeepEquals, test.expect, errMsg) } } type tstGrouper struct { } type tstGroupers []*tstGrouper func (g tstGrouper) Group(key interface{}, items interface{}) (interface{}, error) { ilen := reflect.ValueOf(items).Len() return fmt.Sprintf("%v(%d)", key, ilen), nil } type tstGrouper2 struct { } func (g *tstGrouper2) Group(key interface{}, items interface{}) (interface{}, error) { ilen := reflect.ValueOf(items).Len() return fmt.Sprintf("%v(%d)", key, ilen), nil } func TestGroup(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { key interface{} items interface{} expect interface{} }{ {"a", []*tstGrouper{{}, {}}, "a(2)"}, {"b", tstGroupers{&tstGrouper{}, &tstGrouper{}}, "b(2)"}, {"a", []tstGrouper{{}, {}}, "a(2)"}, {"a", []*tstGrouper2{{}, {}}, "a(2)"}, {"b", []tstGrouper2{{}, {}}, "b(2)"}, {"a", []*tstGrouper{}, "a(0)"}, {"a", []string{"a", "b"}, false}, {"a", "asdf", false}, {"a", nil, false}, {nil, []*tstGrouper{{}, {}}, false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Group(test.key, test.items) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestDelimit(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { seq interface{} delimiter interface{} last interface{} expect template.HTML }{ {[]string{"class1", "class2", "class3"}, " ", nil, "class1 class2 class3"}, {[]int{1, 2, 3, 4, 5}, ",", nil, "1,2,3,4,5"}, {[]int{1, 2, 3, 4, 5}, ", ", nil, "1, 2, 3, 4, 5"}, {[]string{"class1", "class2", "class3"}, " ", " and ", "class1 class2 and class3"}, {[]int{1, 2, 3, 4, 5}, ",", ",", "1,2,3,4,5"}, {[]int{1, 2, 3, 4, 5}, ", ", ", and ", "1, 2, 3, 4, and 5"}, // test maps with and without sorting required {map[string]int{"1": 10, "2": 20, "3": 30, "4": 40, "5": 50}, "--", nil, "10--20--30--40--50"}, {map[string]int{"3": 10, "2": 20, "1": 30, "4": 40, "5": 50}, "--", nil, "30--20--10--40--50"}, {map[string]string{"1": "10", "2": "20", "3": "30", "4": "40", "5": "50"}, "--", nil, "10--20--30--40--50"}, {map[string]string{"3": "10", "2": "20", "1": "30", "4": "40", "5": "50"}, "--", nil, "30--20--10--40--50"}, {map[string]string{"one": "10", "two": "20", "three": "30", "four": "40", "five": "50"}, "--", nil, "50--40--10--30--20"}, {map[int]string{1: "10", 2: "20", 3: "30", 4: "40", 5: "50"}, "--", nil, "10--20--30--40--50"}, {map[int]string{3: "10", 2: "20", 1: "30", 4: "40", 5: "50"}, "--", nil, "30--20--10--40--50"}, {map[float64]string{3.3: "10", 2.3: "20", 1.3: "30", 4.3: "40", 5.3: "50"}, "--", nil, "30--20--10--40--50"}, // test maps with a last delimiter {map[string]int{"1": 10, "2": 20, "3": 30, "4": 40, "5": 50}, "--", "--and--", "10--20--30--40--and--50"}, {map[string]int{"3": 10, "2": 20, "1": 30, "4": 40, "5": 50}, "--", "--and--", "30--20--10--40--and--50"}, {map[string]string{"1": "10", "2": "20", "3": "30", "4": "40", "5": "50"}, "--", "--and--", "10--20--30--40--and--50"}, {map[string]string{"3": "10", "2": "20", "1": "30", "4": "40", "5": "50"}, "--", "--and--", "30--20--10--40--and--50"}, {map[string]string{"one": "10", "two": "20", "three": "30", "four": "40", "five": "50"}, "--", "--and--", "50--40--10--30--and--20"}, {map[int]string{1: "10", 2: "20", 3: "30", 4: "40", 5: "50"}, "--", "--and--", "10--20--30--40--and--50"}, {map[int]string{3: "10", 2: "20", 1: "30", 4: "40", 5: "50"}, "--", "--and--", "30--20--10--40--and--50"}, {map[float64]string{3.5: "10", 2.5: "20", 1.5: "30", 4.5: "40", 5.5: "50"}, "--", "--and--", "30--20--10--40--and--50"}, } { errMsg := qt.Commentf("[%d] %v", i, test) var result template.HTML var err error if test.last == nil { result, err = ns.Delimit(test.seq, test.delimiter) } else { result, err = ns.Delimit(test.seq, test.delimiter, test.last) } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestDictionary(t *testing.T) { c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { values []interface{} expect interface{} }{ {[]interface{}{"a", "b"}, map[string]interface{}{"a": "b"}}, {[]interface{}{[]string{"a", "b"}, "c"}, map[string]interface{}{"a": map[string]interface{}{"b": "c"}}}, { []interface{}{[]string{"a", "b"}, "c", []string{"a", "b2"}, "c2", "b", "c"}, map[string]interface{}{"a": map[string]interface{}{"b": "c", "b2": "c2"}, "b": "c"}, }, {[]interface{}{"a", 12, "b", []int{4}}, map[string]interface{}{"a": 12, "b": []int{4}}}, // errors {[]interface{}{5, "b"}, false}, {[]interface{}{"a", "b", "c"}, false}, } { i := i test := test c.Run(fmt.Sprint(i), func(c *qt.C) { c.Parallel() errMsg := qt.Commentf("[%d] %v", i, test.values) result, err := ns.Dictionary(test.values...) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) return } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.DeepEquals, test.expect, qt.Commentf(fmt.Sprint(result))) }) } } func TestReverse(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) s := []string{"a", "b", "c"} reversed, err := ns.Reverse(s) c.Assert(err, qt.IsNil) c.Assert(reversed, qt.DeepEquals, []string{"c", "b", "a"}, qt.Commentf(fmt.Sprint(reversed))) c.Assert(s, qt.DeepEquals, []string{"a", "b", "c"}) reversed, err = ns.Reverse(nil) c.Assert(err, qt.IsNil) c.Assert(reversed, qt.IsNil) _, err = ns.Reverse(43) c.Assert(err, qt.Not(qt.IsNil)) } func TestEchoParam(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { a interface{} key interface{} expect interface{} }{ {[]int{1, 2, 3}, 1, int64(2)}, {[]uint{1, 2, 3}, 1, uint64(2)}, {[]float64{1.1, 2.2, 3.3}, 1, float64(2.2)}, {[]string{"foo", "bar", "baz"}, 1, "bar"}, {[]TstX{{A: "a", B: "b"}, {A: "c", B: "d"}, {A: "e", B: "f"}}, 1, ""}, {map[string]int{"foo": 1, "bar": 2, "baz": 3}, "bar", int64(2)}, {map[string]uint{"foo": 1, "bar": 2, "baz": 3}, "bar", uint64(2)}, {map[string]float64{"foo": 1.1, "bar": 2.2, "baz": 3.3}, "bar", float64(2.2)}, {map[string]string{"foo": "FOO", "bar": "BAR", "baz": "BAZ"}, "bar", "BAR"}, {map[string]TstX{"foo": {A: "a", B: "b"}, "bar": {A: "c", B: "d"}, "baz": {A: "e", B: "f"}}, "bar", ""}, {map[string]interface{}{"foo": nil}, "foo", ""}, {(*[]string)(nil), "bar", ""}, } { errMsg := qt.Commentf("[%d] %v", i, test) result := ns.EchoParam(test.a, test.key) c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestFirst(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { limit interface{} seq interface{} expect interface{} }{ {int(2), []string{"a", "b", "c"}, []string{"a", "b"}}, {int32(3), []string{"a", "b"}, []string{"a", "b"}}, {int64(2), []int{100, 200, 300}, []int{100, 200}}, {100, []int{100, 200}, []int{100, 200}}, {"1", []int{100, 200, 300}, []int{100}}, {0, []string{"h", "u", "g", "o"}, []string{}}, {int64(-1), []int{100, 200, 300}, false}, {"noint", []int{100, 200, 300}, false}, {1, nil, false}, {nil, []int{100}, false}, {1, t, false}, {1, (*string)(nil), false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.First(test.limit, test.seq) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil) c.Assert(result, qt.DeepEquals, test.expect, errMsg) } } func TestIn(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { l1 interface{} l2 interface{} expect bool }{ {[]string{"a", "b", "c"}, "b", true}, {[]interface{}{"a", "b", "c"}, "b", true}, {[]interface{}{"a", "b", "c"}, "d", false}, {[]string{"a", "b", "c"}, "d", false}, {[]string{"a", "12", "c"}, 12, false}, {[]string{"a", "b", "c"}, nil, false}, {[]int{1, 2, 4}, 2, true}, {[]interface{}{1, 2, 4}, 2, true}, {[]interface{}{1, 2, 4}, nil, false}, {[]interface{}{nil}, nil, false}, {[]int{1, 2, 4}, 3, false}, {[]float64{1.23, 2.45, 4.67}, 1.23, true}, {[]float64{1.234567, 2.45, 4.67}, 1.234568, false}, {[]float64{1, 2, 3}, 1, true}, {[]float32{1, 2, 3}, 1, true}, {"this substring should be found", "substring", true}, {"this substring should not be found", "subseastring", false}, {nil, "foo", false}, // Pointers {pagesPtr{p1, p2, p3, p2}, p2, true}, {pagesPtr{p1, p2, p3, p2}, p4, false}, // Structs {pagesVals{p3v, p2v, p3v, p2v}, p2v, true}, {pagesVals{p3v, p2v, p3v, p2v}, p4v, false}, // template.HTML {template.HTML("this substring should be found"), "substring", true}, {template.HTML("this substring should not be found"), "subseastring", false}, // Uncomparable, use hashstructure {[]string{"a", "b"}, []string{"a", "b"}, false}, {[][]string{{"a", "b"}}, []string{"a", "b"}, true}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.In(test.l1, test.l2) c.Assert(err, qt.IsNil) c.Assert(result, qt.Equals, test.expect, errMsg) } } type testPage struct { Title string } func (p testPage) String() string { return "p-" + p.Title } type ( pagesPtr []*testPage pagesVals []testPage ) var ( p1 = &testPage{"A"} p2 = &testPage{"B"} p3 = &testPage{"C"} p4 = &testPage{"D"} p1v = testPage{"A"} p2v = testPage{"B"} p3v = testPage{"C"} p4v = testPage{"D"} ) func TestIntersect(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { l1, l2 interface{} expect interface{} }{ {[]string{"a", "b", "c", "c"}, []string{"a", "b", "b"}, []string{"a", "b"}}, {[]string{"a", "b"}, []string{"a", "b", "c"}, []string{"a", "b"}}, {[]string{"a", "b", "c"}, []string{"d", "e"}, []string{}}, {[]string{}, []string{}, []string{}}, {[]string{"a", "b"}, nil, []interface{}{}}, {nil, []string{"a", "b"}, []interface{}{}}, {nil, nil, []interface{}{}}, {[]string{"1", "2"}, []int{1, 2}, []string{}}, {[]int{1, 2}, []string{"1", "2"}, []int{}}, {[]int{1, 2, 4}, []int{2, 4}, []int{2, 4}}, {[]int{2, 4}, []int{1, 2, 4}, []int{2, 4}}, {[]int{1, 2, 4}, []int{3, 6}, []int{}}, {[]float64{2.2, 4.4}, []float64{1.1, 2.2, 4.4}, []float64{2.2, 4.4}}, // []interface{} ∩ []interface{} {[]interface{}{"a", "b", "c"}, []interface{}{"a", "b", "b"}, []interface{}{"a", "b"}}, {[]interface{}{1, 2, 3}, []interface{}{1, 2, 2}, []interface{}{1, 2}}, {[]interface{}{int8(1), int8(2), int8(3)}, []interface{}{int8(1), int8(2), int8(2)}, []interface{}{int8(1), int8(2)}}, {[]interface{}{int16(1), int16(2), int16(3)}, []interface{}{int16(1), int16(2), int16(2)}, []interface{}{int16(1), int16(2)}}, {[]interface{}{int32(1), int32(2), int32(3)}, []interface{}{int32(1), int32(2), int32(2)}, []interface{}{int32(1), int32(2)}}, {[]interface{}{int64(1), int64(2), int64(3)}, []interface{}{int64(1), int64(2), int64(2)}, []interface{}{int64(1), int64(2)}}, {[]interface{}{float32(1), float32(2), float32(3)}, []interface{}{float32(1), float32(2), float32(2)}, []interface{}{float32(1), float32(2)}}, {[]interface{}{float64(1), float64(2), float64(3)}, []interface{}{float64(1), float64(2), float64(2)}, []interface{}{float64(1), float64(2)}}, // []interface{} ∩ []T {[]interface{}{"a", "b", "c"}, []string{"a", "b", "b"}, []interface{}{"a", "b"}}, {[]interface{}{1, 2, 3}, []int{1, 2, 2}, []interface{}{1, 2}}, {[]interface{}{int8(1), int8(2), int8(3)}, []int8{1, 2, 2}, []interface{}{int8(1), int8(2)}}, {[]interface{}{int16(1), int16(2), int16(3)}, []int16{1, 2, 2}, []interface{}{int16(1), int16(2)}}, {[]interface{}{int32(1), int32(2), int32(3)}, []int32{1, 2, 2}, []interface{}{int32(1), int32(2)}}, {[]interface{}{int64(1), int64(2), int64(3)}, []int64{1, 2, 2}, []interface{}{int64(1), int64(2)}}, {[]interface{}{uint(1), uint(2), uint(3)}, []uint{1, 2, 2}, []interface{}{uint(1), uint(2)}}, {[]interface{}{float32(1), float32(2), float32(3)}, []float32{1, 2, 2}, []interface{}{float32(1), float32(2)}}, {[]interface{}{float64(1), float64(2), float64(3)}, []float64{1, 2, 2}, []interface{}{float64(1), float64(2)}}, // []T ∩ []interface{} {[]string{"a", "b", "c"}, []interface{}{"a", "b", "b"}, []string{"a", "b"}}, {[]int{1, 2, 3}, []interface{}{1, 2, 2}, []int{1, 2}}, {[]int8{1, 2, 3}, []interface{}{int8(1), int8(2), int8(2)}, []int8{1, 2}}, {[]int16{1, 2, 3}, []interface{}{int16(1), int16(2), int16(2)}, []int16{1, 2}}, {[]int32{1, 2, 3}, []interface{}{int32(1), int32(2), int32(2)}, []int32{1, 2}}, {[]int64{1, 2, 3}, []interface{}{int64(1), int64(2), int64(2)}, []int64{1, 2}}, {[]float32{1, 2, 3}, []interface{}{float32(1), float32(2), float32(2)}, []float32{1, 2}}, {[]float64{1, 2, 3}, []interface{}{float64(1), float64(2), float64(2)}, []float64{1, 2}}, // Structs {pagesPtr{p1, p4, p2, p3}, pagesPtr{p4, p2, p2}, pagesPtr{p4, p2}}, {pagesVals{p1v, p4v, p2v, p3v}, pagesVals{p1v, p3v, p3v}, pagesVals{p1v, p3v}}, {[]interface{}{p1, p4, p2, p3}, []interface{}{p4, p2, p2}, []interface{}{p4, p2}}, {[]interface{}{p1v, p4v, p2v, p3v}, []interface{}{p1v, p3v, p3v}, []interface{}{p1v, p3v}}, {pagesPtr{p1, p4, p2, p3}, pagesPtr{}, pagesPtr{}}, {pagesVals{}, pagesVals{p1v, p3v, p3v}, pagesVals{}}, {[]interface{}{p1, p4, p2, p3}, []interface{}{}, []interface{}{}}, {[]interface{}{}, []interface{}{p1v, p3v, p3v}, []interface{}{}}, // errors {"not array or slice", []string{"a"}, false}, {[]string{"a"}, "not array or slice", false}, // uncomparable types - #3820 {[]map[int]int{{1: 1}, {2: 2}}, []map[int]int{{2: 2}, {3: 3}}, false}, {[][]int{{1, 1}, {1, 2}}, [][]int{{1, 2}, {1, 2}, {1, 3}}, false}, {[]int{1, 1}, [][]int{{1, 2}, {1, 2}, {1, 3}}, false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Intersect(test.l1, test.l2) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) if !reflect.DeepEqual(result, test.expect) { t.Fatalf("[%d] Got\n%v expected\n%v", i, result, test.expect) } } } func TestIsSet(t *testing.T) { t.Parallel() c := qt.New(t) ns := newTestNs() for i, test := range []struct { a interface{} key interface{} expect bool isErr bool }{ {[]interface{}{1, 2, 3, 5}, 2, true, false}, {[]interface{}{1, 2, 3, 5}, "2", true, false}, {[]interface{}{1, 2, 3, 5}, 2.0, true, false}, {[]interface{}{1, 2, 3, 5}, 22, false, false}, {map[string]interface{}{"a": 1, "b": 2}, "b", true, false}, {map[string]interface{}{"a": 1, "b": 2}, "bc", false, false}, {time.Now(), "Day", false, false}, {nil, "nil", false, false}, {[]interface{}{1, 2, 3, 5}, TstX{}, false, true}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.IsSet(test.a, test.key) if test.isErr { continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestLast(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { limit interface{} seq interface{} expect interface{} }{ {int(2), []string{"a", "b", "c"}, []string{"b", "c"}}, {int32(3), []string{"a", "b"}, []string{"a", "b"}}, {int64(2), []int{100, 200, 300}, []int{200, 300}}, {100, []int{100, 200}, []int{100, 200}}, {"1", []int{100, 200, 300}, []int{300}}, {"0", []int{100, 200, 300}, []int{}}, {"0", []string{"a", "b", "c"}, []string{}}, // errors {int64(-1), []int{100, 200, 300}, false}, {"noint", []int{100, 200, 300}, false}, {1, nil, false}, {nil, []int{100}, false}, {1, t, false}, {1, (*string)(nil), false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Last(test.limit, test.seq) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.DeepEquals, test.expect, errMsg) } } func TestQuerify(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { params []interface{} expect interface{} }{ {[]interface{}{"a", "b"}, "a=b"}, {[]interface{}{"a", "b", "c", "d", "f", " &"}, `a=b&c=d&f=+%26`}, // errors {[]interface{}{5, "b"}, false}, {[]interface{}{"a", "b", "c"}, false}, } { errMsg := qt.Commentf("[%d] %v", i, test.params) result, err := ns.Querify(test.params...) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.Equals, test.expect, errMsg) } } func TestSeq(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { args []interface{} expect interface{} }{ {[]interface{}{-2, 5}, []int{-2, -1, 0, 1, 2, 3, 4, 5}}, {[]interface{}{1, 2, 4}, []int{1, 3}}, {[]interface{}{1}, []int{1}}, {[]interface{}{3}, []int{1, 2, 3}}, {[]interface{}{3.2}, []int{1, 2, 3}}, {[]interface{}{0}, []int{}}, {[]interface{}{-1}, []int{-1}}, {[]interface{}{-3}, []int{-1, -2, -3}}, {[]interface{}{3, -2}, []int{3, 2, 1, 0, -1, -2}}, {[]interface{}{6, -2, 2}, []int{6, 4, 2}}, // errors {[]interface{}{1, 0, 2}, false}, {[]interface{}{1, -1, 2}, false}, {[]interface{}{2, 1, 1}, false}, {[]interface{}{2, 1, 1, 1}, false}, {[]interface{}{2001}, false}, {[]interface{}{}, false}, {[]interface{}{0, -1000000}, false}, {[]interface{}{tstNoStringer{}}, false}, {nil, false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Seq(test.args...) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.DeepEquals, test.expect, errMsg) } } func TestShuffle(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { seq interface{} success bool }{ {[]string{"a", "b", "c", "d"}, true}, {[]int{100, 200, 300}, true}, {[]int{100, 200, 300}, true}, {[]int{100, 200}, true}, {[]string{"a", "b"}, true}, {[]int{100, 200, 300}, true}, {[]int{100, 200, 300}, true}, {[]int{100}, true}, // errors {nil, false}, {t, false}, {(*string)(nil), false}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Shuffle(test.seq) if !test.success { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) resultv := reflect.ValueOf(result) seqv := reflect.ValueOf(test.seq) c.Assert(seqv.Len(), qt.Equals, resultv.Len(), errMsg) } } func TestShuffleRandomising(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) // Note that this test can fail with false negative result if the shuffle // of the sequence happens to be the same as the original sequence. However // the probability of the event is 10^-158 which is negligible. seqLen := 100 rand.Seed(time.Now().UTC().UnixNano()) for _, test := range []struct { seq []int }{ {rand.Perm(seqLen)}, } { result, err := ns.Shuffle(test.seq) resultv := reflect.ValueOf(result) c.Assert(err, qt.IsNil) allSame := true for i, v := range test.seq { allSame = allSame && (resultv.Index(i).Interface() == v) } c.Assert(allSame, qt.Equals, false) } } // Also see tests in commons/collection. func TestSlice(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { args []interface{} expected interface{} }{ {[]interface{}{"a", "b"}, []string{"a", "b"}}, {[]interface{}{}, []interface{}{}}, {[]interface{}{nil}, []interface{}{nil}}, {[]interface{}{5, "b"}, []interface{}{5, "b"}}, {[]interface{}{tstNoStringer{}}, []tstNoStringer{{}}}, } { errMsg := qt.Commentf("[%d] %v", i, test.args) result := ns.Slice(test.args...) c.Assert(result, qt.DeepEquals, test.expected, errMsg) } } func TestUnion(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { l1 interface{} l2 interface{} expect interface{} isErr bool }{ {nil, nil, []interface{}{}, false}, {nil, []string{"a", "b"}, []string{"a", "b"}, false}, {[]string{"a", "b"}, nil, []string{"a", "b"}, false}, // []A ∪ []B {[]string{"1", "2"}, []int{3}, []string{}, false}, {[]int{1, 2}, []string{"1", "2"}, []int{}, false}, // []T ∪ []T {[]string{"a", "b", "c", "c"}, []string{"a", "b", "b"}, []string{"a", "b", "c"}, false}, {[]string{"a", "b"}, []string{"a", "b", "c"}, []string{"a", "b", "c"}, false}, {[]string{"a", "b", "c"}, []string{"d", "e"}, []string{"a", "b", "c", "d", "e"}, false}, {[]string{}, []string{}, []string{}, false}, {[]int{1, 2, 3}, []int{3, 4, 5}, []int{1, 2, 3, 4, 5}, false}, {[]int{1, 2, 3}, []int{1, 2, 3}, []int{1, 2, 3}, false}, {[]int{1, 2, 4}, []int{2, 4}, []int{1, 2, 4}, false}, {[]int{2, 4}, []int{1, 2, 4}, []int{2, 4, 1}, false}, {[]int{1, 2, 4}, []int{3, 6}, []int{1, 2, 4, 3, 6}, false}, {[]float64{2.2, 4.4}, []float64{1.1, 2.2, 4.4}, []float64{2.2, 4.4, 1.1}, false}, {[]interface{}{"a", "b", "c", "c"}, []interface{}{"a", "b", "b"}, []interface{}{"a", "b", "c"}, false}, // []T ∪ []interface{} {[]string{"1", "2"}, []interface{}{"9"}, []string{"1", "2", "9"}, false}, {[]int{2, 4}, []interface{}{1, 2, 4}, []int{2, 4, 1}, false}, {[]int8{2, 4}, []interface{}{int8(1), int8(2), int8(4)}, []int8{2, 4, 1}, false}, {[]int8{2, 4}, []interface{}{1, 2, 4}, []int8{2, 4, 1}, false}, {[]int16{2, 4}, []interface{}{1, 2, 4}, []int16{2, 4, 1}, false}, {[]int32{2, 4}, []interface{}{1, 2, 4}, []int32{2, 4, 1}, false}, {[]int64{2, 4}, []interface{}{1, 2, 4}, []int64{2, 4, 1}, false}, {[]float64{2.2, 4.4}, []interface{}{1.1, 2.2, 4.4}, []float64{2.2, 4.4, 1.1}, false}, {[]float32{2.2, 4.4}, []interface{}{1.1, 2.2, 4.4}, []float32{2.2, 4.4, 1.1}, false}, // []interface{} ∪ []T {[]interface{}{"a", "b", "c", "c"}, []string{"a", "b", "d"}, []interface{}{"a", "b", "c", "d"}, false}, {[]interface{}{}, []string{}, []interface{}{}, false}, {[]interface{}{1, 2}, []int{2, 3}, []interface{}{1, 2, 3}, false}, {[]interface{}{1, 2}, []int8{2, 3}, []interface{}{1, 2, 3}, false}, // 28 {[]interface{}{uint(1), uint(2)}, []uint{2, 3}, []interface{}{uint(1), uint(2), uint(3)}, false}, {[]interface{}{1.1, 2.2}, []float64{2.2, 3.3}, []interface{}{1.1, 2.2, 3.3}, false}, // Structs {pagesPtr{p1, p4}, pagesPtr{p4, p2, p2}, pagesPtr{p1, p4, p2}, false}, {pagesVals{p1v}, pagesVals{p3v, p3v}, pagesVals{p1v, p3v}, false}, {[]interface{}{p1, p4}, []interface{}{p4, p2, p2}, []interface{}{p1, p4, p2}, false}, {[]interface{}{p1v}, []interface{}{p3v, p3v}, []interface{}{p1v, p3v}, false}, // #3686 {[]interface{}{p1v}, []interface{}{}, []interface{}{p1v}, false}, {[]interface{}{}, []interface{}{p1v}, []interface{}{p1v}, false}, {pagesPtr{p1}, pagesPtr{}, pagesPtr{p1}, false}, {pagesVals{p1v}, pagesVals{}, pagesVals{p1v}, false}, {pagesPtr{}, pagesPtr{p1}, pagesPtr{p1}, false}, {pagesVals{}, pagesVals{p1v}, pagesVals{p1v}, false}, // errors {"not array or slice", []string{"a"}, false, true}, {[]string{"a"}, "not array or slice", false, true}, // uncomparable types - #3820 {[]map[string]int{{"K1": 1}}, []map[string]int{{"K2": 2}, {"K2": 2}}, false, true}, {[][]int{{1, 1}, {1, 2}}, [][]int{{2, 1}, {2, 2}}, false, true}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Union(test.l1, test.l2) if test.isErr { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) if !reflect.DeepEqual(result, test.expect) { t.Fatalf("[%d] Got\n%v expected\n%v", i, result, test.expect) } } } func TestUniq(t *testing.T) { t.Parallel() c := qt.New(t) ns := New(&deps.Deps{}) for i, test := range []struct { l interface{} expect interface{} isErr bool }{ {[]string{"a", "b", "c"}, []string{"a", "b", "c"}, false}, {[]string{"a", "b", "c", "c"}, []string{"a", "b", "c"}, false}, {[]string{"a", "b", "b", "c"}, []string{"a", "b", "c"}, false}, {[]string{"a", "b", "c", "b"}, []string{"a", "b", "c"}, false}, {[]int{1, 2, 3}, []int{1, 2, 3}, false}, {[]int{1, 2, 3, 3}, []int{1, 2, 3}, false}, {[]int{1, 2, 2, 3}, []int{1, 2, 3}, false}, {[]int{1, 2, 3, 2}, []int{1, 2, 3}, false}, {[4]int{1, 2, 3, 2}, []int{1, 2, 3}, false}, {nil, make([]interface{}, 0), false}, // Pointers {pagesPtr{p1, p2, p3, p2}, pagesPtr{p1, p2, p3}, false}, {pagesPtr{}, pagesPtr{}, false}, // Structs {pagesVals{p3v, p2v, p3v, p2v}, pagesVals{p3v, p2v}, false}, // not Comparable(), use hashstructure {[]map[string]int{ {"K1": 1}, {"K2": 2}, {"K1": 1}, {"K2": 1}, }, []map[string]int{ {"K1": 1}, {"K2": 2}, {"K2": 1}, }, false}, // should fail {1, 1, true}, {"foo", "fo", true}, } { errMsg := qt.Commentf("[%d] %v", i, test) result, err := ns.Uniq(test.l) if test.isErr { c.Assert(err, qt.Not(qt.IsNil), errMsg) continue } c.Assert(err, qt.IsNil, errMsg) c.Assert(result, qt.DeepEquals, test.expect, errMsg) } } func (x *TstX) TstRp() string { return "r" + x.A } func (x TstX) TstRv() string { return "r" + x.B } func (x TstX) TstRv2() string { return "r" + x.B } func (x TstX) unexportedMethod() string { return x.unexported } func (x TstX) MethodWithArg(s string) string { return s } func (x TstX) MethodReturnNothing() {} func (x TstX) MethodReturnErrorOnly() error { return errors.New("some error occurred") } func (x TstX) MethodReturnTwoValues() (string, string) { return "foo", "bar" } func (x TstX) MethodReturnValueWithError() (string, error) { return "", errors.New("some error occurred") } func (x TstX) String() string { return fmt.Sprintf("A: %s, B: %s", x.A, x.B) } type TstX struct { A, B string unexported string } type TstParams struct { params maps.Params } func (x TstParams) Params() maps.Params { return x.params } type TstXIHolder struct { XI TstXI } // Partially implemented by the TstX struct. type TstXI interface { TstRv2() string } func ToTstXIs(slice interface{}) []TstXI { s := reflect.ValueOf(slice) if s.Kind() != reflect.Slice { return nil } tis := make([]TstXI, s.Len()) for i := 0; i < s.Len(); i++ { tsti, ok := s.Index(i).Interface().(TstXI) if !ok { return nil } tis[i] = tsti } return tis } func newDeps(cfg config.Provider) *deps.Deps { l := langs.NewLanguage("en", cfg) l.Set("i18nDir", "i18n") cs, err := helpers.NewContentSpec(l, loggers.NewErrorLogger(), afero.NewMemMapFs()) if err != nil { panic(err) } return &deps.Deps{ Cfg: cfg, Fs: hugofs.NewMem(l), ContentSpec: cs, Log: loggers.NewErrorLogger(), } } func newTestNs() *Namespace { v := viper.New() v.Set("contentDir", "content") return New(newDeps(v)) }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./commands/list_test.go
package commands import ( "bytes" "encoding/csv" "io" "os" "path/filepath" "strings" "testing" qt "github.com/frankban/quicktest" ) func captureStdout(f func() error) (string, error) { old := os.Stdout r, w, _ := os.Pipe() os.Stdout = w err := f() w.Close() os.Stdout = old var buf bytes.Buffer io.Copy(&buf, r) return buf.String(), err } func TestListAll(t *testing.T) { c := qt.New(t) dir, clean, err := createSimpleTestSite(t, testSiteConfig{}) defer clean() c.Assert(err, qt.IsNil) hugoCmd := newCommandsBuilder().addAll().build() cmd := hugoCmd.getCommand() defer func() { os.RemoveAll(dir) }() cmd.SetArgs([]string{"-s=" + dir, "list", "all"}) out, err := captureStdout(func() error { _, err := cmd.ExecuteC() return err }) c.Assert(err, qt.IsNil) r := csv.NewReader(strings.NewReader(out)) header, err := r.Read() c.Assert(err, qt.IsNil) c.Assert(header, qt.DeepEquals, []string{ "path", "slug", "title", "date", "expiryDate", "publishDate", "draft", "permalink", }) record, err := r.Read() c.Assert(err, qt.IsNil) c.Assert(record, qt.DeepEquals, []string{ filepath.Join("content", "p1.md"), "", "P1", "0001-01-01T00:00:00Z", "0001-01-01T00:00:00Z", "0001-01-01T00:00:00Z", "false", "https://example.org/p1/", }) }
package commands import ( "bytes" "encoding/csv" "io" "os" "path/filepath" "strings" "testing" qt "github.com/frankban/quicktest" ) func captureStdout(f func() error) (string, error) { old := os.Stdout r, w, _ := os.Pipe() os.Stdout = w err := f() w.Close() os.Stdout = old var buf bytes.Buffer io.Copy(&buf, r) return buf.String(), err } func TestListAll(t *testing.T) { c := qt.New(t) dir, clean, err := createSimpleTestSite(t, testSiteConfig{}) defer clean() c.Assert(err, qt.IsNil) hugoCmd := newCommandsBuilder().addAll().build() cmd := hugoCmd.getCommand() defer func() { os.RemoveAll(dir) }() cmd.SetArgs([]string{"-s=" + dir, "list", "all"}) out, err := captureStdout(func() error { _, err := cmd.ExecuteC() return err }) c.Assert(err, qt.IsNil) r := csv.NewReader(strings.NewReader(out)) header, err := r.Read() c.Assert(err, qt.IsNil) c.Assert(header, qt.DeepEquals, []string{ "path", "slug", "title", "date", "expiryDate", "publishDate", "draft", "permalink", }) record, err := r.Read() c.Assert(err, qt.IsNil) c.Assert(record, qt.DeepEquals, []string{ filepath.Join("content", "p1.md"), "", "P1", "0001-01-01T00:00:00Z", "0001-01-01T00:00:00Z", "0001-01-01T00:00:00Z", "false", "https://example.org/p1/", }) }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./resources/images/color_test.go
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package images import ( "image/color" "testing" qt "github.com/frankban/quicktest" ) func TestHexStringToColor(t *testing.T) { c := qt.New(t) for _, test := range []struct { arg string expect interface{} }{ {"f", false}, {"#f", false}, {"#fffffff", false}, {"fffffff", false}, {"#fff", color.White}, {"fff", color.White}, {"FFF", color.White}, {"FfF", color.White}, {"#ffffff", color.White}, {"ffffff", color.White}, {"#000", color.Black}, {"#4287f5", color.RGBA{R: 0x42, G: 0x87, B: 0xf5, A: 0xff}}, {"777", color.RGBA{R: 0x77, G: 0x77, B: 0x77, A: 0xff}}, } { test := test c.Run(test.arg, func(c *qt.C) { c.Parallel() result, err := hexStringToColor(test.arg) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil)) return } c.Assert(err, qt.IsNil) c.Assert(result, qt.DeepEquals, test.expect) }) } } func TestAddColorToPalette(t *testing.T) { c := qt.New(t) palette := color.Palette{color.White, color.Black} c.Assert(AddColorToPalette(color.White, palette), qt.HasLen, 2) blue1, _ := hexStringToColor("34c3eb") blue2, _ := hexStringToColor("34c3eb") white, _ := hexStringToColor("fff") c.Assert(AddColorToPalette(white, palette), qt.HasLen, 2) c.Assert(AddColorToPalette(blue1, palette), qt.HasLen, 3) c.Assert(AddColorToPalette(blue2, palette), qt.HasLen, 3) } func TestReplaceColorInPalette(t *testing.T) { c := qt.New(t) palette := color.Palette{color.White, color.Black} offWhite, _ := hexStringToColor("fcfcfc") ReplaceColorInPalette(offWhite, palette) c.Assert(palette, qt.HasLen, 2) c.Assert(palette[0], qt.Equals, offWhite) }
// Copyright 2019 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package images import ( "image/color" "testing" qt "github.com/frankban/quicktest" ) func TestHexStringToColor(t *testing.T) { c := qt.New(t) for _, test := range []struct { arg string expect interface{} }{ {"f", false}, {"#f", false}, {"#fffffff", false}, {"fffffff", false}, {"#fff", color.White}, {"fff", color.White}, {"FFF", color.White}, {"FfF", color.White}, {"#ffffff", color.White}, {"ffffff", color.White}, {"#000", color.Black}, {"#4287f5", color.RGBA{R: 0x42, G: 0x87, B: 0xf5, A: 0xff}}, {"777", color.RGBA{R: 0x77, G: 0x77, B: 0x77, A: 0xff}}, } { test := test c.Run(test.arg, func(c *qt.C) { c.Parallel() result, err := hexStringToColor(test.arg) if b, ok := test.expect.(bool); ok && !b { c.Assert(err, qt.Not(qt.IsNil)) return } c.Assert(err, qt.IsNil) c.Assert(result, qt.DeepEquals, test.expect) }) } } func TestAddColorToPalette(t *testing.T) { c := qt.New(t) palette := color.Palette{color.White, color.Black} c.Assert(AddColorToPalette(color.White, palette), qt.HasLen, 2) blue1, _ := hexStringToColor("34c3eb") blue2, _ := hexStringToColor("34c3eb") white, _ := hexStringToColor("fff") c.Assert(AddColorToPalette(white, palette), qt.HasLen, 2) c.Assert(AddColorToPalette(blue1, palette), qt.HasLen, 3) c.Assert(AddColorToPalette(blue2, palette), qt.HasLen, 3) } func TestReplaceColorInPalette(t *testing.T) { c := qt.New(t) palette := color.Palette{color.White, color.Black} offWhite, _ := hexStringToColor("fcfcfc") ReplaceColorInPalette(offWhite, palette) c.Assert(palette, qt.HasLen, 2) c.Assert(palette[0], qt.Equals, offWhite) }
-1
gohugoio/hugo
8,150
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1
Signed-off-by: Robert-André Mauchin <[email protected]>
eclipseo
"2021-01-18T01:52:30Z"
"2021-01-19T16:25:21Z"
2c8b5d9165011c4b24b494e661ae60dfc7bb7d1b
07ad283f686904e5835f621d73ed342ba2a48eb3
build(deps): bump github.com/spf13/afero from 1.4.1 to 1.5.1. Signed-off-by: Robert-André Mauchin <[email protected]>
./cache/filecache/filecache_pruner_test.go
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package filecache import ( "fmt" "testing" "time" "github.com/spf13/afero" qt "github.com/frankban/quicktest" ) func TestPrune(t *testing.T) { t.Parallel() c := qt.New(t) configStr := ` resourceDir = "myresources" contentDir = "content" dataDir = "data" i18nDir = "i18n" layoutDir = "layouts" assetDir = "assets" archeTypedir = "archetypes" [caches] [caches.getjson] maxAge = "200ms" dir = "/cache/c" [caches.getcsv] maxAge = "200ms" dir = "/cache/d" [caches.assets] maxAge = "200ms" dir = ":resourceDir/_gen" [caches.images] maxAge = "200ms" dir = ":resourceDir/_gen" ` for _, name := range []string{cacheKeyGetCSV, cacheKeyGetJSON, cacheKeyAssets, cacheKeyImages} { msg := qt.Commentf("cache: %s", name) p := newPathsSpec(t, afero.NewMemMapFs(), configStr) caches, err := NewCaches(p) c.Assert(err, qt.IsNil) cache := caches[name] for i := 0; i < 10; i++ { id := fmt.Sprintf("i%d", i) cache.GetOrCreateBytes(id, func() ([]byte, error) { return []byte("abc"), nil }) if i == 4 { // This will expire the first 5 time.Sleep(201 * time.Millisecond) } } count, err := caches.Prune() c.Assert(err, qt.IsNil) c.Assert(count, qt.Equals, 5, msg) for i := 0; i < 10; i++ { id := fmt.Sprintf("i%d", i) v := cache.getString(id) if i < 5 { c.Assert(v, qt.Equals, "") } else { c.Assert(v, qt.Equals, "abc") } } caches, err = NewCaches(p) c.Assert(err, qt.IsNil) cache = caches[name] // Touch one and then prune. cache.GetOrCreateBytes("i5", func() ([]byte, error) { return []byte("abc"), nil }) count, err = caches.Prune() c.Assert(err, qt.IsNil) c.Assert(count, qt.Equals, 4) // Now only the i5 should be left. for i := 0; i < 10; i++ { id := fmt.Sprintf("i%d", i) v := cache.getString(id) if i != 5 { c.Assert(v, qt.Equals, "") } else { c.Assert(v, qt.Equals, "abc") } } } }
// Copyright 2018 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package filecache import ( "fmt" "testing" "time" "github.com/spf13/afero" qt "github.com/frankban/quicktest" ) func TestPrune(t *testing.T) { t.Parallel() c := qt.New(t) configStr := ` resourceDir = "myresources" contentDir = "content" dataDir = "data" i18nDir = "i18n" layoutDir = "layouts" assetDir = "assets" archeTypedir = "archetypes" [caches] [caches.getjson] maxAge = "200ms" dir = "/cache/c" [caches.getcsv] maxAge = "200ms" dir = "/cache/d" [caches.assets] maxAge = "200ms" dir = ":resourceDir/_gen" [caches.images] maxAge = "200ms" dir = ":resourceDir/_gen" ` for _, name := range []string{cacheKeyGetCSV, cacheKeyGetJSON, cacheKeyAssets, cacheKeyImages} { msg := qt.Commentf("cache: %s", name) p := newPathsSpec(t, afero.NewMemMapFs(), configStr) caches, err := NewCaches(p) c.Assert(err, qt.IsNil) cache := caches[name] for i := 0; i < 10; i++ { id := fmt.Sprintf("i%d", i) cache.GetOrCreateBytes(id, func() ([]byte, error) { return []byte("abc"), nil }) if i == 4 { // This will expire the first 5 time.Sleep(201 * time.Millisecond) } } count, err := caches.Prune() c.Assert(err, qt.IsNil) c.Assert(count, qt.Equals, 5, msg) for i := 0; i < 10; i++ { id := fmt.Sprintf("i%d", i) v := cache.getString(id) if i < 5 { c.Assert(v, qt.Equals, "") } else { c.Assert(v, qt.Equals, "abc") } } caches, err = NewCaches(p) c.Assert(err, qt.IsNil) cache = caches[name] // Touch one and then prune. cache.GetOrCreateBytes("i5", func() ([]byte, error) { return []byte("abc"), nil }) count, err = caches.Prune() c.Assert(err, qt.IsNil) c.Assert(count, qt.Equals, 4) // Now only the i5 should be left. for i := 0; i < 10; i++ { id := fmt.Sprintf("i%d", i) v := cache.getString(id) if i != 5 { c.Assert(v, qt.Equals, "") } else { c.Assert(v, qt.Equals, "abc") } } } }
-1