2014-07-01 14:54:25 -06:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import lila.app._
|
|
|
|
import views._
|
|
|
|
|
|
|
|
object Page extends LilaController {
|
|
|
|
|
2016-01-24 23:45:24 -07:00
|
|
|
private def bookmark(name: String) = Open { implicit ctx =>
|
2016-01-26 03:24:59 -07:00
|
|
|
OptionOk(Prismic getBookmark name) {
|
2014-07-01 14:54:25 -06:00
|
|
|
case (doc, resolver) => views.html.site.page(doc, resolver)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-24 23:45:24 -07:00
|
|
|
def thanks = bookmark("thanks")
|
2014-07-01 14:54:25 -06:00
|
|
|
|
2016-01-24 23:45:24 -07:00
|
|
|
def tos = bookmark("tos")
|
2014-07-01 14:54:25 -06:00
|
|
|
|
2016-01-24 23:45:24 -07:00
|
|
|
def contribute = bookmark("help")
|
2014-07-01 14:54:25 -06:00
|
|
|
|
2016-01-24 23:45:24 -07:00
|
|
|
def streamHowTo = bookmark("stream-howto")
|
2014-07-03 17:16:32 -06:00
|
|
|
|
2016-01-24 23:45:24 -07:00
|
|
|
def contact = bookmark("contact")
|
2014-07-29 13:22:10 -06:00
|
|
|
|
2016-01-24 23:45:24 -07:00
|
|
|
def master = bookmark("master")
|
2016-01-24 20:36:09 -07:00
|
|
|
|
2016-01-26 03:24:59 -07:00
|
|
|
def privacy = bookmark("privacy")
|
2016-01-13 20:43:04 -07:00
|
|
|
|
2016-06-08 05:41:08 -06:00
|
|
|
def about = bookmark("about")
|
|
|
|
|
2016-03-04 20:00:41 -07:00
|
|
|
def swag = Open { implicit ctx =>
|
|
|
|
OptionOk(Prismic getBookmark "swag") {
|
|
|
|
case (doc, resolver) => views.html.site.swag(doc, resolver)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-26 05:19:12 -07:00
|
|
|
def variantHome = Open { implicit ctx =>
|
2016-04-25 04:52:29 -06:00
|
|
|
import play.api.libs.json._
|
|
|
|
negotiate(
|
|
|
|
html = OptionOk(Prismic getBookmark "variant") {
|
|
|
|
case (doc, resolver) => views.html.site.variantHome(doc, resolver)
|
|
|
|
},
|
|
|
|
api = _ => Ok(JsArray(chess.variant.Variant.all.map { v =>
|
|
|
|
Json.obj(
|
|
|
|
"id" -> v.id,
|
|
|
|
"key" -> v.key,
|
|
|
|
"name" -> v.name
|
|
|
|
)
|
2017-02-14 08:34:07 -07:00
|
|
|
})).fuccess
|
|
|
|
)
|
2016-01-26 05:19:12 -07:00
|
|
|
}
|
2016-01-19 01:02:54 -07:00
|
|
|
|
2016-01-26 03:24:59 -07:00
|
|
|
def variant(key: String) = Open { implicit ctx =>
|
|
|
|
(for {
|
|
|
|
variant <- chess.variant.Variant.byKey get key
|
|
|
|
perfType <- lila.rating.PerfType byVariant variant
|
|
|
|
} yield OptionOk(Prismic getVariant variant) {
|
|
|
|
case (doc, resolver) => views.html.site.variant(doc, resolver, variant, perfType)
|
|
|
|
}) | notFound
|
|
|
|
}
|
2014-07-01 14:54:25 -06:00
|
|
|
}
|