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 /modules/grils/gril.go | |
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.
Diffstat (limited to 'modules/grils/gril.go')
-rw-r--r-- | modules/grils/gril.go | 23 |
1 files changed, 23 insertions, 0 deletions
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 | } | ||