search for user forum posts
This commit is contained in:
parent
de19399e2e
commit
f50e7fac2b
|
@ -1,4 +1,4 @@
|
|||
@(title: String, moreJs: Html = Html(""))(body: Html)(implicit ctx: Context)
|
||||
@(title: String, searchText: String = "", moreJs: Html = Html(""))(body: Html)(implicit ctx: Context)
|
||||
|
||||
@moreCss = {
|
||||
@cssTag("forum.css")
|
||||
|
@ -15,7 +15,7 @@ moreCss = moreCss,
|
|||
moreJs = forumJs,
|
||||
active = siteMenu.forum.some) {
|
||||
<div id="lichess_forum" class="content_box no_padding">
|
||||
@forum.searchForm()
|
||||
@forum.searchForm(searchText.trim)
|
||||
@body
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
@(text: String, views: Paginator[lila.forum.PostView])(implicit ctx: Context)
|
||||
|
||||
@title = @{ trans.searchInForum.str() + " \"" + text + "\"" }
|
||||
@title = @{ trans.searchInForum.str() + " \"" + text.trim + "\"" }
|
||||
|
||||
@forum.layout(
|
||||
title = title,
|
||||
moreJs = jsTag("vendor/jquery.infinitescroll.min.js")
|
||||
moreJs = jsTag("vendor/jquery.infinitescroll.min.js"),
|
||||
searchText = text
|
||||
) {
|
||||
|
||||
@forum.searchForm(text)
|
||||
|
||||
<h1>@title</h1>
|
||||
|
||||
<p class="nb_results">@views.nbResults posts found</p>
|
||||
|
||||
<table class="slist search_results">
|
||||
@if(views.nbResults > 0) {
|
||||
<tbody class="infinitescroll">
|
||||
|
|
|
@ -56,8 +56,8 @@ evenMoreCss = evenMoreCss) {
|
|||
<div class="social content_box_inter clearfix">
|
||||
<a class="intertab" href="@routes.Relation.following(u.username)">@splitNumber(trans.nbFollowing(info.nbFollowing))</a>
|
||||
<a class="intertab" href="@routes.Relation.followers(u.username)">@splitNumber(trans.nbFollowers(info.nbFollowers))</a>
|
||||
<span class="intertab" >@splitNumber(u.toints + " " + trans.tournamentPoints())</span>
|
||||
<span class="intertab" >@splitNumber(info.nbPosts + " Forum posts")</span>
|
||||
<span class="intertab">@splitNumber(u.toints + " " + trans.tournamentPoints())</span>
|
||||
<a class="intertab" href="@routes.ForumPost.search("user:" + u.username, 1)">@splitNumber(info.nbPosts + " Forum posts")</a>
|
||||
@if(ctx.isAuth && !ctx.is(u)) {
|
||||
<div class="relation_actions">
|
||||
@if(isGranted(_.UserSpy)) {
|
||||
|
|
|
@ -16,15 +16,23 @@ private[forumSearch] final class Query private (
|
|||
from = from,
|
||||
size = size)
|
||||
|
||||
def countRequest = ElasticSearch.Request.Count(makeQuery)
|
||||
def countRequest = ElasticSearch.Request.Count(makeQuery, makeFilters)
|
||||
|
||||
private def makeQuery = terms.foldLeft(boolQuery()) {
|
||||
case (query, term) ⇒ query must {
|
||||
multiMatchQuery(term, fields.body, fields.topic, fields.author)
|
||||
}
|
||||
private def queryTerms = terms filterNot (_ startsWith "user:")
|
||||
private def userSearch = terms find (_ startsWith "user:") flatMap {
|
||||
_.drop(5).some.filter(_.size >= 2)
|
||||
}
|
||||
|
||||
private def makeQuery =
|
||||
if (queryTerms.isEmpty) matchAllQuery
|
||||
else queryTerms.foldLeft(boolQuery) {
|
||||
case (query, term) ⇒ query must {
|
||||
multiMatchQuery(term, fields.body, fields.topic, fields.author)
|
||||
}
|
||||
}
|
||||
|
||||
private def makeFilters = List(
|
||||
userSearch map { termFilter(fields.author, _) },
|
||||
!staff option termFilter(fields.staff, false),
|
||||
!troll option termFilter(fields.troll, false)
|
||||
).flatten.toNel map { fs ⇒ andFilter(fs.list: _*) }
|
||||
|
|
|
@ -223,7 +223,7 @@ div.content_box_inter .intertab {
|
|||
text-transform: capitalize;
|
||||
}
|
||||
div.content_box_inter a.intertab:hover {
|
||||
text-transform: underline;
|
||||
background: #fff;
|
||||
}
|
||||
div.content_box_inter a.intertab.active {
|
||||
background: white;
|
||||
|
|
|
@ -153,6 +153,7 @@ body.dark #top .dropdown,
|
|||
body.dark #GameText a:hover,
|
||||
body.dark div.hooks_wrap a.filter:hover,
|
||||
body.dark div.hooks_wrap a.filter.active,
|
||||
body.dark div.content_box_inter a.intertab:hover,
|
||||
body.dark #top .shown a.toggle {
|
||||
background: #000;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,10 @@ ol.crumbs li:first-child {
|
|||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#lichess_forum .nb_results {
|
||||
padding-left: 25px;
|
||||
}
|
||||
|
||||
#lichess_forum form.search {
|
||||
float: right;
|
||||
margin: 20px;
|
||||
|
|
Loading…
Reference in a new issue