mirror of
https://github.com/writeas/web-core
synced 2018-07-20 11:55:21 +00:00
Make OrderedCollection{Page} funcs generalized for any collection
This commit is contained in:
parent
d67ec28bcc
commit
2432e9717e
@ -30,16 +30,16 @@ type OrderedCollection struct {
|
|||||||
Last string `json:"last,omitempty"`
|
Last string `json:"last,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOrderedCollection(accountRoot string, items int) *OrderedCollection {
|
func NewOrderedCollection(accountRoot, collType string, items int) *OrderedCollection {
|
||||||
oc := OrderedCollection{
|
oc := OrderedCollection{
|
||||||
BaseObject: BaseObject{
|
BaseObject: BaseObject{
|
||||||
Context: []string{
|
Context: []string{
|
||||||
"https://www.w3.org/ns/activitystreams",
|
"https://www.w3.org/ns/activitystreams",
|
||||||
},
|
},
|
||||||
ID: accountRoot + "/outbox",
|
ID: accountRoot + "/" + collType,
|
||||||
Type: "OrderedCollection",
|
Type: "OrderedCollection",
|
||||||
},
|
},
|
||||||
First: accountRoot + "/outbox?page=1",
|
First: accountRoot + "/" + collType + "?page=1",
|
||||||
TotalItems: items,
|
TotalItems: items,
|
||||||
}
|
}
|
||||||
return &oc
|
return &oc
|
||||||
@ -54,18 +54,18 @@ type OrderedCollectionPage struct {
|
|||||||
OrderedItems []Activity `json:"orderedItems"`
|
OrderedItems []Activity `json:"orderedItems"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewOrderedCollectionPage(accountRoot string, items, page int) *OrderedCollectionPage {
|
func NewOrderedCollectionPage(accountRoot, collType string, items, page int) *OrderedCollectionPage {
|
||||||
ocp := OrderedCollectionPage{
|
ocp := OrderedCollectionPage{
|
||||||
BaseObject: BaseObject{
|
BaseObject: BaseObject{
|
||||||
Context: []string{
|
Context: []string{
|
||||||
"https://www.w3.org/ns/activitystreams",
|
"https://www.w3.org/ns/activitystreams",
|
||||||
},
|
},
|
||||||
ID: fmt.Sprintf("%s/outbox?page=%d", accountRoot, page),
|
ID: fmt.Sprintf("%s/%s?page=%d", accountRoot, collType, page),
|
||||||
Type: "OrderedCollectionPage",
|
Type: "OrderedCollectionPage",
|
||||||
},
|
},
|
||||||
TotalItems: items,
|
TotalItems: items,
|
||||||
PartOf: accountRoot + "/outbox",
|
PartOf: accountRoot + "/" + collType,
|
||||||
Next: fmt.Sprintf("%s/outbox?page=%d", accountRoot, page+1),
|
Next: fmt.Sprintf("%s/%s?page=%d", accountRoot, collType, page+1),
|
||||||
}
|
}
|
||||||
return &ocp
|
return &ocp
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user