Copy archetype on signing up

This commit is contained in:
Wancat
2022-11-17 17:27:01 +08:00
parent c6b79938ea
commit a6510b34a4
5 changed files with 18 additions and 3 deletions

View File

@@ -12,6 +12,8 @@ import (
"strings"
"text/template"
"time"
cp "github.com/otiai10/copy"
)
type User struct {
@@ -22,12 +24,13 @@ type User struct {
func (u *User) Dir() string {
dir := path.Join(DATA_DIR, u.Email)
if err := os.MkdirAll(dir, 0755); err != nil {
panic(err)
}
return dir
}
func (u *User) Mkdir() error {
return cp.Copy(ARCHETYPES_DIR, u.Dir())
}
func (u *User) FilePath(name string) string {
return path.Join(u.Dir(), name)
}