Bläddra i källkod

Added TagCollectionPage

* Implements PrevPageURL and NextPageURL
* This allows the collection-tag template to get proper urls for
  paginating using tags.
pull/438/head
Donald Feury 3 år sedan
förälder
incheckning
9ed2687543
1 ändrade filer med 25 tillägg och 4 borttagningar
  1. +25
    -4
      collections.go

+ 25
- 4
collections.go Visa fil

@@ -562,6 +562,30 @@ type CollectionPage struct {
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 {
return &CollectionObj{
Collection: *c,
@@ -916,10 +940,7 @@ func handleViewCollectionTag(app *App, w http.ResponseWriter, r *http.Request) e
}

// Serve collection
displayPage := struct {
CollectionPage
Tag string
}{
displayPage := TagCollectionPage{
CollectionPage: CollectionPage{
DisplayCollection: coll,
StaticPage: pageForReq(app, r),


Laddar…
Avbryt
Spara