Templating

This commit is contained in:
Thibault Duplessis 2012-05-17 02:34:24 +02:00
parent 04c8703e4a
commit 5c1005d1c2
10 changed files with 55 additions and 6 deletions

View file

@ -11,7 +11,7 @@ import play.api.Application
import ui._
final class CoreEnv private (application: Application, settings: Settings) {
final class CoreEnv private (application: Application, val settings: Settings) {
implicit val app = application
import settings._

View file

@ -0,0 +1,11 @@
package lila
package templating
import core.CoreEnv
trait ConfigHelper {
protected def env: CoreEnv
def moretimeSeconds = env.settings.MoretimeSeconds
}

View file

@ -1,6 +1,7 @@
package lila
package templating
import core.Global.{ env coreEnv } // OMG
import http.{ HttpEnvironment, Setting }
object Environment
@ -11,6 +12,9 @@ object Environment
with I18nHelper
with UiHelper
with RequestHelper
with SettingHelper {
with SettingHelper
with UserHelper
with ConfigHelper {
protected def env = coreEnv
}

View file

@ -1,10 +1,10 @@
package lila
package templating
import core.CoreEnv
import controllers._
import http.Context
import i18n.{ LangList, I18nDomain }
import core.Global.env // OMG
import play.api.i18n.Lang
import play.api.templates.Html
@ -12,6 +12,8 @@ import play.api.mvc.RequestHeader
trait I18nHelper {
protected def env: CoreEnv
private val pool = env.i18n.pool
val trans = env.i18n.keys

View file

@ -0,0 +1,13 @@
package lila
package templating
import play.api.templates.Html
import game.DbPlayer
trait UserHelper {
def playerLink(player: DbPlayer, cssClass: String) = Html {
"link " + player.id
}
}

View file

@ -38,13 +38,17 @@
</div>
<div class="lichess_separator"></div>
<div class="table_inner">
{% include (game.isPlayable ? "LichessBundle:Game:table.html.twig" : "LichessBundle:Game:tableEnd.html.twig") with {"player": player} %}
@if(game.playable) {
@round.table(pov)
} else {
@round.tableEnd(pov)
}
</div>
</div>
@game.clock.map { c =>
@round.clock(c, pov.color, "bottom")
@if(!game.finished) {
<a class="moretime" href="#" title="@trans.giveNbSeconds(15)"></a>
<a class="moretime" href="#" title="@trans.giveNbSeconds(moretimeSeconds)"></a>
}
}
</div>

View file

@ -0,0 +1,3 @@
@(pov: Pov)(implicit ctx: Context)
table

View file

@ -0,0 +1,3 @@
@(pov: Pov)(implicit ctx: Context)
table end

View file

@ -1,3 +1,11 @@
@(player: DbPlayer)(implicit ctx: Context)
player @player
@if(player.isAi) {
<div class="username connected">
@trans.aiNameLevelAiLevel("Crafty A.I.", player.aiLevel)
</div>
} else {
<div class="username @player.color.name">
@playerLink(player, "blank_if_play")
</div>
}

1
todo
View file

@ -10,3 +10,4 @@ forms that validate while constructing the object
player timeout depending on game duration
chess captcha is broken sometimes curl localhost:9000/api/captcha/solve/36yabr3t
do not count games vs engine as win/loss
template option.fold