Improved search
This commit is contained in:
@ -8,11 +8,13 @@ import (
|
||||
|
||||
const maxUsers = 6 * 6
|
||||
const maxAnime = 5 * 6
|
||||
const maxPosts = 3
|
||||
const maxThreads = 3
|
||||
|
||||
// Get search page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
term := ctx.Query("q")
|
||||
|
||||
userResults, animeResults := arn.Search(term, maxUsers, maxAnime)
|
||||
return ctx.HTML(components.SearchResults(term, userResults, animeResults))
|
||||
userResults, animeResults, postResults, threadResults := arn.Search(term, maxUsers, maxAnime, maxPosts, maxThreads)
|
||||
return ctx.HTML(components.SearchResults(term, userResults, animeResults, postResults, threadResults))
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
component SearchResults(term string, users []*arn.User, animeResults []*arn.Anime)
|
||||
component SearchResults(term string, users []*arn.User, animeResults []*arn.Anime, postResults []*arn.Post, threadResults []*arn.Thread)
|
||||
h1.page-title= "Search: " + term
|
||||
|
||||
.widgets
|
||||
@ -32,9 +32,26 @@ component SearchResults(term string, users []*arn.User, animeResults []*arn.Anim
|
||||
.widget
|
||||
h3.widget-title
|
||||
Icon("comment")
|
||||
span Forums
|
||||
span Forum
|
||||
|
||||
p.no-search-results.mountable Forums search coming soon.
|
||||
if len(postResults) == 0 && len(threadResults) == 0
|
||||
p.no-search-results.mountable No posts found.
|
||||
else
|
||||
each thread in threadResults
|
||||
.mountable(data-mountable-type="forum")
|
||||
.forum-search-result
|
||||
a.forum-search-result-title.ajax(href=thread.Link())= thread.Title
|
||||
if thread.Author().HasNick()
|
||||
.forum-search-result-author= thread.Author().Nick
|
||||
.forum-search-result-sample= thread.Text
|
||||
|
||||
each post in postResults
|
||||
.mountable(data-mountable-type="forum")
|
||||
.forum-search-result
|
||||
a.forum-search-result-title.ajax(href=post.Link(), data-mountable-type="forum")= post.Thread().Title
|
||||
if post.Author().HasNick()
|
||||
.forum-search-result-author= post.Author().Nick
|
||||
.forum-search-result-sample= post.Text
|
||||
|
||||
.widget
|
||||
h3.widget-title
|
||||
|
@ -2,5 +2,21 @@
|
||||
width 55px !important
|
||||
height 78px !important
|
||||
|
||||
.forum-search-result
|
||||
horizontal
|
||||
|
||||
.forum-search-result-title
|
||||
flex 1
|
||||
clip-long-text
|
||||
|
||||
.forum-search-result-author
|
||||
text-align right
|
||||
opacity 0.5
|
||||
|
||||
.forum-search-result-sample
|
||||
clip-long-text
|
||||
margin-bottom 1rem
|
||||
opacity 0.8
|
||||
|
||||
.no-search-results
|
||||
text-align left
|
Reference in New Issue
Block a user