From d49d40768c8d0fba36c4b0511e294d2bd99715c7 Mon Sep 17 00:00:00 2001 From: 710leo <710leo@gmail.com> Date: Mon, 19 Apr 2021 21:28:02 +0800 Subject: [PATCH] organize configuration --- etc/dict.json | 1 - etc/{ => tpl}/login-code-email.tpl | 0 etc/{ => tpl}/login-code-sms.tpl | 0 etc/{ => tpl}/mail.tpl | 0 etc/{ => tpl}/password-changed-email.tpl | 0 etc/{ => tpl}/sms.tpl | 0 src/modules/server/http/router_auth.go | 6 +++--- src/modules/server/notify/notify.go | 4 ++-- 8 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 etc/dict.json rename etc/{ => tpl}/login-code-email.tpl (100%) rename etc/{ => tpl}/login-code-sms.tpl (100%) rename etc/{ => tpl}/mail.tpl (100%) rename etc/{ => tpl}/password-changed-email.tpl (100%) rename etc/{ => tpl}/sms.tpl (100%) diff --git a/etc/dict.json b/etc/dict.json deleted file mode 100644 index 9e26dfee..00000000 --- a/etc/dict.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/etc/login-code-email.tpl b/etc/tpl/login-code-email.tpl similarity index 100% rename from etc/login-code-email.tpl rename to etc/tpl/login-code-email.tpl diff --git a/etc/login-code-sms.tpl b/etc/tpl/login-code-sms.tpl similarity index 100% rename from etc/login-code-sms.tpl rename to etc/tpl/login-code-sms.tpl diff --git a/etc/mail.tpl b/etc/tpl/mail.tpl similarity index 100% rename from etc/mail.tpl rename to etc/tpl/mail.tpl diff --git a/etc/password-changed-email.tpl b/etc/tpl/password-changed-email.tpl similarity index 100% rename from etc/password-changed-email.tpl rename to etc/tpl/password-changed-email.tpl diff --git a/etc/sms.tpl b/etc/tpl/sms.tpl similarity index 100% rename from etc/sms.tpl rename to etc/tpl/sms.tpl diff --git a/src/modules/server/http/router_auth.go b/src/modules/server/http/router_auth.go index 80605c79..fcbde44f 100644 --- a/src/modules/server/http/router_auth.go +++ b/src/modules/server/http/router_auth.go @@ -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) } diff --git a/src/modules/server/notify/notify.go b/src/modules/server/notify/notify.go index af1ee6af..9debe58f 100644 --- a/src/modules/server/notify/notify.go +++ b/src/modules/server/notify/notify.go @@ -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) },