added body to fnRender
This commit is contained in:
parent
e943271561
commit
5acc4083aa
@ -15,8 +15,9 @@ type ThisPathConfig struct {
|
|||||||
|
|
||||||
// IndexConfig describes index input and output file
|
// IndexConfig describes index input and output file
|
||||||
type IndexConfig struct {
|
type IndexConfig struct {
|
||||||
InputFile *string `yaml:"InputFile"`
|
InputFile *string `yaml:"InputFile"`
|
||||||
OutputFile *string `yaml:"OutputFile"`
|
InputString *string `yaml:"InputString"`
|
||||||
|
OutputFile *string `yaml:"OutputFile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetaData describes meta data for current site/tree node
|
// MetaData describes meta data for current site/tree node
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
cpy "github.com/otiai10/copy"
|
cpy "github.com/otiai10/copy"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ProcessAssets copies the assets from input to output dir
|
||||||
func ProcessAssets() {
|
func ProcessAssets() {
|
||||||
switch config.Config.Assets.Action {
|
switch config.Config.Assets.Action {
|
||||||
case "copy":
|
case "copy":
|
||||||
|
@ -86,6 +86,7 @@ func fillNodeConfig(node *config.PathConfigTree, inBase, outBase, dir string, co
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadContentDir walks through content directory and builds the tree of configurations
|
||||||
func ReadContentDir(inBase string, outBase string, dir string, conf *config.PathConfig, tree *config.PathConfigTree) {
|
func ReadContentDir(inBase string, outBase string, dir string, conf *config.PathConfig, tree *config.PathConfigTree) {
|
||||||
fillNodeConfig(tree, inBase, outBase, dir, conf)
|
fillNodeConfig(tree, inBase, outBase, dir, conf)
|
||||||
|
|
||||||
@ -131,6 +132,7 @@ func ReadContentDir(inBase string, outBase string, dir string, conf *config.Path
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ProcessContent walks recursivly through the input paths and processes all files for output
|
||||||
func ProcessContent(rootConf, conf *config.PathConfigTree) {
|
func ProcessContent(rootConf, conf *config.PathConfigTree) {
|
||||||
CreateDirectory(conf.OutputPath)
|
CreateDirectory(conf.OutputPath)
|
||||||
|
|
||||||
@ -177,6 +179,17 @@ RewriteRule ^$ %{REQUEST_URI}`+goToFixed+`/ [R,L]
|
|||||||
Log.Panicf("could not read '%s':%s", inFile, err)
|
Log.Panicf("could not read '%s':%s", inFile, err)
|
||||||
}
|
}
|
||||||
Log.Infof("processing input file '%s'", inFile)
|
Log.Infof("processing input file '%s'", inFile)
|
||||||
|
} else {
|
||||||
|
// use input string if available and input filename == ""
|
||||||
|
var inputString *string
|
||||||
|
if i := conf.Config.Index; i != nil {
|
||||||
|
inputString = i.InputString
|
||||||
|
}
|
||||||
|
if inputString != nil {
|
||||||
|
Log.Debugf("using input string instead of file")
|
||||||
|
input = []byte(*inputString)
|
||||||
|
spew.Dump(string(input))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newConfig := new(config.PathConfig)
|
newConfig := new(config.PathConfig)
|
||||||
@ -184,6 +197,9 @@ RewriteRule ^$ %{REQUEST_URI}`+goToFixed+`/ [R,L]
|
|||||||
regex := regexp.MustCompile("(?s)^---(.*?)\\r?\\n\\r?---\\r?\\n\\r?")
|
regex := regexp.MustCompile("(?s)^---(.*?)\\r?\\n\\r?---\\r?\\n\\r?")
|
||||||
yamlData := regex.Find(input)
|
yamlData := regex.Find(input)
|
||||||
if string(yamlData) != "" {
|
if string(yamlData) != "" {
|
||||||
|
// replace tabs
|
||||||
|
yamlData = bytes.Replace(yamlData, []byte("\t"), []byte(" "), -1)
|
||||||
|
|
||||||
Log.Debugf("found yaml header in '%s', merging config", inFile)
|
Log.Debugf("found yaml header in '%s', merging config", inFile)
|
||||||
err := yaml.Unmarshal(yamlData, newConfig)
|
err := yaml.Unmarshal(yamlData, newConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
1
helper/markdown.go
Normal file
1
helper/markdown.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package helper
|
@ -8,6 +8,7 @@ import (
|
|||||||
"gitbase.de/apairon/mark2web/config"
|
"gitbase.de/apairon/mark2web/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NavElement is one element with ist attributes and subs
|
||||||
type NavElement struct {
|
type NavElement struct {
|
||||||
Navname string
|
Navname string
|
||||||
GoTo string
|
GoTo string
|
||||||
@ -21,6 +22,7 @@ type NavElement struct {
|
|||||||
SubSlice *[]*NavElement
|
SubSlice *[]*NavElement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BuildNavigation builds the navigation trees for use in templates
|
||||||
func BuildNavigation(conf *config.PathConfigTree, curNavMap *map[string]*NavElement, curNavSlice *[]*NavElement, navActive *[]*NavElement, activeNav string) {
|
func BuildNavigation(conf *config.PathConfigTree, curNavMap *map[string]*NavElement, curNavSlice *[]*NavElement, navActive *[]*NavElement, activeNav string) {
|
||||||
for _, el := range conf.Sub {
|
for _, el := range conf.Sub {
|
||||||
if el.Hidden {
|
if el.Hidden {
|
||||||
|
@ -67,7 +67,7 @@ func FixAssetsPath(str, curNavPath string) string {
|
|||||||
repl = path.Clean(repl) + "/"
|
repl = path.Clean(repl) + "/"
|
||||||
Log.Debugf("new assets paths: %s", repl)
|
Log.Debugf("new assets paths: %s", repl)
|
||||||
return regex.ReplaceAllString(str, repl)
|
return regex.ReplaceAllString(str, repl)
|
||||||
} else {
|
|
||||||
return str
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return str
|
||||||
}
|
}
|
||||||
|
@ -54,10 +54,14 @@ func RequestFn(url *pongo2.Value, args ...*pongo2.Value) *pongo2.Value {
|
|||||||
// RenderFn renders a pongo2 template with additional context
|
// RenderFn renders a pongo2 template with additional context
|
||||||
func RenderFn(templateFilename, outDir, ctx *pongo2.Value, param ...*pongo2.Value) *pongo2.Value {
|
func RenderFn(templateFilename, outDir, ctx *pongo2.Value, param ...*pongo2.Value) *pongo2.Value {
|
||||||
ctxMapKey := ""
|
ctxMapKey := ""
|
||||||
|
body := ""
|
||||||
|
|
||||||
for i, p := range param {
|
for i, p := range param {
|
||||||
switch i {
|
switch i {
|
||||||
case 0:
|
case 0:
|
||||||
ctxMapKey = p.String()
|
ctxMapKey = p.String()
|
||||||
|
case 1:
|
||||||
|
body = p.String()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +96,9 @@ func RenderFn(templateFilename, outDir, ctx *pongo2.Value, param ...*pongo2.Valu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
newNodeConfig.Config.Index = &config.IndexConfig{
|
newNodeConfig.Config.Index = &config.IndexConfig{
|
||||||
InputFile: &indexInFile,
|
InputFile: &indexInFile,
|
||||||
OutputFile: &indexOutFile,
|
OutputFile: &indexOutFile,
|
||||||
|
InputString: &body,
|
||||||
}
|
}
|
||||||
newNodeConfig.Hidden = true
|
newNodeConfig.Hidden = true
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
{{ e.teaser|markdown }}
|
{{ e.teaser|markdown }}
|
||||||
{% if e.body %}
|
{% if e.body %}
|
||||||
<a href="{{ e.title|slugify }}" class="btn">mehr lesen</a>
|
<a href="{{ e.title|slugify }}" class="btn">mehr lesen</a>
|
||||||
{{ fnRender("base_blog_details.html", e.title, e) }}
|
{{ fnRender("base_blog_details.html", e.title, e, "details", e.body) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock part0 %}
|
{% endblock part0 %}
|
||||||
@ -27,7 +27,7 @@
|
|||||||
{{ e.teaser|markdown }}
|
{{ e.teaser|markdown }}
|
||||||
{% if e.body %}
|
{% if e.body %}
|
||||||
<a href="{{ e.title|slugify }}" class="btn">mehr lesen</a>
|
<a href="{{ e.title|slugify }}" class="btn">mehr lesen</a>
|
||||||
{{ fnRender("base_blog_details.html", e.title, e) }}
|
{{ fnRender("base_blog_details.html", e.title, e, "details", e.body) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock part1 %}
|
{% endblock part1 %}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
{% block part0 %}
|
{% block part0 %}
|
||||||
<h1>{{ Data.title }}</h1>
|
<h1>{{ Data.title }}</h1>
|
||||||
{{ Data.teaser|markdown }}
|
{{ Data.details.teaser|markdown }}
|
||||||
{% endblock part0 %}
|
{% endblock part0 %}
|
||||||
|
|
||||||
{% block part1 %}
|
{% block part1 %}
|
||||||
{{ Data.body|markdown }}
|
{{ Body }}
|
||||||
{% endblock part1 %}
|
{% endblock part1 %}
|
Loading…
Reference in New Issue
Block a user