diff --git a/db.go b/db.go
index 86514ff..5ecf9a2 100644
--- a/db.go
+++ b/db.go
@@ -41,7 +41,7 @@ func resultToBlogposts(res *sql.Rows) []BlogPost {
var content, author, title string
var timeInt int64
res.Scan(&content, &author, &title, &timeInt)
- post := BlogPost{Content:content, Author:author, Title:title, Time:time.Unix(timeInt, 0)}
+ post := BlogPost{Content:content, Author:author, Title:title, FTime:time.Unix(timeInt, 0).Format("02.01.2006 - 15:04:05")}
entries = append(entries, post)
}
return entries
diff --git a/main.go b/main.go
index 01fa728..9963689 100644
--- a/main.go
+++ b/main.go
@@ -20,5 +20,6 @@ type BlogPost struct {
Author string `"author"`
Secret string `"secret"`
Time time.Time `"time"`
+ FTime string `"ftime"`
}
diff --git a/server.go b/server.go
index cce9826..07d74f6 100644
--- a/server.go
+++ b/server.go
@@ -15,8 +15,8 @@ type OutputFormatter struct {
Content string
}
-type Wrapper struct {
- Post OutputFormatter
+type Blog struct {
+ Posts []BlogPost
}
func startServer() {
@@ -40,8 +40,7 @@ func get(w http.ResponseWriter, r *http.Request) {
}
*/
results := readBlogpostsFromDB()
- err = t.ExecuteTemplate(w, "overview.html", OutputFormatter{Author: results[0].Author, Content: results[0].Content})
- log.Println(err)
+ t.ExecuteTemplate(w, "overview.html", Blog{results})
}
func post(w http.ResponseWriter, r *http.Request) {
diff --git a/templates/overview.html b/templates/overview.html
index 183bede..81bd62b 100644
--- a/templates/overview.html
+++ b/templates/overview.html
@@ -1,7 +1,43 @@
-
-
- {{.Author}} said: {{.Content}}
+
+
+
+
Random Thought Dump
+
+ {{range $i, $p := $.Posts -}}
+
+
+ [{{$p.FTime}}] <{{$p.Author}}>
+ |
+
+ {{$p.Content}}
+ |
+
+ {{- end}}
+