aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go17
-rw-r--r--views/index.html46
2 files changed, 32 insertions, 31 deletions
diff --git a/main.go b/main.go
index 863dd3a..c3d8ef6 100644
--- a/main.go
+++ b/main.go
@@ -13,9 +13,19 @@ import (
13) 13)
14 14
15var renderer *frontend.Renderer 15var renderer *frontend.Renderer
16var charakterin *login.Charakterin
16 17
17func index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { 18func index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
18 renderer.RenderPage("index", w, make(map[string]interface{})) 19 user, err := charakterin.GetUserFromRequest(r)
20 if err != nil {
21 http.Redirect(w, r, "/login", 302)
22 return
23 }
24
25 data := make(map[string]interface{})
26
27 data["username"] = user.GetName()
28 renderer.RenderPage("index", w, data)
19} 29}
20 30
21func main() { 31func main() {
@@ -27,16 +37,17 @@ func main() {
27 if err := db.Ping(); err != nil { 37 if err := db.Ping(); err != nil {
28 log.Fatal(err) 38 log.Fatal(err)
29 } 39 }
30 40
31 log.Println("database connection established") 41 log.Println("database connection established")
32 42
33 renderer = frontend.New("views") 43 renderer = frontend.New("views")
34 charakterin := login.New(db) 44 charakterin = login.New(db)
35 charakterin.UseRenderer(renderer) 45 charakterin.UseRenderer(renderer)
36 46
37 router := httprouter.New() 47 router := httprouter.New()
38 router.HandlerFunc("GET", "/login", charakterin.DisplayLogin) 48 router.HandlerFunc("GET", "/login", charakterin.DisplayLogin)
39 router.HandlerFunc("POST", "/login", charakterin.Login) 49 router.HandlerFunc("POST", "/login", charakterin.Login)
50 router.HandlerFunc("GET", "/logout", charakterin.Logout)
40 router.GET("/", index) 51 router.GET("/", index)
41 52
42 fs := http.FileServer(http.Dir("assets")) 53 fs := http.FileServer(http.Dir("assets"))
diff --git a/views/index.html b/views/index.html
index fd8c87f..81c801f 100644
--- a/views/index.html
+++ b/views/index.html
@@ -1,43 +1,33 @@
1{{ define "index" }} 1{{ define "index" }}
2<html> 2<html>
3 <head> 3 <head>
4 <link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'> 4 {{ template "materialize" }}
5 <title>grilist</title> 5 <title>grilist</title>
6 <style> 6 <style>
7 body { 7 body {
8 height: 100%; 8 height: 100%;
9 width: 100%;
9 overflow: hidden; 10 overflow: hidden;
10 } 11 }
11 12
12 .benis { 13 h1 {
13 height: 100%; 14 font-size: 100px;
14 width: 100%; 15 }
15 display: table; 16
16 } 17 h1 >small {
17 18 margin-top: -50px;
18 .uguu { 19 font-size: 20%;
19 height: 100%; 20 }
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> 21 </style>
34 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> 22 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
35 </head> 23 </head>
36 <body> 24 <body class="valign-wrapper center-align">
37 <div class="benis"> 25 <div class="container">
38 <div class="uguu"> 26 <div class="center-align">
39 <h1>grilist<br /><small>#tamtam</small></h1> 27 <h1>grilist<small class="blue-grey-text lighten-1">#tamtam</small></h1>
40 </div> 28
29 <a class="btn waves-effect waves-light cyan lighten-3" href="/logout">Ausloggen</a>
30 </div>
41 </div> 31 </div>
42 </body> 32 </body>
43</html> 33</html>