"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hugolib/content_map.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).

content_map.go  (hugo-0.85.0):content_map.go  (hugo-0.86.0)
skipping to change at line 104 skipping to change at line 104
} }
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{}]*contentNo de) { initFn: func(t *contentTree, m map[interface{}]*contentNo de) {
t.Walk(func(s string, v interface{}) bool { t.Walk(func(s string, v interface{}) 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().Met a() meta := n.p.File().FileInfo().Met a()
if meta.Path() != meta.PathFile() { if meta.Path != meta.PathFile() {
// Keep track of the orig inal mount source. // Keep track of the orig inal mount source.
mountKey := filepath.ToSl ash(filepath.Join(meta.Module(), meta.PathFile())) mountKey := filepath.ToSl ash(filepath.Join(meta.Module, meta.PathFile()))
addToReverseMap(mountKey, n, m) addToReverseMap(mountKey, n, m)
} }
} }
k := strings.TrimPrefix(strings.TrimSuffi x(path.Base(s), cmLeafSeparator), cmBranchSeparator) k := strings.TrimPrefix(strings.TrimSuffi x(path.Base(s), cmLeafSeparator), cmBranchSeparator)
addToReverseMap(k, n, m) addToReverseMap(k, n, m)
return false return false
}) })
}, },
}, },
} }
skipping to change at line 201 skipping to change at line 201
if b.err == nil { if b.err == nil {
b.tree.DeletePrefix(b.Key()) b.tree.DeletePrefix(b.Key())
} }
return b return b
} }
func (b *cmInsertKeyBuilder) WithFile(fi hugofs.FileMetaInfo) *cmInsertKeyBuilde r { func (b *cmInsertKeyBuilder) WithFile(fi hugofs.FileMetaInfo) *cmInsertKeyBuilde r {
b.newTopLevel() b.newTopLevel()
m := b.m m := b.m
meta := fi.Meta() meta := fi.Meta()
p := cleanTreeKey(meta.Path()) p := cleanTreeKey(meta.Path)
bundlePath := m.getBundleDir(meta) bundlePath := m.getBundleDir(meta)
isBundle := meta.Classifier().IsBundle() isBundle := meta.Classifier.IsBundle()
if isBundle { if isBundle {
panic("not implemented") panic("not implemented")
} }
p, k := b.getBundle(p) p, k := b.getBundle(p)
if k == "" { if k == "" {
b.err = errors.Errorf("no bundle header found for %q", bundlePath ) b.err = errors.Errorf("no bundle header found for %q", bundlePath )
return b return b
} }
id := k + m.reduceKeyPart(p, fi.Meta().Path()) id := k + m.reduceKeyPart(p, fi.Meta().Path)
b.tree = b.m.resources b.tree = b.m.resources
b.key = id b.key = id
b.baseKey = p b.baseKey = p
return b return b
} }
func (b *cmInsertKeyBuilder) WithSection(s string) *cmInsertKeyBuilder { func (b *cmInsertKeyBuilder) WithSection(s string) *cmInsertKeyBuilder {
s = cleanSectionTreeKey(s) s = cleanSectionTreeKey(s)
b.newTopLevel() b.newTopLevel()
skipping to change at line 350 skipping to change at line 350
return err return err
} }
} }
return nil return nil
} }
func (m *contentMap) AddFilesBundle(header hugofs.FileMetaInfo, resources ...hug ofs.FileMetaInfo) error { func (m *contentMap) AddFilesBundle(header hugofs.FileMetaInfo, resources ...hug ofs.FileMetaInfo) error {
var ( var (
meta = header.Meta() meta = header.Meta()
classifier = meta.Classifier() classifier = meta.Classifier
isBranch = classifier == files.ContentClassBranch isBranch = classifier == files.ContentClassBranch
bundlePath = m.getBundleDir(meta) bundlePath = m.getBundleDir(meta)
n = m.newContentNodeFromFi(header) n = m.newContentNodeFromFi(header)
b = m.newKeyBuilder() b = m.newKeyBuilder()
section string section string
) )
if isBranch { if isBranch {
skipping to change at line 390 skipping to change at line 390
b = b.WithSection(section).ForPage(bundlePath).Insert(n) b = b.WithSection(section).ForPage(bundlePath).Insert(n)
} }
if m.cfg.isRebuild { if m.cfg.isRebuild {
// The resource owner will be either deleted or overwritten on re builds, // The resource owner will be either deleted or overwritten on re builds,
// but make sure we handle deletion of resources (images etc.) as well. // but make sure we handle deletion of resources (images etc.) as well.
b.ForResource("").DeleteAll() b.ForResource("").DeleteAll()
} }
for _, r := range resources { for _, r := range resources {
rb := b.ForResource(cleanTreeKey(r.Meta().Path())) rb := b.ForResource(cleanTreeKey(r.Meta().Path))
rb.Insert(&contentNode{fi: r}) rb.Insert(&contentNode{fi: r})
} }
return nil return nil
} }
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]interface{})
trackRootSection := func(s string, b *contentNode) { trackRootSection := func(s string, b *contentNode) {
skipping to change at line 465 skipping to change at line 465
}, },
} }
b.viewInfo.ref = b b.viewInfo.ref = b
m.taxonomies.Insert(s, b) m.taxonomies.Insert(s, b)
} }
} }
return nil return nil
} }
func (m *contentMap) getBundleDir(meta hugofs.FileMeta) string { func (m *contentMap) getBundleDir(meta *hugofs.FileMeta) string {
dir := cleanTreeKey(filepath.Dir(meta.Path())) dir := cleanTreeKey(filepath.Dir(meta.Path))
switch meta.Classifier() { switch meta.Classifier {
case files.ContentClassContent: case files.ContentClassContent:
return path.Join(dir, meta.TranslationBaseName()) return path.Join(dir, meta.TranslationBaseName)
default: default:
return dir return dir
} }
} }
func (m *contentMap) newContentNodeFromFi(fi hugofs.FileMetaInfo) *contentNode { func (m *contentMap) newContentNodeFromFi(fi hugofs.FileMetaInfo) *contentNode {
return &contentNode{ return &contentNode{
fi: fi, fi: fi,
path: strings.TrimPrefix(filepath.ToSlash(fi.Meta().Path()), "/") , path: strings.TrimPrefix(filepath.ToSlash(fi.Meta().Path), "/"),
} }
} }
func (m *contentMap) getFirstSection(s string) (string, *contentNode) { func (m *contentMap) getFirstSection(s string) (string, *contentNode) {
s = helpers.AddTrailingSlash(s) s = helpers.AddTrailingSlash(s)
for { for {
k, v, found := m.sections.LongestPrefix(s) k, v, found := m.sections.LongestPrefix(s)
if !found { if !found {
return "", nil return "", nil
skipping to change at line 707 skipping to change at line 707
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 interface{}) 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
if c.p != nil { if c.p != nil {
sb.WriteString("|p:" + c.p.Title()) sb.WriteString("|p:" + c.p.Title())
} }
if c.fi != nil { if c.fi != nil {
sb.WriteString("|f:" + filepath.ToSlash(c .fi.Meta().Path())) sb.WriteString("|f:" + filepath.ToSlash(c .fi.Meta().Path))
} }
return sb.String() return sb.String()
} }
sb.WriteString(path.Join(m.cfg.lang, r.Name) + s + cpToSt ring(c) + "\n") sb.WriteString(path.Join(m.cfg.lang, r.Name) + s + cpToSt ring(c) + "\n")
resourcesPrefix := s resourcesPrefix := s
if i == 1 { if i == 1 {
resourcesPrefix += cmLeafSeparator resourcesPrefix += cmLeafSeparator
m.pages.WalkPrefix(s+cmBranchSeparator, func(s st ring, v interface{}) bool { m.pages.WalkPrefix(s+cmBranchSeparator, func(s st ring, v interface{}) bool {
sb.WriteString("\t - P: " + filepath.ToSl ash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename()) + "\n") sb.WriteString("\t - P: " + filepath.ToSl ash((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 interface{}) 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
}) })
return false return false
}) })
} }
return sb.String() return sb.String()
} }
 End of changes. 14 change blocks. 
15 lines changed or deleted 15 lines changed or added

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