Browse Source

starting to implement multilanguage directories

master
arnaucode 7 years ago
parent
commit
43773a153c
3 changed files with 14 additions and 8 deletions
  1. +6
    -4
      main.go
  2. +7
    -3
      readKonstruiConfig.go
  3. +1
    -1
      templating.go

+ 6
- 4
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")
}

+ 7
- 3
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
}

+ 1
- 1
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

Loading…
Cancel
Save