show puzzle menu to beta testers, migrate existing puzzles
This commit is contained in:
parent
e70d54149f
commit
b070b66394
|
@ -19,11 +19,18 @@ final class SiteMenu(trans: I18nKeys) {
|
|||
val forum = new Elem("forum", routes.ForumCateg.index, trans.forum)
|
||||
val tv = new Elem("tv", routes.Tv.index, I18nKey.untranslated("TV"))
|
||||
val message = new Elem("message", routes.Message.inbox(page = 1), trans.inbox)
|
||||
val puzzle = new Elem("puzzle", routes.Puzzle.home, I18nKey untranslated "Puzzles")
|
||||
|
||||
private val authenticated = List(play, game, tournament, user, team, forum, tv)
|
||||
private val anonymous = List(play, game, tournament, user, team, forum, tv)
|
||||
|
||||
def all(me: Option[User]) = me.isDefined.fold(authenticated, anonymous)
|
||||
private val betaTesters = Set("thibault", "hellball", "clarkey", "legend", "chubakka", "iron_logician")
|
||||
|
||||
def all(me: Option[User]) = me match {
|
||||
case Some(me) if betaTesters(me.id) ⇒ authenticated :+ puzzle
|
||||
case Some(me) ⇒ authenticated
|
||||
case _ ⇒ anonymous
|
||||
}
|
||||
}
|
||||
|
||||
object SiteMenu {
|
||||
|
|
|
@ -113,20 +113,17 @@ themepicker = true) {
|
|||
data-max="@lila.analyse.AdvantageChart.max"
|
||||
data-rows="@chart"></div>
|
||||
}.getOrElse {
|
||||
<div class="future_game_analysis in_progress" >
|
||||
@trans.computerAnalysisInProgress()
|
||||
</div>
|
||||
}
|
||||
}.getOrElse {
|
||||
@if(game.analysable && analysis.isEmpty) {
|
||||
<!-- <form class="future_game_analysis@{ctx.isAnon ?? " must_login"}" action="@routes.Analyse.computer(gameId, color.name)" method="post"> -->
|
||||
<!-- <button type="submit" class="button"><span>@trans.requestAComputerAnalysis()</span></button> -->
|
||||
<!-- </form> -->
|
||||
<div class="future_game_analysis">
|
||||
@trans.computerAnalysisInProgress()
|
||||
<div class="spinner"></div>
|
||||
</div>
|
||||
}
|
||||
}.getOrElse {
|
||||
@if(game.analysable && analysis.isEmpty) {
|
||||
<form class="future_game_analysis@{ctx.isAnon ?? " must_login"}" action="@routes.Analyse.computer(gameId, color.name)" method="post">
|
||||
<button type="submit" class="button"><span>@trans.requestAComputerAnalysis()</span></button>
|
||||
</form>
|
||||
}
|
||||
}
|
||||
<div class="view_game_analysis future_game_analysis">
|
||||
<a class="button" href="@routes.Round.watcher(pov.gameId, pov.color.name)">
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
@(title: String)(body: Html)(implicit ctx: Context)
|
||||
@(title: String, evenMoreCss: Option[Html] = None, evenMoreJs: Option[Html] = None)(body: Html)(implicit ctx: Context)
|
||||
|
||||
@moreCss = {
|
||||
@evenMoreCss
|
||||
@cssTag("problem.css")
|
||||
@cssTag("chessboardjs.css")
|
||||
}
|
||||
|
||||
@moreJs = {
|
||||
@evenMoreJs
|
||||
@jsTagCompiled("chessboard.js")
|
||||
@jsTag("vendor/chess.min.js")
|
||||
@jsAt("compiled/problem.js")
|
||||
}
|
||||
|
||||
@base.layout(
|
||||
title = title,
|
||||
moreCss = moreCss,
|
||||
moreJs = moreJs) {
|
||||
moreJs = moreJs,
|
||||
active = siteMenu.puzzle.some) {
|
||||
@body
|
||||
}
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
@(puzzle: lila.puzzle.Puzzle)(implicit ctx: Context)
|
||||
|
||||
@layout("Puzzle " + puzzle.id) {
|
||||
@moreCss = {
|
||||
@cssTag("chessboardjs.css")
|
||||
}
|
||||
|
||||
@moreJs = {
|
||||
@jsTag("vendor/chess.min.js")
|
||||
@jsAt("compiled/problem.js")
|
||||
}
|
||||
|
||||
@layout("Puzzle " + puzzle.id,
|
||||
evenMoreCss = moreCss.some,
|
||||
evenMoreJs = moreJs.some) {
|
||||
|
||||
<div class="content_box" id="puzzle">
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ final class Env(
|
|||
|
||||
def cli = new lila.common.Cli {
|
||||
def process = {
|
||||
case "puzzle" :: "fix" :: "fen" :: Nil ⇒ api.fixFen inject "fixed!"
|
||||
case "puzzle" :: "fix" :: "fen" :: Nil ⇒ api.fixAll inject "fixed!"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.joda.time.DateTime
|
|||
import play.api.libs.iteratee._
|
||||
import play.api.libs.iteratee.Enumerator
|
||||
import play.api.libs.json._
|
||||
import reactivemongo.bson.BSONDocument
|
||||
import reactivemongo.bson.{ BSONDocument, BSONInteger }
|
||||
import reactivemongo.core.commands.Count
|
||||
|
||||
import lila.db.Types.Coll
|
||||
|
@ -65,17 +65,27 @@ private[puzzle] final class PuzzleApi(
|
|||
BSONDocument(Attempt.BSONFields.vote -> v)
|
||||
).void
|
||||
|
||||
def fixFen = puzzleColl.find(BSONDocument()).cursor[Puzzle].enumerate() |>>>
|
||||
(Iteratee.foldM[Puzzle, Unit](()) {
|
||||
case (_, puzzle) ⇒ Generated fenOf puzzle.history match {
|
||||
case Success(fen) ⇒ puzzleColl.update(
|
||||
BSONDocument("_id" -> puzzle.id),
|
||||
BSONDocument("$set" -> BSONDocument(
|
||||
Puzzle.BSONFields.fen -> fen,
|
||||
Puzzle.BSONFields.rating -> Glicko.default
|
||||
))
|
||||
).void
|
||||
case Failure(err) ⇒ fufail(err.getMessage)
|
||||
}
|
||||
def fixAll = puzzleColl.find(
|
||||
BSONDocument(),
|
||||
BSONDocument("history" -> true)
|
||||
).cursor[BSONDocument].enumerate() |>>>
|
||||
(Iteratee.foldM[BSONDocument, Unit](()) {
|
||||
case (_, doc) ⇒
|
||||
val reader = new lila.db.BSON.Reader(doc)
|
||||
val (id, moves) = (reader str "_id", reader str "history" split ' ')
|
||||
Generated fenOf moves match {
|
||||
case Success(fen) ⇒ puzzleColl.update(
|
||||
BSONDocument("_id" -> id),
|
||||
BSONDocument("$set" -> BSONDocument(
|
||||
Puzzle.BSONFields.fen -> fen,
|
||||
Puzzle.BSONFields.rating -> Glicko.default,
|
||||
Puzzle.BSONFields.vote -> BSONInteger(0),
|
||||
Puzzle.BSONFields.attempts -> BSONInteger(0)
|
||||
))
|
||||
).void
|
||||
case Failure(err) ⇒
|
||||
println(err)
|
||||
fufail(err.getMessage)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
8
todo
8
todo
|
@ -106,6 +106,14 @@ ban only latest IP
|
|||
give AI levels ratings
|
||||
connect time chart to pgn viewer and say "time spent on this move: X seconds"
|
||||
|
||||
deploy
|
||||
------
|
||||
db.puzzle.ensureIndex({fen:1},{unique:1})
|
||||
db.puzzle.ensureIndex({date:1})
|
||||
db.puzzle.ensureIndex({vote:1})
|
||||
db.puzzle_attempt.ensureIndex({p:1})
|
||||
db.puzzle_attempt.ensureIndex({u:1})
|
||||
|
||||
infra
|
||||
-------
|
||||
lila nice + thread limit
|
||||
|
|
Loading…
Reference in a new issue