custom code for ChessWhiz because he's pretty awesome

This commit is contained in:
Thibault Duplessis 2014-05-06 21:58:41 +02:00
parent 018b315a5b
commit 212a1a569a
5 changed files with 18 additions and 7 deletions

View file

@ -32,7 +32,7 @@
</div>
}
@streams.map { s =>
<a class="stream" href="@s.url" data-icon="1">&nbsp;@s.name</a>
<a class="stream" href="@s.url"><span data-icon="1">&nbsp;LIVE!</span> @s.name</a>
}
<div id="timeline" data-href="@routes.Lobby.timeline">
@timeline.entries(userTimeline)

View file

@ -7,6 +7,7 @@ import lila.common.PimpedConfig._
final class Env(
config: Config,
hub: lila.hub.Env,
isOnline: String => Boolean,
system: akka.actor.ActorSystem,
scheduler: lila.common.Scheduler) {
@ -22,6 +23,7 @@ final class Env(
private lazy val streaming = new Streaming(
system = system,
isOnline = isOnline,
ustreamApiKey = UstreamApiKey)
def streamsOnAir = streaming.onAir
@ -48,6 +50,7 @@ object Env {
lazy val current = "[boot] tv" describes new Env(
config = lila.common.PlayApp loadConfig "tv",
hub = lila.hub.Env.current,
isOnline = lila.user.Env.current.isOnline,
system = lila.common.PlayApp.system,
scheduler = lila.common.PlayApp.scheduler)
}

View file

@ -6,7 +6,8 @@ import play.api.libs.ws.WS
private final class Streaming(
system: ActorSystem,
ustreamApiKey: String) {
ustreamApiKey: String,
isOnline: String => Boolean) {
import Streaming._
import Twitch.Reads._
@ -26,16 +27,16 @@ private final class Streaming(
case Get => sender ! onAir
case Search =>
val keyword = "lichess.org"
val max = 2
val twitch = WS.url("https://api.twitch.tv/kraken/search/streams")
.withQueryString("q" -> keyword)
.withQueryString("q" -> "lichess.org")
.withHeaders("Accept" -> "application/vnd.twitchtv.v2+json")
.get().map { _.json.asOpt[Twitch.Result] ?? (_.streamsOnAir take max) }
val ustream = WS.url(s"http://api.ustream.tv/json/stream/all/search/description:like:$keyword")
val chesswhiz = isOnline("chesswhiz") ??
WS.url(s"http://api.ustream.tv/json/stream/recent/search/title:like:chesswhiz")
.withQueryString("key" -> ustreamApiKey)
.get().map { _.json.asOpt[Ustream.Result] ?? (_.streamsOnAir take max) }
twitch |+| ustream map StreamsOnAir.apply pipeTo self
twitch |+| chesswhiz map StreamsOnAir.apply pipeTo self
case StreamsOnAir(streams) => onAir = streams
}

View file

@ -114,7 +114,7 @@ object ApplicationBuild extends Build {
play.api, RM, PRM, elastic4s)
)
lazy val tv = project("tv", Seq(common, db, hub, game, chess)).settings(
lazy val tv = project("tv", Seq(common, db, hub, game, user, chess)).settings(
libraryDependencies ++= provided(
play.api, RM, PRM)
)

View file

@ -1978,6 +1978,13 @@ div.lichess_overboard.joining .mini_board {
#site_header a.stream:hover {
text-decoration: underline;
}
#site_header a.stream span {
color: #d59120;
font-weight: bold;
}
#site_header a.stream span:before {
vertical-align: -3px;
}
#timeline {
margin-top: 2em;
border-top: 1px solid #e4e4e4;