Make template directory configurable from config.json

This commit is contained in:
x3 2024-02-25 19:03:35 +01:00
parent 4c6b88d530
commit 4d08ee53b0
Signed by: x3
GPG Key ID: 7E9961E8AD0E240E
2 changed files with 4 additions and 1 deletions

View File

@ -11,6 +11,7 @@ type Config struct {
Address string
DBpath string
StoreDir string
HTMLTemplateDir string
UrlPrefix string
IdLen int
AuthKeyLen int

View File

@ -6,6 +6,8 @@ import (
"io"
"html/template"
"time"
"git.fuwafuwa.moe/x3/ngfshare/config"
)
var tmpl *template.Template
@ -32,7 +34,7 @@ func addFuncs(t *template.Template) *template.Template {
}
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 {
log.Println("LoadTemplates:", err)
return err