2020-04-29 12:57:13 -06:00
|
|
|
package views.html
|
|
|
|
package swiss
|
|
|
|
|
|
|
|
import play.api.libs.json.Json
|
|
|
|
|
|
|
|
import lila.api.Context
|
|
|
|
import lila.app.templating.Environment._
|
|
|
|
import lila.app.ui.ScalatagsTemplate._
|
|
|
|
import lila.common.String.html.safeJsonValue
|
|
|
|
import lila.swiss.Swiss
|
|
|
|
|
|
|
|
import controllers.routes
|
|
|
|
|
|
|
|
object show {
|
|
|
|
|
|
|
|
def apply(
|
2020-04-29 15:46:31 -06:00
|
|
|
s: Swiss,
|
2020-04-29 12:57:13 -06:00
|
|
|
data: play.api.libs.json.JsObject,
|
|
|
|
chatOption: Option[lila.chat.UserChat.Mine]
|
2020-04-29 15:46:31 -06:00
|
|
|
)(implicit ctx: Context): Frag =
|
|
|
|
views.html.base.layout(
|
|
|
|
title = s"${s.name} #${s.id}",
|
|
|
|
moreJs = frag(
|
|
|
|
jsAt(s"compiled/lichess.swiss${isProd ?? (".min")}.js"),
|
2020-05-03 09:00:47 -06:00
|
|
|
embedJsUnsafe(s"""LichessSwiss.start(${safeJsonValue(
|
2020-04-29 15:46:31 -06:00
|
|
|
Json.obj(
|
|
|
|
"data" -> data,
|
|
|
|
"i18n" -> bits.jsI18n,
|
|
|
|
"userId" -> ctx.userId,
|
|
|
|
"chat" -> chatOption.map { c =>
|
|
|
|
chat.json(
|
|
|
|
c.chat,
|
|
|
|
name = trans.chatRoom.txt(),
|
|
|
|
timeout = c.timeout,
|
|
|
|
public = true,
|
|
|
|
resourceId = lila.chat.Chat.ResourceId(s"swiss/${c.chat.id}")
|
|
|
|
)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)})""")
|
|
|
|
),
|
|
|
|
moreCss = cssTag("swiss.show"),
|
|
|
|
chessground = false,
|
|
|
|
openGraph = lila.app.ui
|
|
|
|
.OpenGraph(
|
|
|
|
title = s"${s.name}: ${s.variant.name} ${s.clock.show} #${s.id}",
|
|
|
|
url = s"$netBaseUrl${routes.Swiss.show(s.id.value).url}",
|
|
|
|
description = s"${s.nbPlayers} players compete in the ${showEnglishDate(s.startsAt)} ${s.name} swiss tournament " +
|
|
|
|
s"organized by ${teamIdToName(s.teamId)}. " +
|
|
|
|
s.winnerId.fold("Winner is not yet decided.") { winnerId =>
|
|
|
|
s"${usernameOrId(winnerId)} takes the prize home!"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.some
|
|
|
|
)(
|
|
|
|
main(cls := "swiss")(
|
|
|
|
st.aside(cls := "swiss__side")(
|
|
|
|
swiss.side(s, chatOption.isDefined)
|
|
|
|
),
|
|
|
|
div(cls := "swiss__main")(div(cls := "box"))
|
|
|
|
)
|
|
|
|
)
|
2020-04-29 12:57:13 -06:00
|
|
|
}
|