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