From 43773a153c74164db3285e250446d6e8addfc5a4 Mon Sep 17 00:00:00 2001 From: arnaucode Date: Sun, 12 Nov 2017 01:06:34 +0100 Subject: [PATCH] starting to implement multilanguage directories --- main.go | 10 ++++++---- readKonstruiConfig.go | 10 +++++++--- templating.go | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 50a8b17..7fe378e 100755 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( ) const rawFolderPath = "./webInput" -const newFolderPath = "./webOutput" const konstruiConfigFile = "konstruiConfig.json" func main() { @@ -14,15 +13,18 @@ func main() { c.Green("getting conifg from file konstruiConfig.json") //READ CONFIG: konstruiConfig.json - readKonstruiConfig(rawFolderPath + "/" + konstruiConfigFile) + konstruiConfigs := readKonstruiConfig(rawFolderPath + "/" + konstruiConfigFile) c.Green("configuration:") - fmt.Println(konstruiConfig) + fmt.Println(konstruiConfigs) c.Green("templating") //create directory webOutput _ = os.Mkdir("webOutput", os.ModePerm) //DO TEMPLATING - startTemplating(rawFolderPath, newFolderPath) + for _, konstruiConfig := range konstruiConfigs { + _ = os.Mkdir(konstruiConfig.OutputDir, os.ModePerm) + startTemplating(rawFolderPath, konstruiConfig.OutputDir, konstruiConfig) + } c.Green("webpage finished, files at /webOutput") } diff --git a/readKonstruiConfig.go b/readKonstruiConfig.go index ece3dba..bfdc262 100755 --- a/readKonstruiConfig.go +++ b/readKonstruiConfig.go @@ -18,18 +18,22 @@ type KonstruiConfig struct { Author string `json:"author"` Github string `json:"github"` Website string `json:"website"` + OutputDir string `json:"outputDir"` + LangPrefix string `json:"langPrefix"` Files []string `json:"files"` RepeatPages []RepeatPages CopyRaw []string `json:"copyRaw"` } -var konstruiConfig KonstruiConfig +func readKonstruiConfig(path string) []KonstruiConfig { + var konstruiConfigs []KonstruiConfig -func readKonstruiConfig(path string) { file, e := ioutil.ReadFile(path) if e != nil { fmt.Println("error:", e) } content := string(file) - json.Unmarshal([]byte(content), &konstruiConfig) + json.Unmarshal([]byte(content), &konstruiConfigs) + + return konstruiConfigs } diff --git a/templating.go b/templating.go index 2bd7aaa..6899e3b 100644 --- a/templating.go +++ b/templating.go @@ -245,7 +245,7 @@ func getTagParameters(line string, tagname string, param1 string, param2 string) return param1content, param2content } -func startTemplating(folderPath string, newDir string) { +func startTemplating(folderPath string, newDir string, konstruiConfig KonstruiConfig) { //FILES //do templating for each file in konstruiConfig.Files //konstrui-template