moderator hall of fame

pull/1431/head
Thibault Duplessis 2016-01-11 12:18:26 +07:00
parent aa81c6d53d
commit d5f1ccd4aa
14 changed files with 207 additions and 69 deletions

View File

@ -132,7 +132,15 @@ object Mod extends LilaController {
def gamify = Secure(_.SeeReport) { implicit ctx =>
me =>
Env.mod.gamify.leaderboards map { leaderboards =>
Ok(html.mod.gamify(leaderboards))
Ok(html.mod.gamify.index(leaderboards))
}
}
def gamifyPeriod(periodStr: String) = Secure(_.SeeReport) { implicit ctx =>
me =>
lila.mod.Gamify.Period(periodStr).fold(notFound) { period =>
Env.mod.gamify.leaderboards map { leaderboards =>
Ok(html.mod.gamify.period(leaderboards, period))
}
}
}
}

View File

@ -1,18 +0,0 @@
@(leaderboards: lila.mod.Gamify.Leaderboards)(implicit ctx: Context)
@title = @{ "Moderator hall of fame" }
@mod.layout(
title = title,
active = "leaderboard",
moreCss = cssTag("mod-leaderboard.css")) {
<div id="mod-gamify" class="content_box">
<h1 data-icon="" class="text">@title</h1>
<div class="global clearfix">
<div class="third">@leaderboard(leaderboards.daily, "Daily best mods")</div>
<div class="third">@leaderboard(leaderboards.weekly, "Weekly best mods")</div>
<div class="third">@leaderboard(leaderboards.monthly, "Monthly best mods")</div>
</div>
</div>
}

View File

@ -0,0 +1,26 @@
@(champ: Option[lila.mod.Gamify.ModMixed], img: String, title: String, period: String)(implicit ctx: Context)
<div class="champ">
<img src="@staticUrl(s"images/mod/$img.png")" />
<h2>@title</h2>
@champ.map { m =>
<h3>@userIdLink(m.modId.some, withOnline = false)</h3>
<table>
<tbody>
<tr>
<th>Total score</th>
<td>@m.score</td>
</tr>
<tr>
<th>Actions taken</th>
<td>@m.action</td>
</tr>
<tr>
<th>Reports closed</th>
<td>@m.report</td>
</tr>
</tbody>
</table>
}.getOrElse { Nobody! }
<a class="current" href="@routes.Mod.gamifyPeriod(period)">View current leaderboard</a>
</div>

View File

@ -0,0 +1,24 @@
@(leaderboards: lila.mod.Gamify.Leaderboards)(implicit ctx: Context)
@title = @{ "Moderator hall of fame" }
@mod.layout(
title = title,
active = "gamify",
moreCss = cssTag("mod-gamify.css")) {
<div id="mod-gamify" class="content_box no_padding">
<h1>@title</h1>
<div class="champs clearfix">
<div class="third">
@champion(leaderboards.daily.headOption, "reward1", "Mod of the day", "day")
</div>
<div class="third">
@champion(leaderboards.weekly.headOption, "reward2", "Mod of the week", "week")
</div>
<div class="third">
@champion(leaderboards.monthly.headOption, "reward3", "Mod of the month", "month")
</div>
</div>
</div>
}

View File

@ -7,16 +7,23 @@
<th title="Actions taken">A</th>
<th title="Reports Closed">R</th>
<th>Score</th>
<th>Trolls</th>
<th>Cheats</th>
<th>Others</th>
</tr>
</thead>
<tbody>
@leaderboard.take(10).zipWithIndex.map {
case (m, i) => {
<tr>
<th>@i</th>
<th>@userIdLink(m.modId.some, withOnline = false)</th>
<td>@m.action.localize</td>
<td>@m.report.localize</td>
<td>@m.score.localize</td>
<td class="score">@m.score.localize</td>
<td>WIP</td>
<td>WIP</td>
<td>WIP</td>
</tr>
}
}

View File

@ -0,0 +1,44 @@
@(leaderboards: lila.mod.Gamify.Leaderboards, period: lila.mod.Gamify.Period)(implicit ctx: Context)
@title = @{ s"Moderators of the ${period.toString.toLowerCase}" }
@mod.layout(
title = title,
active = "leaderboard",
moreCss = cssTag("mod-gamify.css")) {
<div id="mod-gamify" class="content_box">
<h1>@title</h1>
<div class="period">
<table>
<thead>
<tr>
<th colspan="2"></th>
<th>Actions</th>
<th>Reports</th>
<th>Score</th>
<th>Trolls</th>
<th>Cheats</th>
<th>Others</th>
</tr>
</thead>
<tbody>
@leaderboards(period).zipWithIndex.map {
case (m, i) => {
<tr>
<th>@(i + 1)</th>
<th>@userIdLink(m.modId.some, withOnline = false)</th>
<td>@m.action.localize</td>
<td>@m.report.localize</td>
<td class="score">@m.score.localize</td>
<td>WIP</td>
<td>WIP</td>
<td>WIP</td>
</tr>
}
}
</tbody>
</table>
</div>
</div>
}

