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