Skip to content

Commit

Permalink
remove translation contribution code
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed May 25, 2017
1 parent 6b5247b commit b03a26c
Show file tree
Hide file tree
Showing 17 changed files with 7 additions and 731 deletions.
65 changes: 2 additions & 63 deletions app/controllers/I18n.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ package controllers
import play.api.data.Form
import play.api.libs.json.Json

import lila.api.Context
import lila.app._
import lila.common.{ Captcha, LilaCookie, HTTPRequest }
import lila.i18n.TransInfo
import views._
import lila.common.{ LilaCookie, HTTPRequest }

object I18n extends LilaController {

private def env = Env.i18n

def select = OpenBody { implicit ctx =>
import play.api.data.Forms._
import play.api.data._
implicit val req = ctx.body
Form(single("lang" -> text.verifying(env.pool contains _))).bindFromRequest.fold(
Form(single("lang" -> text.verifying(Env.i18n.pool contains _))).bindFromRequest.fold(
_ => notFound,
lang => {
ctx.me.filterNot(_.lang contains lang) ?? { me =>
Expand Down Expand Up @@ -47,60 +42,4 @@ object I18n extends LilaController {
)
)
}

def contribute = Open { implicit ctx =>
val mines = (ctx.req.acceptLanguages map env.transInfos.get).toList.flatten.distinct
Ok(html.i18n.contribute(env.transInfos.all, mines)).fuccess
}

def translationForm(lang: String) = Auth { implicit ctx => me =>
OptionFuOk(infoAndContext(lang)) {
case (info, context) => env.forms.translationWithCaptcha map {
case (form, captcha) => renderTranslationForm(form, info, captcha, context = context)
}
}
}

def translationPost(lang: String) = AuthBody { implicit ctx => me =>
OptionFuResult(infoAndContext(lang)) {
case (info, context) =>
implicit val req = ctx.body
val data = env.forms.decodeTranslationBody
FormFuResult(env.forms.translation) { form =>
env.forms.anyCaptcha map { captcha =>
renderTranslationForm(form, info, captcha, data = data, context = context)
}
} { metadata =>
env.forms.process(lang, metadata, data, me.username) inject {
Redirect(routes.I18n.contribute).flashing("success" -> "1")
}
}
}
}

private def infoAndContext(lang: String) = env.transInfos.get(lang) ?? { i =>
env.context.get map (i -> _) map (_.some)
}

private def renderTranslationForm(
form: Form[_],
info: TransInfo,
captcha: Captcha,
context: Map[String, String],
data: Map[String, String] = Map.empty
)(implicit ctx: Context) =
html.i18n.translationForm(
info,
form,
env.keys,
env.pool.default,
env.translator.rawTranslation(info.lang) _,
captcha,
data = data,
context = context
)

def fetch(from: Int) = Open { implicit ctx =>
JsonOk(env jsonFromVersion from)
}
}
23 changes: 0 additions & 23 deletions app/views/i18n/contribute.scala.html

This file was deleted.

18 changes: 0 additions & 18 deletions app/views/i18n/layout.scala.html

This file was deleted.

78 changes: 0 additions & 78 deletions app/views/i18n/translationForm.scala.html

This file was deleted.

16 changes: 0 additions & 16 deletions app/views/i18n/translationLink.scala.html

This file was deleted.

34 changes: 0 additions & 34 deletions app/views/i18n/translations.scala.html

This file was deleted.

6 changes: 0 additions & 6 deletions conf/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,7 @@ report {
i18n {
web_path.relative = ${app.web_path}/trans
file_path.relative = "modules/i18n/messages"
upstream.url_pattern = "https://en.lichess.org/translation/fetch/%d"
collection.translation = translation
request_handler.protocol = ${net.protocol}
context.git {
url = "git://github.com/ornicar/lila.wiki.git"
file = "translation_context.md"
}
cdn_domain = ${net.asset.domain}
}
detectlanguage.api {
Expand Down
4 changes: 0 additions & 4 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,6 @@ GET /video/author/:author controllers.Video.author(author: String)
GET /video/:id controllers.Video.show(id: String)

# I18n
GET /translation/contribute controllers.I18n.contribute
GET /translation/form/:lang controllers.I18n.translationForm(lang: String)
POST /translation/post/:lang controllers.I18n.translationPost(lang: String)
GET /translation/fetch/:from controllers.I18n.fetch(from: Int)
POST /translation/select controllers.I18n.select

# Authentication
Expand Down
61 changes: 0 additions & 61 deletions modules/i18n/src/main/Context.scala

This file was deleted.

Loading

0 comments on commit b03a26c

Please sign in to comment.