diff options
author | rtz12 <koenig@fagott.pw> | 2015-12-28 22:21:05 (UTC) |
---|---|---|
committer | rtz12 <koenig@fagott.pw> | 2015-12-28 22:21:05 (UTC) |
commit | b4c2a5c6d571a44621db07b9930e812868604c6b (patch) | |
tree | 6d2e40636dcc2c149e058cc1aaa89c1edcb6f7a5 | |
parent | d0b0fb006174dfd5b98eae1523ef0fa1fa3db3d2 (diff) |
Hippe Schnecken fuer die Gril-URLs
-rw-r--r-- | modules/grils/gril.go | 16 | ||||
-rw-r--r-- | modules/grils/grils.go | 13 | ||||
-rw-r--r-- | views/list.html | 4 |
3 files changed, 25 insertions, 8 deletions
diff --git a/modules/grils/gril.go b/modules/grils/gril.go index edf25a9..c8c6538 100644 --- a/modules/grils/gril.go +++ b/modules/grils/gril.go | |||
@@ -2,8 +2,12 @@ package grils | |||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "database/sql" | 4 | "database/sql" |
5 | "github.com/lib/pq" | 5 | "fmt" |
6 | "strconv" | ||
7 | "strings" | ||
6 | "time" | 8 | "time" |
9 | |||
10 | "github.com/lib/pq" | ||
7 | ) | 11 | ) |
8 | 12 | ||
9 | type DataSource int | 13 | type DataSource int |
@@ -25,3 +29,13 @@ type Gril struct { | |||
25 | UpdatedAt time.Time | 29 | UpdatedAt time.Time |
26 | Lists []int | 30 | Lists []int |
27 | } | 31 | } |
32 | |||
33 | func (g *Gril) Slug() string { | ||
34 | if g.RomajiName == "" { | ||
35 | return strconv.Itoa(g.ID) | ||
36 | } | ||
37 | return fmt.Sprintf( | ||
38 | "%d/%s", | ||
39 | g.ID, | ||
40 | strings.Replace(g.RomajiName, " ", "", -1)) | ||
41 | } | ||
diff --git a/modules/grils/grils.go b/modules/grils/grils.go index 8ec7bcb..7ea5259 100644 --- a/modules/grils/grils.go +++ b/modules/grils/grils.go | |||
@@ -1,16 +1,18 @@ | |||
1 | package grils | 1 | package grils |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fagott.pw/charakterin" | ||
5 | "fagott.pw/grilist/frontend" | ||
6 | "fagott.pw/grilist/grilist" | ||
7 | "fmt" | 4 | "fmt" |
8 | "github.com/julienschmidt/httprouter" | ||
9 | "log" | 5 | "log" |
10 | "net/http" | 6 | "net/http" |
11 | "regexp" | 7 | "regexp" |
12 | "strconv" | 8 | "strconv" |
13 | "strings" | 9 | "strings" |
10 | |||
11 | "fagott.pw/charakterin" | ||
12 | "fagott.pw/grilist/frontend" | ||
13 | "fagott.pw/grilist/grilist" | ||
14 | |||
15 | "github.com/julienschmidt/httprouter" | ||
14 | ) | 16 | ) |
15 | 17 | ||
16 | var ( | 18 | var ( |
@@ -39,6 +41,7 @@ func (m *GrilsModule) Init(g *grilist.Grilist) { | |||
39 | findIdx() | 41 | findIdx() |
40 | m.g = g | 42 | m.g = g |
41 | m.g.Router.GET("/gril/:id", m.viewGril) | 43 | m.g.Router.GET("/gril/:id", m.viewGril) |
44 | m.g.Router.GET("/gril/:id/*rest", m.viewGril) | ||
42 | } | 45 | } |
43 | 46 | ||
44 | func (m *GrilsModule) Interface() interface{} { | 47 | func (m *GrilsModule) Interface() interface{} { |
@@ -128,7 +131,7 @@ func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) []grilist.Das | |||
128 | Actions: []frontend.Action{ | 131 | Actions: []frontend.Action{ |
129 | frontend.Action{ | 132 | frontend.Action{ |
130 | Name: "anguckieren", | 133 | Name: "anguckieren", |
131 | Link: fmt.Sprintf("/gril/%d", gril.ID), | 134 | Link: "/gril/" + gril.Slug(), |
132 | }, | 135 | }, |
133 | }, | 136 | }, |
134 | }) | 137 | }) |
diff --git a/views/list.html b/views/list.html index fb5f7a3..c944e87 100644 --- a/views/list.html +++ b/views/list.html | |||
@@ -13,10 +13,10 @@ | |||
13 | <h1>{{ $list.Name }}<small>von xyz</small></h1><br /> | 13 | <h1>{{ $list.Name }}<small>von xyz</small></h1><br /> |
14 | <ul> | 14 | <ul> |
15 | {{ range $lg := $list.Grils }} | 15 | {{ range $lg := $list.Grils }} |
16 | <li><a href="/gril/{{ $lg.Gril.ID }}">{{ $lg.Gril.RomajiName }}</a></li> | 16 | <li><a href="/gril/{{ $lg.Gril.Slug }}">{{ $lg.Gril.RomajiName }}</a></li> |
17 | {{ end }} | 17 | {{ end }} |
18 | </ul> | 18 | </ul> |
19 | </div> | 19 | </div> |
20 | </body> | 20 | </body> |
21 | </html> | 21 | </html> |
22 | {{ end }} \ No newline at end of file | 22 | {{ end }} |