diff --git a/app/core/CoreEnv.scala b/app/core/CoreEnv.scala index ba316642ee..40651404ba 100644 --- a/app/core/CoreEnv.scala +++ b/app/core/CoreEnv.scala @@ -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._ diff --git a/app/templating/ConfigHelper.scala b/app/templating/ConfigHelper.scala new file mode 100644 index 0000000000..a741207176 --- /dev/null +++ b/app/templating/ConfigHelper.scala @@ -0,0 +1,11 @@ +package lila +package templating + +import core.CoreEnv + +trait ConfigHelper { + + protected def env: CoreEnv + + def moretimeSeconds = env.settings.MoretimeSeconds +} diff --git a/app/templating/Environment.scala b/app/templating/Environment.scala index c79411a03b..9cd3e2957c 100644 --- a/app/templating/Environment.scala +++ b/app/templating/Environment.scala @@ -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 } diff --git a/app/templating/I18nHelper.scala b/app/templating/I18nHelper.scala index 950ccfa228..03011568ae 100644 --- a/app/templating/I18nHelper.scala +++ b/app/templating/I18nHelper.scala @@ -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 diff --git a/app/templating/UserHelper.scala b/app/templating/UserHelper.scala new file mode 100644 index 0000000000..14d0fc0a62 --- /dev/null +++ b/app/templating/UserHelper.scala @@ -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 + } +} diff --git a/app/views/round/player.scala.html b/app/views/round/player.scala.html index d19e47a69a..533f046944 100644 --- a/app/views/round/player.scala.html +++ b/app/views/round/player.scala.html @@ -38,13 +38,17 @@
- {% 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) + }
@game.clock.map { c => @round.clock(c, pov.color, "bottom") @if(!game.finished) { - + } } diff --git a/app/views/round/table.scala.html b/app/views/round/table.scala.html new file mode 100644 index 0000000000..cfbad1d871 --- /dev/null +++ b/app/views/round/table.scala.html @@ -0,0 +1,3 @@ +@(pov: Pov)(implicit ctx: Context) + +table diff --git a/app/views/round/tableEnd.scala.html b/app/views/round/tableEnd.scala.html new file mode 100644 index 0000000000..59adf87bb8 --- /dev/null +++ b/app/views/round/tableEnd.scala.html @@ -0,0 +1,3 @@ +@(pov: Pov)(implicit ctx: Context) + +table end diff --git a/app/views/round/username.scala.html b/app/views/round/username.scala.html index 30f1053752..60351ce90c 100644 --- a/app/views/round/username.scala.html +++ b/app/views/round/username.scala.html @@ -1,3 +1,11 @@ @(player: DbPlayer)(implicit ctx: Context) -player @player +@if(player.isAi) { +
+ @trans.aiNameLevelAiLevel("Crafty A.I.", player.aiLevel) +
+} else { +
+ @playerLink(player, "blank_if_play") +
+} diff --git a/todo b/todo index a018ed6e24..4165615e0d 100644 --- a/todo +++ b/todo @@ -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