Add Team.irc controlling the team IRC channel
This commit is contained in:
parent
2dd634715e
commit
20a05be034
|
@ -1,16 +1,16 @@
|
|||
package controllers
|
||||
|
||||
import akka.pattern.ask
|
||||
import play.api.data._, Forms._
|
||||
import play.api.libs.concurrent.Akka
|
||||
import play.api.libs.iteratee._
|
||||
import play.api.libs.json._
|
||||
import play.api.mvc._, Results._
|
||||
|
||||
import lila.app._
|
||||
import lila.hub.actorApi.captcha.ValidCaptcha
|
||||
import views._
|
||||
import makeTimeout.large
|
||||
|
||||
import play.api.mvc._, Results._
|
||||
import play.api.data._, Forms._
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.iteratee._
|
||||
import play.api.libs.concurrent.Akka
|
||||
import akka.pattern.ask
|
||||
import views._
|
||||
|
||||
object Main extends LilaController {
|
||||
|
||||
|
@ -35,13 +35,13 @@ object Main extends LilaController {
|
|||
|
||||
def developers = Open { implicit ctx ⇒
|
||||
fuccess {
|
||||
Ok(views.html.site.developers())
|
||||
views.html.site.developers()
|
||||
}
|
||||
}
|
||||
|
||||
def irc = Open { implicit ctx =>
|
||||
fuccess {
|
||||
Ok(views.html.site.irc())
|
||||
def irc = Open { implicit ctx ⇒
|
||||
ctx.me ?? Env.team.api.mine map {
|
||||
views.html.site.irc(_)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,25 +2,25 @@ package lila.app
|
|||
package templating
|
||||
|
||||
import lila.user.Context
|
||||
import lila.team.Team
|
||||
|
||||
trait IRCHelper { self: TeamHelper with SecurityHelper with I18nHelper ⇒
|
||||
|
||||
private val prompt = "1"
|
||||
private val uio = "OT10cnVlde"
|
||||
|
||||
def myIrcUrl(implicit ctx: Context) =
|
||||
def myIrcUrl(teams: List[Team])(implicit ctx: Context) =
|
||||
"""http://webchat.freenode.net?nick=%s&channels=%s&prompt=%s&uio=%s""".format(
|
||||
ctx.username | "Anon-.",
|
||||
myIrcChannels mkString ",",
|
||||
myIrcChannels(teams) mkString ",",
|
||||
prompt,
|
||||
uio)
|
||||
|
||||
def myIrcChannels(implicit ctx: Context): List[String] =
|
||||
teamChans ::: staffChans ::: langChans
|
||||
def myIrcChannels(teams: List[Team])(implicit ctx: Context): List[String] =
|
||||
teamChans(teams) ::: staffChans ::: langChans
|
||||
|
||||
private def teamChans(implicit ctx: Context) = ctx.userId ?? { userId ⇒
|
||||
teamIds(userId) map { "lichess-team-" + _ }
|
||||
}
|
||||
private def teamChans(teams: List[Team]) =
|
||||
teams filter (_.irc) map ("lichess-team-" + _)
|
||||
|
||||
private def staffChans(implicit ctx: Context) =
|
||||
isGranted(_.StaffForum) ?? List("lichess-staff")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@()(implicit ctx: Context)
|
||||
@(teams: List[lila.team.Team])(implicit ctx: Context)
|
||||
|
||||
@title = @{ "IRC #lichess channel on freenode" }
|
||||
|
||||
|
@ -11,7 +11,7 @@ or use your own <a href="http://www.wikihow.com/Get-Started-with-IRC-(Internet-R
|
|||
Server: freenode<br />
|
||||
Channels: <br />
|
||||
<ul class="channels">
|
||||
@myIrcChannels.map { chan =>
|
||||
@myIrcChannels(teams).map { chan =>
|
||||
<li>#@chan</li>
|
||||
}
|
||||
</ul>
|
||||
|
@ -24,6 +24,6 @@ moreCss = cssTag("irc.css")) {
|
|||
|
||||
<div class="content_box irc_box">
|
||||
<h1 class="lichess_title">@title</h1>
|
||||
<iframe src="@myIrcUrl"></iframe>
|
||||
<iframe src="@myIrcUrl(teams)"></iframe>
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@ currentTab = "form".some) {
|
|||
<span>@trans.joiningPolicy()</span>
|
||||
@base.select(form("open"), Seq(1 -> trans.anyoneCanJoin.str(), 0 -> trans.aConfirmationIsRequiredToJoin.str()))
|
||||
</label>
|
||||
<label>
|
||||
<span>Enable IRC channel on @routes.Main.irc</span>
|
||||
@base.select(form("irc"), Seq(1 -> "Yes", 0 -> "No"))
|
||||
</label>
|
||||
<label>
|
||||
<span>@trans.location()</span>
|
||||
@base.input(form("location"))
|
||||
|
|
|
@ -16,6 +16,7 @@ private[team] final class DataForm(val captcher: lila.hub.ActorLazyRef) extends
|
|||
val location = "location" -> optional(text(minLength = 3, maxLength = 80))
|
||||
val description = "description" -> text(minLength = 30, maxLength = 2000)
|
||||
val open = "open" -> number
|
||||
val irc = "irc" -> number
|
||||
val gameId = "gameId" -> text
|
||||
val move = "move" -> text
|
||||
}
|
||||
|
@ -25,6 +26,7 @@ private[team] final class DataForm(val captcher: lila.hub.ActorLazyRef) extends
|
|||
Fields.location,
|
||||
Fields.description,
|
||||
Fields.open,
|
||||
Fields.irc,
|
||||
Fields.gameId,
|
||||
Fields.move)(TeamSetup.apply)(TeamSetup.unapply)
|
||||
.verifying("This team already exists", d ⇒ !teamExists(d).await)
|
||||
|
@ -33,10 +35,12 @@ private[team] final class DataForm(val captcher: lila.hub.ActorLazyRef) extends
|
|||
def edit(team: Team) = Form(mapping(
|
||||
Fields.location,
|
||||
Fields.description,
|
||||
Fields.open)(TeamEdit.apply)(TeamEdit.unapply)) fill TeamEdit(
|
||||
Fields.open,
|
||||
Fields.irc)(TeamEdit.apply)(TeamEdit.unapply)) fill TeamEdit(
|
||||
location = team.location,
|
||||
description = team.description,
|
||||
open = team.open.fold(1, 0))
|
||||
open = team.open.fold(1, 0),
|
||||
irc = team.irc.fold(1, 0))
|
||||
|
||||
val request = Form(mapping(
|
||||
"message" -> text(minLength = 30, maxLength = 2000),
|
||||
|
@ -69,10 +73,12 @@ private[team] case class TeamSetup(
|
|||
location: Option[String],
|
||||
description: String,
|
||||
open: Int,
|
||||
irc: Int,
|
||||
gameId: String,
|
||||
move: String) {
|
||||
|
||||
def isOpen = open == 1
|
||||
def hasIrc = irc == 1
|
||||
|
||||
def trim = copy(
|
||||
name = name.trim,
|
||||
|
@ -83,9 +89,11 @@ private[team] case class TeamSetup(
|
|||
private[team] case class TeamEdit(
|
||||
location: Option[String],
|
||||
description: String,
|
||||
open: Int) {
|
||||
open: Int,
|
||||
irc: Int) {
|
||||
|
||||
def isOpen = open == 1
|
||||
def hasIrc = irc == 1
|
||||
|
||||
def trim = copy(
|
||||
location = location map (_.trim) filter (_.nonEmpty),
|
||||
|
|
|
@ -13,6 +13,7 @@ case class Team(
|
|||
nbMembers: Int,
|
||||
enabled: Boolean,
|
||||
open: Boolean,
|
||||
irc: Boolean,
|
||||
createdAt: DateTime,
|
||||
createdBy: String) {
|
||||
|
||||
|
@ -38,6 +39,7 @@ object Team {
|
|||
nbMembers = 1,
|
||||
enabled = true,
|
||||
open = open,
|
||||
irc = false,
|
||||
createdAt = DateTime.now,
|
||||
createdBy = createdBy.id)
|
||||
|
||||
|
|
Loading…
Reference in a new issue