From d6d002dda847b9bdeb6f464f7a1fafaab0419a55 Mon Sep 17 00:00:00 2001 From: jan Date: Tue, 29 Dec 2015 19:56:33 +0100 Subject: =?UTF-8?q?die=20grils=20werden=20jetzt=20in=20einer=20besseren=20?= =?UTF-8?q?liste=20dargestellt.=20es=20gibt=20bereits=20kn=C3=B6pfe=20zum?= =?UTF-8?q?=20umsortieren,=20muss=20aber=20alles=20noch=20implementiert=20?= =?UTF-8?q?werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff --git a/assets/css/list.css b/assets/css/list.css new file mode 100644 index 0000000..bc51fd2 --- /dev/null +++ b/assets/css/list.css @@ -0,0 +1,19 @@ +.jap-name { + color: rgb(166, 166, 166); +} + +.list-entry { + height: 80px; + padding: 8px; +} + +.list-img { + width: 64px; + height: 64px; +} + +.list-controls { + position: relative; + top: 8px; + left: -15px; +} \ No newline at end of file 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 import ( "database/sql" + "fmt" "github.com/lib/pq" + "os" "time" ) @@ -25,3 +27,24 @@ type Gril struct { UpdatedAt time.Time Lists []int } + +func (g *Gril) ImagePath() string { + exts := []string{"png", "jpg", "gif", "jpeg"} + var imagePath string + for _, ext := range exts { + path := fmt.Sprintf("assets/img/gril/%d/0.%s", g.ID, ext) + if _, err := os.Stat(path); err == nil { + return path + } + } + + if len(imagePath) == 0 { + for _, ext := range exts { + path := fmt.Sprintf("assets/img/gril/%d/1.%s", g.ID, ext) + if _, err := os.Stat(path); err == nil { + return path + } + } + } + return "" +} diff --git a/modules/grils/grils.go b/modules/grils/grils.go index 9bfd6e6..a1c84c7 100644 --- a/modules/grils/grils.go +++ b/modules/grils/grils.go @@ -8,7 +8,6 @@ import ( "github.com/julienschmidt/httprouter" "log" "net/http" - "os" "regexp" "strconv" "strings" @@ -174,28 +173,6 @@ 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 - } - } - - if len(imagePath) == 0 { - for _, ext := range exts { - path := fmt.Sprintf("assets/img/gril/%d/1.%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/modules/lists/lists.go b/modules/lists/lists.go index 94d4030..4c4288f 100644 --- a/modules/lists/lists.go +++ b/modules/lists/lists.go @@ -34,9 +34,8 @@ type List struct { // ListGril ist ein geranktes Gril type ListGril struct { - Gril *grils.Gril - Order int - ImagePath string + Gril *grils.Gril + Order int } // Name gibt den Namen des Moduls zurück diff --git a/views/gril.html b/views/gril.html index b012522..12b2e8d 100644 --- a/views/gril.html +++ b/views/gril.html @@ -12,7 +12,7 @@

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

- +
{{ range $tag := $gril.Tags }}
diff --git a/views/list.html b/views/list.html index 8fc7694..1c32bd7 100644 --- a/views/list.html +++ b/views/list.html @@ -21,7 +21,7 @@ {{ $index }}
- +
{{ $lg.Gril.RomajiName }}
-- cgit v0.10.1