You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
1.0 KiB

package main
import (
"io/ioutil"
"os"
"strings"
)
const rawFolderPath = "./webInput"
const newFolderPath = "./webOutput"
func parseDir(folderPath string, newDir string) {
files, _ := ioutil.ReadDir(folderPath)
for _, f := range files {
fileNameSplitted := strings.Split(f.Name(), ".")
extension := fileNameSplitted[len(fileNameSplitted)-1]
if extension == "html" {
fileContent := putTemplates(folderPath, f.Name())
writeFile(newDir+"/"+f.Name(), fileContent)
} else if extension == "css" {
fileContent := readFile(folderPath, f.Name())
writeFile(newDir+"/"+f.Name(), fileContent)
}
if len(fileNameSplitted) == 1 {
newDir := newDir + "/" + f.Name()
oldDir := rawFolderPath + "/" + f.Name()
if _, err := os.Stat(newDir); os.IsNotExist(err) {
_ = os.Mkdir(newDir, 0700)
}
parseDir(oldDir, newDir)
}
}
}
func main() {
c.Green("getting files from /webInput")
c.Green("templating")
parseDir(rawFolderPath, newFolderPath)
c.Green("webpage finished, wiles at /webOutput")
}