collections via markdown files
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Sebastian Frank
2019-03-22 17:22:03 +01:00
parent 4a9a3eec06
commit ff1da084af
46 changed files with 547 additions and 362 deletions

View File

@@ -130,7 +130,7 @@ func ImageProcessFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *
}
} else {
// local file
imgSource = mark2web.ResolveInputPath(imgSource)
imgSource = mark2web.CurrentTreeNode.ResolveInputPath(imgSource)
if p.Filename == "" {
p.Filename = fmt.Sprintf(
"%s_%s",
@@ -142,7 +142,7 @@ func ImageProcessFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *
var imgTarget string
if p.TargetDir != "" {
imgTarget = mark2web.ResolveOutputPath(
imgTarget = mark2web.CurrentTreeNode.ResolveOutputPath(
path.Clean(p.TargetDir) + "/" +
p.Filename,
)
@@ -158,10 +158,10 @@ func ImageProcessFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *
}
}
p.Filename = mark2web.ResolveNavPath(p.TargetDir + "/" + p.Filename)
p.Filename = mark2web.CurrentTreeNode.ResolveNavPath(p.TargetDir + "/" + p.Filename)
} else {
imgTarget = mark2web.ResolveOutputPath(p.Filename)
imgTarget = mark2web.CurrentTreeNode.ResolveOutputPath(p.Filename)
}
if f, err := os.Stat(imgTarget); err == nil && !f.IsDir() {
@@ -226,5 +226,5 @@ func ImageProcessFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *
helper.Log.Noticef("finished image: %s", imgTarget)
})
}
return pongo2.AsValue(mark2web.ResolveNavPath(p.Filename)), nil
return pongo2.AsValue(mark2web.CurrentTreeNode.ResolveNavPath(p.Filename)), nil
}

View File

@@ -36,9 +36,6 @@ func TestImageProcessFilter(t *testing.T) {
},
},
}
mark2web.CurrentContext = &pongo2.Context{
"CurrentPath": "",
}
os.Remove("../../test/out/fit_300x300_q060_test.jpg")

View File

@@ -8,7 +8,7 @@ import (
// RelativePathFilter returns the relative path to navpoint based on current nav
func RelativePathFilter(in, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {
return pongo2.AsValue(
mark2web.ResolveNavPath(
mark2web.CurrentTreeNode.ResolveNavPath(
in.String(),
),
), nil

View File

@@ -17,10 +17,23 @@ func TestRelativePathFilter(t *testing.T) {
"testabs": "/abs",
"testsub": "../sub/rel",
}
mark2web.Config.Directories.Output = "../../test/out"
mark2web.CurrentTreeNode = &mark2web.TreeNode{
InputPath: "../../test/in/content",
OutputPath: "../../test/out/sub",
Config: &mark2web.PathConfig{
Imaging: &mark2web.ImagingConfig{
Quality: 60,
Height: 300,
Width: 300,
Process: "fit",
},
},
}
Convey("parse template", func() {
mark2web.CurrentContext = &pongo2.Context{
"CurrentPath": "sub",
}
output, err := pongo2.RenderTemplateString("{{ testrel|relative_path }}", ctx)
So(err, ShouldBeNil)