Make template directory configurable from config.json
This commit is contained in:
parent
4c6b88d530
commit
4d08ee53b0
|
@ -11,6 +11,7 @@ type Config struct {
|
||||||
Address string
|
Address string
|
||||||
DBpath string
|
DBpath string
|
||||||
StoreDir string
|
StoreDir string
|
||||||
|
HTMLTemplateDir string
|
||||||
UrlPrefix string
|
UrlPrefix string
|
||||||
IdLen int
|
IdLen int
|
||||||
AuthKeyLen int
|
AuthKeyLen int
|
||||||
|
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"html/template"
|
"html/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.fuwafuwa.moe/x3/ngfshare/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tmpl *template.Template
|
var tmpl *template.Template
|
||||||
|
@ -32,7 +34,7 @@ func addFuncs(t *template.Template) *template.Template {
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadTemplates() error {
|
func LoadTemplates() error {
|
||||||
t, err := addFuncs(template.New("")).ParseGlob("./templates/*")
|
t, err := addFuncs(template.New("")).ParseGlob(fmt.Sprintf("%s/*", config.Conf.HTMLTemplateDir))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("LoadTemplates:", err)
|
log.Println("LoadTemplates:", err)
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue