Added TagCollectionPage
* Implements PrevPageURL and NextPageURL * This allows the collection-tag template to get proper urls for paginating using tags.
This commit is contained in:
parent
530439772d
commit
9ed2687543
|
@ -562,6 +562,30 @@ type CollectionPage struct {
|
||||||
CanInvite bool
|
CanInvite bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TagCollectionPage struct {
|
||||||
|
CollectionPage
|
||||||
|
Tag string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tcp TagCollectionPage) PrevPageURL(prefix string, n int, tl bool) string {
|
||||||
|
u := fmt.Sprintf("/tag:%s", tcp.Tag)
|
||||||
|
if n > 2 {
|
||||||
|
u += fmt.Sprintf("/page/%d", n-1)
|
||||||
|
}
|
||||||
|
if tl {
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
return "/" + prefix + tcp.Alias + u
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tcp TagCollectionPage) NextPageURL(prefix string, n int, tl bool) string {
|
||||||
|
if tl {
|
||||||
|
return fmt.Sprintf("/tag:%s/page/%d", tcp.Tag, n+1)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("/%s%s/tag:%s/page/%d", prefix, tcp.Alias, tcp.Tag, n+1)
|
||||||
|
}
|
||||||
|
|
||||||
func NewCollectionObj(c *Collection) *CollectionObj {
|
func NewCollectionObj(c *Collection) *CollectionObj {
|
||||||
return &CollectionObj{
|
return &CollectionObj{
|
||||||
Collection: *c,
|
Collection: *c,
|
||||||
|
@ -916,10 +940,7 @@ func handleViewCollectionTag(app *App, w http.ResponseWriter, r *http.Request) e
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serve collection
|
// Serve collection
|
||||||
displayPage := struct {
|
displayPage := TagCollectionPage{
|
||||||
CollectionPage
|
|
||||||
Tag string
|
|
||||||
}{
|
|
||||||
CollectionPage: CollectionPage{
|
CollectionPage: CollectionPage{
|
||||||
DisplayCollection: coll,
|
DisplayCollection: coll,
|
||||||
StaticPage: pageForReq(app, r),
|
StaticPage: pageForReq(app, r),
|
||||||
|
|
Loading…
Reference in New Issue