26 lines
636 B
Go
Raw Normal View History

package search
import (
2017-11-11 15:16:25 +00:00
"strings"
"github.com/aerogo/aero"
2017-06-20 20:54:45 +00:00
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
2017-11-07 12:48:33 +00:00
const maxUsers = 25
const maxAnime = 25
2017-11-26 17:04:48 +00:00
const maxPosts = 2
const maxThreads = 2
2017-11-07 13:58:24 +00:00
const maxTracks = 4
2017-12-03 16:02:11 +00:00
const maxCharacters = 22
2017-06-20 20:54:45 +00:00
2017-06-16 23:25:02 +00:00
// Get search page.
func Get(ctx *aero.Context) string {
2017-11-11 15:16:25 +00:00
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
2017-06-20 20:54:45 +00:00
users, animes, posts, threads, tracks, characters := arn.Search(term, maxUsers, maxAnime, maxPosts, maxThreads, maxTracks, maxCharacters)
return ctx.HTML(components.SearchResults(term, users, animes, posts, threads, tracks, characters))
}