mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
423594e03a
commit
b80853de90
342 changed files with 2118 additions and 2102 deletions
|
@ -20,7 +20,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var bufferPool = &sync.Pool{
|
var bufferPool = &sync.Pool{
|
||||||
New: func() interface{} {
|
New: func() any {
|
||||||
return &bytes.Buffer{}
|
return &bytes.Buffer{}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
4
cache/namedmemcache/named_cache.go
vendored
4
cache/namedmemcache/named_cache.go
vendored
|
@ -30,7 +30,7 @@ type Cache struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type cacheEntry struct {
|
type cacheEntry struct {
|
||||||
value interface{}
|
value any
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ func (c *Cache) Clear() {
|
||||||
// create will be called and cached.
|
// create will be called and cached.
|
||||||
// This method is thread safe. It also guarantees that the create func for a given
|
// This method is thread safe. It also guarantees that the create func for a given
|
||||||
// key is invoked only once for this cache.
|
// key is invoked only once for this cache.
|
||||||
func (c *Cache) GetOrCreate(key string, create func() (interface{}, error)) (interface{}, error) {
|
func (c *Cache) GetOrCreate(key string, create func() (any, error)) (any, error) {
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
entry, found := c.cache[key]
|
entry, found := c.cache[key]
|
||||||
c.mu.RUnlock()
|
c.mu.RUnlock()
|
||||||
|
|
6
cache/namedmemcache/named_cache_test.go
vendored
6
cache/namedmemcache/named_cache_test.go
vendored
|
@ -28,7 +28,7 @@ func TestNamedCache(t *testing.T) {
|
||||||
cache := New()
|
cache := New()
|
||||||
|
|
||||||
counter := 0
|
counter := 0
|
||||||
create := func() (interface{}, error) {
|
create := func() (any, error) {
|
||||||
counter++
|
counter++
|
||||||
return counter, nil
|
return counter, nil
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,8 @@ func TestNamedCacheConcurrent(t *testing.T) {
|
||||||
|
|
||||||
cache := New()
|
cache := New()
|
||||||
|
|
||||||
create := func(i int) func() (interface{}, error) {
|
create := func(i int) func() (any, error) {
|
||||||
return func() (interface{}, error) {
|
return func() (any, error) {
|
||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,7 +505,7 @@ func typeName(name, pkg string) string {
|
||||||
|
|
||||||
func uniqueNonEmptyStrings(s []string) []string {
|
func uniqueNonEmptyStrings(s []string) []string {
|
||||||
var unique []string
|
var unique []string
|
||||||
set := map[string]interface{}{}
|
set := map[string]any{}
|
||||||
for _, val := range s {
|
for _, val := range s {
|
||||||
if val == "" {
|
if val == "" {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -85,7 +85,7 @@ type I interface {
|
||||||
Method3(myint int, mystring string)
|
Method3(myint int, mystring string)
|
||||||
Method5() (string, error)
|
Method5() (string, error)
|
||||||
Method6() *net.IP
|
Method6() *net.IP
|
||||||
Method7() interface{}
|
Method7() any
|
||||||
Method8() herrors.ErrorContext
|
Method8() herrors.ErrorContext
|
||||||
method2()
|
method2()
|
||||||
method9() os.FileInfo
|
method9() os.FileInfo
|
||||||
|
|
|
@ -120,14 +120,14 @@ func (c *commandeer) errCount() int {
|
||||||
return int(c.logger.LogCounters().ErrorCounter.Count())
|
return int(c.logger.LogCounters().ErrorCounter.Count())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandeer) getErrorWithContext() interface{} {
|
func (c *commandeer) getErrorWithContext() any {
|
||||||
errCount := c.errCount()
|
errCount := c.errCount()
|
||||||
|
|
||||||
if errCount == 0 {
|
if errCount == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]any)
|
||||||
|
|
||||||
m["Error"] = errors.New(removeErrorPrefixFromLog(c.logger.Errors()))
|
m["Error"] = errors.New(removeErrorPrefixFromLog(c.logger.Errors()))
|
||||||
m["Version"] = hugo.BuildVersionString()
|
m["Version"] = hugo.BuildVersionString()
|
||||||
|
@ -146,7 +146,7 @@ func (c *commandeer) getErrorWithContext() interface{} {
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandeer) Set(key string, value interface{}) {
|
func (c *commandeer) Set(key string, value any) {
|
||||||
if c.configured {
|
if c.configured {
|
||||||
panic("commandeer cannot be changed")
|
panic("commandeer cannot be changed")
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,13 +145,13 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
|
||||||
if m.verbose {
|
if m.verbose {
|
||||||
config := m.m.Config()
|
config := m.m.Config()
|
||||||
return json.Marshal(&struct {
|
return json.Marshal(&struct {
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Time time.Time `json:"time"`
|
Time time.Time `json:"time"`
|
||||||
Owner string `json:"owner"`
|
Owner string `json:"owner"`
|
||||||
Dir string `json:"dir"`
|
Dir string `json:"dir"`
|
||||||
Meta map[string]interface{} `json:"meta"`
|
Meta map[string]any `json:"meta"`
|
||||||
HugoVersion modules.HugoVersion `json:"hugoVersion"`
|
HugoVersion modules.HugoVersion `json:"hugoVersion"`
|
||||||
|
|
||||||
Mounts []modMount `json:"mounts"`
|
Mounts []modMount `json:"mounts"`
|
||||||
}{
|
}{
|
||||||
|
|
|
@ -202,7 +202,7 @@ func (cc *convertCmd) convertAndSavePage(p page.Page, site *hugolib.Site, target
|
||||||
type parsedFile struct {
|
type parsedFile struct {
|
||||||
frontMatterFormat metadecoders.Format
|
frontMatterFormat metadecoders.Format
|
||||||
frontMatterSource []byte
|
frontMatterSource []byte
|
||||||
frontMatter map[string]interface{}
|
frontMatter map[string]any
|
||||||
|
|
||||||
// Everything after Front Matter
|
// Everything after Front Matter
|
||||||
content []byte
|
content []byte
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !nodeploy
|
||||||
// +build !nodeploy
|
// +build !nodeploy
|
||||||
|
|
||||||
package commands
|
package commands
|
||||||
|
|
|
@ -53,15 +53,15 @@ func (c commandError) isUserError() bool {
|
||||||
return c.userError
|
return c.userError
|
||||||
}
|
}
|
||||||
|
|
||||||
func newUserError(a ...interface{}) commandError {
|
func newUserError(a ...any) commandError {
|
||||||
return commandError{s: fmt.Sprintln(a...), userError: true}
|
return commandError{s: fmt.Sprintln(a...), userError: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSystemError(a ...interface{}) commandError {
|
func newSystemError(a ...any) commandError {
|
||||||
return commandError{s: fmt.Sprintln(a...), userError: false}
|
return commandError{s: fmt.Sprintln(a...), userError: false}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSystemErrorF(format string, a ...interface{}) commandError {
|
func newSystemErrorF(format string, a ...any) commandError {
|
||||||
return commandError{s: fmt.Sprintf(format, a...), userError: false}
|
return commandError{s: fmt.Sprintf(format, a...), userError: false}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ func (i *importCmd) createSiteFromJekyll(jekyllRoot, targetDir string, jekyllPos
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *importCmd) loadJekyllConfig(fs afero.Fs, jekyllRoot string) map[string]interface{} {
|
func (i *importCmd) loadJekyllConfig(fs afero.Fs, jekyllRoot string) map[string]any {
|
||||||
path := filepath.Join(jekyllRoot, "_config.yml")
|
path := filepath.Join(jekyllRoot, "_config.yml")
|
||||||
|
|
||||||
exists, err := helpers.Exists(path, fs)
|
exists, err := helpers.Exists(path, fs)
|
||||||
|
@ -265,7 +265,7 @@ func (i *importCmd) loadJekyllConfig(fs afero.Fs, jekyllRoot string) map[string]
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *importCmd) createConfigFromJekyll(fs afero.Fs, inpath string, kind metadecoders.Format, jekyllConfig map[string]interface{}) (err error) {
|
func (i *importCmd) createConfigFromJekyll(fs afero.Fs, inpath string, kind metadecoders.Format, jekyllConfig map[string]any) (err error) {
|
||||||
title := "My New Hugo Site"
|
title := "My New Hugo Site"
|
||||||
baseURL := "http://example.org/"
|
baseURL := "http://example.org/"
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ func (i *importCmd) createConfigFromJekyll(fs afero.Fs, inpath string, kind meta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
in := map[string]interface{}{
|
in := map[string]any{
|
||||||
"baseURL": baseURL,
|
"baseURL": baseURL,
|
||||||
"title": title,
|
"title": title,
|
||||||
"languageCode": "en-us",
|
"languageCode": "en-us",
|
||||||
|
@ -423,7 +423,7 @@ func convertJekyllPost(path, relPath, targetDir string, draft bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertJekyllMetaData(m interface{}, postName string, postDate time.Time, draft bool) (interface{}, error) {
|
func convertJekyllMetaData(m any, postName string, postDate time.Time, draft bool) (any, error) {
|
||||||
metadata, err := maps.ToStringMapE(m)
|
metadata, err := maps.ToStringMapE(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -475,7 +475,7 @@ func convertJekyllMetaData(m interface{}, postName string, postDate time.Time, d
|
||||||
return metadata, nil
|
return metadata, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertJekyllContent(m interface{}, content string) (string, error) {
|
func convertJekyllContent(m any, content string) (string, error) {
|
||||||
metadata, _ := maps.ToStringMapE(m)
|
metadata, _ := maps.ToStringMapE(m)
|
||||||
|
|
||||||
lines := strings.Split(content, "\n")
|
lines := strings.Split(content, "\n")
|
||||||
|
|
|
@ -47,44 +47,44 @@ func TestParseJekyllFilename(t *testing.T) {
|
||||||
func TestConvertJekyllMetadata(t *testing.T) {
|
func TestConvertJekyllMetadata(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
testDataList := []struct {
|
testDataList := []struct {
|
||||||
metadata interface{}
|
metadata any
|
||||||
postName string
|
postName string
|
||||||
postDate time.Time
|
postDate time.Time
|
||||||
draft bool
|
draft bool
|
||||||
expect string
|
expect string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
||||||
`{"date":"2015-10-01T00:00:00Z"}`,
|
`{"date":"2015-10-01T00:00:00Z"}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), true,
|
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), true,
|
||||||
`{"date":"2015-10-01T00:00:00Z","draft":true}`,
|
`{"date":"2015-10-01T00:00:00Z","draft":true}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{"Permalink": "/permalink.html", "layout": "post"},
|
map[any]any{"Permalink": "/permalink.html", "layout": "post"},
|
||||||
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
||||||
`{"date":"2015-10-01T00:00:00Z","url":"/permalink.html"}`,
|
`{"date":"2015-10-01T00:00:00Z","url":"/permalink.html"}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{"permalink": "/permalink.html"},
|
map[any]any{"permalink": "/permalink.html"},
|
||||||
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
||||||
`{"date":"2015-10-01T00:00:00Z","url":"/permalink.html"}`,
|
`{"date":"2015-10-01T00:00:00Z","url":"/permalink.html"}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{"category": nil, "permalink": 123},
|
map[any]any{"category": nil, "permalink": 123},
|
||||||
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
||||||
`{"date":"2015-10-01T00:00:00Z"}`,
|
`{"date":"2015-10-01T00:00:00Z"}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{"Excerpt_Separator": "sep"},
|
map[any]any{"Excerpt_Separator": "sep"},
|
||||||
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
||||||
`{"date":"2015-10-01T00:00:00Z","excerpt_separator":"sep"}`,
|
`{"date":"2015-10-01T00:00:00Z","excerpt_separator":"sep"}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{"category": "book", "layout": "post", "Others": "Goods", "Date": "2015-10-01 12:13:11"},
|
map[any]any{"category": "book", "layout": "post", "Others": "Goods", "Date": "2015-10-01 12:13:11"},
|
||||||
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
"testPost", time.Date(2015, 10, 1, 0, 0, 0, 0, time.UTC), false,
|
||||||
`{"Others":"Goods","categories":["book"],"date":"2015-10-01T12:13:11Z"}`,
|
`{"Others":"Goods","categories":["book"],"date":"2015-10-01T12:13:11Z"}`,
|
||||||
},
|
},
|
||||||
|
@ -102,69 +102,69 @@ func TestConvertJekyllMetadata(t *testing.T) {
|
||||||
func TestConvertJekyllContent(t *testing.T) {
|
func TestConvertJekyllContent(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
testDataList := []struct {
|
testDataList := []struct {
|
||||||
metadata interface{}
|
metadata any
|
||||||
content string
|
content string
|
||||||
expect string
|
expect string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"Test content\r\n<!-- more -->\npart2 content", "Test content\n<!--more-->\npart2 content",
|
"Test content\r\n<!-- more -->\npart2 content", "Test content\n<!--more-->\npart2 content",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"Test content\n<!-- More -->\npart2 content", "Test content\n<!--more-->\npart2 content",
|
"Test content\n<!-- More -->\npart2 content", "Test content\n<!--more-->\npart2 content",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{"excerpt_separator": "<!--sep-->"},
|
map[any]any{"excerpt_separator": "<!--sep-->"},
|
||||||
"Test content\n<!--sep-->\npart2 content",
|
"Test content\n<!--sep-->\npart2 content",
|
||||||
"---\nexcerpt_separator: <!--sep-->\n---\nTest content\n<!--more-->\npart2 content",
|
"---\nexcerpt_separator: <!--sep-->\n---\nTest content\n<!--more-->\npart2 content",
|
||||||
},
|
},
|
||||||
{map[interface{}]interface{}{}, "{% raw %}text{% endraw %}", "text"},
|
{map[any]any{}, "{% raw %}text{% endraw %}", "text"},
|
||||||
{map[interface{}]interface{}{}, "{%raw%} text2 {%endraw %}", "text2"},
|
{map[any]any{}, "{%raw%} text2 {%endraw %}", "text2"},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"{% highlight go %}\nvar s int\n{% endhighlight %}",
|
"{% highlight go %}\nvar s int\n{% endhighlight %}",
|
||||||
"{{< highlight go >}}\nvar s int\n{{< / highlight >}}",
|
"{{< highlight go >}}\nvar s int\n{{< / highlight >}}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"{% highlight go linenos hl_lines=\"1 2\" %}\nvar s string\nvar i int\n{% endhighlight %}",
|
"{% highlight go linenos hl_lines=\"1 2\" %}\nvar s string\nvar i int\n{% endhighlight %}",
|
||||||
"{{< highlight go \"linenos=table,hl_lines=1 2\" >}}\nvar s string\nvar i int\n{{< / highlight >}}",
|
"{{< highlight go \"linenos=table,hl_lines=1 2\" >}}\nvar s string\nvar i int\n{{< / highlight >}}",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Octopress image tag
|
// Octopress image tag
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"{% img http://placekitten.com/890/280 %}",
|
"{% img http://placekitten.com/890/280 %}",
|
||||||
"{{< figure src=\"http://placekitten.com/890/280\" >}}",
|
"{{< figure src=\"http://placekitten.com/890/280\" >}}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"{% img left http://placekitten.com/320/250 Place Kitten #2 %}",
|
"{% img left http://placekitten.com/320/250 Place Kitten #2 %}",
|
||||||
"{{< figure class=\"left\" src=\"http://placekitten.com/320/250\" title=\"Place Kitten #2\" >}}",
|
"{{< figure class=\"left\" src=\"http://placekitten.com/320/250\" title=\"Place Kitten #2\" >}}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"{% img right http://placekitten.com/300/500 150 250 'Place Kitten #3' %}",
|
"{% img right http://placekitten.com/300/500 150 250 'Place Kitten #3' %}",
|
||||||
"{{< figure class=\"right\" src=\"http://placekitten.com/300/500\" width=\"150\" height=\"250\" title=\"Place Kitten #3\" >}}",
|
"{{< figure class=\"right\" src=\"http://placekitten.com/300/500\" width=\"150\" height=\"250\" title=\"Place Kitten #3\" >}}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"{% img right http://placekitten.com/300/500 150 250 'Place Kitten #4' 'An image of a very cute kitten' %}",
|
"{% img right http://placekitten.com/300/500 150 250 'Place Kitten #4' 'An image of a very cute kitten' %}",
|
||||||
"{{< figure class=\"right\" src=\"http://placekitten.com/300/500\" width=\"150\" height=\"250\" title=\"Place Kitten #4\" alt=\"An image of a very cute kitten\" >}}",
|
"{{< figure class=\"right\" src=\"http://placekitten.com/300/500\" width=\"150\" height=\"250\" title=\"Place Kitten #4\" alt=\"An image of a very cute kitten\" >}}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"{% img http://placekitten.com/300/500 150 250 'Place Kitten #4' 'An image of a very cute kitten' %}",
|
"{% img http://placekitten.com/300/500 150 250 'Place Kitten #4' 'An image of a very cute kitten' %}",
|
||||||
"{{< figure src=\"http://placekitten.com/300/500\" width=\"150\" height=\"250\" title=\"Place Kitten #4\" alt=\"An image of a very cute kitten\" >}}",
|
"{{< figure src=\"http://placekitten.com/300/500\" width=\"150\" height=\"250\" title=\"Place Kitten #4\" alt=\"An image of a very cute kitten\" >}}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{},
|
map[any]any{},
|
||||||
"{% img right /placekitten/300/500 'Place Kitten #4' 'An image of a very cute kitten' %}",
|
"{% img right /placekitten/300/500 'Place Kitten #4' 'An image of a very cute kitten' %}",
|
||||||
"{{< figure class=\"right\" src=\"/placekitten/300/500\" title=\"Place Kitten #4\" alt=\"An image of a very cute kitten\" >}}",
|
"{{< figure class=\"right\" src=\"/placekitten/300/500\" title=\"Place Kitten #4\" alt=\"An image of a very cute kitten\" >}}",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[interface{}]interface{}{"category": "book", "layout": "post", "Date": "2015-10-01 12:13:11"},
|
map[any]any{"category": "book", "layout": "post", "Date": "2015-10-01 12:13:11"},
|
||||||
"somecontent",
|
"somecontent",
|
||||||
"---\nDate: \"2015-10-01 12:13:11\"\ncategory: book\nlayout: post\n---\nsomecontent",
|
"---\nDate: \"2015-10-01 12:13:11\"\ncategory: book\nlayout: post\n---\nsomecontent",
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !darwin
|
||||||
// +build !darwin
|
// +build !darwin
|
||||||
|
|
||||||
package commands
|
package commands
|
||||||
|
|
|
@ -32,7 +32,7 @@ type listCmd struct {
|
||||||
*baseBuilderCmd
|
*baseBuilderCmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lc *listCmd) buildSites(config map[string]interface{}) (*hugolib.HugoSites, error) {
|
func (lc *listCmd) buildSites(config map[string]any) (*hugolib.HugoSites, error) {
|
||||||
cfgInit := func(c *commandeer) error {
|
cfgInit := func(c *commandeer) error {
|
||||||
for key, value := range config {
|
for key, value := range config {
|
||||||
c.Set(key, value)
|
c.Set(key, value)
|
||||||
|
@ -75,7 +75,7 @@ List requires a subcommand, e.g. ` + "`hugo list drafts`.",
|
||||||
Short: "List all drafts",
|
Short: "List all drafts",
|
||||||
Long: `List all of the drafts in your content directory.`,
|
Long: `List all of the drafts in your content directory.`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
sites, err := cc.buildSites(map[string]interface{}{"buildDrafts": true})
|
sites, err := cc.buildSites(map[string]any{"buildDrafts": true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return newSystemError("Error building sites", err)
|
return newSystemError("Error building sites", err)
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ List requires a subcommand, e.g. ` + "`hugo list drafts`.",
|
||||||
Short: "List all posts dated in the future",
|
Short: "List all posts dated in the future",
|
||||||
Long: `List all of the posts in your content directory which will be posted in the future.`,
|
Long: `List all of the posts in your content directory which will be posted in the future.`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
sites, err := cc.buildSites(map[string]interface{}{"buildFuture": true})
|
sites, err := cc.buildSites(map[string]any{"buildFuture": true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return newSystemError("Error building sites", err)
|
return newSystemError("Error building sites", err)
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ List requires a subcommand, e.g. ` + "`hugo list drafts`.",
|
||||||
Short: "List all posts already expired",
|
Short: "List all posts already expired",
|
||||||
Long: `List all of the posts in your content directory which has already expired.`,
|
Long: `List all of the posts in your content directory which has already expired.`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
sites, err := cc.buildSites(map[string]interface{}{"buildExpired": true})
|
sites, err := cc.buildSites(map[string]any{"buildExpired": true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return newSystemError("Error building sites", err)
|
return newSystemError("Error building sites", err)
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ List requires a subcommand, e.g. ` + "`hugo list drafts`.",
|
||||||
Short: "List all posts",
|
Short: "List all posts",
|
||||||
Long: `List all of the posts in your content directory, include drafts, future and expired pages.`,
|
Long: `List all of the posts in your content directory, include drafts, future and expired pages.`,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
sites, err := cc.buildSites(map[string]interface{}{
|
sites, err := cc.buildSites(map[string]any{
|
||||||
"buildExpired": true,
|
"buildExpired": true,
|
||||||
"buildDrafts": true,
|
"buildDrafts": true,
|
||||||
"buildFuture": true,
|
"buildFuture": true,
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build nodeploy
|
||||||
// +build nodeploy
|
// +build nodeploy
|
||||||
|
|
||||||
package commands
|
package commands
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build release
|
||||||
// +build release
|
// +build release
|
||||||
|
|
||||||
// Copyright 2017-present The Hugo Authors. All rights reserved.
|
// Copyright 2017-present The Hugo Authors. All rights reserved.
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build !release
|
||||||
// +build !release
|
// +build !release
|
||||||
|
|
||||||
// Copyright 2018 The Hugo Authors. All rights reserved.
|
// Copyright 2018 The Hugo Authors. All rights reserved.
|
||||||
|
|
|
@ -304,7 +304,7 @@ func getRootWatchDirsStr(baseDir string, watchDirs []string) string {
|
||||||
type fileServer struct {
|
type fileServer struct {
|
||||||
baseURLs []string
|
baseURLs []string
|
||||||
roots []string
|
roots []string
|
||||||
errorTemplate func(err interface{}) (io.Reader, error)
|
errorTemplate func(err any) (io.Reader, error)
|
||||||
c *commandeer
|
c *commandeer
|
||||||
s *serverCmd
|
s *serverCmd
|
||||||
}
|
}
|
||||||
|
@ -497,7 +497,7 @@ func (c *commandeer) serve(s *serverCmd) error {
|
||||||
roots: roots,
|
roots: roots,
|
||||||
c: c,
|
c: c,
|
||||||
s: s,
|
s: s,
|
||||||
errorTemplate: func(ctx interface{}) (io.Reader, error) {
|
errorTemplate: func(ctx any) (io.Reader, error) {
|
||||||
b := &bytes.Buffer{}
|
b := &bytes.Buffer{}
|
||||||
err := c.hugo().Tmpl().Execute(templ, b, ctx)
|
err := c.hugo().Tmpl().Execute(templ, b, ctx)
|
||||||
return b, err
|
return b, err
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
// Append appends from to a slice to and returns the resulting slice.
|
// Append appends from to a slice to and returns the resulting slice.
|
||||||
// If length of from is one and the only element is a slice of same type as to,
|
// If length of from is one and the only element is a slice of same type as to,
|
||||||
// it will be appended.
|
// it will be appended.
|
||||||
func Append(to interface{}, from ...interface{}) (interface{}, error) {
|
func Append(to any, from ...any) (any, error) {
|
||||||
tov, toIsNil := indirect(reflect.ValueOf(to))
|
tov, toIsNil := indirect(reflect.ValueOf(to))
|
||||||
|
|
||||||
toIsNil = toIsNil || to == nil
|
toIsNil = toIsNil || to == nil
|
||||||
|
@ -73,8 +73,8 @@ func Append(to interface{}, from ...interface{}) (interface{}, error) {
|
||||||
return tov.Interface(), nil
|
return tov.Interface(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendToInterfaceSliceFromValues(slice1, slice2 reflect.Value) ([]interface{}, error) {
|
func appendToInterfaceSliceFromValues(slice1, slice2 reflect.Value) ([]any, error) {
|
||||||
var tos []interface{}
|
var tos []any
|
||||||
|
|
||||||
for _, slice := range []reflect.Value{slice1, slice2} {
|
for _, slice := range []reflect.Value{slice1, slice2} {
|
||||||
for i := 0; i < slice.Len(); i++ {
|
for i := 0; i < slice.Len(); i++ {
|
||||||
|
@ -85,8 +85,8 @@ func appendToInterfaceSliceFromValues(slice1, slice2 reflect.Value) ([]interface
|
||||||
return tos, nil
|
return tos, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendToInterfaceSlice(tov reflect.Value, from ...interface{}) ([]interface{}, error) {
|
func appendToInterfaceSlice(tov reflect.Value, from ...any) ([]any, error) {
|
||||||
var tos []interface{}
|
var tos []any
|
||||||
|
|
||||||
for i := 0; i < tov.Len(); i++ {
|
for i := 0; i < tov.Len(); i++ {
|
||||||
tos = append(tos, tov.Index(i).Interface())
|
tos = append(tos, tov.Index(i).Interface())
|
||||||
|
|
|
@ -25,25 +25,25 @@ func TestAppend(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
start interface{}
|
start any
|
||||||
addend []interface{}
|
addend []any
|
||||||
expected interface{}
|
expected any
|
||||||
}{
|
}{
|
||||||
{[]string{"a", "b"}, []interface{}{"c"}, []string{"a", "b", "c"}},
|
{[]string{"a", "b"}, []any{"c"}, []string{"a", "b", "c"}},
|
||||||
{[]string{"a", "b"}, []interface{}{"c", "d", "e"}, []string{"a", "b", "c", "d", "e"}},
|
{[]string{"a", "b"}, []any{"c", "d", "e"}, []string{"a", "b", "c", "d", "e"}},
|
||||||
{[]string{"a", "b"}, []interface{}{[]string{"c", "d", "e"}}, []string{"a", "b", "c", "d", "e"}},
|
{[]string{"a", "b"}, []any{[]string{"c", "d", "e"}}, []string{"a", "b", "c", "d", "e"}},
|
||||||
{[]string{"a"}, []interface{}{"b", template.HTML("c")}, []interface{}{"a", "b", template.HTML("c")}},
|
{[]string{"a"}, []any{"b", template.HTML("c")}, []any{"a", "b", template.HTML("c")}},
|
||||||
{nil, []interface{}{"a", "b"}, []string{"a", "b"}},
|
{nil, []any{"a", "b"}, []string{"a", "b"}},
|
||||||
{nil, []interface{}{nil}, []interface{}{nil}},
|
{nil, []any{nil}, []any{nil}},
|
||||||
{[]interface{}{}, []interface{}{[]string{"c", "d", "e"}}, []string{"c", "d", "e"}},
|
{[]any{}, []any{[]string{"c", "d", "e"}}, []string{"c", "d", "e"}},
|
||||||
{
|
{
|
||||||
tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}},
|
tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}},
|
||||||
[]interface{}{&tstSlicer{"c"}},
|
[]any{&tstSlicer{"c"}},
|
||||||
tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}, &tstSlicer{"c"}},
|
tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}, &tstSlicer{"c"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
&tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}},
|
&tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}},
|
||||||
[]interface{}{&tstSlicer{"c"}},
|
[]any{&tstSlicer{"c"}},
|
||||||
tstSlicers{
|
tstSlicers{
|
||||||
&tstSlicer{"a"},
|
&tstSlicer{"a"},
|
||||||
&tstSlicer{"b"},
|
&tstSlicer{"b"},
|
||||||
|
@ -52,26 +52,26 @@ func TestAppend(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}},
|
testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}},
|
||||||
[]interface{}{&tstSlicerIn1{"c"}},
|
[]any{&tstSlicerIn1{"c"}},
|
||||||
testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}, &tstSlicerIn1{"c"}},
|
testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}, &tstSlicerIn1{"c"}},
|
||||||
},
|
},
|
||||||
//https://github.com/gohugoio/hugo/issues/5361
|
//https://github.com/gohugoio/hugo/issues/5361
|
||||||
{
|
{
|
||||||
[]string{"a", "b"},
|
[]string{"a", "b"},
|
||||||
[]interface{}{tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
|
[]any{tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
|
||||||
[]interface{}{"a", "b", &tstSlicer{"a"}, &tstSlicer{"b"}},
|
[]any{"a", "b", &tstSlicer{"a"}, &tstSlicer{"b"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"a", "b"},
|
[]string{"a", "b"},
|
||||||
[]interface{}{&tstSlicer{"a"}},
|
[]any{&tstSlicer{"a"}},
|
||||||
[]interface{}{"a", "b", &tstSlicer{"a"}},
|
[]any{"a", "b", &tstSlicer{"a"}},
|
||||||
},
|
},
|
||||||
// Errors
|
// Errors
|
||||||
{"", []interface{}{[]string{"a", "b"}}, false},
|
{"", []any{[]string{"a", "b"}}, false},
|
||||||
// No string concatenation.
|
// No string concatenation.
|
||||||
{
|
{
|
||||||
"ab",
|
"ab",
|
||||||
[]interface{}{"c"},
|
[]any{"c"},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -17,5 +17,5 @@ package collections
|
||||||
|
|
||||||
// Grouper defines a very generic way to group items by a given key.
|
// Grouper defines a very generic way to group items by a given key.
|
||||||
type Grouper interface {
|
type Grouper interface {
|
||||||
Group(key interface{}, items interface{}) (interface{}, error)
|
Group(key any, items any) (any, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,11 @@ import (
|
||||||
// in collections.Slice template func to get types such as Pages, PageGroups etc.
|
// in collections.Slice template func to get types such as Pages, PageGroups etc.
|
||||||
// instead of the less useful []interface{}.
|
// instead of the less useful []interface{}.
|
||||||
type Slicer interface {
|
type Slicer interface {
|
||||||
Slice(items interface{}) (interface{}, error)
|
Slice(items any) (any, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slice returns a slice of all passed arguments.
|
// Slice returns a slice of all passed arguments.
|
||||||
func Slice(args ...interface{}) interface{} {
|
func Slice(args ...any) any {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,8 @@ func Slice(args ...interface{}) interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
// StringSliceToInterfaceSlice converts ss to []interface{}.
|
// StringSliceToInterfaceSlice converts ss to []interface{}.
|
||||||
func StringSliceToInterfaceSlice(ss []string) []interface{} {
|
func StringSliceToInterfaceSlice(ss []string) []any {
|
||||||
result := make([]interface{}, len(ss))
|
result := make([]any, len(ss))
|
||||||
for i, s := range ss {
|
for i, s := range ss {
|
||||||
result[i] = s
|
result[i] = s
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ type tstSlicer struct {
|
||||||
TheName string
|
TheName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *tstSlicerIn1) Slice(in interface{}) (interface{}, error) {
|
func (p *tstSlicerIn1) Slice(in any) (any, error) {
|
||||||
items := in.([]interface{})
|
items := in.([]any)
|
||||||
result := make(testSlicerInterfaces, len(items))
|
result := make(testSlicerInterfaces, len(items))
|
||||||
for i, v := range items {
|
for i, v := range items {
|
||||||
switch vv := v.(type) {
|
switch vv := v.(type) {
|
||||||
|
@ -60,8 +60,8 @@ func (p *tstSlicerIn1) Slice(in interface{}) (interface{}, error) {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *tstSlicerIn2) Slice(in interface{}) (interface{}, error) {
|
func (p *tstSlicerIn2) Slice(in any) (any, error) {
|
||||||
items := in.([]interface{})
|
items := in.([]any)
|
||||||
result := make(testSlicerInterfaces, len(items))
|
result := make(testSlicerInterfaces, len(items))
|
||||||
for i, v := range items {
|
for i, v := range items {
|
||||||
switch vv := v.(type) {
|
switch vv := v.(type) {
|
||||||
|
@ -82,8 +82,8 @@ func (p *tstSlicerIn2) Name() string {
|
||||||
return p.TheName
|
return p.TheName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *tstSlicer) Slice(in interface{}) (interface{}, error) {
|
func (p *tstSlicer) Slice(in any) (any, error) {
|
||||||
items := in.([]interface{})
|
items := in.([]any)
|
||||||
result := make(tstSlicers, len(items))
|
result := make(tstSlicers, len(items))
|
||||||
for i, v := range items {
|
for i, v := range items {
|
||||||
switch vv := v.(type) {
|
switch vv := v.(type) {
|
||||||
|
@ -103,17 +103,17 @@ func TestSlice(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
args []interface{}
|
args []any
|
||||||
expected interface{}
|
expected any
|
||||||
}{
|
}{
|
||||||
{[]interface{}{"a", "b"}, []string{"a", "b"}},
|
{[]any{"a", "b"}, []string{"a", "b"}},
|
||||||
{[]interface{}{&tstSlicer{"a"}, &tstSlicer{"b"}}, tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
|
{[]any{&tstSlicer{"a"}, &tstSlicer{"b"}}, tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
|
||||||
{[]interface{}{&tstSlicer{"a"}, "b"}, []interface{}{&tstSlicer{"a"}, "b"}},
|
{[]any{&tstSlicer{"a"}, "b"}, []any{&tstSlicer{"a"}, "b"}},
|
||||||
{[]interface{}{}, []interface{}{}},
|
{[]any{}, []any{}},
|
||||||
{[]interface{}{nil}, []interface{}{nil}},
|
{[]any{nil}, []any{nil}},
|
||||||
{[]interface{}{5, "b"}, []interface{}{5, "b"}},
|
{[]any{5, "b"}, []any{5, "b"}},
|
||||||
{[]interface{}{&tstSlicerIn1{"a"}, &tstSlicerIn2{"b"}}, testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn2{"b"}}},
|
{[]any{&tstSlicerIn1{"a"}, &tstSlicerIn2{"b"}}, testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn2{"b"}}},
|
||||||
{[]interface{}{&tstSlicerIn1{"a"}, &tstSlicer{"b"}}, []interface{}{&tstSlicerIn1{"a"}, &tstSlicer{"b"}}},
|
{[]any{&tstSlicerIn1{"a"}, &tstSlicer{"b"}}, []any{&tstSlicerIn1{"a"}, &tstSlicer{"b"}}},
|
||||||
} {
|
} {
|
||||||
errMsg := qt.Commentf("[%d] %v", i, test.args)
|
errMsg := qt.Commentf("[%d] %v", i, test.args)
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ type ErrorSender interface {
|
||||||
// Recover is a helper function that can be used to capture panics.
|
// Recover is a helper function that can be used to capture panics.
|
||||||
// Put this at the top of a method/function that crashes in a template:
|
// Put this at the top of a method/function that crashes in a template:
|
||||||
// defer herrors.Recover()
|
// defer herrors.Recover()
|
||||||
func Recover(args ...interface{}) {
|
func Recover(args ...any) {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
fmt.Println("ERR:", r)
|
fmt.Println("ERR:", r)
|
||||||
args = append(args, "stacktrace from panic: \n"+string(debug.Stack()), "\n")
|
args = append(args, "stacktrace from panic: \n"+string(debug.Stack()), "\n")
|
||||||
|
|
|
@ -128,7 +128,7 @@ type Exec struct {
|
||||||
|
|
||||||
// New will fail if name is not allowed according to the configured security policy.
|
// New will fail if name is not allowed according to the configured security policy.
|
||||||
// Else a configured Runner will be returned ready to be Run.
|
// Else a configured Runner will be returned ready to be Run.
|
||||||
func (e *Exec) New(name string, arg ...interface{}) (Runner, error) {
|
func (e *Exec) New(name string, arg ...any) (Runner, error) {
|
||||||
if err := e.sc.CheckAllowedExec(name); err != nil {
|
if err := e.sc.CheckAllowedExec(name); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -146,8 +146,8 @@ func (e *Exec) New(name string, arg ...interface{}) (Runner, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Npx is a convenience method to create a Runner running npx --no-install <name> <args.
|
// Npx is a convenience method to create a Runner running npx --no-install <name> <args.
|
||||||
func (e *Exec) Npx(name string, arg ...interface{}) (Runner, error) {
|
func (e *Exec) Npx(name string, arg ...any) (Runner, error) {
|
||||||
arg = append(arg[:0], append([]interface{}{"--no-install", name}, arg[0:]...)...)
|
arg = append(arg[:0], append([]any{"--no-install", name}, arg[0:]...)...)
|
||||||
return e.New("npx", arg...)
|
return e.New("npx", arg...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ type commandeer struct {
|
||||||
env []string
|
env []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandeer) command(arg ...interface{}) (*cmdWrapper, error) {
|
func (c *commandeer) command(arg ...any) (*cmdWrapper, error) {
|
||||||
if c == nil {
|
if c == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ func IsFloat(kind reflect.Kind) bool {
|
||||||
|
|
||||||
// IsTruthful returns whether in represents a truthful value.
|
// IsTruthful returns whether in represents a truthful value.
|
||||||
// See IsTruthfulValue
|
// See IsTruthfulValue
|
||||||
func IsTruthful(in interface{}) bool {
|
func IsTruthful(in any) bool {
|
||||||
switch v := in.(type) {
|
switch v := in.(type) {
|
||||||
case reflect.Value:
|
case reflect.Value:
|
||||||
return IsTruthfulValue(v)
|
return IsTruthfulValue(v)
|
||||||
|
|
|
@ -134,7 +134,7 @@ func (f TimeFormatter) Format(t time.Time, layout string) string {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToTimeInDefaultLocationE(i interface{}, location *time.Location) (tim time.Time, err error) {
|
func ToTimeInDefaultLocationE(i any, location *time.Location) (tim time.Time, err error) {
|
||||||
switch vv := i.(type) {
|
switch vv := i.(type) {
|
||||||
case toml.LocalDate:
|
case toml.LocalDate:
|
||||||
return vv.AsTime(location), nil
|
return vv.AsTime(location), nil
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build extended
|
||||||
// +build extended
|
// +build extended
|
||||||
|
|
||||||
package hugo
|
package hugo
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !extended
|
||||||
// +build !extended
|
// +build !extended
|
||||||
|
|
||||||
package hugo
|
package hugo
|
||||||
|
|
|
@ -58,13 +58,13 @@ func (h VersionString) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare implements the compare.Comparer interface.
|
// Compare implements the compare.Comparer interface.
|
||||||
func (h VersionString) Compare(other interface{}) int {
|
func (h VersionString) Compare(other any) int {
|
||||||
v := MustParseVersion(h.String())
|
v := MustParseVersion(h.String())
|
||||||
return compareVersionsWithSuffix(v.Number, v.PatchLevel, v.Suffix, other)
|
return compareVersionsWithSuffix(v.Number, v.PatchLevel, v.Suffix, other)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eq implements the compare.Eqer interface.
|
// Eq implements the compare.Eqer interface.
|
||||||
func (h VersionString) Eq(other interface{}) bool {
|
func (h VersionString) Eq(other any) bool {
|
||||||
s, err := cast.ToStringE(other)
|
s, err := cast.ToStringE(other)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
|
@ -171,15 +171,15 @@ func version(version float32, patchVersion int, suffix string) string {
|
||||||
// running Hugo version.
|
// running Hugo version.
|
||||||
// It returns -1 if the given version is less than, 0 if equal and 1 if greater than
|
// It returns -1 if the given version is less than, 0 if equal and 1 if greater than
|
||||||
// the running version.
|
// the running version.
|
||||||
func CompareVersion(version interface{}) int {
|
func CompareVersion(version any) int {
|
||||||
return compareVersionsWithSuffix(CurrentVersion.Number, CurrentVersion.PatchLevel, CurrentVersion.Suffix, version)
|
return compareVersionsWithSuffix(CurrentVersion.Number, CurrentVersion.PatchLevel, CurrentVersion.Suffix, version)
|
||||||
}
|
}
|
||||||
|
|
||||||
func compareVersions(inVersion float32, inPatchVersion int, in interface{}) int {
|
func compareVersions(inVersion float32, inPatchVersion int, in any) int {
|
||||||
return compareVersionsWithSuffix(inVersion, inPatchVersion, "", in)
|
return compareVersionsWithSuffix(inVersion, inPatchVersion, "", in)
|
||||||
}
|
}
|
||||||
|
|
||||||
func compareVersionsWithSuffix(inVersion float32, inPatchVersion int, suffix string, in interface{}) int {
|
func compareVersionsWithSuffix(inVersion float32, inPatchVersion int, suffix string, in any) int {
|
||||||
var c int
|
var c int
|
||||||
switch d := in.(type) {
|
switch d := in.(type) {
|
||||||
case float64:
|
case float64:
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
// IgnorableLogger is a logger that ignores certain log statements.
|
// IgnorableLogger is a logger that ignores certain log statements.
|
||||||
type IgnorableLogger interface {
|
type IgnorableLogger interface {
|
||||||
Logger
|
Logger
|
||||||
Errorsf(statementID, format string, v ...interface{})
|
Errorsf(statementID, format string, v ...any)
|
||||||
Apply(logger Logger) IgnorableLogger
|
Apply(logger Logger) IgnorableLogger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ func NewIgnorableLogger(logger Logger, statements ...string) IgnorableLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Errorsf logs statementID as an ERROR if not configured as ignoreable.
|
// Errorsf logs statementID as an ERROR if not configured as ignoreable.
|
||||||
func (l ignorableLogger) Errorsf(statementID, format string, v ...interface{}) {
|
func (l ignorableLogger) Errorsf(statementID, format string, v ...any) {
|
||||||
if l.statements[statementID] {
|
if l.statements[statementID] {
|
||||||
// Ignore.
|
// Ignore.
|
||||||
return
|
return
|
||||||
|
|
|
@ -58,21 +58,21 @@ func (w prefixWriter) Write(p []byte) (n int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Logger interface {
|
type Logger interface {
|
||||||
Printf(format string, v ...interface{})
|
Printf(format string, v ...any)
|
||||||
Println(v ...interface{})
|
Println(v ...any)
|
||||||
PrintTimerIfDelayed(start time.Time, name string)
|
PrintTimerIfDelayed(start time.Time, name string)
|
||||||
Debug() *log.Logger
|
Debug() *log.Logger
|
||||||
Debugf(format string, v ...interface{})
|
Debugf(format string, v ...any)
|
||||||
Debugln(v ...interface{})
|
Debugln(v ...any)
|
||||||
Info() *log.Logger
|
Info() *log.Logger
|
||||||
Infof(format string, v ...interface{})
|
Infof(format string, v ...any)
|
||||||
Infoln(v ...interface{})
|
Infoln(v ...any)
|
||||||
Warn() *log.Logger
|
Warn() *log.Logger
|
||||||
Warnf(format string, v ...interface{})
|
Warnf(format string, v ...any)
|
||||||
Warnln(v ...interface{})
|
Warnln(v ...any)
|
||||||
Error() *log.Logger
|
Error() *log.Logger
|
||||||
Errorf(format string, v ...interface{})
|
Errorf(format string, v ...any)
|
||||||
Errorln(v ...interface{})
|
Errorln(v ...any)
|
||||||
Errors() string
|
Errors() string
|
||||||
|
|
||||||
Out() io.Writer
|
Out() io.Writer
|
||||||
|
@ -101,11 +101,11 @@ type logger struct {
|
||||||
errors *bytes.Buffer
|
errors *bytes.Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Printf(format string, v ...interface{}) {
|
func (l *logger) Printf(format string, v ...any) {
|
||||||
l.FEEDBACK.Printf(format, v...)
|
l.FEEDBACK.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Println(v ...interface{}) {
|
func (l *logger) Println(v ...any) {
|
||||||
l.FEEDBACK.Println(v...)
|
l.FEEDBACK.Println(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,19 +113,19 @@ func (l *logger) Debug() *log.Logger {
|
||||||
return l.DEBUG
|
return l.DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Debugf(format string, v ...interface{}) {
|
func (l *logger) Debugf(format string, v ...any) {
|
||||||
l.DEBUG.Printf(format, v...)
|
l.DEBUG.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Debugln(v ...interface{}) {
|
func (l *logger) Debugln(v ...any) {
|
||||||
l.DEBUG.Println(v...)
|
l.DEBUG.Println(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Infof(format string, v ...interface{}) {
|
func (l *logger) Infof(format string, v ...any) {
|
||||||
l.INFO.Printf(format, v...)
|
l.INFO.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Infoln(v ...interface{}) {
|
func (l *logger) Infoln(v ...any) {
|
||||||
l.INFO.Println(v...)
|
l.INFO.Println(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,14 +135,14 @@ func (l *logger) Info() *log.Logger {
|
||||||
|
|
||||||
const panicOnWarningMessage = "Warning trapped. Remove the --panicOnWarning flag to continue."
|
const panicOnWarningMessage = "Warning trapped. Remove the --panicOnWarning flag to continue."
|
||||||
|
|
||||||
func (l *logger) Warnf(format string, v ...interface{}) {
|
func (l *logger) Warnf(format string, v ...any) {
|
||||||
l.WARN.Printf(format, v...)
|
l.WARN.Printf(format, v...)
|
||||||
if PanicOnWarning {
|
if PanicOnWarning {
|
||||||
panic(panicOnWarningMessage)
|
panic(panicOnWarningMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Warnln(v ...interface{}) {
|
func (l *logger) Warnln(v ...any) {
|
||||||
l.WARN.Println(v...)
|
l.WARN.Println(v...)
|
||||||
if PanicOnWarning {
|
if PanicOnWarning {
|
||||||
panic(panicOnWarningMessage)
|
panic(panicOnWarningMessage)
|
||||||
|
@ -153,11 +153,11 @@ func (l *logger) Warn() *log.Logger {
|
||||||
return l.WARN
|
return l.WARN
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Errorf(format string, v ...interface{}) {
|
func (l *logger) Errorf(format string, v ...any) {
|
||||||
l.ERROR.Printf(format, v...)
|
l.ERROR.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Errorln(v ...interface{}) {
|
func (l *logger) Errorln(v ...any) {
|
||||||
l.ERROR.Println(v...)
|
l.ERROR.Println(v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ToStringMapE converts in to map[string]interface{}.
|
// ToStringMapE converts in to map[string]interface{}.
|
||||||
func ToStringMapE(in interface{}) (map[string]interface{}, error) {
|
func ToStringMapE(in any) (map[string]any, error) {
|
||||||
switch vv := in.(type) {
|
switch vv := in.(type) {
|
||||||
case Params:
|
case Params:
|
||||||
return vv, nil
|
return vv, nil
|
||||||
case map[string]string:
|
case map[string]string:
|
||||||
var m = map[string]interface{}{}
|
var m = map[string]any{}
|
||||||
for k, v := range vv {
|
for k, v := range vv {
|
||||||
m[k] = v
|
m[k] = v
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func ToStringMapE(in interface{}) (map[string]interface{}, error) {
|
||||||
// ToParamsAndPrepare converts in to Params and prepares it for use.
|
// ToParamsAndPrepare converts in to Params and prepares it for use.
|
||||||
// If in is nil, an empty map is returned.
|
// If in is nil, an empty map is returned.
|
||||||
// See PrepareParams.
|
// See PrepareParams.
|
||||||
func ToParamsAndPrepare(in interface{}) (Params, bool) {
|
func ToParamsAndPrepare(in any) (Params, bool) {
|
||||||
if types.IsNil(in) {
|
if types.IsNil(in) {
|
||||||
return Params{}, true
|
return Params{}, true
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ func ToParamsAndPrepare(in interface{}) (Params, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustToParamsAndPrepare calls ToParamsAndPrepare and panics if it fails.
|
// MustToParamsAndPrepare calls ToParamsAndPrepare and panics if it fails.
|
||||||
func MustToParamsAndPrepare(in interface{}) Params {
|
func MustToParamsAndPrepare(in any) Params {
|
||||||
if p, ok := ToParamsAndPrepare(in); ok {
|
if p, ok := ToParamsAndPrepare(in); ok {
|
||||||
return p
|
return p
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,13 +65,13 @@ func MustToParamsAndPrepare(in interface{}) Params {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringMap converts in to map[string]interface{}.
|
// ToStringMap converts in to map[string]interface{}.
|
||||||
func ToStringMap(in interface{}) map[string]interface{} {
|
func ToStringMap(in any) map[string]any {
|
||||||
m, _ := ToStringMapE(in)
|
m, _ := ToStringMapE(in)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringMapStringE converts in to map[string]string.
|
// ToStringMapStringE converts in to map[string]string.
|
||||||
func ToStringMapStringE(in interface{}) (map[string]string, error) {
|
func ToStringMapStringE(in any) (map[string]string, error) {
|
||||||
m, err := ToStringMapE(in)
|
m, err := ToStringMapE(in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -80,26 +80,26 @@ func ToStringMapStringE(in interface{}) (map[string]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringMapString converts in to map[string]string.
|
// ToStringMapString converts in to map[string]string.
|
||||||
func ToStringMapString(in interface{}) map[string]string {
|
func ToStringMapString(in any) map[string]string {
|
||||||
m, _ := ToStringMapStringE(in)
|
m, _ := ToStringMapStringE(in)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringMapBool converts in to bool.
|
// ToStringMapBool converts in to bool.
|
||||||
func ToStringMapBool(in interface{}) map[string]bool {
|
func ToStringMapBool(in any) map[string]bool {
|
||||||
m, _ := ToStringMapE(in)
|
m, _ := ToStringMapE(in)
|
||||||
return cast.ToStringMapBool(m)
|
return cast.ToStringMapBool(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToSliceStringMap converts in to []map[string]interface{}.
|
// ToSliceStringMap converts in to []map[string]interface{}.
|
||||||
func ToSliceStringMap(in interface{}) ([]map[string]interface{}, error) {
|
func ToSliceStringMap(in any) ([]map[string]any, error) {
|
||||||
switch v := in.(type) {
|
switch v := in.(type) {
|
||||||
case []map[string]interface{}:
|
case []map[string]any:
|
||||||
return v, nil
|
return v, nil
|
||||||
case []interface{}:
|
case []any:
|
||||||
var s []map[string]interface{}
|
var s []map[string]any
|
||||||
for _, entry := range v {
|
for _, entry := range v {
|
||||||
if vv, ok := entry.(map[string]interface{}); ok {
|
if vv, ok := entry.(map[string]any); ok {
|
||||||
s = append(s, vv)
|
s = append(s, vv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ func (r KeyRenamer) getNewKey(keyPath string) string {
|
||||||
|
|
||||||
// Rename renames the keys in the given map according
|
// Rename renames the keys in the given map according
|
||||||
// to the patterns in the current KeyRenamer.
|
// to the patterns in the current KeyRenamer.
|
||||||
func (r KeyRenamer) Rename(m map[string]interface{}) {
|
func (r KeyRenamer) Rename(m map[string]any) {
|
||||||
r.renamePath("", m)
|
r.renamePath("", m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,15 +158,15 @@ func (KeyRenamer) keyPath(k1, k2 string) string {
|
||||||
return k1 + "/" + k2
|
return k1 + "/" + k2
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r KeyRenamer) renamePath(parentKeyPath string, m map[string]interface{}) {
|
func (r KeyRenamer) renamePath(parentKeyPath string, m map[string]any) {
|
||||||
for key, val := range m {
|
for key, val := range m {
|
||||||
keyPath := r.keyPath(parentKeyPath, key)
|
keyPath := r.keyPath(parentKeyPath, key)
|
||||||
switch val.(type) {
|
switch val.(type) {
|
||||||
case map[interface{}]interface{}:
|
case map[any]any:
|
||||||
val = cast.ToStringMap(val)
|
val = cast.ToStringMap(val)
|
||||||
r.renamePath(keyPath, val.(map[string]interface{}))
|
r.renamePath(keyPath, val.(map[string]any))
|
||||||
case map[string]interface{}:
|
case map[string]any:
|
||||||
r.renamePath(keyPath, val.(map[string]interface{}))
|
r.renamePath(keyPath, val.(map[string]any))
|
||||||
}
|
}
|
||||||
|
|
||||||
newKey := r.getNewKey(keyPath)
|
newKey := r.getNewKey(keyPath)
|
||||||
|
|
|
@ -27,7 +27,7 @@ func TestPrepareParams(t *testing.T) {
|
||||||
expected Params
|
expected Params
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"abC": 32,
|
"abC": 32,
|
||||||
},
|
},
|
||||||
Params{
|
Params{
|
||||||
|
@ -35,16 +35,16 @@ func TestPrepareParams(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"abC": 32,
|
"abC": 32,
|
||||||
"deF": map[interface{}]interface{}{
|
"deF": map[any]any{
|
||||||
23: "A value",
|
23: "A value",
|
||||||
24: map[string]interface{}{
|
24: map[string]any{
|
||||||
"AbCDe": "A value",
|
"AbCDe": "A value",
|
||||||
"eFgHi": "Another value",
|
"eFgHi": "Another value",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"gHi": map[string]interface{}{
|
"gHi": map[string]any{
|
||||||
"J": 25,
|
"J": 25,
|
||||||
},
|
},
|
||||||
"jKl": map[string]string{
|
"jKl": map[string]string{
|
||||||
|
@ -85,23 +85,23 @@ func TestToSliceStringMap(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input interface{}
|
input any
|
||||||
expected []map[string]interface{}
|
expected []map[string]any
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
input: []map[string]interface{}{
|
input: []map[string]any{
|
||||||
{"abc": 123},
|
{"abc": 123},
|
||||||
},
|
},
|
||||||
expected: []map[string]interface{}{
|
expected: []map[string]any{
|
||||||
{"abc": 123},
|
{"abc": 123},
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
input: []interface{}{
|
input: []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"def": 456,
|
"def": 456,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: []map[string]interface{}{
|
expected: []map[string]any{
|
||||||
{"def": 456},
|
{"def": 456},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -116,7 +116,7 @@ func TestToSliceStringMap(t *testing.T) {
|
||||||
|
|
||||||
func TestToParamsAndPrepare(t *testing.T) {
|
func TestToParamsAndPrepare(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
_, ok := ToParamsAndPrepare(map[string]interface{}{"A": "av"})
|
_, ok := ToParamsAndPrepare(map[string]any{"A": "av"})
|
||||||
c.Assert(ok, qt.IsTrue)
|
c.Assert(ok, qt.IsTrue)
|
||||||
|
|
||||||
params, ok := ToParamsAndPrepare(nil)
|
params, ok := ToParamsAndPrepare(nil)
|
||||||
|
@ -127,33 +127,33 @@ func TestToParamsAndPrepare(t *testing.T) {
|
||||||
func TestRenameKeys(t *testing.T) {
|
func TestRenameKeys(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
m := map[string]interface{}{
|
m := map[string]any{
|
||||||
"a": 32,
|
"a": 32,
|
||||||
"ren1": "m1",
|
"ren1": "m1",
|
||||||
"ren2": "m1_2",
|
"ren2": "m1_2",
|
||||||
"sub": map[string]interface{}{
|
"sub": map[string]any{
|
||||||
"subsub": map[string]interface{}{
|
"subsub": map[string]any{
|
||||||
"REN1": "m2",
|
"REN1": "m2",
|
||||||
"ren2": "m2_2",
|
"ren2": "m2_2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"no": map[string]interface{}{
|
"no": map[string]any{
|
||||||
"ren1": "m2",
|
"ren1": "m2",
|
||||||
"ren2": "m2_2",
|
"ren2": "m2_2",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := map[string]interface{}{
|
expected := map[string]any{
|
||||||
"a": 32,
|
"a": 32,
|
||||||
"new1": "m1",
|
"new1": "m1",
|
||||||
"new2": "m1_2",
|
"new2": "m1_2",
|
||||||
"sub": map[string]interface{}{
|
"sub": map[string]any{
|
||||||
"subsub": map[string]interface{}{
|
"subsub": map[string]any{
|
||||||
"new1": "m2",
|
"new1": "m2",
|
||||||
"ren2": "m2_2",
|
"ren2": "m2_2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"no": map[string]interface{}{
|
"no": map[string]any{
|
||||||
"ren1": "m2",
|
"ren1": "m2",
|
||||||
"ren2": "m2_2",
|
"ren2": "m2_2",
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,11 +21,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Params is a map where all keys are lower case.
|
// Params is a map where all keys are lower case.
|
||||||
type Params map[string]interface{}
|
type Params map[string]any
|
||||||
|
|
||||||
// Get does a lower case and nested search in this map.
|
// Get does a lower case and nested search in this map.
|
||||||
// It will return nil if none found.
|
// It will return nil if none found.
|
||||||
func (p Params) Get(indices ...string) interface{} {
|
func (p Params) Get(indices ...string) any {
|
||||||
v, _, _ := getNested(p, indices)
|
v, _, _ := getNested(p, indices)
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ func (p Params) SetDefaultMergeStrategy(s ParamsMergeStrategy) {
|
||||||
p[mergeStrategyKey] = s
|
p[mergeStrategyKey] = s
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNested(m map[string]interface{}, indices []string) (interface{}, string, map[string]interface{}) {
|
func getNested(m map[string]any, indices []string) (any, string, map[string]any) {
|
||||||
if len(indices) == 0 {
|
if len(indices) == 0 {
|
||||||
return nil, "", nil
|
return nil, "", nil
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ func getNested(m map[string]interface{}, indices []string) (interface{}, string,
|
||||||
switch m2 := v.(type) {
|
switch m2 := v.(type) {
|
||||||
case Params:
|
case Params:
|
||||||
return getNested(m2, indices[1:])
|
return getNested(m2, indices[1:])
|
||||||
case map[string]interface{}:
|
case map[string]any:
|
||||||
return getNested(m2, indices[1:])
|
return getNested(m2, indices[1:])
|
||||||
default:
|
default:
|
||||||
return nil, "", nil
|
return nil, "", nil
|
||||||
|
@ -175,7 +175,7 @@ func getNested(m map[string]interface{}, indices []string) (interface{}, string,
|
||||||
// It will first try the exact match and then try to find it as a nested map value,
|
// It will first try the exact match and then try to find it as a nested map value,
|
||||||
// using the given separator, e.g. "mymap.name".
|
// using the given separator, e.g. "mymap.name".
|
||||||
// It assumes that all the maps given have lower cased keys.
|
// It assumes that all the maps given have lower cased keys.
|
||||||
func GetNestedParam(keyStr, separator string, candidates ...Params) (interface{}, error) {
|
func GetNestedParam(keyStr, separator string, candidates ...Params) (any, error) {
|
||||||
keyStr = strings.ToLower(keyStr)
|
keyStr = strings.ToLower(keyStr)
|
||||||
|
|
||||||
// Try exact match first
|
// Try exact match first
|
||||||
|
@ -195,7 +195,7 @@ func GetNestedParam(keyStr, separator string, candidates ...Params) (interface{}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetNestedParamFn(keyStr, separator string, lookupFn func(key string) interface{}) (interface{}, string, map[string]interface{}, error) {
|
func GetNestedParamFn(keyStr, separator string, lookupFn func(key string) any) (any, string, map[string]any, error) {
|
||||||
keySegments := strings.Split(keyStr, separator)
|
keySegments := strings.Split(keyStr, separator)
|
||||||
if len(keySegments) == 0 {
|
if len(keySegments) == 0 {
|
||||||
return nil, "", nil, nil
|
return nil, "", nil, nil
|
||||||
|
@ -211,7 +211,7 @@ func GetNestedParamFn(keyStr, separator string, lookupFn func(key string) interf
|
||||||
}
|
}
|
||||||
|
|
||||||
switch m := first.(type) {
|
switch m := first.(type) {
|
||||||
case map[string]interface{}:
|
case map[string]any:
|
||||||
v, key, owner := getNested(m, keySegments[1:])
|
v, key, owner := getNested(m, keySegments[1:])
|
||||||
return v, key, owner, nil
|
return v, key, owner, nil
|
||||||
case Params:
|
case Params:
|
||||||
|
@ -236,7 +236,7 @@ const (
|
||||||
mergeStrategyKey = "_merge"
|
mergeStrategyKey = "_merge"
|
||||||
)
|
)
|
||||||
|
|
||||||
func toMergeStrategy(v interface{}) ParamsMergeStrategy {
|
func toMergeStrategy(v any) ParamsMergeStrategy {
|
||||||
s := ParamsMergeStrategy(cast.ToString(v))
|
s := ParamsMergeStrategy(cast.ToString(v))
|
||||||
switch s {
|
switch s {
|
||||||
case ParamsMergeStrategyDeep, ParamsMergeStrategyNone, ParamsMergeStrategyShallow:
|
case ParamsMergeStrategyDeep, ParamsMergeStrategyNone, ParamsMergeStrategyShallow:
|
||||||
|
@ -260,13 +260,13 @@ func PrepareParams(m Params) {
|
||||||
retyped = true
|
retyped = true
|
||||||
} else {
|
} else {
|
||||||
switch vv := v.(type) {
|
switch vv := v.(type) {
|
||||||
case map[interface{}]interface{}:
|
case map[any]any:
|
||||||
var p Params = cast.ToStringMap(v)
|
var p Params = cast.ToStringMap(v)
|
||||||
v = p
|
v = p
|
||||||
PrepareParams(p)
|
PrepareParams(p)
|
||||||
retyped = true
|
retyped = true
|
||||||
case map[string]interface{}:
|
case map[string]any:
|
||||||
var p Params = v.(map[string]interface{})
|
var p Params = v.(map[string]any)
|
||||||
v = p
|
v = p
|
||||||
PrepareParams(p)
|
PrepareParams(p)
|
||||||
retyped = true
|
retyped = true
|
||||||
|
|
|
@ -20,13 +20,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetNestedParam(t *testing.T) {
|
func TestGetNestedParam(t *testing.T) {
|
||||||
m := map[string]interface{}{
|
m := map[string]any{
|
||||||
"string": "value",
|
"string": "value",
|
||||||
"first": 1,
|
"first": 1,
|
||||||
"with_underscore": 2,
|
"with_underscore": 2,
|
||||||
"nested": map[string]interface{}{
|
"nested": map[string]any{
|
||||||
"color": "blue",
|
"color": "blue",
|
||||||
"nestednested": map[string]interface{}{
|
"nestednested": map[string]any{
|
||||||
"color": "green",
|
"color": "green",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -34,7 +34,7 @@ func TestGetNestedParam(t *testing.T) {
|
||||||
|
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
must := func(keyStr, separator string, candidates ...Params) interface{} {
|
must := func(keyStr, separator string, candidates ...Params) any {
|
||||||
v, err := GetNestedParam(keyStr, separator, candidates...)
|
v, err := GetNestedParam(keyStr, separator, candidates...)
|
||||||
c.Assert(err, qt.IsNil)
|
c.Assert(err, qt.IsNil)
|
||||||
return v
|
return v
|
||||||
|
@ -53,14 +53,14 @@ func TestGetNestedParam(t *testing.T) {
|
||||||
func TestGetNestedParamFnNestedNewKey(t *testing.T) {
|
func TestGetNestedParamFnNestedNewKey(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
nested := map[string]interface{}{
|
nested := map[string]any{
|
||||||
"color": "blue",
|
"color": "blue",
|
||||||
}
|
}
|
||||||
m := map[string]interface{}{
|
m := map[string]any{
|
||||||
"nested": nested,
|
"nested": nested,
|
||||||
}
|
}
|
||||||
|
|
||||||
existing, nestedKey, owner, err := GetNestedParamFn("nested.new", ".", func(key string) interface{} {
|
existing, nestedKey, owner, err := GetNestedParamFn("nested.new", ".", func(key string) any {
|
||||||
return m[key]
|
return m[key]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
|
|
||||||
// Scratch is a writable context used for stateful operations in Page/Node rendering.
|
// Scratch is a writable context used for stateful operations in Page/Node rendering.
|
||||||
type Scratch struct {
|
type Scratch struct {
|
||||||
values map[string]interface{}
|
values map[string]any
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ func NewScratcher() Scratcher {
|
||||||
// Supports numeric values and strings.
|
// Supports numeric values and strings.
|
||||||
//
|
//
|
||||||
// If the first add for a key is an array or slice, then the next value(s) will be appended.
|
// If the first add for a key is an array or slice, then the next value(s) will be appended.
|
||||||
func (c *Scratch) Add(key string, newAddend interface{}) (string, error) {
|
func (c *Scratch) Add(key string, newAddend any) (string, error) {
|
||||||
var newVal interface{}
|
var newVal any
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
existingAddend, found := c.values[key]
|
existingAddend, found := c.values[key]
|
||||||
c.mu.RUnlock()
|
c.mu.RUnlock()
|
||||||
|
@ -82,7 +82,7 @@ func (c *Scratch) Add(key string, newAddend interface{}) (string, error) {
|
||||||
|
|
||||||
// Set stores a value with the given key in the Node context.
|
// Set stores a value with the given key in the Node context.
|
||||||
// This value can later be retrieved with Get.
|
// This value can later be retrieved with Get.
|
||||||
func (c *Scratch) Set(key string, value interface{}) string {
|
func (c *Scratch) Set(key string, value any) string {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
c.values[key] = value
|
c.values[key] = value
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
|
@ -98,7 +98,7 @@ func (c *Scratch) Delete(key string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns a value previously set by Add or Set.
|
// Get returns a value previously set by Add or Set.
|
||||||
func (c *Scratch) Get(key string) interface{} {
|
func (c *Scratch) Get(key string) any {
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
val := c.values[key]
|
val := c.values[key]
|
||||||
c.mu.RUnlock()
|
c.mu.RUnlock()
|
||||||
|
@ -109,7 +109,7 @@ func (c *Scratch) Get(key string) interface{} {
|
||||||
// Values returns the raw backing map. Note that you should just use
|
// Values returns the raw backing map. Note that you should just use
|
||||||
// this method on the locally scoped Scratch instances you obtain via newScratch, not
|
// this method on the locally scoped Scratch instances you obtain via newScratch, not
|
||||||
// .Page.Scratch etc., as that will lead to concurrency issues.
|
// .Page.Scratch etc., as that will lead to concurrency issues.
|
||||||
func (c *Scratch) Values() map[string]interface{} {
|
func (c *Scratch) Values() map[string]any {
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
defer c.mu.RUnlock()
|
defer c.mu.RUnlock()
|
||||||
return c.values
|
return c.values
|
||||||
|
@ -117,14 +117,14 @@ func (c *Scratch) Values() map[string]interface{} {
|
||||||
|
|
||||||
// SetInMap stores a value to a map with the given key in the Node context.
|
// SetInMap stores a value to a map with the given key in the Node context.
|
||||||
// This map can later be retrieved with GetSortedMapValues.
|
// This map can later be retrieved with GetSortedMapValues.
|
||||||
func (c *Scratch) SetInMap(key string, mapKey string, value interface{}) string {
|
func (c *Scratch) SetInMap(key string, mapKey string, value any) string {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
_, found := c.values[key]
|
_, found := c.values[key]
|
||||||
if !found {
|
if !found {
|
||||||
c.values[key] = make(map[string]interface{})
|
c.values[key] = make(map[string]any)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.values[key].(map[string]interface{})[mapKey] = value
|
c.values[key].(map[string]any)[mapKey] = value
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -134,14 +134,14 @@ func (c *Scratch) DeleteInMap(key string, mapKey string) string {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
_, found := c.values[key]
|
_, found := c.values[key]
|
||||||
if found {
|
if found {
|
||||||
delete(c.values[key].(map[string]interface{}), mapKey)
|
delete(c.values[key].(map[string]any), mapKey)
|
||||||
}
|
}
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSortedMapValues returns a sorted map previously filled with SetInMap.
|
// GetSortedMapValues returns a sorted map previously filled with SetInMap.
|
||||||
func (c *Scratch) GetSortedMapValues(key string) interface{} {
|
func (c *Scratch) GetSortedMapValues(key string) any {
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
|
|
||||||
if c.values[key] == nil {
|
if c.values[key] == nil {
|
||||||
|
@ -149,7 +149,7 @@ func (c *Scratch) GetSortedMapValues(key string) interface{} {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
unsortedMap := c.values[key].(map[string]interface{})
|
unsortedMap := c.values[key].(map[string]any)
|
||||||
c.mu.RUnlock()
|
c.mu.RUnlock()
|
||||||
var keys []string
|
var keys []string
|
||||||
for mapKey := range unsortedMap {
|
for mapKey := range unsortedMap {
|
||||||
|
@ -158,7 +158,7 @@ func (c *Scratch) GetSortedMapValues(key string) interface{} {
|
||||||
|
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
|
|
||||||
sortedArray := make([]interface{}, len(unsortedMap))
|
sortedArray := make([]any, len(unsortedMap))
|
||||||
for i, mapKey := range keys {
|
for i, mapKey := range keys {
|
||||||
sortedArray[i] = unsortedMap[mapKey]
|
sortedArray[i] = unsortedMap[mapKey]
|
||||||
}
|
}
|
||||||
|
@ -168,5 +168,5 @@ func (c *Scratch) GetSortedMapValues(key string) interface{} {
|
||||||
|
|
||||||
// NewScratch returns a new instance of Scratch.
|
// NewScratch returns a new instance of Scratch.
|
||||||
func NewScratch() *Scratch {
|
func NewScratch() *Scratch {
|
||||||
return &Scratch{values: make(map[string]interface{})}
|
return &Scratch{values: make(map[string]any)}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ func TestScratchAddTypedSliceToInterfaceSlice(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
scratch := NewScratch()
|
scratch := NewScratch()
|
||||||
scratch.Set("slice", []interface{}{})
|
scratch.Set("slice", []any{})
|
||||||
|
|
||||||
_, err := scratch.Add("slice", []int{1, 2})
|
_, err := scratch.Add("slice", []int{1, 2})
|
||||||
c.Assert(err, qt.IsNil)
|
c.Assert(err, qt.IsNil)
|
||||||
|
@ -107,7 +107,7 @@ func TestScratchAddDifferentTypedSliceToInterfaceSlice(t *testing.T) {
|
||||||
|
|
||||||
_, err := scratch.Add("slice", []int{1, 2})
|
_, err := scratch.Add("slice", []int{1, 2})
|
||||||
c.Assert(err, qt.IsNil)
|
c.Assert(err, qt.IsNil)
|
||||||
c.Assert(scratch.Get("slice"), qt.DeepEquals, []interface{}{"foo", 1, 2})
|
c.Assert(scratch.Get("slice"), qt.DeepEquals, []any{"foo", 1, 2})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestScratchSet(t *testing.T) {
|
func TestScratchSet(t *testing.T) {
|
||||||
|
@ -185,7 +185,7 @@ func TestScratchSetInMap(t *testing.T) {
|
||||||
scratch.SetInMap("key", "zyx", "Zyx")
|
scratch.SetInMap("key", "zyx", "Zyx")
|
||||||
scratch.SetInMap("key", "abc", "Abc (updated)")
|
scratch.SetInMap("key", "abc", "Abc (updated)")
|
||||||
scratch.SetInMap("key", "def", "Def")
|
scratch.SetInMap("key", "def", "Def")
|
||||||
c.Assert(scratch.GetSortedMapValues("key"), qt.DeepEquals, []interface{}{0: "Abc (updated)", 1: "Def", 2: "Lux", 3: "Zyx"})
|
c.Assert(scratch.GetSortedMapValues("key"), qt.DeepEquals, []any{0: "Abc (updated)", 1: "Def", 2: "Lux", 3: "Zyx"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestScratchDeleteInMap(t *testing.T) {
|
func TestScratchDeleteInMap(t *testing.T) {
|
||||||
|
@ -199,7 +199,7 @@ func TestScratchDeleteInMap(t *testing.T) {
|
||||||
scratch.DeleteInMap("key", "abc")
|
scratch.DeleteInMap("key", "abc")
|
||||||
scratch.SetInMap("key", "def", "Def")
|
scratch.SetInMap("key", "def", "Def")
|
||||||
scratch.DeleteInMap("key", "lmn") // Do nothing
|
scratch.DeleteInMap("key", "lmn") // Do nothing
|
||||||
c.Assert(scratch.GetSortedMapValues("key"), qt.DeepEquals, []interface{}{0: "Def", 1: "Lux", 2: "Zyx"})
|
c.Assert(scratch.GetSortedMapValues("key"), qt.DeepEquals, []any{0: "Def", 1: "Lux", 2: "Zyx"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestScratchGetSortedMapValues(t *testing.T) {
|
func TestScratchGetSortedMapValues(t *testing.T) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
|
|
||||||
// DoArithmetic performs arithmetic operations (+,-,*,/) using reflection to
|
// DoArithmetic performs arithmetic operations (+,-,*,/) using reflection to
|
||||||
// determine the type of the two terms.
|
// determine the type of the two terms.
|
||||||
func DoArithmetic(a, b interface{}, op rune) (interface{}, error) {
|
func DoArithmetic(a, b any, op rune) (any, error) {
|
||||||
av := reflect.ValueOf(a)
|
av := reflect.ValueOf(a)
|
||||||
bv := reflect.ValueOf(b)
|
bv := reflect.ValueOf(b)
|
||||||
var ai, bi int64
|
var ai, bi int64
|
||||||
|
|
|
@ -24,10 +24,10 @@ func TestDoArithmetic(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
a interface{}
|
a any
|
||||||
b interface{}
|
b any
|
||||||
op rune
|
op rune
|
||||||
expect interface{}
|
expect any
|
||||||
}{
|
}{
|
||||||
{3, 2, '+', int64(5)},
|
{3, 2, '+', int64(5)},
|
||||||
{3, 2, '-', int64(1)},
|
{3, 2, '-', int64(1)},
|
||||||
|
|
|
@ -24,7 +24,7 @@ func TestGetRelativePath(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
path string
|
path string
|
||||||
base string
|
base string
|
||||||
expect interface{}
|
expect any
|
||||||
}{
|
}{
|
||||||
{filepath.FromSlash("/a/b"), filepath.FromSlash("/a"), filepath.FromSlash("b")},
|
{filepath.FromSlash("/a/b"), filepath.FromSlash("/a"), filepath.FromSlash("b")},
|
||||||
{filepath.FromSlash("/a/b/c/"), filepath.FromSlash("/a"), filepath.FromSlash("b/c/")},
|
{filepath.FromSlash("/a/b/c/"), filepath.FromSlash("/a"), filepath.FromSlash("b/c/")},
|
||||||
|
|
|
@ -69,7 +69,7 @@ func createPositionStringFormatter(formatStr string) func(p Position) string {
|
||||||
format := replacer.Replace(formatStr)
|
format := replacer.Replace(formatStr)
|
||||||
|
|
||||||
f := func(pos Position) string {
|
f := func(pos Position) string {
|
||||||
args := make([]interface{}, len(identifiersFound))
|
args := make([]any, len(identifiersFound))
|
||||||
for i, id := range identifiersFound {
|
for i, id := range identifiersFound {
|
||||||
switch id {
|
switch id {
|
||||||
case ":file":
|
case ":file":
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var accentTransformerPool = &sync.Pool{
|
var accentTransformerPool = &sync.Pool{
|
||||||
New: func() interface{} {
|
New: func() any {
|
||||||
return transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
|
return transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,13 @@ import (
|
||||||
|
|
||||||
// ToDuration converts v to time.Duration.
|
// ToDuration converts v to time.Duration.
|
||||||
// See ToDurationE if you need to handle errors.
|
// See ToDurationE if you need to handle errors.
|
||||||
func ToDuration(v interface{}) time.Duration {
|
func ToDuration(v any) time.Duration {
|
||||||
d, _ := ToDurationE(v)
|
d, _ := ToDurationE(v)
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDurationE converts v to time.Duration.
|
// ToDurationE converts v to time.Duration.
|
||||||
func ToDurationE(v interface{}) (time.Duration, error) {
|
func ToDurationE(v any) (time.Duration, error) {
|
||||||
if n := cast.ToInt(v); n > 0 {
|
if n := cast.ToInt(v); n > 0 {
|
||||||
return time.Duration(n) * time.Millisecond, nil
|
return time.Duration(n) * time.Millisecond, nil
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,14 @@ func ToDurationE(v interface{}) (time.Duration, error) {
|
||||||
|
|
||||||
// ToStringSlicePreserveString is the same as ToStringSlicePreserveStringE,
|
// ToStringSlicePreserveString is the same as ToStringSlicePreserveStringE,
|
||||||
// but it never fails.
|
// but it never fails.
|
||||||
func ToStringSlicePreserveString(v interface{}) []string {
|
func ToStringSlicePreserveString(v any) []string {
|
||||||
vv, _ := ToStringSlicePreserveStringE(v)
|
vv, _ := ToStringSlicePreserveStringE(v)
|
||||||
return vv
|
return vv
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringSlicePreserveStringE converts v to a string slice.
|
// ToStringSlicePreserveStringE converts v to a string slice.
|
||||||
// If v is a string, it will be wrapped in a string slice.
|
// If v is a string, it will be wrapped in a string slice.
|
||||||
func ToStringSlicePreserveStringE(v interface{}) ([]string, error) {
|
func ToStringSlicePreserveStringE(v any) ([]string, error) {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ func ToStringSlicePreserveStringE(v interface{}) ([]string, error) {
|
||||||
// TypeToString converts v to a string if it's a valid string type.
|
// TypeToString converts v to a string if it's a valid string type.
|
||||||
// Note that this will not try to convert numeric values etc.,
|
// Note that this will not try to convert numeric values etc.,
|
||||||
// use ToString for that.
|
// use ToString for that.
|
||||||
func TypeToString(v interface{}) (string, bool) {
|
func TypeToString(v any) (string, bool) {
|
||||||
switch s := v.(type) {
|
switch s := v.(type) {
|
||||||
case string:
|
case string:
|
||||||
return s, true
|
return s, true
|
||||||
|
@ -110,13 +110,13 @@ func TypeToString(v interface{}) (string, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToString converts v to a string.
|
// ToString converts v to a string.
|
||||||
func ToString(v interface{}) string {
|
func ToString(v any) string {
|
||||||
s, _ := ToStringE(v)
|
s, _ := ToStringE(v)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToStringE converts v to a string.
|
// ToStringE converts v to a string.
|
||||||
func ToStringE(v interface{}) (string, error) {
|
func ToStringE(v any) (string, error) {
|
||||||
if s, ok := TypeToString(v); ok {
|
if s, ok := TypeToString(v); ok {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ func TestToStringSlicePreserveString(t *testing.T) {
|
||||||
|
|
||||||
c.Assert(ToStringSlicePreserveString("Hugo"), qt.DeepEquals, []string{"Hugo"})
|
c.Assert(ToStringSlicePreserveString("Hugo"), qt.DeepEquals, []string{"Hugo"})
|
||||||
c.Assert(ToStringSlicePreserveString(qt.Commentf("Hugo")), qt.DeepEquals, []string{"Hugo"})
|
c.Assert(ToStringSlicePreserveString(qt.Commentf("Hugo")), qt.DeepEquals, []string{"Hugo"})
|
||||||
c.Assert(ToStringSlicePreserveString([]interface{}{"A", "B"}), qt.DeepEquals, []string{"A", "B"})
|
c.Assert(ToStringSlicePreserveString([]any{"A", "B"}), qt.DeepEquals, []string{"A", "B"})
|
||||||
c.Assert(ToStringSlicePreserveString([]int{1, 3}), qt.DeepEquals, []string{"1", "3"})
|
c.Assert(ToStringSlicePreserveString([]int{1, 3}), qt.DeepEquals, []string{"1", "3"})
|
||||||
c.Assert(ToStringSlicePreserveString(nil), qt.IsNil)
|
c.Assert(ToStringSlicePreserveString(nil), qt.IsNil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ type RLocker interface {
|
||||||
|
|
||||||
// KeyValue is a interface{} tuple.
|
// KeyValue is a interface{} tuple.
|
||||||
type KeyValue struct {
|
type KeyValue struct {
|
||||||
Key interface{}
|
Key any
|
||||||
Value interface{}
|
Value any
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyValueStr is a string tuple.
|
// KeyValueStr is a string tuple.
|
||||||
|
@ -41,8 +41,8 @@ type KeyValueStr struct {
|
||||||
|
|
||||||
// KeyValues holds an key and a slice of values.
|
// KeyValues holds an key and a slice of values.
|
||||||
type KeyValues struct {
|
type KeyValues struct {
|
||||||
Key interface{}
|
Key any
|
||||||
Values []interface{}
|
Values []any
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyString returns the key as a string, an empty string if conversion fails.
|
// KeyString returns the key as a string, an empty string if conversion fails.
|
||||||
|
@ -57,7 +57,7 @@ func (k KeyValues) String() string {
|
||||||
// NewKeyValuesStrings takes a given key and slice of values and returns a new
|
// NewKeyValuesStrings takes a given key and slice of values and returns a new
|
||||||
// KeyValues struct.
|
// KeyValues struct.
|
||||||
func NewKeyValuesStrings(key string, values ...string) KeyValues {
|
func NewKeyValuesStrings(key string, values ...string) KeyValues {
|
||||||
iv := make([]interface{}, len(values))
|
iv := make([]any, len(values))
|
||||||
for i := 0; i < len(values); i++ {
|
for i := 0; i < len(values); i++ {
|
||||||
iv[i] = values[i]
|
iv[i] = values[i]
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ type Zeroer interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNil reports whether v is nil.
|
// IsNil reports whether v is nil.
|
||||||
func IsNil(v interface{}) bool {
|
func IsNil(v any) bool {
|
||||||
if v == nil {
|
if v == nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,5 +25,5 @@ func TestKeyValues(t *testing.T) {
|
||||||
kv := NewKeyValuesStrings("key", "a1", "a2")
|
kv := NewKeyValuesStrings("key", "a1", "a2")
|
||||||
|
|
||||||
c.Assert(kv.KeyString(), qt.Equals, "key")
|
c.Assert(kv.KeyString(), qt.Equals, "key")
|
||||||
c.Assert(kv.Values, qt.DeepEquals, []interface{}{"a1", "a2"})
|
c.Assert(kv.Values, qt.DeepEquals, []any{"a1", "a2"})
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,6 @@ package urls
|
||||||
// args must contain a path, but can also point to the target
|
// args must contain a path, but can also point to the target
|
||||||
// language or output format.
|
// language or output format.
|
||||||
type RefLinker interface {
|
type RefLinker interface {
|
||||||
Ref(args map[string]interface{}) (string, error)
|
Ref(args map[string]any) (string, error)
|
||||||
RelRef(args map[string]interface{}) (string, error)
|
RelRef(args map[string]any) (string, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,13 @@ package compare
|
||||||
// The semantics of equals is that the two value are interchangeable
|
// The semantics of equals is that the two value are interchangeable
|
||||||
// in the Hugo templates.
|
// in the Hugo templates.
|
||||||
type Eqer interface {
|
type Eqer interface {
|
||||||
Eq(other interface{}) bool
|
Eq(other any) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProbablyEqer is an equal check that may return false positives, but never
|
// ProbablyEqer is an equal check that may return false positives, but never
|
||||||
// a false negative.
|
// a false negative.
|
||||||
type ProbablyEqer interface {
|
type ProbablyEqer interface {
|
||||||
ProbablyEq(other interface{}) bool
|
ProbablyEq(other any) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comparer can be used to compare two values.
|
// Comparer can be used to compare two values.
|
||||||
|
@ -31,5 +31,5 @@ type ProbablyEqer interface {
|
||||||
// Compare returns -1 if the given version is less than, 0 if equal and 1 if greater than
|
// Compare returns -1 if the given version is less than, 0 if equal and 1 if greater than
|
||||||
// the running version.
|
// the running version.
|
||||||
type Comparer interface {
|
type Comparer interface {
|
||||||
Compare(other interface{}) int
|
Compare(other any) int
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ type Sitemap struct {
|
||||||
Filename string
|
Filename string
|
||||||
}
|
}
|
||||||
|
|
||||||
func DecodeSitemap(prototype Sitemap, input map[string]interface{}) Sitemap {
|
func DecodeSitemap(prototype Sitemap, input map[string]any) Sitemap {
|
||||||
for key, value := range input {
|
for key, value := range input {
|
||||||
switch key {
|
switch key {
|
||||||
case "changefreq":
|
case "changefreq":
|
||||||
|
@ -177,7 +177,7 @@ func (s *Server) MatchRedirect(pattern string) Redirect {
|
||||||
|
|
||||||
type Headers struct {
|
type Headers struct {
|
||||||
For string
|
For string
|
||||||
Values map[string]interface{}
|
Values map[string]any
|
||||||
}
|
}
|
||||||
|
|
||||||
type Redirect struct {
|
type Redirect struct {
|
||||||
|
|
|
@ -27,7 +27,7 @@ func TestBuild(t *testing.T) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
v := New()
|
v := New()
|
||||||
v.Set("build", map[string]interface{}{
|
v.Set("build", map[string]any{
|
||||||
"useResourceCacheWhen": "always",
|
"useResourceCacheWhen": "always",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func TestBuild(t *testing.T) {
|
||||||
|
|
||||||
c.Assert(b.UseResourceCacheWhen, qt.Equals, "always")
|
c.Assert(b.UseResourceCacheWhen, qt.Equals, "always")
|
||||||
|
|
||||||
v.Set("build", map[string]interface{}{
|
v.Set("build", map[string]any{
|
||||||
"useResourceCacheWhen": "foo",
|
"useResourceCacheWhen": "foo",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ func (c *compositeConfig) GetInt(key string) int {
|
||||||
return c.base.GetInt(key)
|
return c.base.GetInt(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *compositeConfig) Merge(key string, value interface{}) {
|
func (c *compositeConfig) Merge(key string, value any) {
|
||||||
c.layer.Merge(key, value)
|
c.layer.Merge(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ func (c *compositeConfig) GetParams(key string) maps.Params {
|
||||||
return c.base.GetParams(key)
|
return c.base.GetParams(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *compositeConfig) GetStringMap(key string) map[string]interface{} {
|
func (c *compositeConfig) GetStringMap(key string) map[string]any {
|
||||||
if c.layer.IsSet(key) {
|
if c.layer.IsSet(key) {
|
||||||
return c.layer.GetStringMap(key)
|
return c.layer.GetStringMap(key)
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ func (c *compositeConfig) GetStringSlice(key string) []string {
|
||||||
return c.base.GetStringSlice(key)
|
return c.base.GetStringSlice(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *compositeConfig) Get(key string) interface{} {
|
func (c *compositeConfig) Get(key string) any {
|
||||||
if c.layer.IsSet(key) {
|
if c.layer.IsSet(key) {
|
||||||
return c.layer.Get(key)
|
return c.layer.Get(key)
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func (c *compositeConfig) GetString(key string) string {
|
||||||
return c.base.GetString(key)
|
return c.base.GetString(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *compositeConfig) Set(key string, value interface{}) {
|
func (c *compositeConfig) Set(key string, value any) {
|
||||||
c.layer.Set(key, value)
|
c.layer.Set(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,11 +67,11 @@ func FromFile(fs afero.Fs, filename string) (Provider, error) {
|
||||||
|
|
||||||
// FromFileToMap is the same as FromFile, but it returns the config values
|
// FromFileToMap is the same as FromFile, but it returns the config values
|
||||||
// as a simple map.
|
// as a simple map.
|
||||||
func FromFileToMap(fs afero.Fs, filename string) (map[string]interface{}, error) {
|
func FromFileToMap(fs afero.Fs, filename string) (map[string]any, error) {
|
||||||
return loadConfigFromFile(fs, filename)
|
return loadConfigFromFile(fs, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
func readConfig(format metadecoders.Format, data []byte) (map[string]interface{}, error) {
|
func readConfig(format metadecoders.Format, data []byte) (map[string]any, error) {
|
||||||
m, err := metadecoders.Default.UnmarshalToMap(data, format)
|
m, err := metadecoders.Default.UnmarshalToMap(data, format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -82,7 +82,7 @@ func readConfig(format metadecoders.Format, data []byte) (map[string]interface{}
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfigFromFile(fs afero.Fs, filename string) (map[string]interface{}, error) {
|
func loadConfigFromFile(fs afero.Fs, filename string) (map[string]any, error) {
|
||||||
m, err := metadecoders.Default.UnmarshalFileToMap(fs, filename)
|
m, err := metadecoders.Default.UnmarshalFileToMap(fs, filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -156,13 +156,13 @@ func LoadConfigFromDir(sourceFs afero.Fs, configDir, environment string) (Provid
|
||||||
|
|
||||||
root := item
|
root := item
|
||||||
if len(keyPath) > 0 {
|
if len(keyPath) > 0 {
|
||||||
root = make(map[string]interface{})
|
root = make(map[string]any)
|
||||||
m := root
|
m := root
|
||||||
for i, key := range keyPath {
|
for i, key := range keyPath {
|
||||||
if i >= len(keyPath)-1 {
|
if i >= len(keyPath)-1 {
|
||||||
m[key] = item
|
m[key] = item
|
||||||
} else {
|
} else {
|
||||||
nm := make(map[string]interface{})
|
nm := make(map[string]any)
|
||||||
m[key] = nm
|
m[key] = nm
|
||||||
m = nm
|
m = nm
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,6 @@ func init() {
|
||||||
|
|
||||||
// RenameKeys renames config keys in m recursively according to a global Hugo
|
// RenameKeys renames config keys in m recursively according to a global Hugo
|
||||||
// alias definition.
|
// alias definition.
|
||||||
func RenameKeys(m map[string]interface{}) {
|
func RenameKeys(m map[string]any) {
|
||||||
keyAliases.Rename(m)
|
keyAliases.Rename(m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ type Provider interface {
|
||||||
GetInt(key string) int
|
GetInt(key string) int
|
||||||
GetBool(key string) bool
|
GetBool(key string) bool
|
||||||
GetParams(key string) maps.Params
|
GetParams(key string) maps.Params
|
||||||
GetStringMap(key string) map[string]interface{}
|
GetStringMap(key string) map[string]any
|
||||||
GetStringMapString(key string) map[string]string
|
GetStringMapString(key string) map[string]string
|
||||||
GetStringSlice(key string) []string
|
GetStringSlice(key string) []string
|
||||||
Get(key string) interface{}
|
Get(key string) any
|
||||||
Set(key string, value interface{})
|
Set(key string, value any)
|
||||||
Merge(key string, value interface{})
|
Merge(key string, value any)
|
||||||
SetDefaults(params maps.Params)
|
SetDefaults(params maps.Params)
|
||||||
SetDefaultMergeStrategy()
|
SetDefaultMergeStrategy()
|
||||||
WalkParams(walkFn func(params ...KeyParams) bool)
|
WalkParams(walkFn func(params ...KeyParams) bool)
|
||||||
|
|
|
@ -84,7 +84,7 @@ type defaultConfigProvider struct {
|
||||||
keyCache sync.Map
|
keyCache sync.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultConfigProvider) Get(k string) interface{} {
|
func (c *defaultConfigProvider) Get(k string) any {
|
||||||
if k == "" {
|
if k == "" {
|
||||||
return c.root
|
return c.root
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ func (c *defaultConfigProvider) GetParams(k string) maps.Params {
|
||||||
return v.(maps.Params)
|
return v.(maps.Params)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultConfigProvider) GetStringMap(k string) map[string]interface{} {
|
func (c *defaultConfigProvider) GetStringMap(k string) map[string]any {
|
||||||
v := c.Get(k)
|
v := c.Get(k)
|
||||||
return maps.ToStringMap(v)
|
return maps.ToStringMap(v)
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ func (c *defaultConfigProvider) GetStringSlice(k string) []string {
|
||||||
return cast.ToStringSlice(v)
|
return cast.ToStringSlice(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultConfigProvider) Set(k string, v interface{}) {
|
func (c *defaultConfigProvider) Set(k string, v any) {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ func (c *defaultConfigProvider) Set(k string, v interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch vv := v.(type) {
|
switch vv := v.(type) {
|
||||||
case map[string]interface{}, map[interface{}]interface{}, map[string]string:
|
case map[string]any, map[any]any, map[string]string:
|
||||||
p := maps.MustToParamsAndPrepare(vv)
|
p := maps.MustToParamsAndPrepare(vv)
|
||||||
v = p
|
v = p
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ func (c *defaultConfigProvider) SetDefaults(params maps.Params) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultConfigProvider) Merge(k string, v interface{}) {
|
func (c *defaultConfigProvider) Merge(k string, v any) {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
k = strings.ToLower(k)
|
k = strings.ToLower(k)
|
||||||
|
@ -289,7 +289,7 @@ func (c *defaultConfigProvider) Merge(k string, v interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch vv := v.(type) {
|
switch vv := v.(type) {
|
||||||
case map[string]interface{}, map[interface{}]interface{}, map[string]string:
|
case map[string]any, map[any]any, map[string]string:
|
||||||
p := maps.MustToParamsAndPrepare(vv)
|
p := maps.MustToParamsAndPrepare(vv)
|
||||||
v = p
|
v = p
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
c.Run("Set and get", func(c *qt.C) {
|
c.Run("Set and get", func(c *qt.C) {
|
||||||
cfg := New()
|
cfg := New()
|
||||||
var k string
|
var k string
|
||||||
var v interface{}
|
var v any
|
||||||
|
|
||||||
k, v = "foo", "bar"
|
k, v = "foo", "bar"
|
||||||
cfg.Set(k, v)
|
cfg.Set(k, v)
|
||||||
|
@ -55,7 +55,7 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
c.Run("Set and get map", func(c *qt.C) {
|
c.Run("Set and get map", func(c *qt.C) {
|
||||||
cfg := New()
|
cfg := New()
|
||||||
|
|
||||||
cfg.Set("foo", map[string]interface{}{
|
cfg.Set("foo", map[string]any{
|
||||||
"bar": "baz",
|
"bar": "baz",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -63,14 +63,14 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
"bar": "baz",
|
"bar": "baz",
|
||||||
})
|
})
|
||||||
|
|
||||||
c.Assert(cfg.GetStringMap("foo"), qt.DeepEquals, map[string]interface{}{"bar": string("baz")})
|
c.Assert(cfg.GetStringMap("foo"), qt.DeepEquals, map[string]any{"bar": string("baz")})
|
||||||
c.Assert(cfg.GetStringMapString("foo"), qt.DeepEquals, map[string]string{"bar": string("baz")})
|
c.Assert(cfg.GetStringMapString("foo"), qt.DeepEquals, map[string]string{"bar": string("baz")})
|
||||||
})
|
})
|
||||||
|
|
||||||
c.Run("Set and get nested", func(c *qt.C) {
|
c.Run("Set and get nested", func(c *qt.C) {
|
||||||
cfg := New()
|
cfg := New()
|
||||||
|
|
||||||
cfg.Set("a", map[string]interface{}{
|
cfg.Set("a", map[string]any{
|
||||||
"B": "bv",
|
"B": "bv",
|
||||||
})
|
})
|
||||||
cfg.Set("a.c", "cv")
|
cfg.Set("a.c", "cv")
|
||||||
|
@ -86,7 +86,7 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
"a": "av",
|
"a": "av",
|
||||||
})
|
})
|
||||||
|
|
||||||
cfg.Set("b", map[string]interface{}{
|
cfg.Set("b", map[string]any{
|
||||||
"b": "bv",
|
"b": "bv",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
|
|
||||||
cfg.Set("a", "av")
|
cfg.Set("a", "av")
|
||||||
|
|
||||||
cfg.Set("", map[string]interface{}{
|
cfg.Set("", map[string]any{
|
||||||
"a": "av2",
|
"a": "av2",
|
||||||
"b": "bv2",
|
"b": "bv2",
|
||||||
})
|
})
|
||||||
|
@ -113,7 +113,7 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
|
|
||||||
cfg.Set("a", "av")
|
cfg.Set("a", "av")
|
||||||
|
|
||||||
cfg.Set("", map[string]interface{}{
|
cfg.Set("", map[string]any{
|
||||||
"b": "bv2",
|
"b": "bv2",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -124,14 +124,14 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
|
|
||||||
cfg = New()
|
cfg = New()
|
||||||
|
|
||||||
cfg.Set("", map[string]interface{}{
|
cfg.Set("", map[string]any{
|
||||||
"foo": map[string]interface{}{
|
"foo": map[string]any{
|
||||||
"a": "av",
|
"a": "av",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cfg.Set("", map[string]interface{}{
|
cfg.Set("", map[string]any{
|
||||||
"foo": map[string]interface{}{
|
"foo": map[string]any{
|
||||||
"b": "bv2",
|
"b": "bv2",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -145,11 +145,11 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
c.Run("Merge default strategy", func(c *qt.C) {
|
c.Run("Merge default strategy", func(c *qt.C) {
|
||||||
cfg := New()
|
cfg := New()
|
||||||
|
|
||||||
cfg.Set("a", map[string]interface{}{
|
cfg.Set("a", map[string]any{
|
||||||
"B": "bv",
|
"B": "bv",
|
||||||
})
|
})
|
||||||
|
|
||||||
cfg.Merge("a", map[string]interface{}{
|
cfg.Merge("a", map[string]any{
|
||||||
"B": "bv2",
|
"B": "bv2",
|
||||||
"c": "cv2",
|
"c": "cv2",
|
||||||
})
|
})
|
||||||
|
@ -163,7 +163,7 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
|
|
||||||
cfg.Set("a", "av")
|
cfg.Set("a", "av")
|
||||||
|
|
||||||
cfg.Merge("", map[string]interface{}{
|
cfg.Merge("", map[string]any{
|
||||||
"a": "av2",
|
"a": "av2",
|
||||||
"b": "bv2",
|
"b": "bv2",
|
||||||
})
|
})
|
||||||
|
@ -176,16 +176,16 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
c.Run("Merge shallow", func(c *qt.C) {
|
c.Run("Merge shallow", func(c *qt.C) {
|
||||||
cfg := New()
|
cfg := New()
|
||||||
|
|
||||||
cfg.Set("a", map[string]interface{}{
|
cfg.Set("a", map[string]any{
|
||||||
"_merge": "shallow",
|
"_merge": "shallow",
|
||||||
"B": "bv",
|
"B": "bv",
|
||||||
"c": map[string]interface{}{
|
"c": map[string]any{
|
||||||
"b": "bv",
|
"b": "bv",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
cfg.Merge("a", map[string]interface{}{
|
cfg.Merge("a", map[string]any{
|
||||||
"c": map[string]interface{}{
|
"c": map[string]any{
|
||||||
"d": "dv2",
|
"d": "dv2",
|
||||||
},
|
},
|
||||||
"e": "ev2",
|
"e": "ev2",
|
||||||
|
@ -203,20 +203,20 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
|
|
||||||
// Issue #8679
|
// Issue #8679
|
||||||
c.Run("Merge typed maps", func(c *qt.C) {
|
c.Run("Merge typed maps", func(c *qt.C) {
|
||||||
for _, left := range []interface{}{
|
for _, left := range []any{
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"c": "cv1",
|
"c": "cv1",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"c": "cv1",
|
"c": "cv1",
|
||||||
},
|
},
|
||||||
map[interface{}]interface{}{
|
map[any]any{
|
||||||
"c": "cv1",
|
"c": "cv1",
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
cfg := New()
|
cfg := New()
|
||||||
|
|
||||||
cfg.Set("", map[string]interface{}{
|
cfg.Set("", map[string]any{
|
||||||
"b": left,
|
"b": left,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -235,27 +235,27 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, left := range []interface{}{
|
for _, left := range []any{
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"b": "bv1",
|
"b": "bv1",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"b": "bv1",
|
"b": "bv1",
|
||||||
},
|
},
|
||||||
map[interface{}]interface{}{
|
map[any]any{
|
||||||
"b": "bv1",
|
"b": "bv1",
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
for _, right := range []interface{}{
|
for _, right := range []any{
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"b": "bv2",
|
"b": "bv2",
|
||||||
"c": "cv2",
|
"c": "cv2",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"b": "bv2",
|
"b": "bv2",
|
||||||
"c": "cv2",
|
"c": "cv2",
|
||||||
},
|
},
|
||||||
map[interface{}]interface{}{
|
map[any]any{
|
||||||
"b": "bv2",
|
"b": "bv2",
|
||||||
"c": "cv2",
|
"c": "cv2",
|
||||||
},
|
},
|
||||||
|
@ -280,12 +280,12 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
c.Run("Prevent _merge only maps", func(c *qt.C) {
|
c.Run("Prevent _merge only maps", func(c *qt.C) {
|
||||||
cfg := New()
|
cfg := New()
|
||||||
|
|
||||||
cfg.Set("", map[string]interface{}{
|
cfg.Set("", map[string]any{
|
||||||
"B": "bv",
|
"B": "bv",
|
||||||
})
|
})
|
||||||
|
|
||||||
cfg.Merge("", map[string]interface{}{
|
cfg.Merge("", map[string]any{
|
||||||
"c": map[string]interface{}{
|
"c": map[string]any{
|
||||||
"_merge": "shallow",
|
"_merge": "shallow",
|
||||||
"d": "dv2",
|
"d": "dv2",
|
||||||
},
|
},
|
||||||
|
@ -299,7 +299,7 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
c.Run("IsSet", func(c *qt.C) {
|
c.Run("IsSet", func(c *qt.C) {
|
||||||
cfg := New()
|
cfg := New()
|
||||||
|
|
||||||
cfg.Set("a", map[string]interface{}{
|
cfg.Set("a", map[string]any{
|
||||||
"B": "bv",
|
"B": "bv",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -357,15 +357,15 @@ func TestDefaultConfigProvider(t *testing.T) {
|
||||||
|
|
||||||
func BenchmarkDefaultConfigProvider(b *testing.B) {
|
func BenchmarkDefaultConfigProvider(b *testing.B) {
|
||||||
type cfger interface {
|
type cfger interface {
|
||||||
Get(key string) interface{}
|
Get(key string) any
|
||||||
Set(key string, value interface{})
|
Set(key string, value any)
|
||||||
IsSet(key string) bool
|
IsSet(key string) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
newMap := func() map[string]interface{} {
|
newMap := func() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"a": map[string]interface{}{
|
"a": map[string]any{
|
||||||
"b": map[string]interface{}{
|
"b": map[string]any{
|
||||||
"c": 32,
|
"c": 32,
|
||||||
"d": 43,
|
"d": 43,
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,7 +35,7 @@ func init() {
|
||||||
cfg.Set("languages", lang)
|
cfg.Set("languages", lang)
|
||||||
cfg.SetDefaultMergeStrategy()
|
cfg.SetDefaultMergeStrategy()
|
||||||
|
|
||||||
configHelpers := map[string]interface{}{
|
configHelpers := map[string]any{
|
||||||
"mergeStrategy": cfg.Get(""),
|
"mergeStrategy": cfg.Get(""),
|
||||||
}
|
}
|
||||||
return docshelper.DocProvider{"config": configHelpers}
|
return docshelper.DocProvider{"config": configHelpers}
|
||||||
|
|
|
@ -147,15 +147,15 @@ func (c Config) CheckAllowedHTTPMethod(method string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToSecurityMap converts c to a map with 'security' as the root key.
|
// ToSecurityMap converts c to a map with 'security' as the root key.
|
||||||
func (c Config) ToSecurityMap() map[string]interface{} {
|
func (c Config) ToSecurityMap() map[string]any {
|
||||||
// Take it to JSON and back to get proper casing etc.
|
// Take it to JSON and back to get proper casing etc.
|
||||||
asJson, err := json.Marshal(c)
|
asJson, err := json.Marshal(c)
|
||||||
herrors.Must(err)
|
herrors.Must(err)
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]any)
|
||||||
herrors.Must(json.Unmarshal(asJson, &m))
|
herrors.Must(json.Unmarshal(asJson, &m))
|
||||||
|
|
||||||
// Add the root
|
// Add the root
|
||||||
sec := map[string]interface{}{
|
sec := map[string]any{
|
||||||
"security": m,
|
"security": m,
|
||||||
}
|
}
|
||||||
return sec
|
return sec
|
||||||
|
@ -196,7 +196,7 @@ func stringSliceToWhitelistHook() mapstructure.DecodeHookFuncType {
|
||||||
return func(
|
return func(
|
||||||
f reflect.Type,
|
f reflect.Type,
|
||||||
t reflect.Type,
|
t reflect.Type,
|
||||||
data interface{}) (interface{}, error) {
|
data any) (any, error) {
|
||||||
|
|
||||||
if t != reflect.TypeOf(Whitelist{}) {
|
if t != reflect.TypeOf(Whitelist{}) {
|
||||||
return data, nil
|
return data, nil
|
||||||
|
|
|
@ -18,7 +18,6 @@ import (
|
||||||
|
|
||||||
qt "github.com/frankban/quicktest"
|
qt "github.com/frankban/quicktest"
|
||||||
"github.com/gohugoio/hugo/config"
|
"github.com/gohugoio/hugo/config"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDecodeConfigFromTOML(t *testing.T) {
|
func TestDecodeConfigFromTOML(t *testing.T) {
|
||||||
|
|
|
@ -346,7 +346,7 @@ func (b *contentBuilder) openInEditorIfConfigured(filename string) error {
|
||||||
editorExec := strings.Fields(editor)[0]
|
editorExec := strings.Fields(editor)[0]
|
||||||
editorFlags := strings.Fields(editor)[1:]
|
editorFlags := strings.Fields(editor)[1:]
|
||||||
|
|
||||||
var args []interface{}
|
var args []any
|
||||||
for _, editorFlag := range editorFlags {
|
for _, editorFlag := range editorFlags {
|
||||||
args = append(args, editorFlag)
|
args = append(args, editorFlag)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func TestNewContentFromFile(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
kind string
|
kind string
|
||||||
path string
|
path string
|
||||||
expected interface{}
|
expected any
|
||||||
}{
|
}{
|
||||||
{"Post", "post", "post/sample-1.md", []string{`title = "Post Arch title"`, `test = "test1"`, "date = \"2015-01-12T19:20:04-07:00\""}},
|
{"Post", "post", "post/sample-1.md", []string{`title = "Post Arch title"`, `test = "test1"`, "date = \"2015-01-12T19:20:04-07:00\""}},
|
||||||
{"Post org-mode", "post", "post/org-1.org", []string{`#+title: ORG-1`}},
|
{"Post org-mode", "post", "post/org-1.org", []string{`#+title: ORG-1`}},
|
||||||
|
@ -368,7 +368,7 @@ Some text.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func cContains(c *qt.C, v interface{}, matches ...string) {
|
func cContains(c *qt.C, v any, matches ...string) {
|
||||||
for _, m := range matches {
|
for _, m := range matches {
|
||||||
c.Assert(v, qt.Contains, m)
|
c.Assert(v, qt.Contains, m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !nodeploy
|
||||||
// +build !nodeploy
|
// +build !nodeploy
|
||||||
|
|
||||||
package deploy
|
package deploy
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !nodeploy
|
||||||
// +build !nodeploy
|
// +build !nodeploy
|
||||||
|
|
||||||
package deploy
|
package deploy
|
||||||
|
|
|
@ -115,7 +115,7 @@ func (m *matcher) Matches(path string) bool {
|
||||||
// decode creates a config from a given Hugo configuration.
|
// decode creates a config from a given Hugo configuration.
|
||||||
func decodeConfig(cfg config.Provider) (deployConfig, error) {
|
func decodeConfig(cfg config.Provider) (deployConfig, error) {
|
||||||
var (
|
var (
|
||||||
mediaTypesConfig []map[string]interface{}
|
mediaTypesConfig []map[string]any
|
||||||
dcfg deployConfig
|
dcfg deployConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !solaris && !nodeploy
|
||||||
// +build !solaris,!nodeploy
|
// +build !solaris,!nodeploy
|
||||||
|
|
||||||
package deploy
|
package deploy
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !nodeploy
|
||||||
// +build !nodeploy
|
// +build !nodeploy
|
||||||
|
|
||||||
package deploy
|
package deploy
|
||||||
|
@ -252,7 +253,7 @@ func TestWalkLocal(t *testing.T) {
|
||||||
if got, err := walkLocal(fs, nil, nil, nil, media.DefaultTypes); err != nil {
|
if got, err := walkLocal(fs, nil, nil, nil, media.DefaultTypes); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
expect := map[string]interface{}{}
|
expect := map[string]any{}
|
||||||
for _, path := range tc.Expect {
|
for _, path := range tc.Expect {
|
||||||
if _, ok := got[path]; !ok {
|
if _, ok := got[path]; !ok {
|
||||||
t.Errorf("expected %q in results, but was not found", path)
|
t.Errorf("expected %q in results, but was not found", path)
|
||||||
|
@ -290,7 +291,7 @@ func TestLocalFile(t *testing.T) {
|
||||||
Description string
|
Description string
|
||||||
Path string
|
Path string
|
||||||
Matcher *matcher
|
Matcher *matcher
|
||||||
MediaTypesConfig []map[string]interface{}
|
MediaTypesConfig []map[string]any
|
||||||
WantContent []byte
|
WantContent []byte
|
||||||
WantSize int64
|
WantSize int64
|
||||||
WantMD5 []byte
|
WantMD5 []byte
|
||||||
|
@ -351,9 +352,9 @@ func TestLocalFile(t *testing.T) {
|
||||||
{
|
{
|
||||||
Description: "Custom MediaType",
|
Description: "Custom MediaType",
|
||||||
Path: "foo.hugo",
|
Path: "foo.hugo",
|
||||||
MediaTypesConfig: []map[string]interface{}{
|
MediaTypesConfig: []map[string]any{
|
||||||
{
|
{
|
||||||
"hugo/custom": map[string]interface{}{
|
"hugo/custom": map[string]any{
|
||||||
"suffixes": []string{"hugo"},
|
"suffixes": []string{"hugo"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !nodeploy
|
||||||
// +build !nodeploy
|
// +build !nodeploy
|
||||||
|
|
||||||
package deploy
|
package deploy
|
||||||
|
|
6
deps/deps.go
vendored
6
deps/deps.go
vendored
|
@ -68,7 +68,7 @@ type Deps struct {
|
||||||
FileCaches filecache.Caches
|
FileCaches filecache.Caches
|
||||||
|
|
||||||
// The translation func to use
|
// The translation func to use
|
||||||
Translate func(translationID string, templateData interface{}) string `json:"-"`
|
Translate func(translationID string, templateData any) string `json:"-"`
|
||||||
|
|
||||||
// The language in use. TODO(bep) consolidate with site
|
// The language in use. TODO(bep) consolidate with site
|
||||||
Language *langs.Language
|
Language *langs.Language
|
||||||
|
@ -83,7 +83,7 @@ type Deps struct {
|
||||||
WithTemplate func(templ tpl.TemplateManager) error `json:"-"`
|
WithTemplate func(templ tpl.TemplateManager) error `json:"-"`
|
||||||
|
|
||||||
// Used in tests
|
// Used in tests
|
||||||
OverloadedTemplateFuncs map[string]interface{}
|
OverloadedTemplateFuncs map[string]any
|
||||||
|
|
||||||
translationProvider ResourceProvider
|
translationProvider ResourceProvider
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ type DepsCfg struct {
|
||||||
TemplateProvider ResourceProvider
|
TemplateProvider ResourceProvider
|
||||||
WithTemplate func(templ tpl.TemplateManager) error
|
WithTemplate func(templ tpl.TemplateManager) error
|
||||||
// Used in tests
|
// Used in tests
|
||||||
OverloadedTemplateFuncs map[string]interface{}
|
OverloadedTemplateFuncs map[string]any
|
||||||
|
|
||||||
// i18n handling.
|
// i18n handling.
|
||||||
TranslationProvider ResourceProvider
|
TranslationProvider ResourceProvider
|
||||||
|
|
|
@ -17,7 +17,7 @@ package docshelper
|
||||||
|
|
||||||
type (
|
type (
|
||||||
DocProviderFunc = func() DocProvider
|
DocProviderFunc = func() DocProvider
|
||||||
DocProvider map[string]map[string]interface{}
|
DocProvider map[string]map[string]any
|
||||||
)
|
)
|
||||||
|
|
||||||
var docProviderFuncs []DocProviderFunc
|
var docProviderFuncs []DocProviderFunc
|
||||||
|
@ -44,7 +44,7 @@ func GetDocProvider() DocProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shallow merge
|
// Shallow merge
|
||||||
func merge(dst, src map[string]interface{}) {
|
func merge(dst, src map[string]any) {
|
||||||
for k, v := range src {
|
for k, v := range src {
|
||||||
dst[k] = v
|
dst[k] = v
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ var (
|
||||||
type ContentSpec struct {
|
type ContentSpec struct {
|
||||||
Converters markup.ConverterProvider
|
Converters markup.ConverterProvider
|
||||||
anchorNameSanitizer converter.AnchorNameSanitizer
|
anchorNameSanitizer converter.AnchorNameSanitizer
|
||||||
getRenderer func(t hooks.RendererType, id interface{}) interface{}
|
getRenderer func(t hooks.RendererType, id any) any
|
||||||
|
|
||||||
// SummaryLength is the length of the summary that Hugo extracts from a content.
|
// SummaryLength is the length of the summary that Hugo extracts from a content.
|
||||||
summaryLength int
|
summaryLength int
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
// This is is just some helpers used to create some JSON used in the Hugo docs.
|
// This is is just some helpers used to create some JSON used in the Hugo docs.
|
||||||
func init() {
|
func init() {
|
||||||
docsProvider := func() docshelper.DocProvider {
|
docsProvider := func() docshelper.DocProvider {
|
||||||
var chromaLexers []interface{}
|
var chromaLexers []any
|
||||||
|
|
||||||
sort.Sort(lexers.Registry.Lexers)
|
sort.Sort(lexers.Registry.Lexers)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ func init() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return docshelper.DocProvider{"chroma": map[string]interface{}{"lexers": chromaLexers}}
|
return docshelper.DocProvider{"chroma": map[string]any{"lexers": chromaLexers}}
|
||||||
}
|
}
|
||||||
|
|
||||||
docshelper.AddDocProviderFunc(docsProvider)
|
docshelper.AddDocProviderFunc(docsProvider)
|
||||||
|
|
|
@ -274,7 +274,7 @@ func (l *DistinctLogger) Reset() {
|
||||||
|
|
||||||
// Println will log the string returned from fmt.Sprintln given the arguments,
|
// Println will log the string returned from fmt.Sprintln given the arguments,
|
||||||
// but not if it has been logged before.
|
// but not if it has been logged before.
|
||||||
func (l *DistinctLogger) Println(v ...interface{}) {
|
func (l *DistinctLogger) Println(v ...any) {
|
||||||
// fmt.Sprint doesn't add space between string arguments
|
// fmt.Sprint doesn't add space between string arguments
|
||||||
logStatement := strings.TrimSpace(fmt.Sprintln(v...))
|
logStatement := strings.TrimSpace(fmt.Sprintln(v...))
|
||||||
l.printIfNotPrinted("println", logStatement, func() {
|
l.printIfNotPrinted("println", logStatement, func() {
|
||||||
|
@ -284,63 +284,63 @@ func (l *DistinctLogger) Println(v ...interface{}) {
|
||||||
|
|
||||||
// Printf will log the string returned from fmt.Sprintf given the arguments,
|
// Printf will log the string returned from fmt.Sprintf given the arguments,
|
||||||
// but not if it has been logged before.
|
// but not if it has been logged before.
|
||||||
func (l *DistinctLogger) Printf(format string, v ...interface{}) {
|
func (l *DistinctLogger) Printf(format string, v ...any) {
|
||||||
logStatement := fmt.Sprintf(format, v...)
|
logStatement := fmt.Sprintf(format, v...)
|
||||||
l.printIfNotPrinted("printf", logStatement, func() {
|
l.printIfNotPrinted("printf", logStatement, func() {
|
||||||
l.Logger.Printf(format, v...)
|
l.Logger.Printf(format, v...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DistinctLogger) Debugf(format string, v ...interface{}) {
|
func (l *DistinctLogger) Debugf(format string, v ...any) {
|
||||||
logStatement := fmt.Sprintf(format, v...)
|
logStatement := fmt.Sprintf(format, v...)
|
||||||
l.printIfNotPrinted("debugf", logStatement, func() {
|
l.printIfNotPrinted("debugf", logStatement, func() {
|
||||||
l.Logger.Debugf(format, v...)
|
l.Logger.Debugf(format, v...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DistinctLogger) Debugln(v ...interface{}) {
|
func (l *DistinctLogger) Debugln(v ...any) {
|
||||||
logStatement := fmt.Sprint(v...)
|
logStatement := fmt.Sprint(v...)
|
||||||
l.printIfNotPrinted("debugln", logStatement, func() {
|
l.printIfNotPrinted("debugln", logStatement, func() {
|
||||||
l.Logger.Debugln(v...)
|
l.Logger.Debugln(v...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DistinctLogger) Infof(format string, v ...interface{}) {
|
func (l *DistinctLogger) Infof(format string, v ...any) {
|
||||||
logStatement := fmt.Sprintf(format, v...)
|
logStatement := fmt.Sprintf(format, v...)
|
||||||
l.printIfNotPrinted("info", logStatement, func() {
|
l.printIfNotPrinted("info", logStatement, func() {
|
||||||
l.Logger.Infof(format, v...)
|
l.Logger.Infof(format, v...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DistinctLogger) Infoln(v ...interface{}) {
|
func (l *DistinctLogger) Infoln(v ...any) {
|
||||||
logStatement := fmt.Sprint(v...)
|
logStatement := fmt.Sprint(v...)
|
||||||
l.printIfNotPrinted("infoln", logStatement, func() {
|
l.printIfNotPrinted("infoln", logStatement, func() {
|
||||||
l.Logger.Infoln(v...)
|
l.Logger.Infoln(v...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DistinctLogger) Warnf(format string, v ...interface{}) {
|
func (l *DistinctLogger) Warnf(format string, v ...any) {
|
||||||
logStatement := fmt.Sprintf(format, v...)
|
logStatement := fmt.Sprintf(format, v...)
|
||||||
l.printIfNotPrinted("warnf", logStatement, func() {
|
l.printIfNotPrinted("warnf", logStatement, func() {
|
||||||
l.Logger.Warnf(format, v...)
|
l.Logger.Warnf(format, v...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DistinctLogger) Warnln(v ...interface{}) {
|
func (l *DistinctLogger) Warnln(v ...any) {
|
||||||
logStatement := fmt.Sprint(v...)
|
logStatement := fmt.Sprint(v...)
|
||||||
l.printIfNotPrinted("warnln", logStatement, func() {
|
l.printIfNotPrinted("warnln", logStatement, func() {
|
||||||
l.Logger.Warnln(v...)
|
l.Logger.Warnln(v...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DistinctLogger) Errorf(format string, v ...interface{}) {
|
func (l *DistinctLogger) Errorf(format string, v ...any) {
|
||||||
logStatement := fmt.Sprint(v...)
|
logStatement := fmt.Sprint(v...)
|
||||||
l.printIfNotPrinted("errorf", logStatement, func() {
|
l.printIfNotPrinted("errorf", logStatement, func() {
|
||||||
l.Logger.Errorf(format, v...)
|
l.Logger.Errorf(format, v...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *DistinctLogger) Errorln(v ...interface{}) {
|
func (l *DistinctLogger) Errorln(v ...any) {
|
||||||
logStatement := fmt.Sprint(v...)
|
logStatement := fmt.Sprint(v...)
|
||||||
l.printIfNotPrinted("errorln", logStatement, func() {
|
l.printIfNotPrinted("errorln", logStatement, func() {
|
||||||
l.Logger.Errorln(v...)
|
l.Logger.Errorln(v...)
|
||||||
|
@ -507,7 +507,7 @@ func PrintFs(fs afero.Fs, path string, w io.Writer) {
|
||||||
|
|
||||||
afero.Walk(fs, path, func(path string, info os.FileInfo, err error) error {
|
afero.Walk(fs, path, func(path string, info os.FileInfo, err error) error {
|
||||||
var filename string
|
var filename string
|
||||||
var meta interface{}
|
var meta any
|
||||||
if fim, ok := info.(hugofs.FileMetaInfo); ok {
|
if fim, ok := info.(hugofs.FileMetaInfo); ok {
|
||||||
filename = fim.Meta().Filename
|
filename = fim.Meta().Filename
|
||||||
meta = fim.Meta()
|
meta = fim.Meta()
|
||||||
|
@ -519,8 +519,8 @@ func PrintFs(fs afero.Fs, path string, w io.Writer) {
|
||||||
|
|
||||||
// HashString returns a hash from the given elements.
|
// HashString returns a hash from the given elements.
|
||||||
// It will panic if the hash cannot be calculated.
|
// It will panic if the hash cannot be calculated.
|
||||||
func HashString(elements ...interface{}) string {
|
func HashString(elements ...any) string {
|
||||||
var o interface{}
|
var o any
|
||||||
if len(elements) == 1 {
|
if len(elements) == 1 {
|
||||||
o = elements[0]
|
o = elements[0]
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,7 +16,7 @@ func newTestPathSpec(fs *hugofs.Fs, v config.Provider) *PathSpec {
|
||||||
return ps
|
return ps
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestDefaultPathSpec(configKeyValues ...interface{}) *PathSpec {
|
func newTestDefaultPathSpec(configKeyValues ...any) *PathSpec {
|
||||||
v := config.New()
|
v := config.New()
|
||||||
fs := hugofs.NewMem(v)
|
fs := hugofs.NewMem(v)
|
||||||
cfg := newTestCfg()
|
cfg := newTestCfg()
|
||||||
|
|
|
@ -49,7 +49,7 @@ type typeChecker struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check implements Checker.Check by checking that got and args[0] is of the same type.
|
// Check implements Checker.Check by checking that got and args[0] is of the same type.
|
||||||
func (c *typeChecker) Check(got interface{}, args []interface{}, note func(key string, value interface{})) (err error) {
|
func (c *typeChecker) Check(got any, args []any, note func(key string, value any)) (err error) {
|
||||||
if want := args[0]; reflect.TypeOf(got) != reflect.TypeOf(want) {
|
if want := args[0]; reflect.TypeOf(got) != reflect.TypeOf(want) {
|
||||||
if _, ok := got.(error); ok && want == nil {
|
if _, ok := got.(error); ok && want == nil {
|
||||||
return errors.New("got non-nil error")
|
return errors.New("got non-nil error")
|
||||||
|
@ -64,7 +64,7 @@ type stringChecker struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check implements Checker.Check by checking that got and args[0] represents the same normalized text (whitespace etc. removed).
|
// Check implements Checker.Check by checking that got and args[0] represents the same normalized text (whitespace etc. removed).
|
||||||
func (c *stringChecker) Check(got interface{}, args []interface{}, note func(key string, value interface{})) (err error) {
|
func (c *stringChecker) Check(got any, args []any, note func(key string, value any)) (err error) {
|
||||||
s1, s2 := cast.ToString(got), cast.ToString(args[0])
|
s1, s2 := cast.ToString(got), cast.ToString(args[0])
|
||||||
|
|
||||||
if s1 == s2 {
|
if s1 == s2 {
|
||||||
|
@ -93,12 +93,12 @@ func normalizeString(s string) string {
|
||||||
// DeepAllowUnexported creates an option to allow compare of unexported types
|
// DeepAllowUnexported creates an option to allow compare of unexported types
|
||||||
// in the given list of types.
|
// in the given list of types.
|
||||||
// see https://github.com/google/go-cmp/issues/40#issuecomment-328615283
|
// see https://github.com/google/go-cmp/issues/40#issuecomment-328615283
|
||||||
func DeepAllowUnexported(vs ...interface{}) cmp.Option {
|
func DeepAllowUnexported(vs ...any) cmp.Option {
|
||||||
m := make(map[reflect.Type]struct{})
|
m := make(map[reflect.Type]struct{})
|
||||||
for _, v := range vs {
|
for _, v := range vs {
|
||||||
structTypes(reflect.ValueOf(v), m)
|
structTypes(reflect.ValueOf(v), m)
|
||||||
}
|
}
|
||||||
var typs []interface{}
|
var typs []any
|
||||||
for t := range m {
|
for t := range m {
|
||||||
typs = append(typs, reflect.New(t).Elem().Interface())
|
typs = append(typs, reflect.New(t).Elem().Interface())
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ func (fi *dirNameOnlyFileInfo) IsDir() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fi *dirNameOnlyFileInfo) Sys() interface{} {
|
func (fi *dirNameOnlyFileInfo) Sys() any {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ func (fs *RootMappingFs) Dirs(base string) ([]FileMetaInfo, error) {
|
||||||
// Filter creates a copy of this filesystem with only mappings matching a filter.
|
// Filter creates a copy of this filesystem with only mappings matching a filter.
|
||||||
func (fs RootMappingFs) Filter(f func(m RootMapping) bool) *RootMappingFs {
|
func (fs RootMappingFs) Filter(f func(m RootMapping) bool) *RootMappingFs {
|
||||||
rootMapToReal := radix.New()
|
rootMapToReal := radix.New()
|
||||||
fs.rootMapToReal.Walk(func(b string, v interface{}) bool {
|
fs.rootMapToReal.Walk(func(b string, v any) bool {
|
||||||
rms := v.([]RootMapping)
|
rms := v.([]RootMapping)
|
||||||
var nrms []RootMapping
|
var nrms []RootMapping
|
||||||
for _, rm := range rms {
|
for _, rm := range rms {
|
||||||
|
@ -250,7 +250,7 @@ func (fs *RootMappingFs) Stat(name string) (os.FileInfo, error) {
|
||||||
|
|
||||||
func (fs *RootMappingFs) hasPrefix(prefix string) bool {
|
func (fs *RootMappingFs) hasPrefix(prefix string) bool {
|
||||||
hasPrefix := false
|
hasPrefix := false
|
||||||
fs.rootMapToReal.WalkPrefix(prefix, func(b string, v interface{}) bool {
|
fs.rootMapToReal.WalkPrefix(prefix, func(b string, v any) bool {
|
||||||
hasPrefix = true
|
hasPrefix = true
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
@ -277,7 +277,7 @@ func (fs *RootMappingFs) getRoots(key string) (string, []RootMapping) {
|
||||||
|
|
||||||
func (fs *RootMappingFs) debug() {
|
func (fs *RootMappingFs) debug() {
|
||||||
fmt.Println("debug():")
|
fmt.Println("debug():")
|
||||||
fs.rootMapToReal.Walk(func(s string, v interface{}) bool {
|
fs.rootMapToReal.Walk(func(s string, v any) bool {
|
||||||
fmt.Println("Key", s)
|
fmt.Println("Key", s)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
@ -285,7 +285,7 @@ func (fs *RootMappingFs) debug() {
|
||||||
|
|
||||||
func (fs *RootMappingFs) getRootsWithPrefix(prefix string) []RootMapping {
|
func (fs *RootMappingFs) getRootsWithPrefix(prefix string) []RootMapping {
|
||||||
var roots []RootMapping
|
var roots []RootMapping
|
||||||
fs.rootMapToReal.WalkPrefix(prefix, func(b string, v interface{}) bool {
|
fs.rootMapToReal.WalkPrefix(prefix, func(b string, v any) bool {
|
||||||
roots = append(roots, v.([]RootMapping)...)
|
roots = append(roots, v.([]RootMapping)...)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
@ -295,7 +295,7 @@ func (fs *RootMappingFs) getRootsWithPrefix(prefix string) []RootMapping {
|
||||||
|
|
||||||
func (fs *RootMappingFs) getAncestors(prefix string) []keyRootMappings {
|
func (fs *RootMappingFs) getAncestors(prefix string) []keyRootMappings {
|
||||||
var roots []keyRootMappings
|
var roots []keyRootMappings
|
||||||
fs.rootMapToReal.WalkPath(prefix, func(s string, v interface{}) bool {
|
fs.rootMapToReal.WalkPath(prefix, func(s string, v any) bool {
|
||||||
if strings.HasPrefix(prefix, s+filepathSeparator) {
|
if strings.HasPrefix(prefix, s+filepathSeparator) {
|
||||||
roots = append(roots, keyRootMappings{
|
roots = append(roots, keyRootMappings{
|
||||||
key: s,
|
key: s,
|
||||||
|
@ -416,7 +416,7 @@ func (fs *RootMappingFs) collectDirEntries(prefix string) ([]os.FileInfo, error)
|
||||||
|
|
||||||
// Next add any file mounts inside the given directory.
|
// Next add any file mounts inside the given directory.
|
||||||
prefixInside := prefix + filepathSeparator
|
prefixInside := prefix + filepathSeparator
|
||||||
fs.rootMapToReal.WalkPrefix(prefixInside, func(s string, v interface{}) bool {
|
fs.rootMapToReal.WalkPrefix(prefixInside, func(s string, v any) bool {
|
||||||
if (strings.Count(s, filepathSeparator) - level) != 1 {
|
if (strings.Count(s, filepathSeparator) - level) != 1 {
|
||||||
// This directory is not part of the current, but we
|
// This directory is not part of the current, but we
|
||||||
// need to include the first name part to make it
|
// need to include the first name part to make it
|
||||||
|
|
|
@ -51,13 +51,13 @@ func TestAlias(t *testing.T) {
|
||||||
fileSuffix string
|
fileSuffix string
|
||||||
urlPrefix string
|
urlPrefix string
|
||||||
urlSuffix string
|
urlSuffix string
|
||||||
settings map[string]interface{}
|
settings map[string]any
|
||||||
}{
|
}{
|
||||||
{"/index.html", "http://example.com", "/", map[string]interface{}{"baseURL": "http://example.com"}},
|
{"/index.html", "http://example.com", "/", map[string]any{"baseURL": "http://example.com"}},
|
||||||
{"/index.html", "http://example.com/some/path", "/", map[string]interface{}{"baseURL": "http://example.com/some/path"}},
|
{"/index.html", "http://example.com/some/path", "/", map[string]any{"baseURL": "http://example.com/some/path"}},
|
||||||
{"/index.html", "http://example.com", "/", map[string]interface{}{"baseURL": "http://example.com", "canonifyURLs": true}},
|
{"/index.html", "http://example.com", "/", map[string]any{"baseURL": "http://example.com", "canonifyURLs": true}},
|
||||||
{"/index.html", "../..", "/", map[string]interface{}{"relativeURLs": true}},
|
{"/index.html", "../..", "/", map[string]any{"relativeURLs": true}},
|
||||||
{".html", "", ".html", map[string]interface{}{"uglyURLs": true}},
|
{".html", "", ".html", map[string]any{"uglyURLs": true}},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
|
@ -335,7 +335,7 @@ Banner: post.jpg`,
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCascadeTestBuilder(t testing.TB, langs []string) *sitesBuilder {
|
func newCascadeTestBuilder(t testing.TB, langs []string) *sitesBuilder {
|
||||||
p := func(m map[string]interface{}) string {
|
p := func(m map[string]any) string {
|
||||||
var yamlStr string
|
var yamlStr string
|
||||||
|
|
||||||
if len(m) > 0 {
|
if len(m) > 0 {
|
||||||
|
@ -392,76 +392,76 @@ defaultContentLanguageInSubDir = false
|
||||||
}
|
}
|
||||||
|
|
||||||
withContent(
|
withContent(
|
||||||
"_index.md", p(map[string]interface{}{
|
"_index.md", p(map[string]any{
|
||||||
"title": "Home",
|
"title": "Home",
|
||||||
"cascade": map[string]interface{}{
|
"cascade": map[string]any{
|
||||||
"title": "Cascade Home",
|
"title": "Cascade Home",
|
||||||
"ICoN": "home.png",
|
"ICoN": "home.png",
|
||||||
"outputs": []string{"HTML"},
|
"outputs": []string{"HTML"},
|
||||||
"weight": 42,
|
"weight": 42,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
"p1.md", p(map[string]interface{}{
|
"p1.md", p(map[string]any{
|
||||||
"title": "p1",
|
"title": "p1",
|
||||||
}),
|
}),
|
||||||
"p2.md", p(map[string]interface{}{}),
|
"p2.md", p(map[string]any{}),
|
||||||
"sect1/_index.md", p(map[string]interface{}{
|
"sect1/_index.md", p(map[string]any{
|
||||||
"title": "Sect1",
|
"title": "Sect1",
|
||||||
"type": "stype",
|
"type": "stype",
|
||||||
"cascade": map[string]interface{}{
|
"cascade": map[string]any{
|
||||||
"title": "Cascade Sect1",
|
"title": "Cascade Sect1",
|
||||||
"icon": "sect1.png",
|
"icon": "sect1.png",
|
||||||
"type": "stype",
|
"type": "stype",
|
||||||
"categories": []string{"catsect1"},
|
"categories": []string{"catsect1"},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
"sect1/s1_2/_index.md", p(map[string]interface{}{
|
"sect1/s1_2/_index.md", p(map[string]any{
|
||||||
"title": "Sect1_2",
|
"title": "Sect1_2",
|
||||||
}),
|
}),
|
||||||
"sect1/s1_2/p1.md", p(map[string]interface{}{
|
"sect1/s1_2/p1.md", p(map[string]any{
|
||||||
"title": "Sect1_2_p1",
|
"title": "Sect1_2_p1",
|
||||||
}),
|
}),
|
||||||
"sect1/s1_2/p2.md", p(map[string]interface{}{
|
"sect1/s1_2/p2.md", p(map[string]any{
|
||||||
"title": "Sect1_2_p2",
|
"title": "Sect1_2_p2",
|
||||||
}),
|
}),
|
||||||
"sect2/_index.md", p(map[string]interface{}{
|
"sect2/_index.md", p(map[string]any{
|
||||||
"title": "Sect2",
|
"title": "Sect2",
|
||||||
}),
|
}),
|
||||||
"sect2/p1.md", p(map[string]interface{}{
|
"sect2/p1.md", p(map[string]any{
|
||||||
"title": "Sect2_p1",
|
"title": "Sect2_p1",
|
||||||
"categories": []string{"cool", "funny", "sad"},
|
"categories": []string{"cool", "funny", "sad"},
|
||||||
"tags": []string{"blue", "green"},
|
"tags": []string{"blue", "green"},
|
||||||
}),
|
}),
|
||||||
"sect2/p2.md", p(map[string]interface{}{}),
|
"sect2/p2.md", p(map[string]any{}),
|
||||||
"sect3/p1.md", p(map[string]interface{}{}),
|
"sect3/p1.md", p(map[string]any{}),
|
||||||
|
|
||||||
// No front matter, see #6855
|
// No front matter, see #6855
|
||||||
"sect3/nofrontmatter.md", `**Hello**`,
|
"sect3/nofrontmatter.md", `**Hello**`,
|
||||||
"sectnocontent/p1.md", `**Hello**`,
|
"sectnocontent/p1.md", `**Hello**`,
|
||||||
"sectnofrontmatter/_index.md", `**Hello**`,
|
"sectnofrontmatter/_index.md", `**Hello**`,
|
||||||
|
|
||||||
"sect4/_index.md", p(map[string]interface{}{
|
"sect4/_index.md", p(map[string]any{
|
||||||
"title": "Sect4",
|
"title": "Sect4",
|
||||||
"cascade": map[string]interface{}{
|
"cascade": map[string]any{
|
||||||
"weight": 52,
|
"weight": 52,
|
||||||
"outputs": []string{"RSS"},
|
"outputs": []string{"RSS"},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
"sect4/p1.md", p(map[string]interface{}{}),
|
"sect4/p1.md", p(map[string]any{}),
|
||||||
"p2.md", p(map[string]interface{}{}),
|
"p2.md", p(map[string]any{}),
|
||||||
"bundle1/index.md", p(map[string]interface{}{}),
|
"bundle1/index.md", p(map[string]any{}),
|
||||||
"bundle1/bp1.md", p(map[string]interface{}{}),
|
"bundle1/bp1.md", p(map[string]any{}),
|
||||||
"categories/_index.md", p(map[string]interface{}{
|
"categories/_index.md", p(map[string]any{
|
||||||
"title": "My Categories",
|
"title": "My Categories",
|
||||||
"cascade": map[string]interface{}{
|
"cascade": map[string]any{
|
||||||
"title": "Cascade Category",
|
"title": "Cascade Category",
|
||||||
"icoN": "cat.png",
|
"icoN": "cat.png",
|
||||||
"weight": 12,
|
"weight": 12,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
"categories/cool/_index.md", p(map[string]interface{}{}),
|
"categories/cool/_index.md", p(map[string]any{}),
|
||||||
"categories/sad/_index.md", p(map[string]interface{}{
|
"categories/sad/_index.md", p(map[string]any{
|
||||||
"cascade": map[string]interface{}{
|
"cascade": map[string]any{
|
||||||
"icon": "sad.png",
|
"icon": "sad.png",
|
||||||
"weight": 32,
|
"weight": 32,
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,7 +28,7 @@ var (
|
||||||
// implementations have no value on their own.
|
// implementations have no value on their own.
|
||||||
|
|
||||||
// Slice is not meant to be used externally. It's a bridge function
|
// Slice is not meant to be used externally. It's a bridge function
|
||||||
func (p *pageState) Slice(items interface{}) (interface{}, error) {
|
func (p *pageState) Slice(items any) (any, error) {
|
||||||
return page.ToPages(items)
|
return page.ToPages(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ func (p *pageState) Slice(items interface{}) (interface{}, error) {
|
||||||
// Group creates a PageGroup from a key and a Pages object
|
// Group creates a PageGroup from a key and a Pages object
|
||||||
// This method is not meant for external use. It got its non-typed arguments to satisfy
|
// This method is not meant for external use. It got its non-typed arguments to satisfy
|
||||||
// a very generic interface in the tpl package.
|
// a very generic interface in the tpl package.
|
||||||
func (p *pageState) Group(key interface{}, in interface{}) (interface{}, error) {
|
func (p *pageState) Group(key any, in any) (any, error) {
|
||||||
pages, err := page.ToPages(in)
|
pages, err := page.ToPages(in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -250,12 +250,12 @@ name = "menu-theme"
|
||||||
|
|
||||||
b.Assert(got["mediatypes"], qt.DeepEquals, maps.Params{
|
b.Assert(got["mediatypes"], qt.DeepEquals, maps.Params{
|
||||||
"text/m2": maps.Params{
|
"text/m2": maps.Params{
|
||||||
"suffixes": []interface{}{
|
"suffixes": []any{
|
||||||
"m2theme",
|
"m2theme",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"text/m1": maps.Params{
|
"text/m1": maps.Params{
|
||||||
"suffixes": []interface{}{
|
"suffixes": []any{
|
||||||
"m1main",
|
"m1main",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -293,13 +293,13 @@ name = "menu-theme"
|
||||||
"pl1": "p1-en-main",
|
"pl1": "p1-en-main",
|
||||||
},
|
},
|
||||||
"menus": maps.Params{
|
"menus": maps.Params{
|
||||||
"main": []interface{}{
|
"main": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"name": "menu-lang-en-main",
|
"name": "menu-lang-en-main",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"theme": []interface{}{
|
"theme": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"name": "menu-lang-en-theme",
|
"name": "menu-lang-en-theme",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -313,18 +313,18 @@ name = "menu-theme"
|
||||||
"pl2": "p2-nb-theme",
|
"pl2": "p2-nb-theme",
|
||||||
},
|
},
|
||||||
"menus": maps.Params{
|
"menus": maps.Params{
|
||||||
"main": []interface{}{
|
"main": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"name": "menu-lang-nb-main",
|
"name": "menu-lang-nb-main",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"theme": []interface{}{
|
"theme": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"name": "menu-lang-nb-theme",
|
"name": "menu-lang-nb-theme",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"top": []interface{}{
|
"top": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"name": "menu-lang-nb-top",
|
"name": "menu-lang-nb-top",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -399,8 +399,8 @@ name = "menu-theme"
|
||||||
"en": maps.Params{
|
"en": maps.Params{
|
||||||
"languagename": "English",
|
"languagename": "English",
|
||||||
"menus": maps.Params{
|
"menus": maps.Params{
|
||||||
"main": []interface{}{
|
"main": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"name": "menu-theme",
|
"name": "menu-theme",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -710,9 +710,9 @@ theme_param="themevalue2"
|
||||||
c.Assert(cfg.Get("imaging.anchor"), qt.Equals, "top")
|
c.Assert(cfg.Get("imaging.anchor"), qt.Equals, "top")
|
||||||
c.Assert(cfg.Get("imaging.quality"), qt.Equals, int64(75))
|
c.Assert(cfg.Get("imaging.quality"), qt.Equals, int64(75))
|
||||||
c.Assert(cfg.Get("imaging.resamplefilter"), qt.Equals, "CatmullRom")
|
c.Assert(cfg.Get("imaging.resamplefilter"), qt.Equals, "CatmullRom")
|
||||||
c.Assert(cfg.Get("stringSlice"), qt.DeepEquals, []interface{}{"c", "d"})
|
c.Assert(cfg.Get("stringSlice"), qt.DeepEquals, []any{"c", "d"})
|
||||||
c.Assert(cfg.Get("floatSlice"), qt.DeepEquals, []interface{}{5.32})
|
c.Assert(cfg.Get("floatSlice"), qt.DeepEquals, []any{5.32})
|
||||||
c.Assert(cfg.Get("intSlice"), qt.DeepEquals, []interface{}{5, 8, 9})
|
c.Assert(cfg.Get("intSlice"), qt.DeepEquals, []any{5, 8, 9})
|
||||||
c.Assert(cfg.Get("params.api_config.api_key"), qt.Equals, "new_key")
|
c.Assert(cfg.Get("params.api_config.api_key"), qt.Equals, "new_key")
|
||||||
c.Assert(cfg.Get("params.api_config.another_key"), qt.Equals, "default another_key")
|
c.Assert(cfg.Get("params.api_config.another_key"), qt.Equals, "default another_key")
|
||||||
c.Assert(cfg.Get("params.mytheme_section.theme_param"), qt.Equals, "themevalue_changed")
|
c.Assert(cfg.Get("params.mytheme_section.theme_param"), qt.Equals, "themevalue_changed")
|
||||||
|
|
|
@ -119,10 +119,10 @@ p3 = "p3params_no_production"
|
||||||
c.Assert(cfg.GetString("params.p3"), qt.Equals, "p3params_development")
|
c.Assert(cfg.GetString("params.p3"), qt.Equals, "p3params_development")
|
||||||
c.Assert(cfg.GetString("languages.no.params.p3"), qt.Equals, "p3params_no_development")
|
c.Assert(cfg.GetString("languages.no.params.p3"), qt.Equals, "p3params_no_development")
|
||||||
|
|
||||||
c.Assert(len(cfg.Get("menus.docs").([]interface{})), qt.Equals, 2)
|
c.Assert(len(cfg.Get("menus.docs").([]any)), qt.Equals, 2)
|
||||||
noMenus := cfg.Get("languages.no.menus.docs")
|
noMenus := cfg.Get("languages.no.menus.docs")
|
||||||
c.Assert(noMenus, qt.Not(qt.IsNil))
|
c.Assert(noMenus, qt.Not(qt.IsNil))
|
||||||
c.Assert(len(noMenus.([]interface{})), qt.Equals, 1)
|
c.Assert(len(noMenus.([]any)), qt.Equals, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadConfigDirError(t *testing.T) {
|
func TestLoadConfigDirError(t *testing.T) {
|
||||||
|
|
|
@ -83,7 +83,7 @@ func newContentMap(cfg contentMapConfig) *contentMap {
|
||||||
m.sections, m.taxonomies,
|
m.sections, m.taxonomies,
|
||||||
}
|
}
|
||||||
|
|
||||||
addToReverseMap := func(k string, n *contentNode, m map[interface{}]*contentNode) {
|
addToReverseMap := func(k string, n *contentNode, m map[any]*contentNode) {
|
||||||
k = strings.ToLower(k)
|
k = strings.ToLower(k)
|
||||||
existing, found := m[k]
|
existing, found := m[k]
|
||||||
if found && existing != ambiguousContentNode {
|
if found && existing != ambiguousContentNode {
|
||||||
|
@ -96,8 +96,8 @@ func newContentMap(cfg contentMapConfig) *contentMap {
|
||||||
m.pageReverseIndex = &contentTreeReverseIndex{
|
m.pageReverseIndex = &contentTreeReverseIndex{
|
||||||
t: []*contentTree{m.pages, m.sections, m.taxonomies},
|
t: []*contentTree{m.pages, m.sections, m.taxonomies},
|
||||||
contentTreeReverseIndexMap: &contentTreeReverseIndexMap{
|
contentTreeReverseIndexMap: &contentTreeReverseIndexMap{
|
||||||
initFn: func(t *contentTree, m map[interface{}]*contentNode) {
|
initFn: func(t *contentTree, m map[any]*contentNode) {
|
||||||
t.Walk(func(s string, v interface{}) bool {
|
t.Walk(func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
if n.p != nil && !n.p.File().IsZero() {
|
if n.p != nil && !n.p.File().IsZero() {
|
||||||
meta := n.p.File().FileInfo().Meta()
|
meta := n.p.File().FileInfo().Meta()
|
||||||
|
@ -396,7 +396,7 @@ func (m *contentMap) AddFilesBundle(header hugofs.FileMetaInfo, resources ...hug
|
||||||
|
|
||||||
func (m *contentMap) CreateMissingNodes() error {
|
func (m *contentMap) CreateMissingNodes() error {
|
||||||
// Create missing home and root sections
|
// Create missing home and root sections
|
||||||
rootSections := make(map[string]interface{})
|
rootSections := make(map[string]any)
|
||||||
trackRootSection := func(s string, b *contentNode) {
|
trackRootSection := func(s string, b *contentNode) {
|
||||||
parts := strings.Split(s, "/")
|
parts := strings.Split(s, "/")
|
||||||
if len(parts) > 2 {
|
if len(parts) > 2 {
|
||||||
|
@ -409,7 +409,7 @@ func (m *contentMap) CreateMissingNodes() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.sections.Walk(func(s string, v interface{}) bool {
|
m.sections.Walk(func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
|
|
||||||
if s == "/" {
|
if s == "/" {
|
||||||
|
@ -420,7 +420,7 @@ func (m *contentMap) CreateMissingNodes() error {
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
m.pages.Walk(func(s string, v interface{}) bool {
|
m.pages.Walk(func(s string, v any) bool {
|
||||||
trackRootSection(s, v.(*contentNode))
|
trackRootSection(s, v.(*contentNode))
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
@ -614,7 +614,7 @@ func (m *contentMap) deleteBundleMatching(matches func(b *contentNode) bool) {
|
||||||
func (m *contentMap) deleteOrphanSections() {
|
func (m *contentMap) deleteOrphanSections() {
|
||||||
var sectionsToDelete []string
|
var sectionsToDelete []string
|
||||||
|
|
||||||
m.sections.Walk(func(s string, v interface{}) bool {
|
m.sections.Walk(func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
|
|
||||||
if n.fi != nil {
|
if n.fi != nil {
|
||||||
|
@ -658,7 +658,7 @@ func (m *contentMap) deleteSectionByPath(s string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *contentMap) deletePageByPath(s string) {
|
func (m *contentMap) deletePageByPath(s string) {
|
||||||
m.pages.Walk(func(s string, v interface{}) bool {
|
m.pages.Walk(func(s string, v any) bool {
|
||||||
fmt.Println("S", s)
|
fmt.Println("S", s)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
@ -689,14 +689,14 @@ func (m *contentMap) testDump() string {
|
||||||
|
|
||||||
for i, r := range []*contentTree{m.pages, m.sections, m.resources} {
|
for i, r := range []*contentTree{m.pages, m.sections, m.resources} {
|
||||||
sb.WriteString(fmt.Sprintf("Tree %d:\n", i))
|
sb.WriteString(fmt.Sprintf("Tree %d:\n", i))
|
||||||
r.Walk(func(s string, v interface{}) bool {
|
r.Walk(func(s string, v any) bool {
|
||||||
sb.WriteString("\t" + s + "\n")
|
sb.WriteString("\t" + s + "\n")
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, r := range []*contentTree{m.pages, m.sections} {
|
for i, r := range []*contentTree{m.pages, m.sections} {
|
||||||
r.Walk(func(s string, v interface{}) bool {
|
r.Walk(func(s string, v any) bool {
|
||||||
c := v.(*contentNode)
|
c := v.(*contentNode)
|
||||||
cpToString := func(c *contentNode) string {
|
cpToString := func(c *contentNode) string {
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
|
@ -715,13 +715,13 @@ func (m *contentMap) testDump() string {
|
||||||
if i == 1 {
|
if i == 1 {
|
||||||
resourcesPrefix += cmLeafSeparator
|
resourcesPrefix += cmLeafSeparator
|
||||||
|
|
||||||
m.pages.WalkPrefix(s+cmBranchSeparator, func(s string, v interface{}) bool {
|
m.pages.WalkPrefix(s+cmBranchSeparator, func(s string, v any) bool {
|
||||||
sb.WriteString("\t - P: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename) + "\n")
|
sb.WriteString("\t - P: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename) + "\n")
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
m.resources.WalkPrefix(resourcesPrefix, func(s string, v interface{}) bool {
|
m.resources.WalkPrefix(resourcesPrefix, func(s string, v any) bool {
|
||||||
sb.WriteString("\t - R: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename) + "\n")
|
sb.WriteString("\t - R: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename) + "\n")
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
@ -791,7 +791,7 @@ type contentTrees []*contentTree
|
||||||
func (t contentTrees) DeletePrefix(prefix string) int {
|
func (t contentTrees) DeletePrefix(prefix string) int {
|
||||||
var count int
|
var count int
|
||||||
for _, tree := range t {
|
for _, tree := range t {
|
||||||
tree.Walk(func(s string, v interface{}) bool {
|
tree.Walk(func(s string, v any) bool {
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
count += tree.DeletePrefix(prefix)
|
count += tree.DeletePrefix(prefix)
|
||||||
|
@ -836,7 +836,7 @@ func (c *contentTree) WalkQuery(query pageMapQuery, walkFn contentTreeNodeCallba
|
||||||
filter = contentTreeNoListAlwaysFilter
|
filter = contentTreeNoListAlwaysFilter
|
||||||
}
|
}
|
||||||
if query.Prefix != "" {
|
if query.Prefix != "" {
|
||||||
c.WalkBelow(query.Prefix, func(s string, v interface{}) bool {
|
c.WalkBelow(query.Prefix, func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
if filter != nil && filter(s, n) {
|
if filter != nil && filter(s, n) {
|
||||||
return false
|
return false
|
||||||
|
@ -847,7 +847,7 @@ func (c *contentTree) WalkQuery(query pageMapQuery, walkFn contentTreeNodeCallba
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Walk(func(s string, v interface{}) bool {
|
c.Walk(func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
if filter != nil && filter(s, n) {
|
if filter != nil && filter(s, n) {
|
||||||
return false
|
return false
|
||||||
|
@ -872,7 +872,7 @@ func (c contentTrees) WalkLinkable(fn contentTreeNodeCallback) {
|
||||||
|
|
||||||
func (c contentTrees) Walk(fn contentTreeNodeCallback) {
|
func (c contentTrees) Walk(fn contentTreeNodeCallback) {
|
||||||
for _, tree := range c {
|
for _, tree := range c {
|
||||||
tree.Walk(func(s string, v interface{}) bool {
|
tree.Walk(func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
return fn(s, n)
|
return fn(s, n)
|
||||||
})
|
})
|
||||||
|
@ -881,7 +881,7 @@ func (c contentTrees) Walk(fn contentTreeNodeCallback) {
|
||||||
|
|
||||||
func (c contentTrees) WalkPrefix(prefix string, fn contentTreeNodeCallback) {
|
func (c contentTrees) WalkPrefix(prefix string, fn contentTreeNodeCallback) {
|
||||||
for _, tree := range c {
|
for _, tree := range c {
|
||||||
tree.WalkPrefix(prefix, func(s string, v interface{}) bool {
|
tree.WalkPrefix(prefix, func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
return fn(s, n)
|
return fn(s, n)
|
||||||
})
|
})
|
||||||
|
@ -891,7 +891,7 @@ func (c contentTrees) WalkPrefix(prefix string, fn contentTreeNodeCallback) {
|
||||||
// WalkBelow walks the tree below the given prefix, i.e. it skips the
|
// WalkBelow walks the tree below the given prefix, i.e. it skips the
|
||||||
// node with the given prefix as key.
|
// node with the given prefix as key.
|
||||||
func (c *contentTree) WalkBelow(prefix string, fn radix.WalkFn) {
|
func (c *contentTree) WalkBelow(prefix string, fn radix.WalkFn) {
|
||||||
c.Tree.WalkPrefix(prefix, func(s string, v interface{}) bool {
|
c.Tree.WalkPrefix(prefix, func(s string, v any) bool {
|
||||||
if s == prefix {
|
if s == prefix {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -901,7 +901,7 @@ func (c *contentTree) WalkBelow(prefix string, fn radix.WalkFn) {
|
||||||
|
|
||||||
func (c *contentTree) getMatch(matches func(b *contentNode) bool) string {
|
func (c *contentTree) getMatch(matches func(b *contentNode) bool) string {
|
||||||
var match string
|
var match string
|
||||||
c.Walk(func(s string, v interface{}) bool {
|
c.Walk(func(s string, v any) bool {
|
||||||
n, ok := v.(*contentNode)
|
n, ok := v.(*contentNode)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
|
@ -920,7 +920,7 @@ func (c *contentTree) getMatch(matches func(b *contentNode) bool) string {
|
||||||
|
|
||||||
func (c *contentTree) hasBelow(s1 string) bool {
|
func (c *contentTree) hasBelow(s1 string) bool {
|
||||||
var t bool
|
var t bool
|
||||||
c.WalkBelow(s1, func(s2 string, v interface{}) bool {
|
c.WalkBelow(s1, func(s2 string, v any) bool {
|
||||||
t = true
|
t = true
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
@ -928,14 +928,14 @@ func (c *contentTree) hasBelow(s1 string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *contentTree) printKeys() {
|
func (c *contentTree) printKeys() {
|
||||||
c.Walk(func(s string, v interface{}) bool {
|
c.Walk(func(s string, v any) bool {
|
||||||
fmt.Println(s)
|
fmt.Println(s)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *contentTree) printKeysPrefix(prefix string) {
|
func (c *contentTree) printKeysPrefix(prefix string) {
|
||||||
c.WalkPrefix(prefix, func(s string, v interface{}) bool {
|
c.WalkPrefix(prefix, func(s string, v any) bool {
|
||||||
fmt.Println(s)
|
fmt.Println(s)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
@ -1040,9 +1040,9 @@ type contentTreeReverseIndex struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type contentTreeReverseIndexMap struct {
|
type contentTreeReverseIndexMap struct {
|
||||||
m map[interface{}]*contentNode
|
m map[any]*contentNode
|
||||||
init sync.Once
|
init sync.Once
|
||||||
initFn func(*contentTree, map[interface{}]*contentNode)
|
initFn func(*contentTree, map[any]*contentNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *contentTreeReverseIndex) Reset() {
|
func (c *contentTreeReverseIndex) Reset() {
|
||||||
|
@ -1051,9 +1051,9 @@ func (c *contentTreeReverseIndex) Reset() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *contentTreeReverseIndex) Get(key interface{}) *contentNode {
|
func (c *contentTreeReverseIndex) Get(key any) *contentNode {
|
||||||
c.init.Do(func() {
|
c.init.Do(func() {
|
||||||
c.m = make(map[interface{}]*contentNode)
|
c.m = make(map[any]*contentNode)
|
||||||
for _, tree := range c.t {
|
for _, tree := range c.t {
|
||||||
c.initFn(tree, c.m)
|
c.initFn(tree, c.m)
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ func (m *pageMap) createMissingTaxonomyNodes() error {
|
||||||
if m.cfg.taxonomyDisabled {
|
if m.cfg.taxonomyDisabled {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
m.taxonomyEntries.Walk(func(s string, v interface{}) bool {
|
m.taxonomyEntries.Walk(func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
vi := n.viewInfo
|
vi := n.viewInfo
|
||||||
k := cleanSectionTreeKey(vi.name.plural + "/" + vi.termKey)
|
k := cleanSectionTreeKey(vi.name.plural + "/" + vi.termKey)
|
||||||
|
@ -174,7 +174,7 @@ func (m *pageMap) newPageFromContentNode(n *contentNode, parentBucket *pagesMapB
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.init.Add(func() (interface{}, error) {
|
ps.init.Add(func() (any, error) {
|
||||||
pp, err := newPagePaths(s, ps, metaProvider)
|
pp, err := newPagePaths(s, ps, metaProvider)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -271,7 +271,7 @@ func (m *pageMap) newResource(fim hugofs.FileMetaInfo, owner *pageState) (resour
|
||||||
func (m *pageMap) createSiteTaxonomies() error {
|
func (m *pageMap) createSiteTaxonomies() error {
|
||||||
m.s.taxonomies = make(TaxonomyList)
|
m.s.taxonomies = make(TaxonomyList)
|
||||||
var walkErr error
|
var walkErr error
|
||||||
m.taxonomies.Walk(func(s string, v interface{}) bool {
|
m.taxonomies.Walk(func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
t := n.viewInfo
|
t := n.viewInfo
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ func (m *pageMap) createSiteTaxonomies() error {
|
||||||
walkErr = errors.Errorf("missing taxonomy: %s", viewName.plural)
|
walkErr = errors.Errorf("missing taxonomy: %s", viewName.plural)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
m.taxonomyEntries.WalkPrefix(s, func(ss string, v interface{}) bool {
|
m.taxonomyEntries.WalkPrefix(s, func(ss string, v any) bool {
|
||||||
b2 := v.(*contentNode)
|
b2 := v.(*contentNode)
|
||||||
info := b2.viewInfo
|
info := b2.viewInfo
|
||||||
taxonomy.add(info.termKey, page.NewWeightedPage(info.weight, info.ref.p, n.p))
|
taxonomy.add(info.termKey, page.NewWeightedPage(info.weight, info.ref.p, n.p))
|
||||||
|
@ -337,7 +337,7 @@ func (m *pageMap) assemblePages() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
m.pages.Walk(func(s string, v interface{}) bool {
|
m.pages.Walk(func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
|
|
||||||
var shouldBuild bool
|
var shouldBuild bool
|
||||||
|
@ -397,7 +397,7 @@ func (m *pageMap) assemblePages() error {
|
||||||
func (m *pageMap) assembleResources(s string, p *pageState, parentBucket *pagesMapBucket) error {
|
func (m *pageMap) assembleResources(s string, p *pageState, parentBucket *pagesMapBucket) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
m.resources.WalkPrefix(s, func(s string, v interface{}) bool {
|
m.resources.WalkPrefix(s, func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
meta := n.fi.Meta()
|
meta := n.fi.Meta()
|
||||||
classifier := meta.Classifier
|
classifier := meta.Classifier
|
||||||
|
@ -432,7 +432,7 @@ func (m *pageMap) assembleSections() error {
|
||||||
var sectionsToDelete []string
|
var sectionsToDelete []string
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
m.sections.Walk(func(s string, v interface{}) bool {
|
m.sections.Walk(func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
var shouldBuild bool
|
var shouldBuild bool
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ func (m *pageMap) assembleTaxonomies() error {
|
||||||
var taxonomiesToDelete []string
|
var taxonomiesToDelete []string
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
m.taxonomies.Walk(func(s string, v interface{}) bool {
|
m.taxonomies.Walk(func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
|
|
||||||
if n.p != nil {
|
if n.p != nil {
|
||||||
|
@ -861,7 +861,7 @@ func (b *pagesMapBucket) getTaxonomyEntries() page.Pages {
|
||||||
ref := b.owner.treeRef
|
ref := b.owner.treeRef
|
||||||
viewInfo := ref.n.viewInfo
|
viewInfo := ref.n.viewInfo
|
||||||
prefix := strings.ToLower("/" + viewInfo.name.plural + "/" + viewInfo.termKey + "/")
|
prefix := strings.ToLower("/" + viewInfo.name.plural + "/" + viewInfo.termKey + "/")
|
||||||
ref.m.taxonomyEntries.WalkPrefix(prefix, func(s string, v interface{}) bool {
|
ref.m.taxonomyEntries.WalkPrefix(prefix, func(s string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
pas = append(pas, n.viewInfo.ref.p)
|
pas = append(pas, n.viewInfo.ref.p)
|
||||||
return false
|
return false
|
||||||
|
@ -967,7 +967,7 @@ func (w *sectionWalker) walkLevel(prefix string, createVisitor func() sectionWal
|
||||||
|
|
||||||
visitor := createVisitor()
|
visitor := createVisitor()
|
||||||
|
|
||||||
w.m.taxonomies.WalkBelow(prefix, func(s string, v interface{}) bool {
|
w.m.taxonomies.WalkBelow(prefix, func(s string, v any) bool {
|
||||||
currentLevel := strings.Count(s, "/")
|
currentLevel := strings.Count(s, "/")
|
||||||
|
|
||||||
if currentLevel > level+1 {
|
if currentLevel > level+1 {
|
||||||
|
@ -986,7 +986,7 @@ func (w *sectionWalker) walkLevel(prefix string, createVisitor func() sectionWal
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
w.m.taxonomyEntries.WalkPrefix(s, func(ss string, v interface{}) bool {
|
w.m.taxonomyEntries.WalkPrefix(s, func(ss string, v any) bool {
|
||||||
n := v.(*contentNode)
|
n := v.(*contentNode)
|
||||||
w.err = visitor.handlePage(ss, n)
|
w.err = visitor.handlePage(ss, n)
|
||||||
return w.err != nil
|
return w.err != nil
|
||||||
|
@ -998,7 +998,7 @@ func (w *sectionWalker) walkLevel(prefix string, createVisitor func() sectionWal
|
||||||
return w.err != nil
|
return w.err != nil
|
||||||
})
|
})
|
||||||
|
|
||||||
w.m.sections.WalkBelow(prefix, func(s string, v interface{}) bool {
|
w.m.sections.WalkBelow(prefix, func(s string, v any) bool {
|
||||||
currentLevel := strings.Count(s, "/")
|
currentLevel := strings.Count(s, "/")
|
||||||
if currentLevel > level+1 {
|
if currentLevel > level+1 {
|
||||||
return false
|
return false
|
||||||
|
@ -1010,7 +1010,7 @@ func (w *sectionWalker) walkLevel(prefix string, createVisitor func() sectionWal
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
w.m.pages.WalkPrefix(s+cmBranchSeparator, func(s string, v interface{}) bool {
|
w.m.pages.WalkPrefix(s+cmBranchSeparator, func(s string, v any) bool {
|
||||||
w.err = visitor.handlePage(s, v.(*contentNode))
|
w.err = visitor.handlePage(s, v.(*contentNode))
|
||||||
return w.err != nil
|
return w.err != nil
|
||||||
})
|
})
|
||||||
|
|
|
@ -33,10 +33,10 @@ func TestDataDir(t *testing.T) {
|
||||||
equivDataDirs[0].addSource("data/test/a.json", `{ "b" : { "c1": "red" , "c2": "blue" } }`)
|
equivDataDirs[0].addSource("data/test/a.json", `{ "b" : { "c1": "red" , "c2": "blue" } }`)
|
||||||
equivDataDirs[1].addSource("data/test/a.yaml", "b:\n c1: red\n c2: blue")
|
equivDataDirs[1].addSource("data/test/a.yaml", "b:\n c1: red\n c2: blue")
|
||||||
equivDataDirs[2].addSource("data/test/a.toml", "[b]\nc1 = \"red\"\nc2 = \"blue\"\n")
|
equivDataDirs[2].addSource("data/test/a.toml", "[b]\nc1 = \"red\"\nc2 = \"blue\"\n")
|
||||||
expected := map[string]interface{}{
|
expected := map[string]any{
|
||||||
"test": map[string]interface{}{
|
"test": map[string]any{
|
||||||
"a": map[string]interface{}{
|
"a": map[string]any{
|
||||||
"b": map[string]interface{}{
|
"b": map[string]any{
|
||||||
"c1": "red",
|
"c1": "red",
|
||||||
"c2": "blue",
|
"c2": "blue",
|
||||||
},
|
},
|
||||||
|
@ -56,10 +56,10 @@ func TestDataDirNumeric(t *testing.T) {
|
||||||
equivDataDirs[0].addSource("data/test/a.json", `{ "b" : { "c1": 1.7 , "c2": 2.9 } }`)
|
equivDataDirs[0].addSource("data/test/a.json", `{ "b" : { "c1": 1.7 , "c2": 2.9 } }`)
|
||||||
equivDataDirs[1].addSource("data/test/a.yaml", "b:\n c1: 1.7\n c2: 2.9")
|
equivDataDirs[1].addSource("data/test/a.yaml", "b:\n c1: 1.7\n c2: 2.9")
|
||||||
equivDataDirs[2].addSource("data/test/a.toml", "[b]\nc1 = 1.7\nc2 = 2.9\n")
|
equivDataDirs[2].addSource("data/test/a.toml", "[b]\nc1 = 1.7\nc2 = 2.9\n")
|
||||||
expected := map[string]interface{}{
|
expected := map[string]any{
|
||||||
"test": map[string]interface{}{
|
"test": map[string]any{
|
||||||
"a": map[string]interface{}{
|
"a": map[string]any{
|
||||||
"b": map[string]interface{}{
|
"b": map[string]any{
|
||||||
"c1": 1.7,
|
"c1": 1.7,
|
||||||
"c2": 2.9,
|
"c2": 2.9,
|
||||||
},
|
},
|
||||||
|
@ -75,10 +75,10 @@ func TestDataDirBoolean(t *testing.T) {
|
||||||
equivDataDirs[0].addSource("data/test/a.json", `{ "b" : { "c1": true , "c2": false } }`)
|
equivDataDirs[0].addSource("data/test/a.json", `{ "b" : { "c1": true , "c2": false } }`)
|
||||||
equivDataDirs[1].addSource("data/test/a.yaml", "b:\n c1: true\n c2: false")
|
equivDataDirs[1].addSource("data/test/a.yaml", "b:\n c1: true\n c2: false")
|
||||||
equivDataDirs[2].addSource("data/test/a.toml", "[b]\nc1 = true\nc2 = false\n")
|
equivDataDirs[2].addSource("data/test/a.toml", "[b]\nc1 = true\nc2 = false\n")
|
||||||
expected := map[string]interface{}{
|
expected := map[string]any{
|
||||||
"test": map[string]interface{}{
|
"test": map[string]any{
|
||||||
"a": map[string]interface{}{
|
"a": map[string]any{
|
||||||
"b": map[string]interface{}{
|
"b": map[string]any{
|
||||||
"c1": true,
|
"c1": true,
|
||||||
"c2": false,
|
"c2": false,
|
||||||
},
|
},
|
||||||
|
@ -102,13 +102,13 @@ func TestDataDirTwoFiles(t *testing.T) {
|
||||||
equivDataDirs[2].addSource("data/test.toml", "hello = [\"world\", \"foo\"]")
|
equivDataDirs[2].addSource("data/test.toml", "hello = [\"world\", \"foo\"]")
|
||||||
|
|
||||||
expected :=
|
expected :=
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"test": map[string]interface{}{
|
"test": map[string]any{
|
||||||
"hello": []interface{}{
|
"hello": []any{
|
||||||
"world",
|
"world",
|
||||||
"foo",
|
"foo",
|
||||||
},
|
},
|
||||||
"foo": map[string]interface{}{
|
"foo": map[string]any{
|
||||||
"bar": "foofoo",
|
"bar": "foofoo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -138,11 +138,11 @@ func TestDataDirOverriddenValue(t *testing.T) {
|
||||||
equivDataDirs[2].addSource("data/test.toml", "v1 = \"1\"")
|
equivDataDirs[2].addSource("data/test.toml", "v1 = \"1\"")
|
||||||
|
|
||||||
expected :=
|
expected :=
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"a": map[string]interface{}{"a": "1"},
|
"a": map[string]any{"a": "1"},
|
||||||
"test": map[string]interface{}{
|
"test": map[string]any{
|
||||||
"v1": map[string]interface{}{"v1-2": "2"},
|
"v1": map[string]any{"v1-2": "2"},
|
||||||
"v2": map[string]interface{}{"v2": []interface{}{"2", "3"}},
|
"v2": map[string]any{"v2": []any{"2", "3"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,11 +162,11 @@ func TestDataDirArrayAtTopLevelOfFile(t *testing.T) {
|
||||||
`)
|
`)
|
||||||
|
|
||||||
expected :=
|
expected :=
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"test": []interface{}{
|
"test": []any{
|
||||||
map[string]interface{}{"hello": "world"},
|
map[string]any{"hello": "world"},
|
||||||
map[string]interface{}{"what": "time"},
|
map[string]any{"what": "time"},
|
||||||
map[string]interface{}{"is": "lunch?"},
|
map[string]any{"is": "lunch?"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,12 +183,12 @@ func TestDataDirMultipleSources(t *testing.T) {
|
||||||
dd.addSource("data/test/second.yaml", "tender: 2")
|
dd.addSource("data/test/second.yaml", "tender: 2")
|
||||||
|
|
||||||
expected :=
|
expected :=
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"test": map[string]interface{}{
|
"test": map[string]any{
|
||||||
"first": map[string]interface{}{
|
"first": map[string]any{
|
||||||
"bar": 1,
|
"bar": 1,
|
||||||
},
|
},
|
||||||
"second": map[string]interface{}{
|
"second": map[string]any{
|
||||||
"tender": 2,
|
"tender": 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -213,14 +213,14 @@ func TestDataDirMultipleSourcesCommingled(t *testing.T) {
|
||||||
// 1. A theme uses the same key; the main data folder wins
|
// 1. A theme uses the same key; the main data folder wins
|
||||||
// 2. A sub folder uses the same key: the sub folder wins
|
// 2. A sub folder uses the same key: the sub folder wins
|
||||||
expected :=
|
expected :=
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"a": map[string]interface{}{
|
"a": map[string]any{
|
||||||
"b1": map[string]interface{}{
|
"b1": map[string]any{
|
||||||
"c1": "data/a/b1",
|
"c1": "data/a/b1",
|
||||||
"c2": "mytheme/data/a/b1",
|
"c2": "mytheme/data/a/b1",
|
||||||
},
|
},
|
||||||
"b2": "data/a",
|
"b2": "data/a",
|
||||||
"b3": []interface{}{"x", "y", "z"},
|
"b3": []any{"x", "y", "z"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,10 +239,10 @@ func TestDataDirCollidingChildArrays(t *testing.T) {
|
||||||
// 1. A theme uses the same key; the main data folder wins
|
// 1. A theme uses the same key; the main data folder wins
|
||||||
// 2. A sub folder uses the same key: the sub folder wins
|
// 2. A sub folder uses the same key: the sub folder wins
|
||||||
expected :=
|
expected :=
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"a": map[string]interface{}{
|
"a": map[string]any{
|
||||||
"b1": "data/a",
|
"b1": "data/a",
|
||||||
"b2": []interface{}{"1", "2", "3"},
|
"b2": []any{"1", "2", "3"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,9 +257,9 @@ func TestDataDirCollidingTopLevelArrays(t *testing.T) {
|
||||||
dd.addSource("data/a/b1.json", `["1", "2", "3"]`)
|
dd.addSource("data/a/b1.json", `["1", "2", "3"]`)
|
||||||
|
|
||||||
expected :=
|
expected :=
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"a": map[string]interface{}{
|
"a": map[string]any{
|
||||||
"b1": []interface{}{"1", "2", "3"},
|
"b1": []any{"1", "2", "3"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,11 +277,11 @@ func TestDataDirCollidingMapsAndArrays(t *testing.T) {
|
||||||
dd.addSource("data/b.json", `["x", "y", "z"]`)
|
dd.addSource("data/b.json", `["x", "y", "z"]`)
|
||||||
|
|
||||||
expected :=
|
expected :=
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"a": map[string]interface{}{
|
"a": map[string]any{
|
||||||
"music": "Queen's Rebuke",
|
"music": "Queen's Rebuke",
|
||||||
},
|
},
|
||||||
"b": []interface{}{"x", "y", "z"},
|
"b": []any{"x", "y", "z"},
|
||||||
}
|
}
|
||||||
|
|
||||||
doTestDataDir(t, dd, expected, "theme", "mytheme")
|
doTestDataDir(t, dd, expected, "theme", "mytheme")
|
||||||
|
@ -297,9 +297,9 @@ func TestDataDirNestedDirectories(t *testing.T) {
|
||||||
dd.addSource("data/test1/20/05/b.json", `{ "artist" : "Charlie Parker" }`)
|
dd.addSource("data/test1/20/05/b.json", `{ "artist" : "Charlie Parker" }`)
|
||||||
|
|
||||||
expected :=
|
expected :=
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"a": []interface{}{"1", "2", "3"},
|
"a": []any{"1", "2", "3"},
|
||||||
"test1": map[string]interface{}{"20": map[string]interface{}{"05": map[string]interface{}{"b": map[string]interface{}{"artist": "Charlie Parker"}}, "06": map[string]interface{}{"a": map[string]interface{}{"artist": "Michael Brecker"}}}},
|
"test1": map[string]any{"20": map[string]any{"05": map[string]any{"b": map[string]any{"artist": "Charlie Parker"}}, "06": map[string]any{"a": map[string]any{"artist": "Michael Brecker"}}}},
|
||||||
}
|
}
|
||||||
|
|
||||||
doTestDataDir(t, dd, expected, "theme", "mytheme")
|
doTestDataDir(t, dd, expected, "theme", "mytheme")
|
||||||
|
@ -313,7 +313,7 @@ func (d *dataDir) addSource(path, content string) {
|
||||||
d.sources = append(d.sources, [2]string{path, content})
|
d.sources = append(d.sources, [2]string{path, content})
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTestEquivalentDataDirs(t *testing.T, equivDataDirs []dataDir, expected interface{}, configKeyValues ...interface{}) {
|
func doTestEquivalentDataDirs(t *testing.T, equivDataDirs []dataDir, expected any, configKeyValues ...any) {
|
||||||
for i, dd := range equivDataDirs {
|
for i, dd := range equivDataDirs {
|
||||||
err := doTestDataDirImpl(t, dd, expected, configKeyValues...)
|
err := doTestDataDirImpl(t, dd, expected, configKeyValues...)
|
||||||
if err != "" {
|
if err != "" {
|
||||||
|
@ -322,14 +322,14 @@ func doTestEquivalentDataDirs(t *testing.T, equivDataDirs []dataDir, expected in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTestDataDir(t *testing.T, dd dataDir, expected interface{}, configKeyValues ...interface{}) {
|
func doTestDataDir(t *testing.T, dd dataDir, expected any, configKeyValues ...any) {
|
||||||
err := doTestDataDirImpl(t, dd, expected, configKeyValues...)
|
err := doTestDataDirImpl(t, dd, expected, configKeyValues...)
|
||||||
if err != "" {
|
if err != "" {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTestDataDirImpl(t *testing.T, dd dataDir, expected interface{}, configKeyValues ...interface{}) (err string) {
|
func doTestDataDirImpl(t *testing.T, dd dataDir, expected any, configKeyValues ...any) (err string) {
|
||||||
cfg, fs := newTestCfg()
|
cfg, fs := newTestCfg()
|
||||||
|
|
||||||
for i := 0; i < len(configKeyValues); i += 2 {
|
for i := 0; i < len(configKeyValues); i += 2 {
|
||||||
|
|
|
@ -294,12 +294,12 @@ func TestShortcodeTweet(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
for i, this := range []struct {
|
for i, this := range []struct {
|
||||||
privacy map[string]interface{}
|
privacy map[string]any
|
||||||
in, resp, expected string
|
in, resp, expected string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"twitter": map[string]interface{}{
|
"twitter": map[string]any{
|
||||||
"simple": true,
|
"simple": true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -308,8 +308,8 @@ func TestShortcodeTweet(t *testing.T) {
|
||||||
`.twitter-tweet a`,
|
`.twitter-tweet a`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"twitter": map[string]interface{}{
|
"twitter": map[string]any{
|
||||||
"simple": false,
|
"simple": false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -318,8 +318,8 @@ func TestShortcodeTweet(t *testing.T) {
|
||||||
`(?s)<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Hugo 0.15 will have 30%\+ faster render times thanks to this commit <a href="https://t.co/FfzhM8bNhT">https://t.co/FfzhM8bNhT</a> <a href="https://twitter.com/hashtag/gohugo\?src=hash&ref_src=twsrc%5Etfw">#gohugo</a> <a href="https://twitter.com/hashtag/golang\?src=hash&ref_src=twsrc%5Etfw">#golang</a> <a href="https://t.co/ITbMNU2BUf">https://t.co/ITbMNU2BUf</a></p>— Steve Francia \(@spf13\) <a href="https://twitter.com/spf13/status/666616452582129664\?ref_src=twsrc%5Etfw">November 17, 2015</a></blockquote>\s*<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>`,
|
`(?s)<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Hugo 0.15 will have 30%\+ faster render times thanks to this commit <a href="https://t.co/FfzhM8bNhT">https://t.co/FfzhM8bNhT</a> <a href="https://twitter.com/hashtag/gohugo\?src=hash&ref_src=twsrc%5Etfw">#gohugo</a> <a href="https://twitter.com/hashtag/golang\?src=hash&ref_src=twsrc%5Etfw">#golang</a> <a href="https://t.co/ITbMNU2BUf">https://t.co/ITbMNU2BUf</a></p>— Steve Francia \(@spf13\) <a href="https://twitter.com/spf13/status/666616452582129664\?ref_src=twsrc%5Etfw">November 17, 2015</a></blockquote>\s*<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"twitter": map[string]interface{}{
|
"twitter": map[string]any{
|
||||||
"simple": false,
|
"simple": false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -330,8 +330,8 @@ func TestShortcodeTweet(t *testing.T) {
|
||||||
} {
|
} {
|
||||||
// overload getJSON to return mock API response from Twitter
|
// overload getJSON to return mock API response from Twitter
|
||||||
tweetFuncMap := template.FuncMap{
|
tweetFuncMap := template.FuncMap{
|
||||||
"getJSON": func(urlParts ...interface{}) interface{} {
|
"getJSON": func(urlParts ...any) any {
|
||||||
var v interface{}
|
var v any
|
||||||
err := json.Unmarshal([]byte(this.resp), &v)
|
err := json.Unmarshal([]byte(this.resp), &v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("[%d] unexpected error in json.Unmarshal: %s", i, err)
|
t.Fatalf("[%d] unexpected error in json.Unmarshal: %s", i, err)
|
||||||
|
@ -382,13 +382,13 @@ func TestShortcodeInstagram(t *testing.T) {
|
||||||
} {
|
} {
|
||||||
// overload getJSON to return mock API response from Instagram
|
// overload getJSON to return mock API response from Instagram
|
||||||
instagramFuncMap := template.FuncMap{
|
instagramFuncMap := template.FuncMap{
|
||||||
"getJSON": func(args ...interface{}) interface{} {
|
"getJSON": func(args ...any) any {
|
||||||
headers := args[len(args)-1].(map[string]interface{})
|
headers := args[len(args)-1].(map[string]any)
|
||||||
auth := headers["Authorization"]
|
auth := headers["Authorization"]
|
||||||
if auth != "Bearer dummytoken" {
|
if auth != "Bearer dummytoken" {
|
||||||
return fmt.Errorf("invalid access token: %q", auth)
|
return fmt.Errorf("invalid access token: %q", auth)
|
||||||
}
|
}
|
||||||
var v interface{}
|
var v any
|
||||||
err := json.Unmarshal([]byte(this.resp), &v)
|
err := json.Unmarshal([]byte(this.resp), &v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("[%d] unexpected error in json.Unmarshal: %s", i, err)
|
return fmt.Errorf("[%d] unexpected error in json.Unmarshal: %s", i, err)
|
||||||
|
|
|
@ -314,12 +314,12 @@ func TestStaticFsMultiHost(t *testing.T) {
|
||||||
v.Set("theme", "t1")
|
v.Set("theme", "t1")
|
||||||
v.Set("defaultContentLanguage", "en")
|
v.Set("defaultContentLanguage", "en")
|
||||||
|
|
||||||
langConfig := map[string]interface{}{
|
langConfig := map[string]any{
|
||||||
"no": map[string]interface{}{
|
"no": map[string]any{
|
||||||
"staticDir": "static_no",
|
"staticDir": "static_no",
|
||||||
"baseURL": "https://example.org/no/",
|
"baseURL": "https://example.org/no/",
|
||||||
},
|
},
|
||||||
"en": map[string]interface{}{
|
"en": map[string]any{
|
||||||
"baseURL": "https://example.org/en/",
|
"baseURL": "https://example.org/en/",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -362,17 +362,17 @@ func TestMakePathRelative(t *testing.T) {
|
||||||
c.Assert(fs.Source.MkdirAll(filepath.Join(workDir, "static", "d2"), 0777), qt.IsNil)
|
c.Assert(fs.Source.MkdirAll(filepath.Join(workDir, "static", "d2"), 0777), qt.IsNil)
|
||||||
c.Assert(fs.Source.MkdirAll(filepath.Join(workDir, "dust", "d2"), 0777), qt.IsNil)
|
c.Assert(fs.Source.MkdirAll(filepath.Join(workDir, "dust", "d2"), 0777), qt.IsNil)
|
||||||
|
|
||||||
moduleCfg := map[string]interface{}{
|
moduleCfg := map[string]any{
|
||||||
"mounts": []interface{}{
|
"mounts": []any{
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"source": "dist",
|
"source": "dist",
|
||||||
"target": "static/mydist",
|
"target": "static/mydist",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"source": "dust",
|
"source": "dust",
|
||||||
"target": "static/foo/bar",
|
"target": "static/foo/bar",
|
||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]any{
|
||||||
"source": "static",
|
"source": "static",
|
||||||
"target": "static",
|
"target": "static",
|
||||||
},
|
},
|
||||||
|
|
|
@ -79,7 +79,7 @@ type HugoSites struct {
|
||||||
codeownerInfo *codeownerInfo
|
codeownerInfo *codeownerInfo
|
||||||
|
|
||||||
// As loaded from the /data dirs
|
// As loaded from the /data dirs
|
||||||
data map[string]interface{}
|
data map[string]any
|
||||||
|
|
||||||
contentInit sync.Once
|
contentInit sync.Once
|
||||||
content *pageMaps
|
content *pageMaps
|
||||||
|
@ -189,7 +189,7 @@ func (h *hugoSitesInit) Reset() {
|
||||||
h.translations.Reset()
|
h.translations.Reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HugoSites) Data() map[string]interface{} {
|
func (h *HugoSites) Data() map[string]any {
|
||||||
if _, err := h.init.data.Do(); err != nil {
|
if _, err := h.init.data.Do(); err != nil {
|
||||||
h.SendError(errors.Wrap(err, "failed to load data"))
|
h.SendError(errors.Wrap(err, "failed to load data"))
|
||||||
return nil
|
return nil
|
||||||
|
@ -359,7 +359,7 @@ func newHugoSites(cfg deps.DepsCfg, sites ...*Site) (*HugoSites, error) {
|
||||||
donec: make(chan bool),
|
donec: make(chan bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
h.init.data.Add(func() (interface{}, error) {
|
h.init.data.Add(func() (any, error) {
|
||||||
err := h.loadData(h.PathSpec.BaseFs.Data.Dirs)
|
err := h.loadData(h.PathSpec.BaseFs.Data.Dirs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to load data")
|
return nil, errors.Wrap(err, "failed to load data")
|
||||||
|
@ -367,7 +367,7 @@ func newHugoSites(cfg deps.DepsCfg, sites ...*Site) (*HugoSites, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
h.init.layouts.Add(func() (interface{}, error) {
|
h.init.layouts.Add(func() (any, error) {
|
||||||
for _, s := range h.Sites {
|
for _, s := range h.Sites {
|
||||||
if err := s.Tmpl().(tpl.TemplateManager).MarkReady(); err != nil {
|
if err := s.Tmpl().(tpl.TemplateManager).MarkReady(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -376,7 +376,7 @@ func newHugoSites(cfg deps.DepsCfg, sites ...*Site) (*HugoSites, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
h.init.translations.Add(func() (interface{}, error) {
|
h.init.translations.Add(func() (any, error) {
|
||||||
if len(h.Sites) > 1 {
|
if len(h.Sites) > 1 {
|
||||||
allTranslations := pagesToTranslationsMap(h.Sites)
|
allTranslations := pagesToTranslationsMap(h.Sites)
|
||||||
assignTranslationsToPages(allTranslations, h.Sites)
|
assignTranslationsToPages(allTranslations, h.Sites)
|
||||||
|
@ -385,7 +385,7 @@ func newHugoSites(cfg deps.DepsCfg, sites ...*Site) (*HugoSites, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
h.init.gitInfo.Add(func() (interface{}, error) {
|
h.init.gitInfo.Add(func() (any, error) {
|
||||||
err := h.loadGitInfo()
|
err := h.loadGitInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to load Git info")
|
return nil, errors.Wrap(err, "failed to load Git info")
|
||||||
|
@ -857,7 +857,7 @@ func (h *HugoSites) Pages() page.Pages {
|
||||||
func (h *HugoSites) loadData(fis []hugofs.FileMetaInfo) (err error) {
|
func (h *HugoSites) loadData(fis []hugofs.FileMetaInfo) (err error) {
|
||||||
spec := source.NewSourceSpec(h.PathSpec, nil, nil)
|
spec := source.NewSourceSpec(h.PathSpec, nil, nil)
|
||||||
|
|
||||||
h.data = make(map[string]interface{})
|
h.data = make(map[string]any)
|
||||||
for _, fi := range fis {
|
for _, fi := range fis {
|
||||||
fileSystem := spec.NewFilesystemFromFileMetaInfo(fi)
|
fileSystem := spec.NewFilesystemFromFileMetaInfo(fi)
|
||||||
files, err := fileSystem.Files()
|
files, err := fileSystem.Files()
|
||||||
|
@ -875,7 +875,7 @@ func (h *HugoSites) loadData(fis []hugofs.FileMetaInfo) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HugoSites) handleDataFile(r source.File) error {
|
func (h *HugoSites) handleDataFile(r source.File) error {
|
||||||
var current map[string]interface{}
|
var current map[string]any
|
||||||
|
|
||||||
f, err := r.FileInfo().Meta().Open()
|
f, err := r.FileInfo().Meta().Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -890,9 +890,9 @@ func (h *HugoSites) handleDataFile(r source.File) error {
|
||||||
for _, key := range keyParts {
|
for _, key := range keyParts {
|
||||||
if key != "" {
|
if key != "" {
|
||||||
if _, ok := current[key]; !ok {
|
if _, ok := current[key]; !ok {
|
||||||
current[key] = make(map[string]interface{})
|
current[key] = make(map[string]any)
|
||||||
}
|
}
|
||||||
current = current[key].(map[string]interface{})
|
current = current[key].(map[string]any)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,16 +910,16 @@ func (h *HugoSites) handleDataFile(r source.File) error {
|
||||||
|
|
||||||
switch data.(type) {
|
switch data.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
case map[string]interface{}:
|
case map[string]any:
|
||||||
|
|
||||||
switch higherPrecedentData.(type) {
|
switch higherPrecedentData.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
current[r.BaseFileName()] = data
|
current[r.BaseFileName()] = data
|
||||||
case map[string]interface{}:
|
case map[string]any:
|
||||||
// merge maps: insert entries from data for keys that
|
// merge maps: insert entries from data for keys that
|
||||||
// don't already exist in higherPrecedentData
|
// don't already exist in higherPrecedentData
|
||||||
higherPrecedentMap := higherPrecedentData.(map[string]interface{})
|
higherPrecedentMap := higherPrecedentData.(map[string]any)
|
||||||
for key, value := range data.(map[string]interface{}) {
|
for key, value := range data.(map[string]any) {
|
||||||
if _, exists := higherPrecedentMap[key]; exists {
|
if _, exists := higherPrecedentMap[key]; exists {
|
||||||
// this warning could happen if
|
// this warning could happen if
|
||||||
// 1. A theme uses the same key; the main data folder wins
|
// 1. A theme uses the same key; the main data folder wins
|
||||||
|
@ -936,7 +936,7 @@ func (h *HugoSites) handleDataFile(r source.File) error {
|
||||||
"higher precedence %T data already in the data tree", data, r.Path(), higherPrecedentData)
|
"higher precedence %T data already in the data tree", data, r.Path(), higherPrecedentData)
|
||||||
}
|
}
|
||||||
|
|
||||||
case []interface{}:
|
case []any:
|
||||||
if higherPrecedentData == nil {
|
if higherPrecedentData == nil {
|
||||||
current[r.BaseFileName()] = data
|
current[r.BaseFileName()] = data
|
||||||
} else {
|
} else {
|
||||||
|
@ -970,7 +970,7 @@ func (h *HugoSites) errWithFileContext(err error, f source.File) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HugoSites) readData(f source.File) (interface{}, error) {
|
func (h *HugoSites) readData(f source.File) (any, error) {
|
||||||
file, err := f.FileInfo().Meta().Open()
|
file, err := f.FileInfo().Meta().Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "readData: failed to open data file")
|
return nil, errors.Wrap(err, "readData: failed to open data file")
|
||||||
|
|
|
@ -28,7 +28,7 @@ func TestMultiSitesMainLangInRoot(t *testing.T) {
|
||||||
func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
|
func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
|
||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
siteConfig := map[string]interface{}{
|
siteConfig := map[string]any{
|
||||||
"DefaultContentLanguage": "fr",
|
"DefaultContentLanguage": "fr",
|
||||||
"DefaultContentLanguageInSubdir": defaultInSubDir,
|
"DefaultContentLanguageInSubdir": defaultInSubDir,
|
||||||
}
|
}
|
||||||
|
@ -1235,7 +1235,7 @@ func writeNewContentFile(t *testing.T, fs afero.Fs, title, date, filename string
|
||||||
}
|
}
|
||||||
|
|
||||||
type multiSiteTestBuilder struct {
|
type multiSiteTestBuilder struct {
|
||||||
configData interface{}
|
configData any
|
||||||
config string
|
config string
|
||||||
configFormat string
|
configFormat string
|
||||||
|
|
||||||
|
@ -1251,14 +1251,14 @@ func (b *multiSiteTestBuilder) WithNewConfig(config string) *multiSiteTestBuilde
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *multiSiteTestBuilder) WithNewConfigData(data interface{}) *multiSiteTestBuilder {
|
func (b *multiSiteTestBuilder) WithNewConfigData(data any) *multiSiteTestBuilder {
|
||||||
b.WithConfigTemplate(data, b.configFormat, b.config)
|
b.WithConfigTemplate(data, b.configFormat, b.config)
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMultiSiteTestBuilder(t testing.TB, configFormat, config string, configData interface{}) *multiSiteTestBuilder {
|
func newMultiSiteTestBuilder(t testing.TB, configFormat, config string, configData any) *multiSiteTestBuilder {
|
||||||
if configData == nil {
|
if configData == nil {
|
||||||
configData = map[string]interface{}{
|
configData = map[string]any{
|
||||||
"DefaultContentLanguage": "fr",
|
"DefaultContentLanguage": "fr",
|
||||||
"DefaultContentLanguageInSubdir": true,
|
"DefaultContentLanguageInSubdir": true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func TestImageOps(t *testing.T) {
|
||||||
c.Assert(err, qt.IsNil)
|
c.Assert(err, qt.IsNil)
|
||||||
defer clean()
|
defer clean()
|
||||||
|
|
||||||
newBuilder := func(timeout interface{}) *sitesBuilder {
|
newBuilder := func(timeout any) *sitesBuilder {
|
||||||
v := config.New()
|
v := config.New()
|
||||||
v.Set("workingDir", workDir)
|
v.Set("workingDir", workDir)
|
||||||
v.Set("baseURL", "https://example.org")
|
v.Set("baseURL", "https://example.org")
|
||||||
|
|
|
@ -251,7 +251,7 @@ Content.
|
||||||
c.Assert(contentStr, qt.Contains, "SVP3-RELREF: /sv/sect/p-sv-3/")
|
c.Assert(contentStr, qt.Contains, "SVP3-RELREF: /sv/sect/p-sv-3/")
|
||||||
|
|
||||||
// Test RelRef with and without language indicator.
|
// Test RelRef with and without language indicator.
|
||||||
nn3RefArgs := map[string]interface{}{
|
nn3RefArgs := map[string]any{
|
||||||
"path": "/sect/page3.md",
|
"path": "/sect/page3.md",
|
||||||
"lang": "nn",
|
"lang": "nn",
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ type pageContext interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrapErr adds some context to the given error if possible.
|
// wrapErr adds some context to the given error if possible.
|
||||||
func wrapErr(err error, ctx interface{}) error {
|
func wrapErr(err error, ctx any) error {
|
||||||
if pc, ok := ctx.(pageContext); ok {
|
if pc, ok := ctx.(pageContext); ok {
|
||||||
return pc.wrapError(err)
|
return pc.wrapError(err)
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ func (p *pageState) Err() error {
|
||||||
|
|
||||||
// Eq returns whether the current page equals the given page.
|
// Eq returns whether the current page equals the given page.
|
||||||
// This is what's invoked when doing `{{ if eq $page $otherPage }}`
|
// This is what's invoked when doing `{{ if eq $page $otherPage }}`
|
||||||
func (p *pageState) Eq(other interface{}) bool {
|
func (p *pageState) Eq(other any) bool {
|
||||||
pp, err := unwrapPage(other)
|
pp, err := unwrapPage(other)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
|
@ -600,7 +600,7 @@ func (p *pageState) mapContent(bucket *pagesMapBucket, meta *pageMeta) error {
|
||||||
s := p.shortcodeState
|
s := p.shortcodeState
|
||||||
|
|
||||||
rn := &pageContentMap{
|
rn := &pageContentMap{
|
||||||
items: make([]interface{}, 0, 20),
|
items: make([]any, 0, 20),
|
||||||
}
|
}
|
||||||
|
|
||||||
iter := p.source.parsed.Iterator()
|
iter := p.source.parsed.Iterator()
|
||||||
|
@ -737,12 +737,12 @@ Loop:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pageState) errorf(err error, format string, a ...interface{}) error {
|
func (p *pageState) errorf(err error, format string, a ...any) error {
|
||||||
if herrors.UnwrapErrorWithFileContext(err) != nil {
|
if herrors.UnwrapErrorWithFileContext(err) != nil {
|
||||||
// More isn't always better.
|
// More isn't always better.
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
args := append([]interface{}{p.Language().Lang, p.pathOrTitle()}, a...)
|
args := append([]any{p.Language().Lang, p.pathOrTitle()}, a...)
|
||||||
format = "[%s] page %q: " + format
|
format = "[%s] page %q: " + format
|
||||||
if err == nil {
|
if err == nil {
|
||||||
errors.Errorf(format, args...)
|
errors.Errorf(format, args...)
|
||||||
|
|
|
@ -111,7 +111,7 @@ type pageContentMap struct {
|
||||||
hasNonMarkdownShortcode bool
|
hasNonMarkdownShortcode bool
|
||||||
|
|
||||||
// *shortcode, pageContentReplacement or pageparser.Item
|
// *shortcode, pageContentReplacement or pageparser.Item
|
||||||
items []interface{}
|
items []any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pageContentMap) AddBytes(item pageparser.Item) {
|
func (p *pageContentMap) AddBytes(item pageparser.Item) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ type pageData struct {
|
||||||
data page.Data
|
data page.Data
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pageData) Data() interface{} {
|
func (p *pageData) Data() any {
|
||||||
p.dataInit.Do(func() {
|
p.dataInit.Do(func() {
|
||||||
p.data = make(page.Data)
|
p.data = make(page.Data)
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ type pageMeta struct {
|
||||||
bundleType files.ContentClass
|
bundleType files.ContentClass
|
||||||
|
|
||||||
// Params contains configuration defined in the params section of page frontmatter.
|
// Params contains configuration defined in the params section of page frontmatter.
|
||||||
params map[string]interface{}
|
params map[string]any
|
||||||
|
|
||||||
title string
|
title string
|
||||||
linkTitle string
|
linkTitle string
|
||||||
|
@ -110,7 +110,7 @@ type pageMeta struct {
|
||||||
|
|
||||||
// This is the raw front matter metadata that is going to be assigned to
|
// This is the raw front matter metadata that is going to be assigned to
|
||||||
// the Resources above.
|
// the Resources above.
|
||||||
resourcesMetadata []map[string]interface{}
|
resourcesMetadata []map[string]any
|
||||||
|
|
||||||
f source.File
|
f source.File
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ type pageMeta struct {
|
||||||
|
|
||||||
s *Site
|
s *Site
|
||||||
|
|
||||||
renderingConfigOverrides map[string]interface{}
|
renderingConfigOverrides map[string]any
|
||||||
contentConverterInit sync.Once
|
contentConverterInit sync.Once
|
||||||
contentConverter converter.Converter
|
contentConverter converter.Converter
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ func (p *pageMeta) IsPage() bool {
|
||||||
//
|
//
|
||||||
// This method is also implemented on SiteInfo.
|
// This method is also implemented on SiteInfo.
|
||||||
// TODO(bep) interface
|
// TODO(bep) interface
|
||||||
func (p *pageMeta) Param(key interface{}) (interface{}, error) {
|
func (p *pageMeta) Param(key any) (any, error) {
|
||||||
return resource.Param(p, p.s.Info.Params(), key)
|
return resource.Param(p, p.s.Info.Params(), key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ func (pm *pageMeta) mergeBucketCascades(b1, b2 *pagesMapBucket) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, frontmatter map[string]interface{}) error {
|
func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, frontmatter map[string]any) error {
|
||||||
pm.params = make(maps.Params)
|
pm.params = make(maps.Params)
|
||||||
|
|
||||||
if frontmatter == nil && (parentBucket == nil || parentBucket.cascade == nil) {
|
if frontmatter == nil && (parentBucket == nil || parentBucket.cascade == nil) {
|
||||||
|
@ -368,7 +368,7 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
frontmatter = make(map[string]interface{})
|
frontmatter = make(map[string]any)
|
||||||
}
|
}
|
||||||
|
|
||||||
var cascade map[page.PageMatcher]maps.Params
|
var cascade map[page.PageMatcher]maps.Params
|
||||||
|
@ -546,22 +546,22 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron
|
||||||
pm.translationKey = cast.ToString(v)
|
pm.translationKey = cast.ToString(v)
|
||||||
pm.params[loki] = pm.translationKey
|
pm.params[loki] = pm.translationKey
|
||||||
case "resources":
|
case "resources":
|
||||||
var resources []map[string]interface{}
|
var resources []map[string]any
|
||||||
handled := true
|
handled := true
|
||||||
|
|
||||||
switch vv := v.(type) {
|
switch vv := v.(type) {
|
||||||
case []map[interface{}]interface{}:
|
case []map[any]any:
|
||||||
for _, vvv := range vv {
|
for _, vvv := range vv {
|
||||||
resources = append(resources, maps.ToStringMap(vvv))
|
resources = append(resources, maps.ToStringMap(vvv))
|
||||||
}
|
}
|
||||||
case []map[string]interface{}:
|
case []map[string]any:
|
||||||
resources = append(resources, vv...)
|
resources = append(resources, vv...)
|
||||||
case []interface{}:
|
case []any:
|
||||||
for _, vvv := range vv {
|
for _, vvv := range vv {
|
||||||
switch vvvv := vvv.(type) {
|
switch vvvv := vvv.(type) {
|
||||||
case map[interface{}]interface{}:
|
case map[any]any:
|
||||||
resources = append(resources, maps.ToStringMap(vvvv))
|
resources = append(resources, maps.ToStringMap(vvvv))
|
||||||
case map[string]interface{}:
|
case map[string]any:
|
||||||
resources = append(resources, vvvv)
|
resources = append(resources, vvvv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -591,14 +591,14 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron
|
||||||
pm.params[loki] = vv
|
pm.params[loki] = vv
|
||||||
default: // handle array of strings as well
|
default: // handle array of strings as well
|
||||||
switch vvv := vv.(type) {
|
switch vvv := vv.(type) {
|
||||||
case []interface{}:
|
case []any:
|
||||||
if len(vvv) > 0 {
|
if len(vvv) > 0 {
|
||||||
switch vvv[0].(type) {
|
switch vvv[0].(type) {
|
||||||
case map[interface{}]interface{}: // Proper parsing structured array from YAML based FrontMatter
|
case map[any]any:
|
||||||
pm.params[loki] = vvv
|
pm.params[loki] = vvv
|
||||||
case map[string]interface{}: // Proper parsing structured array from JSON based FrontMatter
|
case map[string]any:
|
||||||
pm.params[loki] = vvv
|
pm.params[loki] = vvv
|
||||||
case []interface{}:
|
case []any:
|
||||||
pm.params[loki] = vvv
|
pm.params[loki] = vvv
|
||||||
default:
|
default:
|
||||||
a := make([]string, len(vvv))
|
a := make([]string, len(vvv))
|
||||||
|
@ -744,7 +744,7 @@ func (p *pageMeta) applyDefaultValues(n *contentNode) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !p.f.IsZero() {
|
if !p.f.IsZero() {
|
||||||
var renderingConfigOverrides map[string]interface{}
|
var renderingConfigOverrides map[string]any
|
||||||
bfParam := getParamToLower(p, "blackfriday")
|
bfParam := getParamToLower(p, "blackfriday")
|
||||||
if bfParam != nil {
|
if bfParam != nil {
|
||||||
renderingConfigOverrides = maps.ToStringMap(bfParam)
|
renderingConfigOverrides = maps.ToStringMap(bfParam)
|
||||||
|
@ -757,7 +757,7 @@ func (p *pageMeta) applyDefaultValues(n *contentNode) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pageMeta) newContentConverter(ps *pageState, markup string, renderingConfigOverrides map[string]interface{}) (converter.Converter, error) {
|
func (p *pageMeta) newContentConverter(ps *pageState, markup string, renderingConfigOverrides map[string]any) (converter.Converter, error) {
|
||||||
if ps == nil {
|
if ps == nil {
|
||||||
panic("no Page provided")
|
panic("no Page provided")
|
||||||
}
|
}
|
||||||
|
@ -806,7 +806,7 @@ func (p *pageMeta) Slug() string {
|
||||||
return p.urlPaths.Slug
|
return p.urlPaths.Slug
|
||||||
}
|
}
|
||||||
|
|
||||||
func getParam(m resource.ResourceParamsProvider, key string, stringToLower bool) interface{} {
|
func getParam(m resource.ResourceParamsProvider, key string, stringToLower bool) any {
|
||||||
v := m.Params()[strings.ToLower(key)]
|
v := m.Params()[strings.ToLower(key)]
|
||||||
|
|
||||||
if v == nil {
|
if v == nil {
|
||||||
|
@ -837,6 +837,6 @@ func getParam(m resource.ResourceParamsProvider, key string, stringToLower bool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getParamToLower(m resource.ResourceParamsProvider, key string) interface{} {
|
func getParamToLower(m resource.ResourceParamsProvider, key string) any {
|
||||||
return getParam(m, key, true)
|
return getParam(m, key, true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ func newPageBucket(p *pageState) *pagesMapBucket {
|
||||||
func newPageFromMeta(
|
func newPageFromMeta(
|
||||||
n *contentNode,
|
n *contentNode,
|
||||||
parentBucket *pagesMapBucket,
|
parentBucket *pagesMapBucket,
|
||||||
meta map[string]interface{},
|
meta map[string]any,
|
||||||
metaProvider *pageMeta) (*pageState, error) {
|
metaProvider *pageMeta) (*pageState, error) {
|
||||||
if metaProvider.f == nil {
|
if metaProvider.f == nil {
|
||||||
metaProvider.f = page.NewZeroFile(metaProvider.s.LogDistinct)
|
metaProvider.f = page.NewZeroFile(metaProvider.s.LogDistinct)
|
||||||
|
@ -119,7 +119,7 @@ func newPageFromMeta(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.init.Add(func() (interface{}, error) {
|
ps.init.Add(func() (any, error) {
|
||||||
pp, err := newPagePaths(metaProvider.s, ps, metaProvider)
|
pp, err := newPagePaths(metaProvider.s, ps, metaProvider)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -189,7 +189,7 @@ type pageDeprecatedWarning struct {
|
||||||
func (p *pageDeprecatedWarning) IsDraft() bool { return p.p.m.draft }
|
func (p *pageDeprecatedWarning) IsDraft() bool { return p.p.m.draft }
|
||||||
func (p *pageDeprecatedWarning) Hugo() hugo.Info { return p.p.s.Info.Hugo() }
|
func (p *pageDeprecatedWarning) Hugo() hugo.Info { return p.p.s.Info.Hugo() }
|
||||||
func (p *pageDeprecatedWarning) LanguagePrefix() string { return p.p.s.Info.LanguagePrefix }
|
func (p *pageDeprecatedWarning) LanguagePrefix() string { return p.p.s.Info.LanguagePrefix }
|
||||||
func (p *pageDeprecatedWarning) GetParam(key string) interface{} {
|
func (p *pageDeprecatedWarning) GetParam(key string) any {
|
||||||
return p.p.m.params[strings.ToLower(key)]
|
return p.p.m.params[strings.ToLower(key)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (p *pagePaginator) reset() {
|
||||||
p.pagePaginatorInit = &pagePaginatorInit{}
|
p.pagePaginatorInit = &pagePaginatorInit{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pagePaginator) Paginate(seq interface{}, options ...interface{}) (*page.Pager, error) {
|
func (p *pagePaginator) Paginate(seq any, options ...any) (*page.Pager, error) {
|
||||||
var initErr error
|
var initErr error
|
||||||
p.init.Do(func() {
|
p.init.Do(func() {
|
||||||
pagerSize, err := page.ResolvePagerSize(p.source.s.Cfg, options...)
|
pagerSize, err := page.ResolvePagerSize(p.source.s.Cfg, options...)
|
||||||
|
@ -68,7 +68,7 @@ func (p *pagePaginator) Paginate(seq interface{}, options ...interface{}) (*page
|
||||||
return p.current, nil
|
return p.current, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pagePaginator) Paginator(options ...interface{}) (*page.Pager, error) {
|
func (p *pagePaginator) Paginator(options ...any) (*page.Pager, error) {
|
||||||
var initErr error
|
var initErr error
|
||||||
p.init.Do(func() {
|
p.init.Do(func() {
|
||||||
pagerSize, err := page.ResolvePagerSize(p.source.s.Cfg, options...)
|
pagerSize, err := page.ResolvePagerSize(p.source.s.Cfg, options...)
|
||||||
|
|
|
@ -195,11 +195,11 @@ func newPageContentOutput(p *pageState, po *pageOutput) (*pageContentOutput, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// There may be recursive loops in shortcodes and render hooks.
|
// There may be recursive loops in shortcodes and render hooks.
|
||||||
cp.initMain = parent.BranchWithTimeout(p.s.siteCfg.timeout, func(ctx context.Context) (interface{}, error) {
|
cp.initMain = parent.BranchWithTimeout(p.s.siteCfg.timeout, func(ctx context.Context) (any, error) {
|
||||||
return nil, initContent()
|
return nil, initContent()
|
||||||
})
|
})
|
||||||
|
|
||||||
cp.initPlain = cp.initMain.Branch(func() (interface{}, error) {
|
cp.initPlain = cp.initMain.Branch(func() (any, error) {
|
||||||
cp.plain = helpers.StripHTML(string(cp.content))
|
cp.plain = helpers.StripHTML(string(cp.content))
|
||||||
cp.plainWords = strings.Fields(cp.plain)
|
cp.plainWords = strings.Fields(cp.plain)
|
||||||
cp.setWordCounts(p.m.isCJKLanguage)
|
cp.setWordCounts(p.m.isCJKLanguage)
|
||||||
|
@ -272,7 +272,7 @@ func (p *pageContentOutput) Reset() {
|
||||||
p.renderHooks = &renderHooks{}
|
p.renderHooks = &renderHooks{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pageContentOutput) Content() (interface{}, error) {
|
func (p *pageContentOutput) Content() (any, error) {
|
||||||
if p.p.s.initInit(p.initMain, p.p) {
|
if p.p.s.initInit(p.initMain, p.p) {
|
||||||
return p.content, nil
|
return p.content, nil
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ func (p *pageContentOutput) WordCount() int {
|
||||||
return p.wordCount
|
return p.wordCount
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pageContentOutput) RenderString(args ...interface{}) (template.HTML, error) {
|
func (p *pageContentOutput) RenderString(args ...any) (template.HTML, error) {
|
||||||
if len(args) < 1 || len(args) > 2 {
|
if len(args) < 1 || len(args) > 2 {
|
||||||
return "", errors.New("want 1 or 2 arguments")
|
return "", errors.New("want 1 or 2 arguments")
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ func (p *pageContentOutput) RenderString(args ...interface{}) (template.HTML, er
|
||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
sidx = 0
|
sidx = 0
|
||||||
} else {
|
} else {
|
||||||
m, ok := args[0].(map[string]interface{})
|
m, ok := args[0].(map[string]any)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", errors.New("first argument must be a map")
|
return "", errors.New("first argument must be a map")
|
||||||
}
|
}
|
||||||
|
@ -433,14 +433,14 @@ func (p *pageContentOutput) initRenderHooks() error {
|
||||||
|
|
||||||
type cacheKey struct {
|
type cacheKey struct {
|
||||||
tp hooks.RendererType
|
tp hooks.RendererType
|
||||||
id interface{}
|
id any
|
||||||
f output.Format
|
f output.Format
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCache := make(map[cacheKey]interface{})
|
renderCache := make(map[cacheKey]any)
|
||||||
var renderCacheMu sync.Mutex
|
var renderCacheMu sync.Mutex
|
||||||
|
|
||||||
resolvePosition := func(ctx interface{}) text.Position {
|
resolvePosition := func(ctx any) text.Position {
|
||||||
var offset int
|
var offset int
|
||||||
|
|
||||||
switch v := ctx.(type) {
|
switch v := ctx.(type) {
|
||||||
|
@ -459,7 +459,7 @@ func (p *pageContentOutput) initRenderHooks() error {
|
||||||
return pos
|
return pos
|
||||||
}
|
}
|
||||||
|
|
||||||
p.renderHooks.getRenderer = func(tp hooks.RendererType, id interface{}) interface{} {
|
p.renderHooks.getRenderer = func(tp hooks.RendererType, id any) any {
|
||||||
renderCacheMu.Lock()
|
renderCacheMu.Lock()
|
||||||
defer renderCacheMu.Unlock()
|
defer renderCacheMu.Unlock()
|
||||||
|
|
||||||
|
@ -650,7 +650,7 @@ func (t targetPathsHolder) targetPaths() page.TargetPaths {
|
||||||
return t.paths
|
return t.paths
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeToString(h tpl.TemplateHandler, templ tpl.Template, data interface{}) (string, error) {
|
func executeToString(h tpl.TemplateHandler, templ tpl.Template, data any) (string, error) {
|
||||||
b := bp.GetBuffer()
|
b := bp.GetBuffer()
|
||||||
defer bp.PutBuffer(b)
|
defer bp.PutBuffer(b)
|
||||||
if err := h.Execute(templ, b, data); err != nil {
|
if err := h.Execute(templ, b, data); err != nil {
|
||||||
|
|
|
@ -30,23 +30,23 @@ type pageRef struct {
|
||||||
p *pageState
|
p *pageState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p pageRef) Ref(argsm map[string]interface{}) (string, error) {
|
func (p pageRef) Ref(argsm map[string]any) (string, error) {
|
||||||
return p.ref(argsm, p.p)
|
return p.ref(argsm, p.p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p pageRef) RefFrom(argsm map[string]interface{}, source interface{}) (string, error) {
|
func (p pageRef) RefFrom(argsm map[string]any, source any) (string, error) {
|
||||||
return p.ref(argsm, source)
|
return p.ref(argsm, source)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p pageRef) RelRef(argsm map[string]interface{}) (string, error) {
|
func (p pageRef) RelRef(argsm map[string]any) (string, error) {
|
||||||
return p.relRef(argsm, p.p)
|
return p.relRef(argsm, p.p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p pageRef) RelRefFrom(argsm map[string]interface{}, source interface{}) (string, error) {
|
func (p pageRef) RelRefFrom(argsm map[string]any, source any) (string, error) {
|
||||||
return p.relRef(argsm, source)
|
return p.relRef(argsm, source)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p pageRef) decodeRefArgs(args map[string]interface{}) (refArgs, *Site, error) {
|
func (p pageRef) decodeRefArgs(args map[string]any) (refArgs, *Site, error) {
|
||||||
var ra refArgs
|
var ra refArgs
|
||||||
err := mapstructure.WeakDecode(args, &ra)
|
err := mapstructure.WeakDecode(args, &ra)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -74,7 +74,7 @@ func (p pageRef) decodeRefArgs(args map[string]interface{}) (refArgs, *Site, err
|
||||||
return ra, s, nil
|
return ra, s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p pageRef) ref(argsm map[string]interface{}, source interface{}) (string, error) {
|
func (p pageRef) ref(argsm map[string]any, source any) (string, error) {
|
||||||
args, s, err := p.decodeRefArgs(argsm)
|
args, s, err := p.decodeRefArgs(argsm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "invalid arguments to Ref")
|
return "", errors.Wrap(err, "invalid arguments to Ref")
|
||||||
|
@ -91,7 +91,7 @@ func (p pageRef) ref(argsm map[string]interface{}, source interface{}) (string,
|
||||||
return s.refLink(args.Path, source, false, args.OutputFormat)
|
return s.refLink(args.Path, source, false, args.OutputFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p pageRef) relRef(argsm map[string]interface{}, source interface{}) (string, error) {
|
func (p pageRef) relRef(argsm map[string]any, source any) (string, error) {
|
||||||
args, s, err := p.decodeRefArgs(argsm)
|
args, s, err := p.decodeRefArgs(argsm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "invalid arguments to Ref")
|
return "", errors.Wrap(err, "invalid arguments to Ref")
|
||||||
|
|
|
@ -25,7 +25,7 @@ type pageTree struct {
|
||||||
p *pageState
|
p *pageState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pt pageTree) IsAncestor(other interface{}) (bool, error) {
|
func (pt pageTree) IsAncestor(other any) (bool, error) {
|
||||||
if pt.p == nil {
|
if pt.p == nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func (pt pageTree) CurrentSection() page.Page {
|
||||||
return p.Parent()
|
return p.Parent()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pt pageTree) IsDescendant(other interface{}) (bool, error) {
|
func (pt pageTree) IsDescendant(other any) (bool, error) {
|
||||||
if pt.p == nil {
|
if pt.p == nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ func (pt pageTree) FirstSection() page.Page {
|
||||||
return b.p
|
return b.p
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pt pageTree) InSection(other interface{}) (bool, error) {
|
func (pt pageTree) InSection(other any) (bool, error) {
|
||||||
if pt.p == nil || types.IsNil(other) {
|
if pt.p == nil || types.IsNil(other) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,7 +298,7 @@ func checkPageTitle(t *testing.T, page page.Page, title string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPageContent(t *testing.T, page page.Page, expected string, msg ...interface{}) {
|
func checkPageContent(t *testing.T, page page.Page, expected string, msg ...any) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
a := normalizeContent(expected)
|
a := normalizeContent(expected)
|
||||||
b := normalizeContent(content(page))
|
b := normalizeContent(content(page))
|
||||||
|
@ -325,7 +325,7 @@ func checkPageTOC(t *testing.T, page page.Page, toc string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPageSummary(t *testing.T, page page.Page, summary string, msg ...interface{}) {
|
func checkPageSummary(t *testing.T, page page.Page, summary string, msg ...any) {
|
||||||
a := normalizeContent(string(page.Summary()))
|
a := normalizeContent(string(page.Summary()))
|
||||||
b := normalizeContent(summary)
|
b := normalizeContent(summary)
|
||||||
if a != b {
|
if a != b {
|
||||||
|
@ -369,7 +369,7 @@ func normalizeExpected(ext, str string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAllMarkdownEnginesForPages(t *testing.T,
|
func testAllMarkdownEnginesForPages(t *testing.T,
|
||||||
assertFunc func(t *testing.T, ext string, pages page.Pages), settings map[string]interface{}, pageSources ...string) {
|
assertFunc func(t *testing.T, ext string, pages page.Pages), settings map[string]any, pageSources ...string) {
|
||||||
|
|
||||||
engines := []struct {
|
engines := []struct {
|
||||||
ext string
|
ext string
|
||||||
|
@ -399,8 +399,8 @@ func testAllMarkdownEnginesForPages(t *testing.T,
|
||||||
contentDir = s
|
contentDir = s
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Set("security", map[string]interface{}{
|
cfg.Set("security", map[string]any{
|
||||||
"exec": map[string]interface{}{
|
"exec": map[string]any{
|
||||||
"allow": []string{"^python$", "^rst2html.*", "^asciidoctor$"},
|
"allow": []string{"^python$", "^rst2html.*", "^asciidoctor$"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -572,7 +572,7 @@ func TestCreateNewPage(t *testing.T) {
|
||||||
checkPageType(t, p, "page")
|
checkPageType(t, p, "page")
|
||||||
}
|
}
|
||||||
|
|
||||||
settings := map[string]interface{}{
|
settings := map[string]any{
|
||||||
"contentDir": "mycontent",
|
"contentDir": "mycontent",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,7 +697,7 @@ func TestPageWithShortCodeInSummary(t *testing.T) {
|
||||||
func TestPageWithAdditionalExtension(t *testing.T) {
|
func TestPageWithAdditionalExtension(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
cfg, fs := newTestCfg()
|
cfg, fs := newTestCfg()
|
||||||
cfg.Set("markup", map[string]interface{}{
|
cfg.Set("markup", map[string]any{
|
||||||
"defaultMarkdownHandler": "blackfriday", // TODO(bep)
|
"defaultMarkdownHandler": "blackfriday", // TODO(bep)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1039,18 +1039,18 @@ func TestPageWithLastmodFromGitInfo(t *testing.T) {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
c.Assert(err, qt.IsNil)
|
c.Assert(err, qt.IsNil)
|
||||||
|
|
||||||
cfg.Set("frontmatter", map[string]interface{}{
|
cfg.Set("frontmatter", map[string]any{
|
||||||
"lastmod": []string{":git", "lastmod"},
|
"lastmod": []string{":git", "lastmod"},
|
||||||
})
|
})
|
||||||
cfg.Set("defaultContentLanguage", "en")
|
cfg.Set("defaultContentLanguage", "en")
|
||||||
|
|
||||||
langConfig := map[string]interface{}{
|
langConfig := map[string]any{
|
||||||
"en": map[string]interface{}{
|
"en": map[string]any{
|
||||||
"weight": 1,
|
"weight": 1,
|
||||||
"languageName": "English",
|
"languageName": "English",
|
||||||
"contentDir": "content",
|
"contentDir": "content",
|
||||||
},
|
},
|
||||||
"nn": map[string]interface{}{
|
"nn": map[string]any{
|
||||||
"weight": 2,
|
"weight": 2,
|
||||||
"languageName": "Nynorsk",
|
"languageName": "Nynorsk",
|
||||||
"contentDir": "content_nn",
|
"contentDir": "content_nn",
|
||||||
|
@ -1102,7 +1102,7 @@ lastMod: 2018-02-28
|
||||||
Content
|
Content
|
||||||
`
|
`
|
||||||
|
|
||||||
cfg.Set("frontmatter", map[string]interface{}{
|
cfg.Set("frontmatter", map[string]any{
|
||||||
"date": []string{dateHandler, "date"},
|
"date": []string{dateHandler, "date"},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1163,7 +1163,7 @@ func TestWordCountWithAllCJKRunesWithoutHasCJKLanguage(t *testing.T) {
|
||||||
|
|
||||||
func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) {
|
func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
settings := map[string]interface{}{"hasCJKLanguage": true}
|
settings := map[string]any{"hasCJKLanguage": true}
|
||||||
|
|
||||||
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
|
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
|
||||||
p := pages[0]
|
p := pages[0]
|
||||||
|
@ -1176,7 +1176,7 @@ func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) {
|
||||||
|
|
||||||
func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) {
|
func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
settings := map[string]interface{}{"hasCJKLanguage": true}
|
settings := map[string]any{"hasCJKLanguage": true}
|
||||||
|
|
||||||
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
|
assertFunc := func(t *testing.T, ext string, pages page.Pages) {
|
||||||
p := pages[0]
|
p := pages[0]
|
||||||
|
@ -1195,7 +1195,7 @@ func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) {
|
||||||
|
|
||||||
func TestWordCountWithIsCJKLanguageFalse(t *testing.T) {
|
func TestWordCountWithIsCJKLanguageFalse(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
settings := map[string]interface{}{
|
settings := map[string]any{
|
||||||
"hasCJKLanguage": true,
|
"hasCJKLanguage": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue