Simplified search route
This commit is contained in:
parent
3de29e9925
commit
783c3f878c
@ -139,8 +139,7 @@ func Configure(app *aero.Application) {
|
|||||||
l.Page("/compare/animelist/:nick-1/:nick-2", compare.AnimeList)
|
l.Page("/compare/animelist/:nick-1/:nick-2", compare.AnimeList)
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
l.Page("/search", search.Get)
|
l.Page("/search/*term", search.Get)
|
||||||
l.Page("/search/:term", search.Get)
|
|
||||||
|
|
||||||
// Shop
|
// Shop
|
||||||
l.Page("/shop", shop.Get)
|
l.Page("/shop", shop.Get)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package search
|
package search
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
"github.com/animenotifier/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
@ -14,7 +16,8 @@ const maxTracks = 4
|
|||||||
|
|
||||||
// Get search page.
|
// Get search page.
|
||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
term := ctx.Query("q")
|
term := ctx.Get("term")
|
||||||
|
term = strings.TrimPrefix(term, "/")
|
||||||
|
|
||||||
users, animes, posts, threads, tracks := arn.Search(term, maxUsers, maxAnime, maxPosts, maxThreads, maxTracks)
|
users, animes, posts, threads, tracks := arn.Search(term, maxUsers, maxAnime, maxPosts, maxThreads, maxTracks)
|
||||||
return ctx.HTML(components.SearchResults(term, users, animes, posts, threads, tracks))
|
return ctx.HTML(components.SearchResults(term, users, animes, posts, threads, tracks))
|
||||||
|
15
rewrite.go
15
rewrite.go
@ -25,21 +25,6 @@ func rewrite(ctx *aero.RewriteContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search
|
|
||||||
if strings.HasPrefix(requestURI, "/search/") {
|
|
||||||
searchTerm := requestURI[len("/search/"):]
|
|
||||||
ctx.Request.URL.RawQuery = "q=" + searchTerm
|
|
||||||
ctx.SetURI("/search")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasPrefix(requestURI, "/_/search/") {
|
|
||||||
searchTerm := requestURI[len("/_/search/"):]
|
|
||||||
ctx.Request.URL.RawQuery = "q=" + searchTerm
|
|
||||||
ctx.SetURI("/_/search")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Analytics
|
// Analytics
|
||||||
if requestURI == "/dark-flame-master" {
|
if requestURI == "/dark-flame-master" {
|
||||||
ctx.SetURI("/api/new/analytics")
|
ctx.SetURI("/api/new/analytics")
|
||||||
|
Loading…
Reference in New Issue
Block a user