diff --git a/README.md b/README.md index f6c1ff4..a159170 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Timmy [![Go Report Card](https://goreportcard.com/badge/github.com/arnaucode/timmy)](https://goreportcard.com/report/github.com/arnaucode/timmy) +# Konstrui [![Go Report Card](https://goreportcard.com/badge/github.com/arnaucode/konstrui)](https://goreportcard.com/report/github.com/arnaucode/konstrui) web templating engine for static websites, written in Go lang -![timmy](https://raw.githubusercontent.com/arnaucode/timmy/master/timmy.png "timmy") +![konstrui](https://raw.githubusercontent.com/arnaucode/konstrui/master/konstrui.png "konstrui") ## Example @@ -12,6 +12,7 @@ web templating engine for static websites, written in Go lang ``` webInput/ + konstruiConfig.json index.html templates/ userTemplate.html @@ -29,7 +30,7 @@ webInput/

My first paragraph.

- + @@ -68,7 +69,7 @@ webInput/ ] ``` -- Set the configuration file timmyConfig.json in the webInput directory: +- Set the configuration file konstruiConfig.json in the webInput directory: ```json { @@ -85,10 +86,10 @@ webInput/ ``` -- Execute Timmy +- Execute konstrui ``` -./timmy +./konstrui ``` - Output: diff --git a/fileOperations.go b/fileOperations.go index 71fabf5..ddc2f6c 100644 --- a/fileOperations.go +++ b/fileOperations.go @@ -59,8 +59,8 @@ func generateFromTemplateAndData(templateContent string, entries []dataEntry) st func getTemplateParameters(line string) (string, string) { var templatePath string var data string - line = strings.Replace(line, "", "", -1) + line = strings.Replace(line, "", "", -1) attributes := strings.Split(line, " ") //fmt.Println(attributes) for i := 0; i < len(attributes); i++ { @@ -90,7 +90,7 @@ func putTemplates(folderPath string, filename string) string { lineCount := 1 for scanner.Scan() { currentLine := scanner.Text() - if strings.Contains(currentLine, "") { + if strings.Contains(currentLine, "") { templatePath, data := getTemplateParameters(currentLine) fileContent = fileContent + useTemplate(templatePath, data) } else { diff --git a/konstrui b/konstrui new file mode 100755 index 0000000..5f6daf4 Binary files /dev/null and b/konstrui differ diff --git a/timmy.png b/konstrui.png similarity index 100% rename from timmy.png rename to konstrui.png diff --git a/main.go b/main.go index c8bc8f1..2ff5811 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( const rawFolderPath = "./webInput" const newFolderPath = "./webOutput" -const timmyConfigFile = "timmyConfig.json" +const konstruiConfigFile = "konstruiConfig.json" func parseDir(folderPath string, newDir string) { files, _ := ioutil.ReadDir(folderPath) @@ -34,8 +34,8 @@ func parseDir(folderPath string, newDir string) { } } func startTemplating(folderPath string, newDir string) { - for i := 0; i < len(timmyConfig.Files); i++ { - fName := timmyConfig.Files[i] + for i := 0; i < len(konstruiConfig.Files); i++ { + fName := konstruiConfig.Files[i] fileNameSplitted := strings.Split(fName, ".") extension := fileNameSplitted[len(fileNameSplitted)-1] if extension == "html" { @@ -49,10 +49,10 @@ func startTemplating(folderPath string, newDir string) { } func main() { c.Green("getting files from /webInput") - c.Green("getting conifg from file timmyConfig.json") - readTimmyConfig(rawFolderPath + "/" + timmyConfigFile) + c.Green("getting conifg from file konstruiConfig.json") + readKonstruiConfig(rawFolderPath + "/" + konstruiConfigFile) c.Green("configuration:") - fmt.Println(timmyConfig.Files) + fmt.Println(konstruiConfig.Files) c.Green("templating") //parseDir(rawFolderPath, newFolderPath) startTemplating(rawFolderPath, newFolderPath) diff --git a/readTimmyConfig.go b/readKonstruiConfig.go similarity index 57% rename from readTimmyConfig.go rename to readKonstruiConfig.go index 1fbcac7..a5d181c 100644 --- a/readTimmyConfig.go +++ b/readKonstruiConfig.go @@ -6,8 +6,8 @@ import ( "io/ioutil" ) -//TimmyConfig is the configuration from the file timmyConfig.json, on the folder /webInput -type TimmyConfig struct { +//KonstruiConfig is the configuration from the file konstruiConfig.json, on the folder /webInput +type KonstruiConfig struct { Title string `json:"title"` Author string `json:"author"` Github string `json:"github"` @@ -15,13 +15,13 @@ type TimmyConfig struct { Files []string `json:"files"` } -var timmyConfig TimmyConfig +var konstruiConfig KonstruiConfig -func readTimmyConfig(path string) { +func readKonstruiConfig(path string) { file, e := ioutil.ReadFile(path) if e != nil { fmt.Println("error:", e) } content := string(file) - json.Unmarshal([]byte(content), &timmyConfig) + json.Unmarshal([]byte(content), &konstruiConfig) } diff --git a/timmy b/timmy deleted file mode 100755 index 19b8712..0000000 Binary files a/timmy and /dev/null differ