diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-05-13 17:42:32 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-05-13 22:13:54 -0400 |
commit | 920306cbcad3df05e01699cd19f3767e069ab139 (patch) | |
tree | 32d8990ad80f5ce4e47b1ff0acdc0e1479bd43bd /init.go | |
parent | 61d34d492a6baab8e2aa420c1b1d0a562624b7d1 (diff) | |
download | getwtxt-920306cbcad3df05e01699cd19f3767e069ab139.tar.gz |
template initialization added
Diffstat (limited to 'init.go')
-rw-r--r-- | init.go | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/init.go b/init.go index f871a72..ee76f01 100644 --- a/init.go +++ b/init.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "html/template" "log" "os" "os/signal" @@ -24,11 +25,15 @@ var confObj = &configuration{} // signals to close the log file var closelog = make(chan bool, 1) +// templates +var tmpls *template.Template + func init() { checkFlags() titleScreen() initConfig() initLogging() + tmpls = initTemplates() watchForInterrupt() } @@ -69,15 +74,17 @@ func initConfig() { viper.SetDefault("port", 9001) viper.SetDefault("logfile", "getwtxt.log") - viper.SetDefault("twtxtfile", "/var/twtxt/twtxt.txt") + viper.SetDefault("stdoutLogging", false) confObj.port = viper.GetInt("port") confObj.logfile = viper.GetString("logfile") confObj.stdoutLogging = viper.GetBool("stdoutLogging") - confObj.instance.name = viper.GetString("instance.name") - confObj.instance.url = viper.GetString("instance.url") - confObj.instance.owner = viper.GetString("instance.owner") - confObj.instance.mail = viper.GetString("instance.mail") + confObj.version = getwtxt + confObj.Instance.Name = viper.GetString("instance.name") + confObj.Instance.URL = viper.GetString("instance.url") + confObj.Instance.Owner = viper.GetString("instance.owner") + confObj.Instance.Mail = viper.GetString("instance.mail") + confObj.Instance.Desc = viper.GetString("instance.description") } func initLogging() { @@ -121,15 +128,21 @@ func rebindConfig() { confObj.port = viper.GetInt("port") confObj.logfile = viper.GetString("logfile") confObj.stdoutLogging = viper.GetBool("stdoutLogging") - confObj.instance.name = viper.GetString("instance.name") - confObj.instance.url = viper.GetString("instance.url") - confObj.instance.owner = viper.GetString("instance.owner") - confObj.instance.mail = viper.GetString("instance.mail") + confObj.Instance.Name = viper.GetString("instance.name") + confObj.Instance.URL = viper.GetString("instance.url") + confObj.Instance.Owner = viper.GetString("instance.owner") + confObj.Instance.Mail = viper.GetString("instance.mail") + confObj.Instance.Desc = viper.GetString("instance.description") // reinitialize logging initLogging() } +// Parse the HTML templates +func initTemplates() *template.Template { + return template.Must(template.ParseFiles("assets/tmpl/index.html")) +} + // Watch for SIGINT aka ^C // Close the log file then exit func watchForInterrupt() { |