summary refs log tree commit diff stats
path: root/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'init.go')
-rw-r--r--init.go31
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() {
c1efc41470764126e9a1a7f4e0cfec4213587'>ce2c1efc ^
60338448 ^
e99038ea ^
ce2c1efc ^
ce2c1efc ^
60338448 ^
34c84469 ^















ce2c1efc ^
34c84469 ^















c8a3ccbe ^
34c84469 ^
52daf072 ^






2104d1a7 ^

52daf072 ^









2104d1a7 ^
52daf072 ^

33352536 ^
52daf072 ^

33352536 ^
52daf072 ^



33352536 ^
2104d1a7 ^
33352536 ^





52daf072 ^

2104d1a7 ^
b1635a5c ^
33352536 ^

52daf072 ^
33352536 ^

52daf072 ^
33352536 ^
8aeb85f0 ^
52daf072 ^
33352536 ^

52daf072 ^
33352536 ^


2104d1a7 ^
33352536 ^
2104d1a7 ^
33352536 ^

52daf072 ^

33352536 ^

b1635a5c ^
33352536 ^

52daf072 ^




fa786ea7 ^
52daf072 ^

8aeb85f0 ^
52daf072 ^











34c84469 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154