View File

@ -14,7 +14,7 @@
<a href="@routes.ForumCateg.show("staff")">Staff Forum</a>
}
@if(isGranted(_.SeeReport)) {
<a class="@active.active("leaderboard")" href="@routes.Mod.gamify">Leaderboards</a>
<a class="@active.active("gamify")" href="@routes.Mod.gamify">Hall of fame</a>
}
}

View File

@ -275,6 +275,7 @@ POST /mod/:username/email controllers.Mod.setEmail(username: String
POST /mod/:username/notify-slack controllers.Mod.notifySlack(username: String)
GET /mod/ip-intel controllers.Mod.ipIntel(ip: String)
GET /mod/leaderboard controllers.Mod.gamify
GET /mod/leaderboard/:period controllers.Mod.gamifyPeriod(period: String)
# Wiki
GET /wiki controllers.Wiki.home

View File

@ -67,7 +67,21 @@ final class Gamify(
object Gamify {
case class Leaderboards(daily: List[ModMixed], weekly: List[ModMixed], monthly: List[ModMixed])
sealed trait Period
object Period {
case object Day extends Period
case object Week extends Period
case object Month extends Period
def apply(p: String) = List(Day, Week, Month).find(_.toString.toLowerCase == p)
}
case class Leaderboards(daily: List[ModMixed], weekly: List[ModMixed], monthly: List[ModMixed]) {
def apply(period: Period) = period match {
case Period.Day => daily
case Period.Week => weekly
case Period.Month => monthly
}
}
case class ModCount(modId: String, count: Int)
case class ModMixed(modId: String, action: Int, report: Int) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

View File

@ -0,0 +1,79 @@
#mod-gamify h1 {
font-family: 'PT Serif';
font-size: 3em;
letter-spacing: 5px;
text-align: center;
display: block;
margin-bottom: 30px;
}
#mod-gamify .third {
float: left;
width: 33.33%;
}
#mod-gamify .champ {
text-align: center;
}
#mod-gamify .champ h2 {
font-family: 'Roboto';
font-weight: 300;
font-size: 1.8em;
text-transform: uppercase;
opacity: 0.7;
}
#mod-gamify .champ h3 {
font-family: 'PT Serif';
font-size: 3em;
color: #d59120;
overflow: hidden;
text-overflow: ellipsis;
margin: 15px 0 25px 0;
}
#mod-gamify .champ h3 a {
color: #d59120;
}
#mod-gamify .champ table {
margin: auto;
}
#mod-gamify .champ table tr th {
text-transform: uppercase;
}
#mod-gamify .champ table tr td {
font-size: 2em;
font-family: monospace;
text-align: right;
line-height: 50px;
}
#mod-gamify .champ table tr:first-child td {
font-size: 3em;
}
#mod-gamify .champ a.current {
display: block;
margin: 30px 0 20px 0;
}
#mod-gamify .period table {
width: 100%;
}
#mod-gamify .period table thead {
font-family: 'PT Serif';
font-size: 1.2em;
}
#mod-gamify .period table td,
#mod-gamify .period table thead th {
padding: 7px;
}
#mod-gamify .period table thead th:first-child {
padding: 0;
}
#mod-gamify .period table * {
text-align: right;
}
#mod-gamify .period table tbody {
font-size: 1.3em;
}
#mod-gamify .period table tbody th {
text-align: left;
font-size: 1.5em;
}
#mod-gamify .period table td.score {
font-size: 1.5em;
}

View File

@ -1,47 +0,0 @@
#mod-gamify h1 {
color: #d59120;
font-family: 'PT Serif';
font-size: 3em;
letter-spacing: 5px;
}
#mod-gamify h1::before {
animation: fire 1.25s ease-in-out infinite alternate;
font-size: 60px;
margin-right: 20px;
color: #d59120;
}
#mod-gamify .global {
width: 100%;
margin-top: 30px;
}
#mod-gamify .global .third {
float: left;
width: 31.3%;
margin-right: 3%;
}
#mod-gamify .global .third:last-child {
margin-right: 0;
}
#mod-gamify .global table {
width: 100%;
}
#mod-gamify .global table thead {
font-family: 'PT Serif';
font-size: 1.2em;
}
#mod-gamify .global table td,
#mod-gamify .global table thead th {
padding: 7px;
}
#mod-gamify .global table thead th:first-child {
padding: 0;
}
#mod-gamify .global table * {
text-align: right;
}
#mod-gamify .global table *:first-child {
text-align: left;
}
#mod-gamify .global table td:last-child {
font-weight: bold;
}