show leaderboard on homepage

This commit is contained in:
Thibault Duplessis 2013-12-21 21:39:31 +01:00
parent 02fd990eba
commit 830a357d24
9 changed files with 56 additions and 38 deletions

View file

@ -24,6 +24,7 @@ final class Env(
history = Env.lobby.history,
featured = Env.game.featured,
relations = Env.relation.api,
leaderboard = Env.user.cached.topRatingDay.apply,
recentGames = () Env.timeline.getter.recentGames,
timelineEntries = Env.timeline.getter.userEntries _)

View file

@ -27,8 +27,8 @@ object Lobby extends LilaController {
tours = TournamentRepo.createdUnprotected,
filter = Env.setup.filter
).map(_.fold(Redirect(_), {
case (preload, entries, gameEntries, posts, tours, featured) status(html.lobby.home(
Json stringify preload, entries, gameEntries, posts, tours, featured)) |> { response
case (preload, entries, gameEntries, posts, tours, featured, leaderboard) status(html.lobby.home(
Json stringify preload, entries, gameEntries, posts, tours, featured, leaderboard)) |> { response
ctx.req.session.data.contains(LilaCookie.sessionId).fold(
response,
response withCookies LilaCookie.makeSessionId(ctx.req)

View file

@ -24,10 +24,11 @@ final class Preload(
history: History,
featured: Featured,
relations: RelationApi,
leaderboard: Int => Fu[List[User]],
recentGames: () Fu[List[GameEntry]],
timelineEntries: String Fu[List[Entry]]) {
private type RightResponse = (JsObject, List[Entry], List[GameEntry], List[PostLiteView], List[Created], Option[Game])
private type RightResponse = (JsObject, List[Entry], List[GameEntry], List[PostLiteView], List[Created], Option[Game], List[User])
private type Response = Either[Call, RightResponse]
def apply(
@ -41,13 +42,14 @@ final class Preload(
featured.one zip
(ctx.userId ?? relations.blocks) zip
(ctx.userId ?? timelineEntries) zip
leaderboard(10) zip
filter map {
case (((((((hooks, gameEntries), posts), tours), feat), blocks), entries), filter)
case ((((((((hooks, gameEntries), posts), tours), feat), blocks), entries), leaderboard), filter)
(Right((Json.obj(
"version" -> history.version,
"pool" -> JsArray(hooks map (_.render)),
"filter" -> filter.render,
"blocks" -> blocks
), entries, gameEntries, posts, tours, feat)))
), entries, gameEntries, posts, tours, feat, leaderboard)))
}
}

View file

@ -1,4 +1,4 @@
@()(implicit ctx: Context)
@(leaderboard: List[User])(implicit ctx: Context)
<div class="lichess_ground">
<div class="lichess_table lichess_table_not_started" id="start_buttons">
@ -6,4 +6,25 @@
<a class="lichess_button button config_@b.code" href="@b.route" onclick="return false" title="@b.title()">@b.name()</a>
}
</div>
<div class="leaderboard undertable">
<div class="user_top">
<div class="undertable_top">
<a class="more" title="@trans.people()" href="@routes.User.list()">@trans.more() »</a>
<span class="title">Today's Leaders</span>
</div>
<div class="undertable_inner">
<table>
<tbody>
@leaderboard.map { u =>
<tr>
<td>@userLink(u, withRating = false, cssClass="revert-underline".some)</td>
<td>@u.rating</td>
<td>@showProgress(u.progress)</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>

View file

@ -1,4 +1,4 @@
@(preload: String, userTimeline: List[lila.timeline.Entry], gameTimeline: List[lila.timeline.GameEntry], forumRecent: List[lila.forum.PostLiteView], tours: List[lila.tournament.Created], featured: Option[Game])(implicit ctx: Context)
@(preload: String, userTimeline: List[lila.timeline.Entry], gameTimeline: List[lila.timeline.GameEntry], forumRecent: List[lila.forum.PostLiteView], tours: List[lila.tournament.Created], featured: Option[Game], leaderboard: List[User])(implicit ctx: Context)
@underchat = {
<a class="watchtv revert-underline" href="@routes.Tv.index">Watch Lichess TV</a>
@ -70,7 +70,7 @@ underchat = underchat.some) {
<div id="hook_filter"></div>
</div>
</div>
@lobby.buttons()
@lobby.buttons(leaderboard)
@lobby.undertable(gameTimeline, forumRecent, tours)
</div>
}

View file

@ -19,39 +19,21 @@
@user.layout(trans.chessPlayers.str(), goodies = goodies.some) {
<div class="content_box">
<div class="user_lists clearfix">
@user.top(progressDay, "Progress today") { u =>
<td>@u.rating</td>
<td>@showProgress(u.progress)</td>
}
@user.top(ratingDay, "Leaderboard today") { u =>
<td>@u.rating</td>
<td>@showProgress(u.progress)</td>
}
@user.topLeader(progressDay, "Progress today")
@user.topLeader(ratingDay, "Leaderboard today")
@user.topActive(nbDay, "Active today", true)
@user.top(progressWeek, "Progress this week") { u =>
<td>@u.rating</td>
<td>@showProgress(u.progress)</td>
}
@user.top(ratingWeek, "Leaderboard this week") { u =>
<td>@u.rating</td>
<td>@showProgress(u.progress)</td>
}
@user.topLeader(progressWeek, "Progress this week")
@user.topLeader(ratingWeek, "Leaderboard this week")
@user.topActive(nbWeek, "Active this week", true)
@user.top(progressMonth, "Progress this month") { u =>
<td>@u.rating</td>
<td>@showProgress(u.progress)</td>
}
@user.top(rating, "Leaderboard") { u =>
<td>@u.rating</td>
<td>@showProgress(u.progress)</td>
}
@user.topLeader(progressMonth, "Progress this month")
@user.topLeader(rating, "Leaderboard")
@user.topActive(nb, "Active players", true)
@user.top(bullet, "Best bullet players")(_.perfs.bullet.glicko.intRating)
@user.top(blitz, "Best blitz players")(_.perfs.blitz.glicko.intRating)
@user.top(slow, "Best slow players", true)(_.perfs.slow.glicko.intRating)
@user.top(bullet, "Best bullet players")(u => Html(s"<td>${u.perfs.bullet.glicko.intRating}</td>"))
@user.top(blitz, "Best blitz players")(u => Html(s"<td>${u.perfs.blitz.glicko.intRating}</td>"))
@user.top(slow, "Best slow players", true)(u => Html(s"<td>${u.perfs.slow.glicko.intRating}</td>"))
</div>
</div>
}

View file

@ -7,7 +7,7 @@
@users.map { u =>
<tr>
<td>@userLink(u, withRating = false, cssClass="revert-underline".some)</td>
<td>@f(u)</td>
@f(u)
</tr>
}
</tbody>

View file

@ -0,0 +1,5 @@
@(users: List[User], title: Any, last: Boolean = false)(implicit ctx: Context)
@user.top(users, title) { u =>
<td>@u.rating</td>
<td>@showProgress(u.progress)</td>
}

View file

@ -263,13 +263,20 @@ div.lichess_table.spectator {
}
div.lichess_table_not_started {
position: absolute;
top: 176px;
top: 100px;
left: 0px;
width: 242px;
box-shadow: none;
border: none;
padding: 0;
top: 100px;
}
div.lichess_homepage div.leaderboard {
position: absolute;
top: 514px;
width: 242px;
}
div.lichess_homepage div.leaderboard div.undertable_inner {
height: auto;
}
div.lichess_table div.username {
padding-left: 16px;