aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2015-12-29 18:52:53 (UTC)
committerjan <jan@ruken.pw>2015-12-29 18:52:53 (UTC)
commitb46c72a602cc9b3780c6f01f4275703e6b3e5b2e (patch)
tree0da2055df7165ec06d55b0b70ba3c5ed4fc648e7
parent0921b37a8b3f7f97128ae447b75cffeb1d4d22dc (diff)
wip: richtige liste für grils
-rw-r--r--modules/lists/lists.go19
-rw-r--r--views/list.html71
-rw-r--r--views/navbar.html2
3 files changed, 69 insertions, 23 deletions
diff --git a/modules/lists/lists.go b/modules/lists/lists.go
index dcc7046..94d4030 100644
--- a/modules/lists/lists.go
+++ b/modules/lists/lists.go
@@ -34,8 +34,9 @@ type List struct {
34 34
35// ListGril ist ein geranktes Gril 35// ListGril ist ein geranktes Gril
36type ListGril struct { 36type ListGril struct {
37 Gril *grils.Gril 37 Gril *grils.Gril
38 Order int 38 Order int
39 ImagePath string
39} 40}
40 41
41// Name gibt den Namen des Moduls zurück 42// Name gibt den Namen des Moduls zurück
@@ -91,7 +92,7 @@ func (m *Module) getListGrils(list *List) error {
91func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, error) { 92func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, error) {
92 var lists []*List 93 var lists []*List
93 94
94 rows, err := m.g.DB.Query(fmt.Sprintf(`SELECT id, name, description, fork_of, updated_at FROM grilist.lists WHERE %s`, whereClause), params...) 95 rows, err := m.g.DB.Query(fmt.Sprintf(`SELECT id, name, description, fork_of, updated_at, user_id FROM grilist.lists WHERE %s`, whereClause), params...)
95 if err != nil { 96 if err != nil {
96 return nil, err 97 return nil, err
97 } 98 }
@@ -99,8 +100,8 @@ func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, e
99 defer rows.Close() 100 defer rows.Close()
100 for rows.Next() { 101 for rows.Next() {
101 list := &List{} 102 list := &List{}
102 103 var ownerID int
103 if err := rows.Scan(&list.ID, &list.Name, &list.Description, &list.ForkOf, &list.UpdatedAt); err != nil { 104 if err := rows.Scan(&list.ID, &list.Name, &list.Description, &list.ForkOf, &list.UpdatedAt, &ownerID); err != nil {
104 log.Println("error scanning row in getLists:", err) 105 log.Println("error scanning row in getLists:", err)
105 continue 106 continue
106 } 107 }
@@ -110,6 +111,14 @@ func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, e
110 continue 111 continue
111 } 112 }
112 113
114 // Owner kriegn
115 owner, err := m.g.Charakterin.GetUserByID(ownerID)
116 if err != nil {
117 log.Println("error retreiving owner of list", err)
118 continue
119 }
120 list.Owner = owner
121
113 lists = append(lists, list) 122 lists = append(lists, list)
114 } 123 }
115 124
diff --git a/views/list.html b/views/list.html
index fb5f7a3..8fc7694 100644
--- a/views/list.html
+++ b/views/list.html
@@ -1,22 +1,59 @@
1{{ define "list" }} 1{{ define "list" }}
2{{ $list := .list }} 2{{ $list := .list }}
3<html> 3<html>
4 <head> 4 <head>
5 {{ template "materialize" }} 5 {{ template "materialize" }}
6 <title>grilist</title> 6 <title>grilist</title>
7 <link rel="stylesheet" href="/assets/css/gril.css" /> 7 <link rel="stylesheet" href="/assets/css/list.css" />
8 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> 8 <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
9 </head> 9 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
10 <body> 10 </head>
11 {{ template "navbar" . }} 11 <body>
12 <div class="container"> 12 {{ template "navbar" . }}
13 <h1>{{ $list.Name }}<small>von xyz</small></h1><br /> 13 <div class="container">
14 <ul> 14 <h1>{{ $list.Name }}<small>von {{ $list.Owner.GetName }}</small></h1><br />
15 {{ range $lg := $list.Grils }} 15 <ul class="gril-list">
16 <li><a href="/gril/{{ $lg.Gril.ID }}">{{ $lg.Gril.RomajiName }}</a></li> 16 {{ range $index, $lg := $list.Grils }}
17 {{ end }} 17 <li id="{{ $index }}" class="col s12 m8 offset-m2 l6 offset-l3">
18 </ul> 18 <div class="card-panel hoverable list-entry">
19 </div> 19 <div class="row valign-wrapper">
20 </body> 20 <div class="col s1 rank-text">
21 {{ $index }}
22 </div>
23 <div class="col s3 m2">
24 <img src="{{ $lg.Image }}" alt="" class="circle list-img" />
25 </div>
26 <div class="col s6 m6">
27 <span><a href="/gril/{{ $lg.Gril.ID }}">{{ $lg.Gril.RomajiName }}</a><br />
28 <span class="jap-name">{{ $lg.Gril.KanjiName }}</span>
29 </span>
30 </div>
31 <div class="col s2 m3">
32 <div class="hide-on-med-and-up">
33 <div class="row list-controls valign-wrapper">
34 <div class="col s6 left-align">
35 <i class="material-icons" onClick="">keyboard_arrow_up</i>
36 <i class="material-icons" onClick="">keyboard_arrow_down</i>
37 </div>
38 <div class="col s4 left-align">
39 <i class="hide-on-med-and-up material-icons delete-icon" onClick="">delete</i>
40 </div>
41 </div>
42 </div>
43 <div class="hide-on-small-only">
44 <div class="valign-wrapper">
45 <i class="medium material-icons" onClick="">keyboard_arrow_up</i>
46 <i class="medium material-icons" onClick="">keyboard_arrow_down</i>
47 <i class="material-icons" onClick="">delete</i>
48 </div>
49 </div>
50 </div>
51 </div>
52 </div>
53 </li>
54 {{ end }}
55 </ul>
56 </div>
57 </body>
21</html> 58</html>
22{{ end }} \ No newline at end of file 59{{ end }} \ No newline at end of file
diff --git a/views/navbar.html b/views/navbar.html
index 70911e4..8905a1d 100644
--- a/views/navbar.html
+++ b/views/navbar.html
@@ -4,7 +4,7 @@
4 <a href="/" class="brand-logo center">grilist</a> 4 <a href="/" class="brand-logo center">grilist</a>
5 <ul id="nav-mobile" class="right hide-on-med-and-down"> 5 <ul id="nav-mobile" class="right hide-on-med-and-down">
6 {{ if .user }} 6 {{ if .user }}
7 <li><a href="/">{{ .user.Name }}</a></li> 7 <li><a href="/">{{ .user.GetName }}</a></li>
8 <li><a href="/logout">Ausloggen</a></li> 8 <li><a href="/logout">Ausloggen</a></li>
9 {{ else }} 9 {{ else }}
10 <li><a href="/login">Einloggen</a></li> 10 <li><a href="/login">Einloggen</a></li>