From e90f77d8cc4cc29a2d16b8b2257642befee45e77 Mon Sep 17 00:00:00 2001 From: jan Date: Tue, 29 Dec 2015 00:11:01 +0100 Subject: interfacekacke entfernt diff --git a/grilist/grilist.go b/grilist/grilist.go index baff81c..f9a79b2 100644 --- a/grilist/grilist.go +++ b/grilist/grilist.go @@ -23,7 +23,6 @@ type Grilist struct { // Module ist ein Modul für Grilist. type Module interface { Init(*Grilist) - Interface() interface{} Name() string ProvideDashboardData(*charakterin.User) []DashboardCategory } diff --git a/modules/grils/grils.go b/modules/grils/grils.go index 8ec7bcb..a1c84c7 100644 --- a/modules/grils/grils.go +++ b/modules/grils/grils.go @@ -41,10 +41,6 @@ func (m *GrilsModule) Init(g *grilist.Grilist) { m.g.Router.GET("/gril/:id", m.viewGril) } -func (m *GrilsModule) Interface() interface{} { - return m -} - func (m *GrilsModule) getGrils(whereClause string, params ...interface{}) ([]*Gril, error) { var grils []*Gril diff --git a/modules/lists/lists.go b/modules/lists/lists.go index 47501c2..dcc7046 100644 --- a/modules/lists/lists.go +++ b/modules/lists/lists.go @@ -52,7 +52,7 @@ func (m *Module) Init(g *grilist.Grilist) { log.Fatal("lists: grils module not found") } - grilsModule, ok := gm.Interface().(*grils.GrilsModule) + grilsModule, ok := gm.(*grils.GrilsModule) if !ok { log.Fatal("lists: error with grils module") } @@ -60,11 +60,6 @@ func (m *Module) Init(g *grilist.Grilist) { m.g.Router.GET("/list/:id", m.viewList) } -// Interface gibt das Modul zurück -func (m *Module) Interface() interface{} { - return m -} - func (m *Module) getListGrils(list *List) error { rows, err := m.g.DB.Query(`SELECT gril_id, "order" FROM grilist.lists_grils WHERE list_id = $1`, list.ID) if err != nil { @@ -161,8 +156,8 @@ func listsToCards(lists []*List) []frontend.Card { Link: fmt.Sprintf("/list/%d", list.ID), }, frontend.Action{ - Name: fmt.Sprintf(`%d gril%s`, len(list.Grils), s), - Link: "#", + Name: fmt.Sprintf(`%d gril%s`, len(list.Grils), s), + Link: "#", Disabled: true, }, }, -- cgit v0.10.1 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 From 0921b37a8b3f7f97128ae447b75cffeb1d4d22dc Mon Sep 17 00:00:00 2001 From: jan Date: Tue, 29 Dec 2015 02:02:01 +0100 Subject: bild zentrieren diff --git a/views/gril.html b/views/gril.html index 7983aa1..b012522 100644 --- a/views/gril.html +++ b/views/gril.html @@ -11,8 +11,8 @@ {{ template "navbar" . }}

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

-
- +
+
{{ range $tag := $gril.Tags }}
-- cgit v0.10.1 From 5fc85b069844a4a4f242559ae76ba900bccd7ba3 Mon Sep 17 00:00:00 2001 From: jan Date: Tue, 29 Dec 2015 13:54:14 +0100 Subject: alternativ das thumbnail als bild anzeigen diff --git a/modules/grils/grils.go b/modules/grils/grils.go index 7cbec77..9bfd6e6 100644 --- a/modules/grils/grils.go +++ b/modules/grils/grils.go @@ -184,6 +184,16 @@ func (m *GrilsModule) viewGril(w http.ResponseWriter, r *http.Request, p httprou 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) -- cgit v0.10.1 From b46c72a602cc9b3780c6f01f4275703e6b3e5b2e Mon Sep 17 00:00:00 2001 From: jan Date: Tue, 29 Dec 2015 19:52:53 +0100 Subject: =?UTF-8?q?wip:=20richtige=20liste=20f=C3=BCr=20grils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit diff --git a/modules/lists/lists.go b/modules/lists/lists.go index dcc7046..94d4030 100644 --- a/modules/lists/lists.go +++ b/modules/lists/lists.go @@ -34,8 +34,9 @@ type List struct { // ListGril ist ein geranktes Gril type ListGril struct { - Gril *grils.Gril - Order int + Gril *grils.Gril + Order int + ImagePath string } // Name gibt den Namen des Moduls zurück @@ -91,7 +92,7 @@ func (m *Module) getListGrils(list *List) error { func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, error) { var lists []*List - rows, err := m.g.DB.Query(fmt.Sprintf(`SELECT id, name, description, fork_of, updated_at FROM grilist.lists WHERE %s`, whereClause), params...) + rows, err := m.g.DB.Query(fmt.Sprintf(`SELECT id, name, description, fork_of, updated_at, user_id FROM grilist.lists WHERE %s`, whereClause), params...) if err != nil { return nil, err } @@ -99,8 +100,8 @@ func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, e defer rows.Close() for rows.Next() { list := &List{} - - if err := rows.Scan(&list.ID, &list.Name, &list.Description, &list.ForkOf, &list.UpdatedAt); err != nil { + var ownerID int + if err := rows.Scan(&list.ID, &list.Name, &list.Description, &list.ForkOf, &list.UpdatedAt, &ownerID); err != nil { log.Println("error scanning row in getLists:", err) continue } @@ -110,6 +111,14 @@ func (m *Module) getLists(whereClause string, params ...interface{}) ([]*List, e continue } + // Owner kriegn + owner, err := m.g.Charakterin.GetUserByID(ownerID) + if err != nil { + log.Println("error retreiving owner of list", err) + continue + } + list.Owner = owner + lists = append(lists, list) } diff --git a/views/list.html b/views/list.html index fb5f7a3..8fc7694 100644 --- a/views/list.html +++ b/views/list.html @@ -1,22 +1,59 @@ {{ define "list" }} {{ $list := .list }} - - {{ template "materialize" }} - grilist - - - - - {{ template "navbar" . }} -
-

{{ $list.Name }}von xyz


- -
- + + {{ template "materialize" }} + grilist + + + + + + {{ template "navbar" . }} +
+

{{ $list.Name }}von {{ $list.Owner.GetName }}


+
    + {{ range $index, $lg := $list.Grils }} +
  • +
    +
    +
    + {{ $index }} +
    +
    + +
    +
    + {{ $lg.Gril.RomajiName }}
    + {{ $lg.Gril.KanjiName }} +
    +
    +
    +
    +
    +
    + keyboard_arrow_up + keyboard_arrow_down +
    +
    + delete +
    +
    +
    +
    +
    + keyboard_arrow_up + keyboard_arrow_down + delete +
    +
    +
    +
    +
    +
  • + {{ end }} +
+
+ {{ end }} \ No newline at end of file diff --git a/views/navbar.html b/views/navbar.html index 70911e4..8905a1d 100644 --- a/views/navbar.html +++ b/views/navbar.html @@ -4,7 +4,7 @@