This commit is contained in:
parent
29f01a2618
commit
938e597f3f
10
content.go
10
content.go
@ -16,7 +16,7 @@ import (
|
||||
|
||||
// ReadContentDir walks through content directory and builds the tree of configurations
|
||||
func (node *TreeNode) ReadContentDir(inBase string, outBase string, dir string, conf *PathConfig) {
|
||||
node.FillConfig(inBase, outBase, dir, conf)
|
||||
node.fillConfig(inBase, outBase, dir, conf)
|
||||
|
||||
files, err := ioutil.ReadDir(node.InputPath)
|
||||
if err != nil {
|
||||
@ -61,7 +61,7 @@ func (node *TreeNode) ReadContentDir(inBase string, outBase string, dir string,
|
||||
}
|
||||
|
||||
// ProcessContent walks recursivly through the input paths and processes all files for output
|
||||
func (node *TreeNode) ProcessContent(rootConf *TreeNode) {
|
||||
func (node *TreeNode) ProcessContent() {
|
||||
helper.CreateDirectory(node.OutputPath)
|
||||
|
||||
curNavPath := strings.TrimPrefix(node.OutputPath, Config.Directories.Output)
|
||||
@ -223,14 +223,14 @@ RewriteRule ^$ %{REQUEST_URI}`+goToFixed+`/ [R,L]
|
||||
navMap := make(map[string]*NavElement)
|
||||
navSlice := make([]*NavElement, 0)
|
||||
navActive := make([]*NavElement, 0)
|
||||
BuildNavigation(rootConf, &navMap, &navSlice, &navActive, curNavPath)
|
||||
buildNavigation(node.root, &navMap, &navSlice, &navActive, curNavPath)
|
||||
|
||||
// read yaml header as data for template
|
||||
ctx := NewContext()
|
||||
ctx["This"] = newConfig.This
|
||||
ctx["Meta"] = newConfig.Meta
|
||||
ctx["Data"] = newConfig.Data
|
||||
ctx["ColMap"] = rootConf.ColMap // root as NavMap and NavSlice, for sub go to NavElement.ColMap
|
||||
ctx["ColMap"] = node.root.ColMap // root as NavMap and NavSlice, for sub go to NavElement.ColMap
|
||||
ctx["NavMap"] = navMap
|
||||
ctx["NavSlice"] = navSlice
|
||||
ctx["NavActive"] = navActive
|
||||
@ -289,7 +289,7 @@ RewriteRule ^$ %{REQUEST_URI}`+goToFixed+`/ [R,L]
|
||||
i := 0
|
||||
// sub can dynamically increase, so no for range
|
||||
for i < len(node.Sub) {
|
||||
node.Sub[i].ProcessContent(rootConf)
|
||||
node.Sub[i].ProcessContent()
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,11 @@ func (node *TreeNode) handleCollections() {
|
||||
|
||||
}
|
||||
|
||||
func (node *TreeNode) FillConfig(inBase, outBase, dir string, conf *PathConfig) {
|
||||
func (node *TreeNode) fillConfig(inBase, outBase, dir string, conf *PathConfig) {
|
||||
if node.root == nil {
|
||||
// this must be root
|
||||
node.root = node
|
||||
}
|
||||
inPath := inBase
|
||||
if dir != "" {
|
||||
inPath += "/" + dir
|
||||
@ -225,7 +229,7 @@ func (node *TreeNode) FillConfig(inBase, outBase, dir string, conf *PathConfig)
|
||||
|
||||
func Add2Nav(currentNode *TreeNode, pathConfig *PathConfig, tplFilename, outDir string, navname string, ctx interface{}, dataMapKey string, body string, hidden bool) {
|
||||
newNode := new(TreeNode)
|
||||
newNode.FillConfig(
|
||||
newNode.fillConfig(
|
||||
currentNode.InputPath,
|
||||
currentNode.OutputPath,
|
||||
outDir,
|
||||
|
@ -138,7 +138,7 @@ func main() {
|
||||
if _, err := os.Stat(filtersDir); !os.IsNotExist(err) {
|
||||
filter.RegisterFilters(filtersDir)
|
||||
}
|
||||
tree.ProcessContent(tree)
|
||||
tree.ProcessContent()
|
||||
|
||||
mark2web.ProcessAssets()
|
||||
|
||||
|
@ -24,9 +24,9 @@ type NavElement struct {
|
||||
SubSlice *[]*NavElement
|
||||
}
|
||||
|
||||
// BuildNavigation builds the navigation trees for use in templates
|
||||
func BuildNavigation(node *TreeNode, curNavMap *map[string]*NavElement, curNavSlice *[]*NavElement, navActive *[]*NavElement, activeNav string) {
|
||||
for _, el := range node.Sub {
|
||||
// buildNavigation builds the navigation trees for use in templates
|
||||
func buildNavigation(tree *TreeNode, curNavMap *map[string]*NavElement, curNavSlice *[]*NavElement, navActive *[]*NavElement, activeNav string) {
|
||||
for _, el := range tree.Sub {
|
||||
if el.Hidden {
|
||||
continue // ignore hidden nav points from collections
|
||||
}
|
||||
@ -98,6 +98,6 @@ func BuildNavigation(node *TreeNode, curNavMap *map[string]*NavElement, curNavSl
|
||||
*curNavSlice = append(*curNavSlice, &navEl)
|
||||
}
|
||||
|
||||
BuildNavigation(el, &subMap, &subSlice, navActive, activeNav)
|
||||
buildNavigation(el, &subMap, &subSlice, navActive, activeNav)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user