From 8d92bdf7da95e1085485c0e60b9dac19c246e235 Mon Sep 17 00:00:00 2001 From: Alexander Kavon Date: Tue, 23 Jan 2024 06:33:20 -0500 Subject: move ui templates into src, update conf to handle other paths, export User Insert Hooks --- src/conf/conf.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/conf/conf.go') diff --git a/src/conf/conf.go b/src/conf/conf.go index 62ffb57..a0852dc 100644 --- a/src/conf/conf.go +++ b/src/conf/conf.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "os" + "path/filepath" "github.com/BurntSushi/toml" ) @@ -39,15 +40,16 @@ func NewConf() *Conf { if err != nil { log.Fatal(err) } - filepath := os.Getenv("NEWSSTAND_CONFIG_PATH") - if filepath == "" { - filepath = cwd + "/.newsstandrc.toml" + configpath := os.Getenv("NEWSSTAND_CONFIG_PATH") + if configpath == "" { + configpath = "./.newsstandrc.toml" } - log.Printf("Config file path: %s", filepath) + confpath := filepath.Clean(filepath.Join(cwd, configpath)) + log.Printf("Config file path: %s", confpath) c := Conf{ cwd, - filepath, + confpath, Db{ Hostname: "localhost", }, @@ -55,7 +57,7 @@ func NewConf() *Conf { UiPath: cwd + "/ui", }, } - _, err = toml.DecodeFile(filepath, &c) + _, err = toml.DecodeFile(confpath, &c) if err != nil { log.Fatalln(err) } -- cgit v1.2.3