Skip to content

Commit

Permalink
rewrite tournament templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Dec 4, 2018
1 parent 019fb3e commit 2e56673
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 166 deletions.
2 changes: 1 addition & 1 deletion app/views/blog/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1 class="lichess_title" data-icon="6">
</h1>
<div class="list infinitescroll">
@pager.currentPageResults.map { doc =>
<article class="paginated_element">
<article class="paginated">
@doc.getText("blog.title").map { title =>
<h1 class="blog_title"><a href="@routes.Blog.show(doc.id, doc.slug, prismic.maybeRef)">@title</a></h1>
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/coach/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h1>Top chess coaches</h1>
</div>
<div class="list infinitescroll">
@pager.currentPageResults.map { c =>
<div class="coach paginated_element" data-dedup="@c.coach.id">
<div class="coach paginated" data-dedup="@c.coach.id">
@widget(c)
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/forum/search.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>@title</h1>
<tr></tr>
}
@views.currentPageResults.map { view =>
<tr class="paginated_element">
<tr class="paginated">
<td>
<a class="post" href="@routes.ForumPost.redirect(view.post.id)">@view.categ.name - @view.topic.name #@view.post.number</a>
<p>@nl2br(shorten(view.post.text.replace("\n\n", "\n"), 200))</p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/game/widgets.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object widgets {
)(implicit ctx: Context): Frag = games map { g =>
val fromPlayer = user flatMap g.player
val firstPlayer = fromPlayer | g.firstPlayer
div(cls := "game_row paginated_element")(
div(cls := "game_row paginated")(
gameFen(Pov(g, firstPlayer), ownerLink, withTitle = false),
a(cls := "game_link_overlay", href := gameLink(g, firstPlayer.color, ownerLink)),
div(cls := "infos", dataIcon := bits.gameIcon(g))(
Expand Down
2 changes: 1 addition & 1 deletion app/views/message/inbox.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h1>@trans.inbox()</h1>
</th></tr>
}
@threads.currentPageResults.map { thread =>
<tr class="paginated_element @if(thread.isUnReadBy(me)){ new} @if(thread.asMod){ mod}">
<tr class="paginated @if(thread.isUnReadBy(me)){ new} @if(thread.asMod){ mod}">
<td class="author">
@userIdLink(thread.visibleOtherUserId(me), none)
</td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/qa/questionPreview.scala.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@(q: lila.qa.Question, a: Option[lila.qa.Answer] = None)(implicit ctx: Context)

<tr class="paginated_element">
<tr class="paginated">
<td class="meat">
<div class="tags">@tags(q.tags)</div>
@a.map { ans =>
Expand Down
2 changes: 1 addition & 1 deletion app/views/relay/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>@title</h1>
<h2>Completed</h2>
<div class="list infinitescroll">
@pager.currentPageResults.map { r =>
<div class="relay paginated_element">
<div class="relay paginated">
@widget(r)
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/streamer/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h1>@titleTag(s.user.title)@s.streamer.name</h1>
}
<div class="list infinitescroll">
@pager.currentPageResults.map { s =>
<div class="streamer paginated_element" data-dedup="@s.streamer.id">@widget(s, none)</div>
<div class="streamer paginated" data-dedup="@s.streamer.id">@widget(s, none)</div>
}
@pager.nextPage.map { np =>
<div class="pager none">
Expand Down
2 changes: 1 addition & 1 deletion app/views/study/list.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
} else {
<div class="list infinitescroll">
@pager.currentPageResults.map { s =>
<div class="study paginated_element">
<div class="study paginated">
@widget(s)
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/team/showContent.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2>@trans.teamRecentMembers()</h2>
<div class="pager none"><a rel="next" href="@routes.Team.show(t.id, np)">Next</a></div>
}
@members.currentPageResults.map { member =>
<div class="paginated_element">@userLink(member.user)</div>
<div class="paginated">@userLink(member.user)</div>
}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/team/teamTr.scala.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@(t: lila.team.Team)(implicit ctx: Context)

<tr class="paginated_element">
<tr class="paginated">
<td class="subject">
<a class="team-name" href="@routes.Team.show(t.id)">
<span data-icon="f" class="@{myTeam(t.id).??("is-green")}"></span>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tournament/crud/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h1 class="lichess_title">
<tr></tr>
}
@tours.currentPageResults.map { tour =>
<tr class="paginated_element">
<tr class="paginated">
<td><a href="@routes.TournamentCrud.edit(tour.id)">@tour.fullName</a></td>
<td>@tour.variant.name</td>
<td>@tour.clock</td>
Expand Down
47 changes: 47 additions & 0 deletions app/views/tournament/finishedPaginator.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package views.html.tournament

import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.tournament.Tournament

import controllers.routes

object finishedPaginator {

def apply(finished: lila.common.paginator.Paginator[Tournament])(implicit ctx: Context) =
tbody(cls := "infinitescroll")(
finished.nextPage.map { np =>
tr(th(cls := "pager none")(
a(rel := "next", href := routes.Tournament.home(np))("Next")
))
},
finished.currentPageResults.map { t =>
tr(cls := List(
"paginated" -> true,
"scheduled" -> t.isScheduled
))(
td(cls := "icon")(iconTag(tournamentIconChar(t))),
td(cls := "header")(
a(href := routes.Tournament.show(t.id))(
span(cls := "name")(t.fullName),
span(cls := "setup")(
t.clock.show,
"",
if (t.variant.exotic) t.variant.name else t.perfType.map(_.name),
!t.position.initial option frag("", trans.thematic()),
"",
t.mode.fold(trans.casualTournament, trans.ratedTournament)()
)
)
),
td(cls := "duration")(t.durationString),
td(cls := "winner")(
userIdLink(t.winnerId, withOnline = false),
br
),
td(cls := "text", dataIcon := "r")(t.nbPlayers.localize)
)
}
)
}
36 changes: 0 additions & 36 deletions app/views/tournament/finishedPaginator.scala.html

This file was deleted.

88 changes: 88 additions & 0 deletions app/views/tournament/home.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package views.html.tournament

import play.twirl.api.Html

import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.common.String.html.safeJsonValue
import lila.tournament.Tournament

import controllers.routes

object home {

def apply(
scheduled: List[Tournament],
finished: lila.common.paginator.Paginator[Tournament],
winners: lila.tournament.AllWinners,
json: play.api.libs.json.JsObject
)(implicit ctx: Context) =
layout(
title = trans.tournaments.txt(),
moreJs = frag(
infiniteScrollTag,
jsAt(s"compiled/lichess.tournamentSchedule${isProd ?? (".min")}.js"),
embedJs(s"""var app=LichessTournamentSchedule.app(document.getElementById('tournament_schedule'), {
data: ${safeJsonValue(json)},
i18n: ${jsI18n()}
});
var d=lichess.StrongSocket.defaults;d.params.flag="tournament";d.events.reload=app.update;""")
),
side = Some(frag(
div(cls := "tournament_home_side")(
div(cls := "tournament_links")(
a(dataIcon := "", cls := "text", href := routes.Tournament.help("arena".some))(trans.tournamentFAQ())
),
h2(cls := "leaderboard_title"),
a(href := routes.Tournament.leaderboard)(trans.leaderboard())
),
ul(cls := "tournament_leaderboard")(
winners.top.map { w =>
li(
userIdLink(w.userId.some),
a(title := w.tourName, href := routes.Tournament.show(w.tourId))(scheduledTournamentNameShortHtml(w.tourName))
)
}
),
h2(cls := "leaderboard_title")(trans.lichessTournaments()),
div(cls := "scheduled_tournaments")(
scheduled.map { tour =>
tour.schedule.filter(s => s.freq != lila.tournament.Schedule.Freq.Hourly) map { s =>
a(href := routes.Tournament.show(tour.id), dataIcon := tournamentIconChar(tour), cls := s"is-gold ${s.freq.name}")(
strong(tour.name),
momentFromNow(s.at)
)
}
}
)
)),
openGraph = lila.app.ui.OpenGraph(
url = s"$netBaseUrl${routes.Tournament.home().url}",
title = trans.tournamentHomeTitle.txt(),
description = trans.tournamentHomeDescription.txt()
).some
) {
div(cls := "content_box tournament_box no_padding")(
div(cls := "create_tournament")(
a(href := "/tournament/calendar", cls := "blue")(trans.tournamentCalendar()),
ctx.isAuth option a(href := routes.Tournament.form(), cls := "button")(trans.createANewTournament())
),
h1(trans.tournaments()),
div(id := "tournament_schedule"),
div(id := "tournament_list")(
table(cls := "slist finished")(
thead(
tr(
th(colspan := 2, cls := "large")(trans.finished()),
th(trans.duration()),
th(trans.winner()),
th(trans.players())
)
),
finishedPaginator(finished)
)
)
)
}
}
79 changes: 0 additions & 79 deletions app/views/tournament/home.scala.html

This file was deleted.

Loading

0 comments on commit 2e56673

Please sign in to comment.