aboutsummaryrefslogtreecommitdiff
path: root/modules/grils
diff options
context:
space:
mode:
authorrtz12 <koenig@fagott.pw>2015-12-29 19:51:43 (UTC)
committerrtz12 <koenig@fagott.pw>2015-12-29 19:51:43 (UTC)
commit989ab00b731d659aa17d6a626efb899f8e400936 (patch)
tree8f31f5987a0ee6232b730dfad3fdd4d75f9ce153 /modules/grils
parentc2498d562d3e30e4795056058fc3d8a5cec4ec11 (diff)
parent1354a3a30c1639c1441e79356df12601151630a6 (diff)
Merge branch 'master' of projekte.fagott.pw:grilist
Diffstat (limited to 'modules/grils')
-rw-r--r--modules/grils/gril.go25
-rw-r--r--modules/grils/grils.go4
2 files changed, 25 insertions, 4 deletions
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