From f92f312cd3ebfacd2302b852e9097796ffa813af Mon Sep 17 00:00:00 2001 From: jan Date: Tue, 29 Dec 2015 01:56:42 +0100 Subject: bilder anzeigen (testweise) 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 ( "github.com/julienschmidt/httprouter" "log" "net/http" + "os" "regexp" "strconv" "strings" @@ -173,6 +174,18 @@ func (m *GrilsModule) viewGril(w http.ResponseWriter, r *http.Request, p httprou data["user"] = user data["gril"] = gril + // get the file ending + exts := []string{"png", "jpg", "gif", "jpeg"} + var imagePath string + for _, ext := range exts { + path := fmt.Sprintf("assets/img/gril/%d/0.%s", gril.ID, ext) + if _, err := os.Stat(path); err == nil { + imagePath = path + break + } + } + data["imagePath"] = "/" + imagePath + m.g.Renderer.RenderPage("gril", w, data) } 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 @@ {{ template "navbar" . }}

{{ $gril.RomajiName }}{{ $gril.KanjiName }}

+
+ +
{{ range $tag := $gril.Tags }}
{{ $tag }} -- cgit v0.10.1