display short descriptions on events list
This commit is contained in:
parent
6e0165404a
commit
f8c9938ed1
|
@ -16,8 +16,10 @@ object Relay extends LilaController {
|
|||
private def relayNotFound(implicit ctx: Context) = NotFound(html.relay.notFound())
|
||||
|
||||
val index = Open { implicit ctx =>
|
||||
env.repo recent 30 map { relays =>
|
||||
Ok(html.relay.home(relays))
|
||||
env.repo recent 50 flatMap { relays =>
|
||||
env.contentApi byRelays relays map { contents =>
|
||||
Ok(html.relay.home(relays, contents))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ underchat = none) {
|
|||
<div class="content_box relay_box" data-icon="m">
|
||||
<h1>@rel.baseName</h1>
|
||||
@content.map { c =>
|
||||
<p class="edited">Last edited on @showDate(c.updatedAt) by @userIdLink(c.updatedBy.some).</p>
|
||||
<p class="edited">Last edited @momentFromNow(c.updatedAt) by @userIdLink(c.updatedBy.some).</p>
|
||||
}
|
||||
<form class="plain create content_box_content" action="@routes.Relay.contentPost(rel.id, rel.slug)" method="POST">
|
||||
<p class="help">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@(relays: List[lila.relay.Relay])(implicit ctx: Context)
|
||||
@(relays: List[lila.relay.Relay], contents: List[lila.relay.Content])(implicit ctx: Context)
|
||||
|
||||
@side = {
|
||||
<div class="side">
|
||||
|
@ -29,8 +29,11 @@ side = side.some) {
|
|||
<td>@showDate(rel.date)</td>
|
||||
<td>
|
||||
<a class="name" href="@routes.Relay.show(rel.id, rel.slug)">
|
||||
<strong>@rel.baseName</strong> - @rel.extName
|
||||
<strong>@rel.baseName</strong> - <em>@rel.extName</em>
|
||||
</a>
|
||||
@contents.find(_ matches rel).flatMap(_.short).map { short =>
|
||||
<span class="short">@escape(short)</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if(rel.status == lila.relay.Relay.Status.Finished) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div class="side">
|
||||
<div class="side_box padded">
|
||||
@content.flatMap(_.short).map { short =>
|
||||
<p class="short">@short</p>
|
||||
<p class="short">@escape(short)</p>
|
||||
}
|
||||
<a class="text" data-icon="I" href="@routes.Relay.index">Back to events list</a>
|
||||
@if(isGranted(_.RelayContent)) {
|
||||
|
|
|
@ -3,13 +3,17 @@ package lila.relay
|
|||
import org.joda.time.DateTime
|
||||
|
||||
case class Content(
|
||||
_id: String,
|
||||
short: Option[String],
|
||||
long: Option[String],
|
||||
notes: Option[String],
|
||||
createdAt: DateTime,
|
||||
updatedAt: DateTime,
|
||||
updatedBy: String)
|
||||
_id: String,
|
||||
short: Option[String],
|
||||
long: Option[String],
|
||||
notes: Option[String],
|
||||
updatedAt: DateTime,
|
||||
updatedBy: String) {
|
||||
|
||||
def id = _id
|
||||
|
||||
def matches(relay: Relay) = id == relay.baseSlug
|
||||
}
|
||||
|
||||
object Content {
|
||||
|
||||
|
|
|
@ -16,6 +16,12 @@ final class ContentApi(coll: Coll) {
|
|||
|
||||
def byRelay(relay: Relay): Fu[Option[Content]] = byId(Content mkId relay)
|
||||
|
||||
def byIds(ids: Seq[String]): Fu[List[Content]] = coll.find(
|
||||
BSONDocument("_id" -> BSONDocument("$in" -> ids))
|
||||
).cursor[Content].collect[List]()
|
||||
|
||||
def byRelays(relays: Seq[Relay]): Fu[List[Content]] = byIds(relays.map(Content.mkId).distinct)
|
||||
|
||||
def upsert(relay: Relay, data: ContentApi.Data, user: lila.user.User): Funit = {
|
||||
val now = DateTime.now
|
||||
byRelay(relay) flatMap {
|
||||
|
@ -24,7 +30,6 @@ final class ContentApi(coll: Coll) {
|
|||
short = data.short,
|
||||
long = data.long,
|
||||
notes = data.notes,
|
||||
createdAt = now,
|
||||
updatedAt = now,
|
||||
updatedBy = user.id))
|
||||
case Some(content) => coll.update(
|
||||
|
|
|
@ -24,9 +24,9 @@ case class Relay(
|
|||
|
||||
def activeGames = games.filterNot(_.end)
|
||||
|
||||
def slug = mkSlug(name)
|
||||
lazy val slug = mkSlug(name)
|
||||
|
||||
def baseSlug = mkSlug(baseName)
|
||||
lazy val baseSlug = mkSlug(baseName)
|
||||
|
||||
private def mkSlug(str: String) = Relay.SlugR.replaceAllIn(lila.common.String slugify str, "-")
|
||||
}
|
||||
|
|
|
@ -77,17 +77,24 @@ div.chat_panels {
|
|||
line-height: 2.3em;
|
||||
}
|
||||
#relay_list table.slist td {
|
||||
padding-top: 1em;
|
||||
padding-bottom: 1em;
|
||||
padding-top: 1.5em;
|
||||
padding-bottom: 1.5em;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
#relay_list table.slist .name {
|
||||
text-decoration: none;
|
||||
letter-spacing: 1px;
|
||||
display: block;
|
||||
}
|
||||
#relay_list table.slist .name em {
|
||||
font-style: italic;
|
||||
}
|
||||
#relay_list table.slist .name:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#relay_list table.slist .short {
|
||||
font-size: italic;
|
||||
}
|
||||
#relay_content table {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue