2016-11-22 03:34:59 +00:00
|
|
|
package search
|
|
|
|
|
|
|
|
import (
|
2017-11-11 15:16:25 +00:00
|
|
|
"strings"
|
|
|
|
|
2016-11-22 03:34:59 +00:00
|
|
|
"github.com/aerogo/aero"
|
2017-06-20 20:54:45 +00:00
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
"github.com/animenotifier/notify.moe/components"
|
2016-11-22 03:34:59 +00:00
|
|
|
)
|
|
|
|
|
2017-11-07 12:48:33 +00:00
|
|
|
const maxUsers = 25
|
|
|
|
const maxAnime = 25
|
2017-07-20 12:26:43 +00:00
|
|
|
const maxPosts = 3
|
|
|
|
const maxThreads = 3
|
2017-11-07 13:58:24 +00:00
|
|
|
const maxTracks = 4
|
2017-11-26 16:06:04 +00:00
|
|
|
const maxCharacters = 0
|
2017-06-20 20:54:45 +00:00
|
|
|
|
2017-06-16 23:25:02 +00:00
|
|
|
// Get search page.
|
2016-11-22 03:34:59 +00:00
|
|
|
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
|
|
|
|
2017-11-25 23:14:20 +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))
|
2016-11-22 03:34:59 +00:00
|
|
|
}
|