The backend for the AiteStory website
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package viewmodel
import ( "fmt"
"git.aiterp.net/AiteRP/aitestory/model" "git.aiterp.net/gisle/wrouter/auth" )
// IndexTags is a view model for rendering the tag lists.
type IndexTags struct { Base IndexBase
Type string Tags []model.Tag TagCategories []string
tagMap map[string][]model.Tag }
// Map lazy-loads the map of tags, which is only
// used when listing all of them.
func (it IndexTags) Map() map[string][]model.Tag { // Set up the map
it.tagMap = make(map[string][]model.Tag, len(model.TagTypes)) for _, tagType := range model.TagTypes { it.tagMap[tagType] = make([]model.Tag, 0, 64) }
// Organize
for _, tag := range it.Tags { it.tagMap[tag.Type] = append(it.tagMap[tag.Type], tag) }
return it.tagMap }
// Setup sets up the page model and the base, and should
// be run after the details have been filled in.
func (it *IndexTags) Setup(user *auth.User, viewPath string) { title := it.Type if it.Type != "" { title = "All" }
it.setupMenu() it.setupBase(user, fmt.Sprintf("%s Tags", title), viewPath) }
|