aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2015-12-29 00:56:42 (UTC)
committerjan <jan@ruken.pw>2015-12-29 00:56:42 (UTC)
commitf92f312cd3ebfacd2302b852e9097796ffa813af (patch)
treeab21488bf0cbcfd83dcc606ade5f07d6849af894
parente90f77d8cc4cc29a2d16b8b2257642befee45e77 (diff)
bilder anzeigen (testweise)
-rw-r--r--modules/grils/grils.go13
-rw-r--r--views/gril.html3
2 files changed, 16 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
diff --git a/views/gril.html b/views/gril.html
index c7ecbdc..7983aa1 100644
--- a/views/gril.html
+++ b/views/gril.html
@@ -11,6 +11,9 @@
11 {{ template "navbar" . }} 11 {{ template "navbar" . }}
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">
15 <img class="center-align" src="{{ .imagePath }}" />
16 </div>
14 {{ range $tag := $gril.Tags }} 17 {{ range $tag := $gril.Tags }}
15 <div class="chip"> 18 <div class="chip">
16 {{ $tag }} 19 {{ $tag }}