Merge branch 'master' into asso
* master: remove wiki module add /about Fix two typos in the quotes
This commit is contained in:
commit
ff09621d17
|
@ -103,7 +103,6 @@ object Env {
|
|||
def db = lila.db.Env.current
|
||||
def user = lila.user.Env.current
|
||||
def security = lila.security.Env.current
|
||||
def wiki = lila.wiki.Env.current
|
||||
def hub = lila.hub.Env.current
|
||||
def socket = lila.socket.Env.current
|
||||
def message = lila.message.Env.current
|
||||
|
|
|
@ -27,6 +27,8 @@ object Page extends LilaController {
|
|||
|
||||
def privacy = bookmark("privacy")
|
||||
|
||||
def about = bookmark("about")
|
||||
|
||||
def swag = Open { implicit ctx =>
|
||||
OptionOk(Prismic getBookmark "swag") {
|
||||
case (doc, resolver) => views.html.site.swag(doc, resolver)
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package controllers
|
||||
|
||||
import lila.app._
|
||||
import views._
|
||||
|
||||
import play.api.mvc._, Results._
|
||||
|
||||
object Wiki extends LilaController {
|
||||
|
||||
val home = Open { implicit ctx =>
|
||||
fuccess(Redirect(routes.Wiki.show("Lichess-Wiki")))
|
||||
}
|
||||
|
||||
def show(slug: String) = Open { implicit ctx =>
|
||||
OptionOk(Env.wiki.api.show(slug, lang(ctx.req).language)) {
|
||||
case (page, pages) => html.wiki.show(page, pages)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
@(title: String, pages: List[lila.wiki.Page])(body: Html)(implicit ctx: Context)
|
||||
|
||||
@moreCss = {
|
||||
@cssTag("wiki.css")
|
||||
}
|
||||
|
||||
@side = {
|
||||
<div class="sidebar">
|
||||
@wiki.menu(pages)
|
||||
</div>
|
||||
}
|
||||
|
||||
@base.layout(
|
||||
title = title,
|
||||
moreCss = moreCss,
|
||||
side = side.some) {
|
||||
<div id="wiki">@body</div>
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
@(pages: List[lila.wiki.Page])(implicit ctx: Context)
|
||||
|
||||
<ul>
|
||||
@pages.map { page =>
|
||||
<li>
|
||||
<a href="@routes.Wiki.show(page.slug)">@page.title</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
|
@ -1,11 +0,0 @@
|
|||
@(page: lila.wiki.Page, pages: List[lila.wiki.Page])(implicit ctx: Context)
|
||||
|
||||
@wiki.layout(pages = pages, title = page.title) {
|
||||
|
||||
<div class="content_box small_box wiki_box">
|
||||
<h1 class="lichess_title">@page.title</h1>
|
||||
<div class="body">
|
||||
@Html(page.body)
|
||||
</div>
|
||||
</div>
|
||||
}
|
|
@ -564,11 +564,6 @@ fishnet {
|
|||
application {
|
||||
global="lila.app.Global"
|
||||
}
|
||||
wiki {
|
||||
collection.page = wiki
|
||||
git.url = "git://github.com/ornicar/lichess.wiki.git"
|
||||
markdown_path = "/usr/bin/markdown"
|
||||
}
|
||||
importer {
|
||||
delay = 50 milliseconds
|
||||
}
|
||||
|
|
|
@ -322,10 +322,6 @@ GET /mod/leaderboard controllers.Mod.gamify
|
|||
GET /mod/leaderboard/:period controllers.Mod.gamifyPeriod(period: String)
|
||||
GET /mod/search controllers.Mod.search
|
||||
|
||||
# Wiki
|
||||
GET /wiki controllers.Wiki.home
|
||||
GET /wiki/:slug controllers.Wiki.show(slug: String)
|
||||
|
||||
# Bookmark
|
||||
POST /bookmark/$gameId<\w{8}> controllers.Bookmark.toggle(gameId: String)
|
||||
|
||||
|
@ -429,6 +425,7 @@ GET /terms-of-service controllers.Page.tos
|
|||
GET /privacy controllers.Page.privacy
|
||||
GET /contact controllers.Page.contact
|
||||
GET /swag controllers.Page.swag
|
||||
GET /about controllers.Page.about
|
||||
|
||||
# Variants
|
||||
GET /variant controllers.Page.variantHome
|
||||
|
|
|
@ -36,7 +36,6 @@ private[api] final class Cli(bus: lila.common.Bus, renderer: ActorSelection) ext
|
|||
private def processors =
|
||||
lila.user.Env.current.cli.process orElse
|
||||
lila.security.Env.current.cli.process orElse
|
||||
lila.wiki.Env.current.cli.process orElse
|
||||
lila.i18n.Env.current.cli.process orElse
|
||||
lila.game.Env.current.cli.process orElse
|
||||
lila.gameSearch.Env.current.cli.process orElse
|
||||
|
|
|
@ -402,7 +402,7 @@ object Quote {
|
|||
, new Quote("Analysis, if it is really carried out with a complete concentration of his powers, forms and completes a chess player.", "Lev Polugaevsky")
|
||||
, new Quote("Anyone who wishes to learn how to play chess well must make himself or herself thoroughly conversant with the play in positions where the players have castled on opposite sides.", "Alexander Kotov")
|
||||
, new Quote("Apart from direct mistakes, there is nothing more ruinous than routine play, the aim of which is mechanical development.", "Alexei Suetin")
|
||||
, new Quote("As Rousseau could not compose without his cat beside him, so I cannot play chess without my king's bishop. In its absense the game to me is lifeless and void. The vitalizing factor is missing, and I can devise no plan of attack.", "Siegbert Tarrasch")
|
||||
, new Quote("As Rousseau could not compose without his cat beside him, so I cannot play chess without my king's bishop. In its absence the game to me is lifeless and void. The vitalizing factor is missing, and I can devise no plan of attack.", "Siegbert Tarrasch")
|
||||
, new Quote("As a chess player one has to be able to control one’s feelings, one has to be as cold as a machine.", "Levon Aronian")
|
||||
, new Quote("As a rule, pawn endings have a forced character, and they can be worked out conclusively.", "Mark Dvoretsky")
|
||||
, new Quote("As a rule, so-called \"positional\" sacrifices are considered more difficult, and therefore more praise-worthy, than those which are based exclusively on an exact calculation of tactical possibilities.", "Alexander Alekhine")
|
||||
|
@ -563,7 +563,7 @@ object Quote {
|
|||
, new Quote("Chess is a battle between your aversion to thinking and your aversion to losing.", "Someone")
|
||||
, new Quote("It was once said that Tal sacrificed 9 pawns for an attack", "Mato")
|
||||
, new Quote("Be well enough prepared that preparation won't play a role.", "Magnus Carlsen")
|
||||
, new Quote("I don't study; I create..", "Viktor Korchnoi")
|
||||
, new Quote("I don't study; I create.", "Viktor Korchnoi")
|
||||
)
|
||||
|
||||
implicit def quoteWriter: OWrites[Quote] = OWrites { q =>
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package lila.wiki
|
||||
|
||||
import Page.DefaultLang
|
||||
|
||||
import lila.db.dsl._
|
||||
|
||||
private[wiki] final class Api(coll: Coll) {
|
||||
|
||||
import Page.PageBSONHandler
|
||||
|
||||
def show(slug: String, lang: String): Fu[Option[(Page, List[Page])]] = for {
|
||||
page ← coll.uno[Page]($doc("slug" -> slug, "lang" -> lang)) orElse
|
||||
coll.uno[Page]($doc("slug" -> slug, "lang" -> DefaultLang))
|
||||
pages ← coll.find($doc(
|
||||
"lang" $in (lang, DefaultLang)
|
||||
)).sort($sort asc "number").cursor[Page]().gather[List]()
|
||||
} yield page map { _ -> makeMenu(pages) }
|
||||
|
||||
private def makeMenu(pages: List[Page]): List[Page] = {
|
||||
val (defaultPages, langPages) = pages partition (_.isDefaultLang)
|
||||
defaultPages map { dPage =>
|
||||
langPages.find(_.number == dPage.number) | dPage
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package lila.wiki
|
||||
|
||||
import com.typesafe.config.Config
|
||||
|
||||
import lila.db.dsl._
|
||||
|
||||
final class Env(config: Config, db: lila.db.Env) {
|
||||
|
||||
private val CollectionPage = config getString "collection.page"
|
||||
private val GitUrl = config getString "git.url"
|
||||
private val MarkdownPath = config getString "markdown_path"
|
||||
|
||||
private lazy val pageColl = db(CollectionPage)
|
||||
|
||||
lazy val api = new Api(pageColl)
|
||||
|
||||
private lazy val fetcher = new Fetch(
|
||||
coll = pageColl,
|
||||
gitUrl = GitUrl,
|
||||
markdownPath = MarkdownPath)
|
||||
|
||||
def cli = new lila.common.Cli {
|
||||
def process = {
|
||||
case "wiki" :: "fetch" :: Nil =>
|
||||
fetcher.apply inject "Fetched wiki from github"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object Env {
|
||||
|
||||
lazy val current = "wiki" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "wiki",
|
||||
db = lila.db.Env.current)
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package lila.wiki
|
||||
|
||||
import java.io.File
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.concurrent.Future
|
||||
|
||||
import com.google.common.io.Files
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.lib.Repository
|
||||
import Page.DefaultLang
|
||||
|
||||
import lila.db.dsl._
|
||||
|
||||
private[wiki] final class Fetch(
|
||||
coll: Coll,
|
||||
gitUrl: String,
|
||||
markdownPath: String) {
|
||||
|
||||
import Page.PageBSONHandler
|
||||
|
||||
def apply: Funit = getFiles flatMap { files =>
|
||||
val (defaultPages, langPages) = files.map(filePage).flatten partition (_.isDefaultLang)
|
||||
val newLangPages = (langPages map { page =>
|
||||
defaultPages find (_.number == page.number) map { default =>
|
||||
page.copy(slug = default.slug)
|
||||
}
|
||||
}).flatten
|
||||
coll.remove($empty) >> (newLangPages ::: defaultPages).map { page =>
|
||||
coll.insert[Page](page)
|
||||
}.sequenceFu.void
|
||||
}
|
||||
|
||||
private def filePage(file: File): Option[Page] = {
|
||||
val name = """^(.+)\.md$""".r.replaceAllIn(file.getName, _ group 1)
|
||||
if (name == "Home") None
|
||||
else Page.make(name, toHtml(file))
|
||||
}
|
||||
|
||||
private def getFiles: Fu[List[File]] = Future {
|
||||
val dir = Files.createTempDir
|
||||
dir.deleteOnExit
|
||||
Git.cloneRepository
|
||||
.setURI(gitUrl)
|
||||
.setDirectory(dir)
|
||||
.setBare(false)
|
||||
.call
|
||||
dir.listFiles.toList filter (_.isFile) sortBy (_.getName)
|
||||
}
|
||||
|
||||
private def toHtml(file: File): String = {
|
||||
val command = s"""$markdownPath ${file.getAbsolutePath}"""
|
||||
val output = new java.io.ByteArrayOutputStream
|
||||
import scala.sys.process._
|
||||
(command #> output).!
|
||||
new String(output.toByteArray, "UTF-8")
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package lila.wiki
|
||||
|
||||
import java.text.Normalizer
|
||||
import java.util.regex.Matcher.quoteReplacement
|
||||
|
||||
case class Page(
|
||||
id: String,
|
||||
slug: String,
|
||||
number: Int,
|
||||
lang: String,
|
||||
title: String,
|
||||
body: String) {
|
||||
|
||||
def isDefaultLang = lang == Page.DefaultLang
|
||||
}
|
||||
|
||||
object Page {
|
||||
|
||||
val DefaultLang = "en"
|
||||
val NameRegex = """^(\w{2,3})_(\d+)_(.+)$""".r
|
||||
|
||||
// name = en_1_Some Title
|
||||
def make(name: String, body: String): Option[Page] = name match {
|
||||
case NameRegex(lang, numberStr, title) =>
|
||||
parseIntOption(numberStr) map { number =>
|
||||
Page(
|
||||
id = name,
|
||||
number = number,
|
||||
slug = slugify(title),
|
||||
lang = lang,
|
||||
title = title.replace("-", " "),
|
||||
body = body)
|
||||
}
|
||||
case _ => none
|
||||
}
|
||||
|
||||
// does not lowercase
|
||||
private def slugify(input: String) = {
|
||||
val nowhitespace = input.replace(" ", "_")
|
||||
val normalized = Normalizer.normalize(nowhitespace, Normalizer.Form.NFD)
|
||||
"""[^\w-]""".r.replaceAllIn(normalized, "")
|
||||
}
|
||||
|
||||
private def dropNumber(input: String) =
|
||||
"""^\d+_(.+)$""".r.replaceAllIn(input, m => quoteReplacement(m group 1))
|
||||
|
||||
import lila.db.dsl.BSONJodaDateTimeHandler
|
||||
implicit val PageBSONHandler = reactivemongo.bson.Macros.handler[Page]
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
package lila
|
||||
|
||||
package object wiki extends PackageObject with WithPlay
|
|
@ -52,7 +52,7 @@ object ApplicationBuild extends Build {
|
|||
))
|
||||
|
||||
lazy val modules = Seq(
|
||||
chess, common, db, rating, user, security, wiki, hub, socket,
|
||||
chess, common, db, rating, user, security, hub, socket,
|
||||
message, notifyModule, i18n, game, bookmark, search,
|
||||
gameSearch, timeline, forum, forumSearch, team, teamSearch,
|
||||
analyse, mod, site, round, lobby, setup,
|
||||
|
@ -306,11 +306,6 @@ object ApplicationBuild extends Build {
|
|||
play.api, play.test, RM)
|
||||
)
|
||||
|
||||
lazy val wiki = project("wiki", Seq(common, db)).settings(
|
||||
libraryDependencies ++= provided(
|
||||
play.api, RM, jgit, guava)
|
||||
)
|
||||
|
||||
lazy val report = project("report", Seq(common, db, user)).settings(
|
||||
libraryDependencies ++= provided(
|
||||
play.api, RM)
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
#wiki .body {
|
||||
margin-top: 2em;
|
||||
text-align: left;
|
||||
min-height: 400px;
|
||||
}
|
||||
#wiki div.wiki_box {
|
||||
text-align: center;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
#wiki div.wiki_box em {
|
||||
font-style: italic;
|
||||
}
|
||||
#wiki div.wiki_box strong em {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#wiki div.wiki_box li {
|
||||
list-style: disc inside;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
#wiki div.wiki_box p {
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
#wiki div.wiki_box img {
|
||||
max-width: 510px;
|
||||
}
|
||||
|
||||
#wiki h2 {
|
||||
font-size: 1.5em;
|
||||
line-height: 2em;
|
||||
}
|
||||
|
||||
div.sidebar {
|
||||
margin-top: 30px;
|
||||
}
|
||||
div.sidebar a {
|
||||
display: block;
|
||||
font-size: 1.2em;
|
||||
padding: 0.5em 0 0.5em 0;
|
||||
}
|
Loading…
Reference in a new issue