Improved search

This commit is contained in:
2017-07-20 14:26:43 +02:00
parent ecb9e4ad86
commit 5ea14e8fc1
10 changed files with 115 additions and 46 deletions

View File

@ -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))
}

View File

@ -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

View File

@ -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