show paris meetup on homepage

This commit is contained in:
Thibault Duplessis 2015-03-22 10:01:40 +01:00
parent 8561f1e420
commit 1a44f21bf2
6 changed files with 25 additions and 6 deletions

View file

@ -24,7 +24,8 @@ final class Env(
dailyPuzzle = Env.puzzle.daily,
streamsOnAir = () => Env.tv.streamsOnAir,
countRounds = Env.round.count,
lobbyApi = Env.api.lobbyApi)
lobbyApi = Env.api.lobbyApi,
geoIP = Env.security.geoIP)
lazy val userInfo = mashup.UserInfo(
countUsers = () => Env.user.countEnabled,

View file

@ -19,9 +19,10 @@ final class Preload(
streamsOnAir: => () => Fu[List[StreamOnAir]],
dailyPuzzle: () => Fu[Option[lila.puzzle.DailyPuzzle]],
countRounds: () => Int,
lobbyApi: lila.api.LobbyApi) {
lobbyApi: lila.api.LobbyApi,
geoIP: lila.security.GeoIP) {
private type Response = (JsObject, List[Entry], List[MiniForumPost], List[Enterable], Option[Game], List[(User, PerfType)], List[Winner], Option[lila.puzzle.DailyPuzzle], List[StreamOnAir], List[lila.blog.MiniPost], Int)
private type Response = (JsObject, List[Entry], List[MiniForumPost], List[Enterable], Option[Game], List[(User, PerfType)], List[Winner], Option[lila.puzzle.DailyPuzzle], List[StreamOnAir], List[lila.blog.MiniPost], Int, Boolean)
def apply(
posts: Fu[List[MiniForumPost]],
@ -36,6 +37,9 @@ final class Preload(
dailyPuzzle() zip
streamsOnAir() map {
case ((((((((data, posts), tours), feat), entries), lead), tWinners), puzzle), streams) =>
(data, entries, posts, tours, feat, lead, tWinners, puzzle, streams, Env.blog.lastPostCache.apply, countRounds())
val inParis = geoIP(ctx.req.remoteAddress) ?? { loc =>
loc.country == "France" && loc.region.orElse(loc.city) == Some("Paris")
}
(data, entries, posts, tours, feat, lead, tWinners, puzzle, streams, Env.blog.lastPostCache.apply, countRounds(), inParis)
}
}

View file

@ -45,6 +45,10 @@ object Environment
type FormWithCaptcha = (play.api.data.Form[_], lila.common.Captcha)
private val parisMeetupDate = new org.joda.time.DateTime(2015, 3, 25, 19, 0)
def beforeParisMeetup =
org.joda.time.DateTime.now.isBefore(parisMeetupDate)
def netDomain = apiEnv.Net.Domain
def netBaseUrl = apiEnv.Net.BaseUrl
lazy val portsString = (apiEnv.Net.Port :: apiEnv.Net.ExtraPorts) mkString ","

View file

@ -1,4 +1,4 @@
@(data: play.api.libs.json.JsObject, userTimeline: List[lila.timeline.Entry], forumRecent: List[lila.forum.MiniForumPost], tours: List[lila.tournament.Enterable], featured: Option[Game], leaderboard: List[(User, lila.rating.PerfType)], tournamentWinners: List[lila.tournament.Winner], puzzle: Option[lila.puzzle.DailyPuzzle], streams: List[lila.tv.StreamOnAir], lastPost: List[lila.blog.MiniPost], nbRounds: Int)(implicit ctx: Context)
@(data: play.api.libs.json.JsObject, userTimeline: List[lila.timeline.Entry], forumRecent: List[lila.forum.MiniForumPost], tours: List[lila.tournament.Enterable], featured: Option[Game], leaderboard: List[(User, lila.rating.PerfType)], tournamentWinners: List[lila.tournament.Winner], puzzle: Option[lila.puzzle.DailyPuzzle], streams: List[lila.tv.StreamOnAir], lastPost: List[lila.blog.MiniPost], nbRounds: Int, inParis: Boolean)(implicit ctx: Context)
@underchat = {
<div id="featured_game">
@ -10,6 +10,11 @@
}
@side = {
@if(inParis && beforeParisMeetup) {
<a class="stream" href="http://lichess.org/forum/off-topic-discussion/third-lichess-meetup-in-paris-on-wednesday-25th">
<span class="text" data-icon="h">Join the Paris Meetup!</span>
</a>
}
<div id="streams_on_air">@tv.streamsOnAir(streams)</div>
@ctx.me.map { u =>
<div id="timeline" data-href="@routes.Lobby.timeline">

View file

@ -10,7 +10,8 @@ final class GeoIP(file: String, cacheTtl: Duration) {
private val geoIp = MaxMindIpGeo(file, 0)
private val cache = Builder.cache(cacheTtl, compute)
private def compute(ip: String): Option[Location] = geoIp getLocation ip map Location.apply
private def compute(ip: String): Option[Location] =
geoIp getLocation ip map Location.apply
def apply(ip: String): Option[Location] = cache get ip

View file

@ -605,6 +605,10 @@ div.game_config div.color_submits button.random span {
height: 55px;
padding: 0;
}
#site_header a.paris_meetup {
color: #d59120;
font-weight: bold;
}
#timeline {
margin-top: 2em;
border-top: 1px solid #e4e4e4;