aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go11
-rw-r--r--views/index.html44
2 files changed, 53 insertions, 2 deletions
diff --git a/main.go b/main.go
index ba1d012..c0b1d23 100644
--- a/main.go
+++ b/main.go
@@ -11,6 +11,12 @@ import (
11 _ "github.com/lib/pq" 11 _ "github.com/lib/pq"
12) 12)
13 13
14var renderer *frontend.Renderer
15
16func index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
17 renderer.RenderPage("index", w, make(map[string]interface{}))
18}
19
14func main() { 20func main() {
15 // Datenbankverbindung aufbauen 21 // Datenbankverbindung aufbauen
16 db, err := sql.Open("postgres", "host=grilist.moe user=grilist dbname=grilist password=grilist sslmode=disable") 22 db, err := sql.Open("postgres", "host=grilist.moe user=grilist dbname=grilist password=grilist sslmode=disable")
@@ -19,13 +25,14 @@ func main() {
19 } 25 }
20 log.Println("database connection established") 26 log.Println("database connection established")
21 27
22 frontend := frontend.New("views") 28 renderer = frontend.New("views")
23 charakterin := login.New(db) 29 charakterin := login.New(db)
24 charakterin.UseRenderer(frontend) 30 charakterin.UseRenderer(renderer)
25 31
26 router := httprouter.New() 32 router := httprouter.New()
27 router.HandlerFunc("GET", "/login", charakterin.DisplayLogin) 33 router.HandlerFunc("GET", "/login", charakterin.DisplayLogin)
28 router.HandlerFunc("POST", "/login", charakterin.Login) 34 router.HandlerFunc("POST", "/login", charakterin.Login)
35 router.GET("/", index)
29 36
30 fs := http.FileServer(http.Dir("assets")) 37 fs := http.FileServer(http.Dir("assets"))
31 http.Handle("/assets/", http.StripPrefix("/assets/", fs)) 38 http.Handle("/assets/", http.StripPrefix("/assets/", fs))
diff --git a/views/index.html b/views/index.html
new file mode 100644
index 0000000..fd8c87f
--- /dev/null
+++ b/views/index.html
@@ -0,0 +1,44 @@
1{{ define "index" }}
2<html>
3 <head>
4 <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
5 <title>grilist</title>
6 <style>
7 body {
8 height: 100%;
9 overflow: hidden;
10 }
11
12 .benis {
13 height: 100%;
14 width: 100%;
15 display: table;
16 }
17
18 .uguu {
19 height: 100%;
20 vertical-align: middle;
21 display: table-cell;
22 }
23
24 h1 {
25 font-family: 'Roboto', sans-serif;
26 font-size: 88px;
27 width: 100%;
28 text-align: center;
29 }
30 h1 > small {
31 font-size: 33%;
32 }
33 </style>
34 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
35 </head>
36 <body>
37 <div class="benis">
38 <div class="uguu">
39 <h1>grilist<br /><small>#tamtam</small></h1>
40 </div>
41 </div>
42 </body>
43</html>
44{{ end }} \ No newline at end of file