"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "resources/page/page_matcher.go" between
hugo-0.85.0.tar.gz and hugo-0.86.0.tar.gz

About: Hugo is a static site generator that takes a source directory of Markdown files and templates and uses these as input to create a complete website (written in Go).

page_matcher.go  (hugo-0.85.0):page_matcher.go  (hugo-0.86.0)
skipping to change at line 22 skipping to change at line 22
// limitations under the License. // limitations under the License.
package page package page
import ( import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/hugofs/glob" "github.com/gohugoio/hugo/hugofs/glob"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
) )
// A PageMatcher can be used to match a Page with Glob patterns. // A PageMatcher can be used to match a Page with Glob patterns.
// Note that the pattern matching is case insensitive. // Note that the pattern matching is case insensitive.
type PageMatcher struct { type PageMatcher struct {
// A Glob pattern matching the content path below /content. // A Glob pattern matching the content path below /content.
// Expects Unix-styled slashes. // Expects Unix-styled slashes.
// Note that this is the virtual path, so it starts at the mount root // Note that this is the virtual path, so it starts at the mount root
skipping to change at line 73 skipping to change at line 74
p = "/" + p p = "/" + p
} }
if err == nil && !g.Match(p) { if err == nil && !g.Match(p) {
return false return false
} }
} }
return true return true
} }
// DecodeCascade decodes in which could be eiter a map or a slice of maps.
func DecodeCascade(in interface{}) (map[PageMatcher]maps.Params, error) {
m, err := maps.ToSliceStringMap(in)
if err != nil {
return map[PageMatcher]maps.Params{
{}: maps.ToStringMap(in),
}, nil
}
cascade := make(map[PageMatcher]maps.Params)
for _, vv := range m {
var m PageMatcher
if mv, found := vv["_target"]; found {
err := DecodePageMatcher(mv, &m)
if err != nil {
return nil, err
}
}
c, found := cascade[m]
if found {
// Merge
for k, v := range vv {
if _, found := c[k]; !found {
c[k] = v
}
}
} else {
cascade[m] = vv
}
}
return cascade, nil
}
// DecodePageMatcher decodes m into v. // DecodePageMatcher decodes m into v.
func DecodePageMatcher(m interface{}, v *PageMatcher) error { func DecodePageMatcher(m interface{}, v *PageMatcher) error {
if err := mapstructure.WeakDecode(m, v); err != nil { if err := mapstructure.WeakDecode(m, v); err != nil {
return err return err
} }
v.Kind = strings.ToLower(v.Kind) v.Kind = strings.ToLower(v.Kind)
if v.Kind != "" { if v.Kind != "" {
if _, found := kindMap[v.Kind]; !found { if _, found := kindMap[v.Kind]; !found {
return errors.Errorf("%q is not a valid Page Kind", v.Kin d) return errors.Errorf("%q is not a valid Page Kind", v.Kin d)
 End of changes. 2 change blocks. 
0 lines changed or deleted 37 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)