diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/grils/gril.go | 16 | ||||
-rw-r--r-- | modules/grils/grils.go | 13 |
2 files changed, 23 insertions, 6 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 | }) |