From 1fecb5faae3001519adfd1affb44d8c1ffb8a649 Mon Sep 17 00:00:00 2001 From: Sebastian Frank Date: Thu, 14 Feb 2019 14:42:46 +0100 Subject: [PATCH] slug for output directories --- .gitmodules | 6 ++++++ .../README.md | 0 .../bild.jpg | Bin main.go | 15 ++++++++------- vendor/github.com/gosimple/slug | 1 + vendor/github.com/rainycape/unidecode | 1 + 6 files changed, 16 insertions(+), 7 deletions(-) rename example/content/de/main/{02_Leistungen_und_Referenzen => 02_Leistungen und Referenzen}/README.md (100%) rename example/content/de/main/{02_Leistungen_und_Referenzen => 02_Leistungen und Referenzen}/bild.jpg (100%) create mode 160000 vendor/github.com/gosimple/slug create mode 160000 vendor/github.com/rainycape/unidecode diff --git a/.gitmodules b/.gitmodules index 4e9b561..025f199 100644 --- a/.gitmodules +++ b/.gitmodules @@ -40,3 +40,9 @@ [submodule "vendor/github.com/juju/errors"] path = vendor/github.com/juju/errors url = https://github.com/juju/errors +[submodule "vendor/github.com/gosimple/slug"] + path = vendor/github.com/gosimple/slug + url = https://github.com/gosimple/slug +[submodule "vendor/github.com/rainycape/unidecode"] + path = vendor/github.com/rainycape/unidecode + url = https://github.com/rainycape/unidecode diff --git a/example/content/de/main/02_Leistungen_und_Referenzen/README.md b/example/content/de/main/02_Leistungen und Referenzen/README.md similarity index 100% rename from example/content/de/main/02_Leistungen_und_Referenzen/README.md rename to example/content/de/main/02_Leistungen und Referenzen/README.md diff --git a/example/content/de/main/02_Leistungen_und_Referenzen/bild.jpg b/example/content/de/main/02_Leistungen und Referenzen/bild.jpg similarity index 100% rename from example/content/de/main/02_Leistungen_und_Referenzen/bild.jpg rename to example/content/de/main/02_Leistungen und Referenzen/bild.jpg diff --git a/main.go b/main.go index ebd959a..cbbbc20 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/flosch/pongo2" + "github.com/gosimple/slug" "github.com/op/go-logging" cpy "github.com/otiai10/copy" "gopkg.in/russross/blackfriday.v2" @@ -155,19 +156,19 @@ func readContentDir(inBase string, outBase string, dir string, conf *PathConfig, stripedDir = regex.ReplaceAllString(stripedDir, "$1") } } - regex := regexp.MustCompile("[^a-zA-Z]") - stripedDir = regex.ReplaceAllString(stripedDir, "_") - outPath := outBase + "/" + stripedDir - outPath = path.Clean(outPath) - - log.Infof("calculated output directory: %s", outPath) - tree.OutputPath = outPath if tree.Config.This.Navname == nil { navname := strings.Replace(stripedDir, "_", " ", -1) tree.Config.This.Navname = &navname } + stripedDir = slug.Make(stripedDir) + outPath := outBase + "/" + stripedDir + outPath = path.Clean(outPath) + + log.Infof("calculated output directory: %s", outPath) + tree.OutputPath = outPath + // first only files for _, f := range files { p := inPath + "/" + f.Name() diff --git a/vendor/github.com/gosimple/slug b/vendor/github.com/gosimple/slug new file mode 160000 index 0000000..42ac18c --- /dev/null +++ b/vendor/github.com/gosimple/slug @@ -0,0 +1 @@ +Subproject commit 42ac18c34c2c6f4843fa48167317dcaa9416d1e2 diff --git a/vendor/github.com/rainycape/unidecode b/vendor/github.com/rainycape/unidecode new file mode 160000 index 0000000..cb7f23e --- /dev/null +++ b/vendor/github.com/rainycape/unidecode @@ -0,0 +1 @@ +Subproject commit cb7f23ec59bec0d61b19c56cd88cee3d0cc1870c