|
|
@ -1,6 +1,7 @@ |
|
|
|
package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"io/ioutil" |
|
|
|
"os" |
|
|
|
"strings" |
|
|
@ -8,6 +9,7 @@ import ( |
|
|
|
|
|
|
|
const rawFolderPath = "./webInput" |
|
|
|
const newFolderPath = "./webOutput" |
|
|
|
const timmyConfigFile = "timmyConfig.json" |
|
|
|
|
|
|
|
func parseDir(folderPath string, newDir string) { |
|
|
|
files, _ := ioutil.ReadDir(folderPath) |
|
|
@ -31,9 +33,28 @@ func parseDir(folderPath string, newDir string) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
func startTemplating(folderPath string, newDir string) { |
|
|
|
for i := 0; i < len(timmyConfig.Files); i++ { |
|
|
|
fName := timmyConfig.Files[i] |
|
|
|
fileNameSplitted := strings.Split(fName, ".") |
|
|
|
extension := fileNameSplitted[len(fileNameSplitted)-1] |
|
|
|
if extension == "html" { |
|
|
|
fileContent := putTemplates(folderPath, fName) |
|
|
|
writeFile(newDir+"/"+fName, fileContent) |
|
|
|
} else if extension == "css" { |
|
|
|
fileContent := readFile(folderPath, fName) |
|
|
|
writeFile(newDir+"/"+fName, fileContent) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
func main() { |
|
|
|
c.Green("getting files from /webInput") |
|
|
|
c.Green("getting conifg from file timmyConfig.json") |
|
|
|
readTimmyConfig(rawFolderPath + "/" + timmyConfigFile) |
|
|
|
c.Green("configuration:") |
|
|
|
fmt.Println(timmyConfig.Files) |
|
|
|
c.Green("templating") |
|
|
|
parseDir(rawFolderPath, newFolderPath) |
|
|
|
//parseDir(rawFolderPath, newFolderPath)
|
|
|
|
startTemplating(rawFolderPath, newFolderPath) |
|
|
|
c.Green("webpage finished, wiles at /webOutput") |
|
|
|
} |