1
0
mirror of https://github.com/beego/bee.git synced 2024-11-23 06:40:54 +00:00
bee/g_views.go
Faissal Elamraoui b8250ebb72 New Bee banner
Added a new Bee banner using ASCII art. When bee is invoked,
the banner is displayed with the version number (short banner).
A More verbose Banner is added to 'bee version' which shows
more information about the host and Go runtime.
2016-06-01 14:30:29 +02:00

52 lines
1.4 KiB
Go

package main
import (
"os"
"path"
"fmt"
)
// recipe
// admin/recipe
func generateView(vpath, crupath string) {
ColorLog("[INFO] Generating view...\n")
absvpath := path.Join(crupath, "views", vpath)
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)
fmt.Println("\tcreate\t", cfile)
} 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)
fmt.Println("\tcreate\t", cfile)
} 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)
fmt.Println("\tcreate\t", cfile)
} 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)
fmt.Println("\tcreate\t", cfile)
} else {
ColorLog("[ERRO] Could not create view file: %s\n", err)
os.Exit(2)
}
}