Add developers page and embedding facilities

This commit is contained in:
Thibault Duplessis 2013-01-02 05:06:17 +01:00
parent d2ff942c6b
commit dc2cc4910c
11 changed files with 60 additions and 14 deletions

View file

@ -83,8 +83,10 @@ trait LilaController
protected def JsonIOk(map: IO[Map[String, Any]]) = JsonOk(map.unsafePerformIO)
protected def JsIOk(js: IO[String], headers: (String, String)*) =
Ok(js.unsafePerformIO) as JAVASCRIPT withHeaders (headers: _*)
protected def JsIOk(js: IO[String], headers: (String, String)*) = JsOk(js.unsafePerformIO)
protected def JsOk(js: String, headers: (String, String)*) =
Ok(js) as JAVASCRIPT withHeaders (headers: _*)
protected def ValidOk(valid: Valid[Unit]) = valid.fold(
e BadRequest(e.shows),

View file

@ -45,4 +45,15 @@ object Main extends LilaController {
def captchaCheck(id: String) = Open { implicit ctx
Ok(env.site.captcha get id valid ~get("solution") fold (1, 0))
}
def embed = Open { implicit ctx
JsOk("""document.write("<iframe src='%s?embed=" + document.domain + "' class='lichess-iframe' allowtransparency='true' frameBorder='0' style='width: %dpx; height: %dpx;' title='Lichess free online chess'></iframe>");"""
.format(env.settings.NetBaseUrl, getInt("w") | 820, getInt("h") | 650),
CACHE_CONTROL -> "max-age=86400"
)
}
def developers = Open { implicit ctx
Ok(views.html.site.developers())
}
}

View file

@ -13,7 +13,7 @@ trait RequestGetter {
req.queryString get name flatMap (_.headOption) filter (""!=)
protected def getInt(name: String)(implicit ctx: Context) =
get(name)(ctx) map (_.toInt)
get(name)(ctx) flatMap parseIntOption
protected def getOr(name: String, default: String)(implicit ctx: Context) =
get(name)(ctx) getOrElse default

View file

@ -30,6 +30,9 @@ object Global extends GlobalSettings {
else Action(NotFound("I am an AI server")).some
}
else {
req.queryString get "embed" flatMap (_.headOption) filter (""!=) foreach { embed
println("[embed] %s -> %s".format(embed, req.path))
}
env.monitor.rpsProvider.countRequest()
env.security.wiretap(req)
env.security.firewall.requestHandler(req) orElse

View file

@ -7,7 +7,7 @@ import play.api.templates.Html
trait AssetHelper {
val assetVersion = 36
val assetVersion = 37
def cssTag(name: String) = css("stylesheets/" + name)

View file

@ -106,10 +106,10 @@
<div class="footer">
<div class="right">
<a href="http://github.com/ornicar">github.com/ornicar</a> | <a class="js_email">email me</a><br />
<a href="@routes.Wiki.home()" class="blank_if_play">@trans.learnMoreAboutLichess()</a><br />
<a href="@routes.Main.developers">Developers</a> |
<a href="http://www.facebook.com/appcenter/510511915639555">Facebook app</a>
</div>
<a href="@routes.Wiki.home()">Wiki</a> |
<a href="@routes.Wiki.home()" title="@trans.learnMoreAboutLichess()">Wiki</a> |
<a href="@routes.ForumCateg.show("lichess-feedback", 1)" title="Having a suggestion, feature request or bug report? Let me know">Feedback</a> |
<a href="http://github.com/ornicar/lila" target="_blank" title="See what's inside, fork and contribute">Source Code</a><br />
<a href="@routes.Monitor.index">Monitor</a> |

View file

@ -0,0 +1,21 @@
@()(implicit ctx: Context)
@site.layout(
title = "Developers",
moreCss = cssTag("developers.css")) {
<div class="content_box small_box developers">
<h1 class="lichess_title">Developers</h1>
<p>
Do you have a chess website, and want to add a live chess section?<br />
Add the following line to your site html:
</p>
<pre>&lt;script src="http://en.lichess.org/embed.js?w=820h=650"&gt;&lt;/script&gt;</pre>
<p>The <strong>w</strong> and <strong>h</strong> parameters control the width and height of the chess window.</p>
<p>Integration example: <a href="http://www.chessworldweb.com/ru/lichess.html">ChessWorldWeb live chess</a></p>
</div>
}

View file

@ -1,5 +1,6 @@
@(title: String)(body: Html)(implicit ctx: Context)
@(title: String, moreCss: Html = Html(""))(body: Html)(implicit ctx: Context)
@base.layout(
title = title,
active = none)(body)
active = none,
moreCss = moreCss)(body)

View file

@ -1,5 +1,6 @@
#Site
GET /socket controllers.Main.websocket
GET /embed.js controllers.Main.embed
# Game
GET /games controllers.Game.realtime
@ -180,6 +181,7 @@ GET /monitor/status controllers.Monitor.status
# Misc
POST /cli controllers.Cli.command
GET /captcha/$id<[\w]{8}> controllers.Main.captchaCheck(id: String)
GET /developers controllers.Main.developers
# Assets
GET /assets/*file controllers.Assets.at(path="/public", file)

View file

@ -0,0 +1,12 @@
div.developers p {
font-size: 1.2em;
line-height: 1.7em;
}
div.developers pre {
font-size: 1.2em;
font: monospace;
margin: 3em 0;
display; block;
overflow: visible;
}

View file

@ -1,9 +1,3 @@
#wiki h1 {
font-size: 1.8em;
color: #666;
font-weight: normal;
}
#wiki .body {
margin-top: 2em;
text-align: left;