diff options
author | jan <jan@ruken.pw> | 2015-12-29 00:56:42 (UTC) |
---|---|---|
committer | jan <jan@ruken.pw> | 2015-12-29 00:56:42 (UTC) |
commit | f92f312cd3ebfacd2302b852e9097796ffa813af (patch) | |
tree | ab21488bf0cbcfd83dcc606ade5f07d6849af894 /modules | |
parent | e90f77d8cc4cc29a2d16b8b2257642befee45e77 (diff) |
bilder anzeigen (testweise)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/grils/grils.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/grils/grils.go b/modules/grils/grils.go index a1c84c7..7cbec77 100644 --- a/modules/grils/grils.go +++ b/modules/grils/grils.go | |||
@@ -8,6 +8,7 @@ import ( | |||
8 | "github.com/julienschmidt/httprouter" | 8 | "github.com/julienschmidt/httprouter" |
9 | "log" | 9 | "log" |
10 | "net/http" | 10 | "net/http" |
11 | "os" | ||
11 | "regexp" | 12 | "regexp" |
12 | "strconv" | 13 | "strconv" |
13 | "strings" | 14 | "strings" |
@@ -173,6 +174,18 @@ func (m *GrilsModule) viewGril(w http.ResponseWriter, r *http.Request, p httprou | |||
173 | data["user"] = user | 174 | data["user"] = user |
174 | data["gril"] = gril | 175 | data["gril"] = gril |
175 | 176 | ||
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 | data["imagePath"] = "/" + imagePath | ||
188 | |||
176 | m.g.Renderer.RenderPage("gril", w, data) | 189 | m.g.Renderer.RenderPage("gril", w, data) |
177 | } | 190 | } |
178 | 191 | ||