aboutsummaryrefslogtreecommitdiff
path: root/modules/grils
diff options
context:
space:
mode:
authorrtz12 <koenig@fagott.pw>2015-12-28 22:21:05 (UTC)
committerrtz12 <koenig@fagott.pw>2015-12-28 22:21:05 (UTC)
commitb4c2a5c6d571a44621db07b9930e812868604c6b (patch)
tree6d2e40636dcc2c149e058cc1aaa89c1edcb6f7a5 /modules/grils
parentd0b0fb006174dfd5b98eae1523ef0fa1fa3db3d2 (diff)
Hippe Schnecken fuer die Gril-URLs
Diffstat (limited to 'modules/grils')
-rw-r--r--modules/grils/gril.go16
-rw-r--r--modules/grils/grils.go13
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
3import ( 3import (
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
9type DataSource int 13type 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
33func (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 @@
1package grils 1package grils
2 2
3import ( 3import (
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
16var ( 18var (
@@ -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
44func (m *GrilsModule) Interface() interface{} { 47func (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 })