2014-08-11 02:01:56 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-07-11 10:35:35 +00:00
|
|
|
"fmt"
|
2014-08-11 02:01:56 +00:00
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
)
|
|
|
|
|
|
|
|
// recipe
|
|
|
|
// admin/recipe
|
|
|
|
func generateView(vpath, crupath string) {
|
2016-06-01 12:30:29 +00:00
|
|
|
ColorLog("[INFO] Generating view...\n")
|
2014-08-11 09:01:00 +00:00
|
|
|
absvpath := path.Join(crupath, "views", vpath)
|
2014-08-11 02:01:56 +00:00
|
|
|
os.MkdirAll(absvpath, os.ModePerm)
|
|
|
|
cfile := path.Join(absvpath, "index.tpl")
|
|
|
|
if f, err := os.OpenFile(cfile, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666); err == nil {
|
|
|
|
defer f.Close()
|
|
|
|
f.WriteString(cfile)
|
2016-06-01 12:30:29 +00:00
|
|
|
fmt.Println("\tcreate\t", cfile)
|
2014-08-11 02:01:56 +00:00
|
|
|
} else {
|
|
|
|
ColorLog("[ERRO] Could not create view file: %s\n", err)
|
|
|
|
os.Exit(2)
|
|
|
|
}
|
|
|
|
cfile = path.Join(absvpath, "show.tpl")
|
|
|
|
if f, err := os.OpenFile(cfile, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666); err == nil {
|
|
|
|
defer f.Close()
|
|
|
|
f.WriteString(cfile)
|
2016-06-01 12:30:29 +00:00
|
|
|
fmt.Println("\tcreate\t", cfile)
|
2014-08-11 02:01:56 +00:00
|
|
|
} else {
|
|
|
|
ColorLog("[ERRO] Could not create view file: %s\n", err)
|
|
|
|
os.Exit(2)
|
|
|
|
}
|
|
|
|
cfile = path.Join(absvpath, "create.tpl")
|
|
|
|
if f, err := os.OpenFile(cfile, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666); err == nil {
|
|
|
|
defer f.Close()
|
|
|
|
f.WriteString(cfile)
|
2016-06-01 12:30:29 +00:00
|
|
|
fmt.Println("\tcreate\t", cfile)
|
2014-08-11 02:01:56 +00:00
|
|
|
} else {
|
|
|
|
ColorLog("[ERRO] Could not create view file: %s\n", err)
|
|
|
|
os.Exit(2)
|
|
|
|
}
|
|
|
|
cfile = path.Join(absvpath, "edit.tpl")
|
|
|
|
if f, err := os.OpenFile(cfile, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0666); err == nil {
|
|
|
|
defer f.Close()
|
|
|
|
f.WriteString(cfile)
|
2016-06-01 12:30:29 +00:00
|
|
|
fmt.Println("\tcreate\t", cfile)
|
2014-08-11 02:01:56 +00:00
|
|
|
} else {
|
|
|
|
ColorLog("[ERRO] Could not create view file: %s\n", err)
|
|
|
|
os.Exit(2)
|
|
|
|
}
|
|
|
|
}
|