Skip to content

Commit

Permalink
Show tags on recently published content page
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham Tackley committed Dec 19, 2011
1 parent cc3f9a2 commit 85b060c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
9 changes: 9 additions & 0 deletions app/assets/stylesheets/std.less
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ html, body {
}
}

.tag-list {
list-style-type: disc;

li {
float: left;
padding-right: 5px;
margin-left: 20px;
}
}
@import "_search";

11 changes: 8 additions & 3 deletions app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import play.api._
import play.api.mvc._
import lib.Backend
import org.joda.time.DateTime
import com.gu.openplatform.contentapi.model.Tag

object Application extends Controller {

Expand All @@ -22,9 +23,12 @@ object Application extends Controller {
private def publishedContent = {
val currentHits = Api.countsData
Backend.last24hoursOfContent.get.map { c =>
PublishedContent(c.webPublicationDate, c.webUrl, c.webTitle,
PublishedContent(
c.webPublicationDate, c.webUrl, c.webTitle,
currentHits.get(c.webUrl).map(_.toString).getOrElse("0"),
c.sectionName.getOrElse(""))
c.sectionName.getOrElse(""),
c.tags
)
}
}

Expand All @@ -44,7 +48,8 @@ case class PublishedContent(
url: String,
title: String,
hitsPerSec: String,
section: String
section: String,
tags: List[Tag]
) {
lazy val cssClass = hitsPerSec match {
case "0" => "zero"
Expand Down
10 changes: 2 additions & 8 deletions app/lib/LatestContentActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,15 @@ class LatestContentActor extends Actor {
log("Getting latest content published since "+ lastDateTime + "...")

val apiNewContent: List[Content] =
Api.search.fromDate(lastDateTime).orderBy("oldest").pageSize(50).results.reverse
Api.search.fromDate(lastDateTime).showTags("all").orderBy("oldest").pageSize(50).results.reverse

// because of the way we handle dates we will always get at least one item of content repeated
// so remove stuff we've already got from the api list
val newContent = apiNewContent.filterNot(c => latestContent.exists(_.id == c.id))

latestContent = newContent ::: latestContent.filter(_.webPublicationDate.plusHours(24).isAfterNow)

log("Content list is now " + latestContent.size + " entries: ")

latestContent.foreach(c =>
log(" %s %s" format (c.webPublicationDate, c.id))
)

log("(EOL)")
log("Content list is now " + latestContent.size + " entries")

case LatestContentActor.Get() =>
self.channel ! latestContent
Expand Down
32 changes: 29 additions & 3 deletions app/views/snippets/contentChart.scala.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
@(content: List[controllers.PublishedContent])
<div class="well">
<!--
<div style="float:right">
<label style="padding: 0">
<input type="checkbox" name="tags-toggle" id="tags-toggle">
<span>show tags</span>
</label>
</div>
-->
<div>@content.size items</div>
</div>

<table>
@for(c <- content) {
<tr>
<td>@c.publicationDate.toString("d MMM HH:mm:ss")</td>
<td><span class="label percent-cps @c.cssClass">@c.hitsPerSec</span>&nbsp;
@Html(c.section) <a href="@c.url">@Html(c.title)</a></td>
<td>
<span class="label percent-cps @c.cssClass">@c.hitsPerSec</span>&nbsp;
@Html(c.section) <a href="@c.url">@Html(c.title)</a>
<ol class="tag-list">
@for(t <- c.tags) {
<li><a href="@t.webUrl">@t.webTitle</a></li>
}
</ol>
</td>
</tr>
}
</table>
</table>


<script type="text/javascript">
$("#tags-toggle").change(function() {
console.log("change clicked!")
})
</script>

0 comments on commit 85b060c

Please sign in to comment.