diff --git a/RELEASE.md b/RELEASE.md index 57fcb17..37419a6 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,16 +1,3 @@ NEUERUNGEN: -- pongo2-addons standardmäßig eingebunden -- fnRequest Template-Funktion für Web-Requests -- fnRender Template-Funktion um Unterseiten zu rendern -- eigene Filter via Javascript -- image_process Template-Filter um Bilder zu skalieren (resize, fit, fill) -- json Template-Filter um Variablen als JSON auszugeben -- dump Template-Filter um Variablen über spew.Dump auszugeben -- Collections via Web-Request mit optionaler Unternavigation -- Timestamp Variable - -BUG FIXES: - -- CR in Markdown entfernt, blackfriday-Bug -- Pfadangaben gesäubert, da sonst bei `-out ./html` der Assets-Pfad falsch ermittelt wurde +- `t=ZIEL_VERZEICHNIS` Parameter im `image_process` Filter diff --git a/VERSION b/VERSION index 1cc5f65..8cfbc90 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 \ No newline at end of file +1.1.1 \ No newline at end of file diff --git a/config/tree.go b/config/tree.go index 6f56e62..3ccdfe7 100644 --- a/config/tree.go +++ b/config/tree.go @@ -116,8 +116,9 @@ type ImagingConfig struct { Anchor string `yaml:"Anchor"` Quality int `yaml:"Quality"` - Filename string `yaml:"-"` - Format string `yaml:"-"` + TargetDir string `yaml:"-"` + Filename string `yaml:"-"` + Format string `yaml:"-"` } // PathConfig of subdir diff --git a/helper/template_filters.go b/helper/template_filters.go index 14bfbbb..c5c5401 100644 --- a/helper/template_filters.go +++ b/helper/template_filters.go @@ -109,6 +109,8 @@ func parseImageParams(str string) (*config.ImagingConfig, error) { p.Height, err = strconv.Atoi(e[1]) case "f": p.Filename = e[1] + case "t": + p.TargetDir = e[1] case "p": p.Process = e[1] case "a": @@ -207,7 +209,29 @@ func ImageProcessFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, * } } - imgTarget := ResolveOutputPath(p.Filename) + var imgTarget string + if p.TargetDir != "" { + imgTarget = ResolveOutputPath( + path.Clean(p.TargetDir) + "/" + + p.Filename, + ) + + pt := path.Dir(imgTarget) + if _, err := os.Stat(pt); os.IsNotExist(err) { + Log.Infof("create image target dir: %s", pt) + if err := os.MkdirAll(pt, 0755); err != nil { + return nil, &pongo2.Error{ + Sender: "filter:image_resize", + OrigError: fmt.Errorf("could not create image target dir '%s': %s", pt, err), + } + } + } + + p.Filename = ResolveNavPath(p.TargetDir + "/" + p.Filename) + + } else { + imgTarget = ResolveOutputPath(p.Filename) + } if f, err := os.Stat(imgTarget); err == nil && !f.IsDir() { Log.Noticef("skipped processing image from %s to %s, file already exists", imgSource, imgTarget) diff --git a/website/templates/base.html b/website/templates/base.html index 2a94dd3..a69ab2d 100755 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -56,10 +56,10 @@ {% for sl in Data.slider %}
{{ sl.alt }}
{% endfor %} @@ -103,10 +103,10 @@
{% if Data.background %} {{ Meta.Title }} {% endif %}