organize configuration

This commit is contained in:
710leo 2021-04-19 21:28:02 +08:00
parent c71264ab30
commit d49d40768c
8 changed files with 5 additions and 6 deletions

View File

@ -1 +0,0 @@
{}

View File

@ -58,7 +58,7 @@ func getConfigFile(name, ext string) (string, error) {
}
func init() {
filename, err := getConfigFile("login-code-sms", "tpl")
filename, err := getConfigFile("tpl/login-code-sms", "tpl")
if err != nil {
log.Fatal(err)
}
@ -68,7 +68,7 @@ func init() {
log.Fatalf("open %s err: %s", filename, err)
}
filename, err = getConfigFile("login-code-email", "tpl")
filename, err = getConfigFile("tpl/login-code-email", "tpl")
if err != nil {
log.Fatal(err)
}
@ -77,7 +77,7 @@ func init() {
log.Fatalf("open %s err: %s", filename, err)
}
filename, err = getConfigFile("password-changed-email", "tpl")
filename, err = getConfigFile("tpl/password-changed-email", "tpl")
if err != nil {
log.Fatal(err)
}

View File

@ -182,7 +182,7 @@ func genContent(isUpgrade bool, events []*models.Event) (string, string) {
}
// 生成告警邮件
fp := path.Join(file.SelfDir(), "etc", "mail.tpl")
fp := path.Join(file.SelfDir(), "etc", "tpl", "mail.tpl")
t, err := template.ParseFiles(fp)
if err != nil {
logger.Errorf("InternalServerError: cannot parse %s %v", fp, err)
@ -199,7 +199,7 @@ func genContent(isUpgrade bool, events []*models.Event) (string, string) {
}
// 生成告警短信短信和IM复用一个内容模板
fp = path.Join(file.SelfDir(), "etc", "sms.tpl")
fp = path.Join(file.SelfDir(), "etc", "tpl", "sms.tpl")
t, err = template.New("sms.tpl").Funcs(template.FuncMap{
"unescaped": func(str string) interface{} { return template.HTML(str) },
"urlconvert": func(str string) interface{} { return template.URL(str) },