aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/css/list.css27
-rw-r--r--grilist/grilist.go1
-rw-r--r--modules/grils/gril.go25
-rw-r--r--modules/grils/grils.go4
-rw-r--r--modules/lists/lists.go25
-rw-r--r--views/gril.html3
-rw-r--r--views/list.html74
-rw-r--r--views/navbar.html2
8 files changed, 127 insertions, 34 deletions
diff --git a/assets/css/list.css b/assets/css/list.css
new file mode 100644
index 0000000..7e6dde9
--- /dev/null
+++ b/assets/css/list.css
@@ -0,0 +1,27 @@
1.jap-name {
2 color: rgb(166, 166, 166);
3}
4
5.list-entry {
6 height: 80px;
7 padding: 8px;
8}
9
10.list-img {
11 width: 64px;
12 height: 64px;
13}
14
15.list-controls {
16 position: relative;
17 top: 8px;
18 left: -15px;
19}
20
21.gril-img {
22 background-repeat: no-repeat;
23 background-position: center center;
24 background-size: cover;
25 width: 64px;
26 height: 64px;
27} \ No newline at end of file
diff --git a/grilist/grilist.go b/grilist/grilist.go
index baff81c..f9a79b2 100644
--- a/grilist/grilist.go
+++ b/grilist/grilist.go
@@ -23,7 +23,6 @@ type Grilist struct {
23// Module ist ein Modul für Grilist. 23// Module ist ein Modul für Grilist.
24type Module interface { 24type Module interface {
25 Init(*Grilist) 25 Init(*Grilist)
26 Interface() interface{}
27 Name() string 26 Name() string
28 ProvideDashboardData(*charakterin.User) []DashboardCategory 27 ProvideDashboardData(*charakterin.User) []DashboardCategory
29} 28}
diff --git a/modules/grils/gril.go b/modules/grils/gril.go
index c8c6538..89dd7c4 100644
--- a/modules/grils/gril.go
+++ b/modules/grils/gril.go
@@ -3,6 +3,7 @@ package grils
3import ( 3import (
4 "database/sql" 4 "database/sql"
5 "fmt" 5 "fmt"
6 "os"
6 "strconv" 7 "strconv"
7 "strings" 8 "strings"
8 "time" 9 "time"
@@ -39,3 +40,27 @@ func (g *Gril) Slug() string {
39 g.ID, 40 g.ID,
40 strings.Replace(g.RomajiName, " ", "", -1)) 41 strings.Replace(g.RomajiName, " ", "", -1))
41} 42}
43
44func (g *Gril) ImagePath(prioritizeThumbnail bool) string {
45 var big string
46 exts := []string{"png", "jpg", "gif", "jpeg"}
47 for _, ext := range exts {
48 path := fmt.Sprintf("assets/img/gril/%d/0.%s", g.ID, ext)
49 if _, err := os.Stat(path); err == nil {
50 if prioritizeThumbnail {
51 big = path
52 } else {
53 return path
54 }
55 }
56 }
57
58 for _, ext := range exts {
59 path := fmt.Sprintf("assets/img/gril/%d/1.%s", g.ID, ext)
60 if _, err := os.Stat(path); err == nil {
61 return path
62 }
63 }
64
65 return big
66}
diff --git a/modules/grils/grils.go b/modules/grils/grils.go
index 46d0fb3..0df93a0 100644
--- a/modules/grils/grils.go
+++ b/modules/grils/grils.go
@@ -44,10 +44,6 @@ func (m *GrilsModule) Init(g *grilist.Grilist) {
44 m.g.Router.GET("/gril/:id/*rest", m.viewGril) 44 m.g.Router.GET("/gril/:id/*rest", m.viewGril)
45} 45}
46 46
47func (m *GrilsModule) Interface() interface{} {
48 return m
49}
50
51func (m *GrilsModule) getGrils(whereClause string, params ...interface{}) ([]*Gril, error) { 47func (m *GrilsModule) getGrils(whereClause string, params ...interface{}) ([]*Gril, error) {
52 var grils []*Gril 48 var grils []*Gril
53 49
diff --git a/modules/lists/lists.go b/modules/lists/lists.go
index 47501c2..4c4288f 100644
--- a/modules/lists/lists.go
+++ b/modules/lists/lists.go
@@ -52,7 +52,7 @@ func (m *Module) Init(g *grilist.Grilist) {
52 log.Fatal("lists: grils module not found") 52 log.Fatal("lists: grils module not found")
53 } 53 }
54 54
55 grilsModule, ok := gm.Interface().(*grils.GrilsModule) 55 grilsModule, ok := gm.(*grils.GrilsModule)
56 if !ok { 56 if !ok {
57 log.Fatal("lists: error with grils module") 57 log.Fatal("lists: error with grils module")
58 } 58 }
@@ -60,11 +60,6 @@ func (m *Module) Init(g *grilist.Grilist) {
60 m.g.Router.GET("/list/:id", m.viewList) 60 m.g.Router.GET("/list/:id", m.viewList)
61} 61}
62 62
63// Interface gibt das Modul zurück
64func (m *Module) Interface() interface{} {
65 return m
66}
67
68func (m *Module) getListGrils(list *List) error { 63func (m *Module) getListGrils(list *List) error {
69 rows, err := m.g.DB.Query(`SELECT gril_id, "order" FROM grilist.lists_grils WHERE list_id = $1`, list.ID) 64 rows, err := m.g.DB.Query(`SELECT gril_id, "order" FROM grilist.lists_grils WHERE list_id = $1`, list.ID)
70 if err != nil { 65 if err != nil {
@@ -96,7 +91,7 @@ func (m *Module) getListGrils(list *List) error {
96func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, error) { 91func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, error) {
97 var lists []*List 92 var lists []*List
98 93
99 rows, err := m.g.DB.Query(fmt.Sprintf(`SELECT id, name, description, fork_of, updated_at FROM grilist.lists WHERE %s`, whereClause), params...) 94 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...)
100 if err != nil { 95 if err != nil {
101 return nil, err 96 return nil, err
102 } 97 }
@@ -104,8 +99,8 @@ func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, e
104 defer rows.Close() 99 defer rows.Close()
105 for rows.Next() { 100 for rows.Next() {
106 list := &List{} 101 list := &List{}
107 102 var ownerID int
108 if err := rows.Scan(&list.ID, &list.Name, &list.Description, &list.ForkOf, &list.UpdatedAt); err != nil { 103 if err := rows.Scan(&list.ID, &list.Name, &list.Description, &list.ForkOf, &list.UpdatedAt, &ownerID); err != nil {
109 log.Println("error scanning row in getLists:", err) 104 log.Println("error scanning row in getLists:", err)
110 continue 105 continue
111 } 106 }
@@ -115,6 +110,14 @@ func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, e
115 continue 110 continue
116 } 111 }
117 112
113 // Owner kriegn
114 owner, err := m.g.Charakterin.GetUserByID(ownerID)
115 if err != nil {
116 log.Println("error retreiving owner of list", err)
117 continue
118 }
119 list.Owner = owner
120
118 lists = append(lists, list) 121 lists = append(lists, list)
119 } 122 }
120 123
@@ -161,8 +164,8 @@ func listsToCards(lists []*List) []frontend.Card {
161 Link: fmt.Sprintf("/list/%d", list.ID), 164 Link: fmt.Sprintf("/list/%d", list.ID),
162 }, 165 },
163 frontend.Action{ 166 frontend.Action{
164 Name: fmt.Sprintf(`<span class="chip">%d gril%s</span>`, len(list.Grils), s), 167 Name: fmt.Sprintf(`<span class="chip">%d gril%s</span>`, len(list.Grils), s),
165 Link: "#", 168 Link: "#",
166 Disabled: true, 169 Disabled: true,
167 }, 170 },
168 }, 171 },
diff --git a/views/gril.html b/views/gril.html
index 803cdde..776f14f 100644
--- a/views/gril.html
+++ b/views/gril.html
@@ -17,6 +17,9 @@
17 {{ $alias }}{{ end }} 17 {{ $alias }}{{ end }}
18 </p> 18 </p>
19 {{ end }} 19 {{ end }}
20 <div class="row center-align">
21 <img src="/{{ $gril.ImagePath false }}" />
22 </div>
20 {{ range $tag := $gril.Tags }} 23 {{ range $tag := $gril.Tags }}
21 <a href="/tag/{{ $tag }}" 24 <a href="/tag/{{ $tag }}"
22 alt="Mit &quot;{{ $tag }}&quot; getaggte Grils einsehen" 25 alt="Mit &quot;{{ $tag }}&quot; getaggte Grils einsehen"
diff --git a/views/list.html b/views/list.html
index c944e87..0393d19 100644
--- a/views/list.html
+++ b/views/list.html
@@ -1,22 +1,62 @@
1{{ define "list" }} 1{{ define "list" }}
2{{ $list := .list }} 2{{ $list := .list }}
3{{ $user := .user }}
3<html> 4<html>
4 <head> 5 <head>
5 {{ template "materialize" }} 6 {{ template "materialize" }}
6 <title>grilist</title> 7 <title>grilist</title>
7 <link rel="stylesheet" href="/assets/css/gril.css" /> 8 <link rel="stylesheet" href="/assets/css/list.css" />
8 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> 9 <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
9 </head> 10 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
10 <body> 11 </head>
11 {{ template "navbar" . }} 12 <body>
12 <div class="container"> 13 {{ template "navbar" . }}
13 <h1>{{ $list.Name }}<small>von xyz</small></h1><br /> 14 <div class="container">
14 <ul> 15 <h1>{{ $list.Name }}<small>von {{ $list.Owner.GetName }}</small></h1><br />
15 {{ range $lg := $list.Grils }} 16 <ul class="gril-list">
16 <li><a href="/gril/{{ $lg.Gril.Slug }}">{{ $lg.Gril.RomajiName }}</a></li> 17 {{ range $index, $lg := $list.Grils }}
17 {{ end }} 18 <li id="{{ $index }}" class="col s12 m8 offset-m2 l6 offset-l3">
18 </ul> 19 <div class="card-panel hoverable list-entry">
19 </div> 20 <div class="row valign-wrapper">
20 </body> 21 <div class="col s1 rank-text">
22 {{ $index }}
23 </div>
24 <div class="col s3 m2">
25 <div class="circle gril-img" style="background-image: url(/{{ $lg.Gril.ImagePath true }})"> </div>
26 </div>
27 <div class="col s6 m6">
28 <span><a href="/gril/{{ $lg.Gril.Slug }}">{{ $lg.Gril.RomajiName }}</a><br />
29 <span class="jap-name">{{ $lg.Gril.KanjiName }}</span>
30 </span>
31 </div>
32 {{ if ($user) and eq $user.ID $list.Owner.ID }}
33 <div class="col s2 m3">
34 <div class="hide-on-med-and-up">
35 <div class="row list-controls valign-wrapper">
36 <div class="col s6 left-align">
37 <i class="material-icons grey-text" onClick="">keyboard_arrow_up</i>
38 <i class="material-icons grey-text" onClick="">keyboard_arrow_down</i>
39 </div>
40 <div class="col s4 left-align">
41 <i class="hide-on-med-and-up material-icons delete-icon grey-text" onClick="">delete</i>
42 </div>
43 </div>
44 </div>
45 <div class="hide-on-small-only">
46 <div class="valign-wrapper">
47 <i class="medium material-icons grey-text" onClick="">keyboard_arrow_up</i>
48 <i class="medium material-icons grey-text" onClick="">keyboard_arrow_down</i>
49 <i class="material-icons grey-text" onClick="">delete</i>
50 </div>
51 </div>
52 </div>
53 {{ end }}
54 </div>
55 </div>
56 </li>
57 {{ end }}
58 </ul>
59 </div>
60 </body>
21</html> 61</html>
22{{ end }} 62{{ end }}
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>