diff options
author | jan <jan@ruken.pw> | 2015-12-29 18:56:33 (UTC) |
---|---|---|
committer | jan <jan@ruken.pw> | 2015-12-29 18:56:33 (UTC) |
commit | d6d002dda847b9bdeb6f464f7a1fafaab0419a55 (patch) | |
tree | d0b64c779c1aab618e82d419c1071944d0b18b3d | |
parent | 0189b471cab18ec565bfa5605015d6f994cdde00 (diff) |
die grils werden jetzt in einer besseren liste dargestellt. es gibt bereits knöpfe zum umsortieren, muss aber alles noch implementiert werden.
-rw-r--r-- | assets/css/list.css | 19 | ||||
-rw-r--r-- | modules/grils/gril.go | 23 | ||||
-rw-r--r-- | modules/grils/grils.go | 23 | ||||
-rw-r--r-- | modules/lists/lists.go | 5 | ||||
-rw-r--r-- | views/gril.html | 2 | ||||
-rw-r--r-- | views/list.html | 2 |
6 files changed, 46 insertions, 28 deletions
diff --git a/assets/css/list.css b/assets/css/list.css new file mode 100644 index 0000000..bc51fd2 --- /dev/null +++ b/assets/css/list.css | |||
@@ -0,0 +1,19 @@ | |||
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 | } \ No newline at end of file | ||
diff --git a/modules/grils/gril.go b/modules/grils/gril.go index edf25a9..a450647 100644 --- a/modules/grils/gril.go +++ b/modules/grils/gril.go | |||
@@ -2,7 +2,9 @@ package grils | |||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "database/sql" | 4 | "database/sql" |
5 | "fmt" | ||
5 | "github.com/lib/pq" | 6 | "github.com/lib/pq" |
7 | "os" | ||
6 | "time" | 8 | "time" |
7 | ) | 9 | ) |
8 | 10 | ||
@@ -25,3 +27,24 @@ type Gril struct { | |||
25 | UpdatedAt time.Time | 27 | UpdatedAt time.Time |
26 | Lists []int | 28 | Lists []int |
27 | } | 29 | } |
30 | |||
31 | func (g *Gril) ImagePath() string { | ||
32 | exts := []string{"png", "jpg", "gif", "jpeg"} | ||
33 | var imagePath string | ||
34 | for _, ext := range exts { | ||
35 | path := fmt.Sprintf("assets/img/gril/%d/0.%s", g.ID, ext) | ||
36 | if _, err := os.Stat(path); err == nil { | ||
37 | return path | ||
38 | } | ||
39 | } | ||
40 | |||
41 | if len(imagePath) == 0 { | ||
42 | for _, ext := range exts { | ||
43 | path := fmt.Sprintf("assets/img/gril/%d/1.%s", g.ID, ext) | ||
44 | if _, err := os.Stat(path); err == nil { | ||
45 | return path | ||
46 | } | ||
47 | } | ||
48 | } | ||
49 | return "" | ||
50 | } | ||
diff --git a/modules/grils/grils.go b/modules/grils/grils.go index 9bfd6e6..a1c84c7 100644 --- a/modules/grils/grils.go +++ b/modules/grils/grils.go | |||
@@ -8,7 +8,6 @@ import ( | |||
8 | "github.com/julienschmidt/httprouter" | 8 | "github.com/julienschmidt/httprouter" |
9 | "log" | 9 | "log" |
10 | "net/http" | 10 | "net/http" |
11 | "os" | ||
12 | "regexp" | 11 | "regexp" |
13 | "strconv" | 12 | "strconv" |
14 | "strings" | 13 | "strings" |
@@ -174,28 +173,6 @@ func (m *GrilsModule) viewGril(w http.ResponseWriter, r *http.Request, p httprou | |||
174 | data["user"] = user | 173 | data["user"] = user |
175 | data["gril"] = gril | 174 | data["gril"] = gril |
176 | 175 | ||
177 | // get the file ending | ||
178 | exts := []string{"png", "jpg", "gif", "jpeg"} | ||
179 | var imagePath string | ||
180 | for _, ext := range exts { | ||
181 | path := fmt.Sprintf("assets/img/gril/%d/0.%s", gril.ID, ext) | ||
182 | if _, err := os.Stat(path); err == nil { | ||
183 | imagePath = path | ||
184 | break | ||
185 | } | ||
186 | } | ||
187 | |||
188 | if len(imagePath) == 0 { | ||
189 | for _, ext := range exts { | ||
190 | path := fmt.Sprintf("assets/img/gril/%d/1.%s", gril.ID, ext) | ||
191 | if _, err := os.Stat(path); err == nil { | ||
192 | imagePath = path | ||
193 | break | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | data["imagePath"] = "/" + imagePath | ||
198 | |||
199 | m.g.Renderer.RenderPage("gril", w, data) | 176 | m.g.Renderer.RenderPage("gril", w, data) |
200 | } | 177 | } |
201 | 178 | ||
diff --git a/modules/lists/lists.go b/modules/lists/lists.go index 94d4030..4c4288f 100644 --- a/modules/lists/lists.go +++ b/modules/lists/lists.go | |||
@@ -34,9 +34,8 @@ type List struct { | |||
34 | 34 | ||
35 | // ListGril ist ein geranktes Gril | 35 | // ListGril ist ein geranktes Gril |
36 | type ListGril struct { | 36 | type ListGril struct { |
37 | Gril *grils.Gril | 37 | Gril *grils.Gril |
38 | Order int | 38 | Order int |
39 | ImagePath string | ||
40 | } | 39 | } |
41 | 40 | ||
42 | // Name gibt den Namen des Moduls zurück | 41 | // Name gibt den Namen des Moduls zurück |
diff --git a/views/gril.html b/views/gril.html index b012522..12b2e8d 100644 --- a/views/gril.html +++ b/views/gril.html | |||
@@ -12,7 +12,7 @@ | |||
12 | <div class="container"> | 12 | <div class="container"> |
13 | <h1>{{ $gril.RomajiName }}<small>{{ $gril.KanjiName }}</small></h1> | 13 | <h1>{{ $gril.RomajiName }}<small>{{ $gril.KanjiName }}</small></h1> |
14 | <div class="row center-align"> | 14 | <div class="row center-align"> |
15 | <img src="{{ .imagePath }}" /> | 15 | <img src="/{{ $gril.ImagePath }}" /> |
16 | </div> | 16 | </div> |
17 | {{ range $tag := $gril.Tags }} | 17 | {{ range $tag := $gril.Tags }} |
18 | <div class="chip"> | 18 | <div class="chip"> |
diff --git a/views/list.html b/views/list.html index 8fc7694..1c32bd7 100644 --- a/views/list.html +++ b/views/list.html | |||
@@ -21,7 +21,7 @@ | |||
21 | {{ $index }} | 21 | {{ $index }} |
22 | </div> | 22 | </div> |
23 | <div class="col s3 m2"> | 23 | <div class="col s3 m2"> |
24 | <img src="{{ $lg.Image }}" alt="" class="circle list-img" /> | 24 | <img src="/{{ $lg.Gril.ImagePath }}" alt="" class="circle list-img" /> |
25 | </div> | 25 | </div> |
26 | <div class="col s6 m6"> | 26 | <div class="col s6 m6"> |
27 | <span><a href="/gril/{{ $lg.Gril.ID }}">{{ $lg.Gril.RomajiName }}</a><br /> | 27 | <span><a href="/gril/{{ $lg.Gril.ID }}">{{ $lg.Gril.RomajiName }}</a><br /> |