From b4c2a5c6d571a44621db07b9930e812868604c6b Mon Sep 17 00:00:00 2001 From: rtz12 Date: Mon, 28 Dec 2015 23:21:05 +0100 Subject: Hippe Schnecken fuer die Gril-URLs 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 import ( "database/sql" - "github.com/lib/pq" + "fmt" + "strconv" + "strings" "time" + + "github.com/lib/pq" ) type DataSource int @@ -25,3 +29,13 @@ type Gril struct { UpdatedAt time.Time Lists []int } + +func (g *Gril) Slug() string { + if g.RomajiName == "" { + return strconv.Itoa(g.ID) + } + return fmt.Sprintf( + "%d/%s", + g.ID, + strings.Replace(g.RomajiName, " ", "", -1)) +} 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 @@ package grils import ( - "fagott.pw/charakterin" - "fagott.pw/grilist/frontend" - "fagott.pw/grilist/grilist" "fmt" - "github.com/julienschmidt/httprouter" "log" "net/http" "regexp" "strconv" "strings" + + "fagott.pw/charakterin" + "fagott.pw/grilist/frontend" + "fagott.pw/grilist/grilist" + + "github.com/julienschmidt/httprouter" ) var ( @@ -39,6 +41,7 @@ func (m *GrilsModule) Init(g *grilist.Grilist) { findIdx() m.g = g m.g.Router.GET("/gril/:id", m.viewGril) + m.g.Router.GET("/gril/:id/*rest", m.viewGril) } func (m *GrilsModule) Interface() interface{} { @@ -128,7 +131,7 @@ func (m *GrilsModule) ProvideDashboardData(user *charakterin.User) []grilist.Das Actions: []frontend.Action{ frontend.Action{ Name: "anguckieren", - Link: fmt.Sprintf("/gril/%d", gril.ID), + Link: "/gril/" + gril.Slug(), }, }, }) 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 @@

{{ $list.Name }}von xyz


-{{ end }} \ No newline at end of file +{{ end }} -- cgit v0.10.1