lila/app/views/lobby/home.scala

232 lines
7.6 KiB
Scala
Raw Normal View History

2018-12-02 23:37:47 -07:00
package views.html.lobby
import controllers.routes
2019-12-08 11:12:00 -07:00
import play.api.libs.json.Json
2018-12-02 23:37:47 -07:00
import lila.api.Context
2019-12-04 16:39:16 -07:00
import lila.app.mashup.Preload.Homepage
2018-12-02 23:37:47 -07:00
import lila.app.templating.Environment._
2018-12-05 01:45:46 -07:00
import lila.app.ui.ScalatagsTemplate._
2019-01-15 00:02:28 -07:00
import lila.common.String.html.safeJsonValue
2018-12-02 23:37:47 -07:00
import lila.game.Pov
object home {
2019-12-04 16:39:16 -07:00
def apply(homepage: Homepage)(implicit ctx: Context) = {
import homepage._
views.html.base.layout(
title = "",
fullTitle = Some {
s"lichess.${if (netConfig.isProd) "org" else "dev"}${trans.freeOnlineChess.txt()}"
2019-12-04 16:39:16 -07:00
},
moreJs = frag(
2020-09-04 04:08:24 -06:00
jsModule("lobby"),
2020-09-04 08:10:30 -06:00
embedJsUnsafeLoadThen(
s"""LichessLobby(${safeJsonValue(
2019-12-13 07:30:20 -07:00
Json.obj(
2020-04-06 12:38:55 -06:00
"data" -> data,
2019-12-04 16:39:16 -07:00
"playban" -> playban.map { pb =>
Json.obj(
2019-12-13 07:30:20 -07:00
"minutes" -> pb.mins,
2019-12-04 16:39:16 -07:00
"remainingSeconds" -> (pb.remainingSeconds + 3)
)
},
"i18n" -> i18nJsObject(i18nKeys)
2019-12-13 07:30:20 -07:00
)
2020-09-04 08:10:30 -06:00
)})"""
2019-12-04 16:39:16 -07:00
)
),
moreCss = cssTag("lobby"),
chessground = false,
2019-12-13 07:30:20 -07:00
openGraph = lila.app.ui
.OpenGraph(
2020-09-04 04:08:24 -06:00
image = assetUrl("logo/lichess-tile-wide.png").some,
twitterImage = assetUrl("logo/lichess-tile.png").some,
2019-12-13 07:30:20 -07:00
title = "The best free, adless Chess server",
url = netBaseUrl,
description = trans.siteDescription.txt()
)
2020-09-04 04:08:24 -06:00
.some
2019-12-04 16:39:16 -07:00
) {
2019-12-13 07:30:20 -07:00
main(
cls := List(
2021-05-06 14:35:53 -06:00
"lobby" -> true,
"lobby-nope" -> (playban.isDefined || currentGame.isDefined),
"lobby--no-simuls" -> simuls.isEmpty
2019-12-13 07:30:20 -07:00
)
)(
div(cls := "lobby__table")(
div(cls := "bg-switch", title := "Dark mode")(
div(cls := "bg-switch__track"),
div(cls := "bg-switch__thumb")
),
2019-12-13 07:30:20 -07:00
div(cls := "lobby__start")(
ctx.blind option h2("Play"),
a(
href := routes.Setup.hookForm,
2019-12-13 07:30:20 -07:00
cls := List(
2019-12-04 16:39:16 -07:00
"button button-metal config_hook" -> true,
2019-12-13 07:30:20 -07:00
"disabled" -> (playban.isDefined || currentGame.isDefined || ctx.isBot)
),
trans.createAGame()
),
a(
href := routes.Setup.friendForm(none),
cls := List(
2019-12-04 16:39:16 -07:00
"button button-metal config_friend" -> true,
2019-12-13 07:30:20 -07:00
"disabled" -> currentGame.isDefined
),
trans.playWithAFriend()
2019-12-04 16:39:16 -07:00
),
2019-12-13 07:30:20 -07:00
a(
href := routes.Setup.aiForm,
2019-12-13 07:30:20 -07:00
cls := List(
"button button-metal config_ai" -> true,
"disabled" -> currentGame.isDefined
2019-12-04 16:39:16 -07:00
),
2019-12-13 07:30:20 -07:00
trans.playWithTheMachine()
2019-12-04 16:39:16 -07:00
)
2019-02-28 05:22:45 -07:00
),
2019-12-13 07:30:20 -07:00
div(cls := "lobby__counters")(
ctx.blind option h2("Counters"),
2020-10-02 12:17:10 -06:00
a(
id := "nb_connected_players",
href := ctx.noBlind.option(routes.User.list.url)
2020-10-02 12:17:10 -06:00
)(
trans.nbPlayers(
strong(dataCount := homepage.counters.members)(homepage.counters.members.localize)
)
),
2020-10-02 12:17:10 -06:00
a(
id := "nb_games_in_play",
href := ctx.noBlind.option(routes.Tv.games.url)
2020-10-02 12:17:10 -06:00
)(
trans.nbGamesInPlay(
strong(dataCount := homepage.counters.rounds)(homepage.counters.rounds.localize)
)
2019-12-13 07:30:20 -07:00
)
)
),
currentGame.map(bits.currentGameInfo) orElse
playban.map(bits.playbanInfo) getOrElse {
2020-09-21 01:28:28 -06:00
if (ctx.blind) blindLobby(blindGames)
else bits.lobbyApp
},
2019-12-13 07:30:20 -07:00
div(cls := "lobby__side")(
ctx.blind option h2("Highlights"),
2020-06-30 14:36:43 -06:00
ctx.noKid option st.section(cls := "lobby__streams")(
views.html.streamer.bits liveStreams streams,
streams.live.streams.nonEmpty option a(href := routes.Streamer.index(), cls := "more")(
trans.streamersMenu(),
" »"
)
),
2019-12-13 07:30:20 -07:00
div(cls := "lobby__spotlights")(
events.map(bits.spotlight),
!ctx.isBot option frag(
lila.tournament.Spotlight.select(tours, ctx.me, 3 - events.size) map {
views.html.tournament.homepageSpotlight(_)
},
2020-04-19 12:55:51 -06:00
simuls.filter(isFeaturable) map views.html.simul.bits.homepageSpotlight
2019-12-13 07:30:20 -07:00
)
),
if (ctx.isAuth)
div(cls := "timeline")(
2019-12-08 11:12:00 -07:00
ctx.blind option h2("Timeline"),
views.html.timeline entries userTimeline,
userTimeline.nonEmpty option a(cls := "more", href := routes.Timeline.home)(
2020-07-22 04:52:52 -06:00
trans.more(),
" »"
)
2019-12-08 11:12:00 -07:00
)
2019-12-13 07:30:20 -07:00
else
div(cls := "about-side")(
2019-12-04 16:39:16 -07:00
ctx.blind option h2("About"),
2019-12-13 07:30:20 -07:00
trans.xIsAFreeYLibreOpenSourceChessServer(
"Lichess",
a(cls := "blue", href := routes.Plan.features)(trans.really.txt())
2019-12-13 07:30:20 -07:00
),
2019-12-04 16:39:16 -07:00
" ",
a(href := "/about")(trans.aboutX("Lichess"), "...")
2019-02-27 01:57:53 -07:00
)
2019-12-13 07:30:20 -07:00
),
featured map { g =>
div(cls := "lobby__tv")(
2020-08-16 02:10:50 -06:00
views.html.game.mini(Pov naturalOrientation g, tv = true)
2019-12-13 07:30:20 -07:00
)
},
puzzle map { p =>
2020-11-30 10:09:44 -07:00
views.html.puzzle.embed.dailyLink(p)(ctx.lang)(cls := "lobby__puzzle")
2019-12-13 07:30:20 -07:00
},
ctx.noBot option bits.underboards(tours, simuls, leaderboard, tournamentWinners),
ctx.noKid option div(cls := "lobby__forum lobby__box")(
a(cls := "lobby__box__top", href := routes.ForumCateg.index)(
h2(cls := "title text", dataIcon := "")(trans.latestForumPosts()),
2020-01-13 06:45:08 -07:00
span(cls := "more")(trans.more(), " »")
2018-12-02 23:37:47 -07:00
),
2019-12-13 07:30:20 -07:00
div(cls := "lobby__box__content")(
views.html.forum.post recent forumRecent
)
),
bits.lastPosts(lastPost),
div(cls := "lobby__support")(
a(href := routes.Plan.index)(
2019-12-13 07:30:20 -07:00
iconTag(patronIconChar),
span(cls := "lobby__support__text")(
2020-02-09 07:38:26 -07:00
strong(trans.patron.donate()),
span(trans.patron.becomePatron())
2019-02-27 01:57:53 -07:00
)
2019-12-04 16:39:16 -07:00
),
2019-12-13 07:30:20 -07:00
a(href := "https://shop.spreadshirt.com/lichess-org")(
iconTag(""),
span(cls := "lobby__support__text")(
strong("Swag Store"),
span(trans.playChessInStyle())
)
2018-12-02 23:37:47 -07:00
)
2019-12-13 07:30:20 -07:00
),
div(cls := "lobby__about")(
ctx.blind option h2("About"),
a(href := "/about")(trans.aboutX("Lichess")),
a(href := "/faq")(trans.faq.faqAbbreviation()),
2020-02-08 18:37:00 -07:00
a(href := "/contact")(trans.contact.contact()),
2019-12-13 07:30:20 -07:00
a(href := "/mobile")(trans.mobileApp()),
a(href := routes.Page.tos)(trans.termsOfService()),
2020-09-27 15:16:05 -06:00
a(href := "/privacy")(trans.privacy()),
a(href := "/source")(trans.sourceCode()),
a(href := "/ads")("Ads"),
2020-02-27 14:31:48 -07:00
views.html.base.bits.connectLinks
2019-02-28 05:38:04 -07:00
)
2019-12-13 07:30:20 -07:00
)
}
2019-12-04 16:39:16 -07:00
}
2018-12-02 23:37:47 -07:00
private val i18nKeys = List(
2018-12-02 23:37:47 -07:00
trans.realTime,
trans.correspondence,
trans.nbGamesInPlay,
trans.player,
trans.time,
trans.joinTheGame,
trans.cancel,
trans.casual,
trans.rated,
trans.variant,
trans.mode,
trans.list,
trans.graph,
trans.filterGames,
trans.youNeedAnAccountToDoThat,
trans.oneDay,
trans.nbDays,
trans.aiNameLevelAiLevel,
trans.yourTurn,
trans.rating,
trans.createAGame,
trans.quickPairing,
trans.lobby,
trans.custom,
trans.anonymous
).map(_.key)
2018-12-02 23:37:47 -07:00
}