Permalink
Browse files

Started playframework 2.0 beta migration...

... now to get the comet/ajax to work ;)
  • Loading branch information...
1 parent cd15aca commit 6d439449a374c44caca7fa8c57ecb215b51e1edd @tackley committed Nov 28, 2011
View
@@ -1,3 +1,5 @@
*~
target/
.idea*/
+
+logs/
View
@@ -0,0 +1,20 @@
+import lib.Backend
+import play.api._
+
+
+
+
+object Global extends GlobalSettings {
+ override def onStart(app: Application) {
+ Logger.info("Starting...")
+ Backend.start()
+ Logger.info("Started")
+ }
+
+ override def onStop(app: Application) {
+ Logger.info("Stopping...")
+ Backend.stop()
+ Logger.info("Stopped")
+
+ }
+}
@@ -0,0 +1,16 @@
+package controllers
+
+import play.api._
+import play.api.mvc._
+
+object Application extends Controller {
+
+ def index = Action { Ok(views.html.index()) }
+
+ def top10 = Action { Ok(views.html.top10()) }
+
+ def top20 = TODO
+
+ def details = TODO
+
+}
@@ -1,4 +1,4 @@
-package dashboard.lib
+package lib
import akka.actor.Actor._
import akka.actor.Scheduler
@@ -7,20 +7,20 @@ import java.util.concurrent.TimeUnit
object Backend {
val listener = actorOf[EventListener].start()
- Scheduler.schedule(listener, TruncateClickStream(), 1, 1, TimeUnit.MINUTES)
- Scheduler.schedule(listener, UpdateFrontend(), 5, 5, TimeUnit.SECONDS)
val mqReader = new MqReader(listener)
def start() {
+ Scheduler.restart()
+ Scheduler.schedule(listener, TruncateClickStream(), 1, 1, TimeUnit.MINUTES)
spawn {
mqReader.start()
}
}
def stop() {
- mqReader.stop()
Scheduler.shutdown()
+ mqReader.stop()
listener.stop()
}
@@ -1,4 +1,4 @@
-package dashboard.lib
+package lib
object Calculator {
@@ -1,4 +1,4 @@
-package dashboard.lib
+package lib
import org.joda.time.format.DateTimeFormat
import org.joda.time.DateTime
@@ -1,14 +1,12 @@
-package dashboard.lib
+package lib
import akka.actor._
import akka.event.EventHandler
import collection.GenSeq
import org.scala_tools.time.Imports._
-import dashboard.comet._
case class TruncateClickStream()
case class GetClickStream()
-case class UpdateFrontend()
// it's very very important that this class is totally immutable!
@@ -47,9 +45,6 @@ class EventListener extends Actor {
case GetClickStream() => self.channel ! clickStream
- case UpdateFrontend() => {
- TopHitsServer ! clickStream
- }
}
}
@@ -1,21 +1,23 @@
-package dashboard.lib
+package lib
import org.zeromq.ZMQ
import akka.actor.ActorRef
+import play.api.Logger
object MqReader {
// 10 is a magic number here : I know we're sampling 2 servers, and we have 20 in total
val SCALE_TO_FULL_SITE = 10
}
class MqReader(actor: ActorRef) {
+ val logger = Logger(getClass)
var keepRunning = true
def stop() {
- println("waiting for stop...")
+ logger.info("waiting for stop...")
keepRunning = false
Thread.sleep(2000)
- println("stop has hopefully happened")
+ logger.info("stop has hopefully happened")
}
def start() {
@@ -50,7 +52,7 @@ class MqReader(actor: ActorRef) {
sub.close()
context.term()
- println("Stopped!")
+ logger.info("Stopped!")
}
@@ -1,8 +1,7 @@
-package dashboard.lib
+package lib
import xml.NodeSeq
import java.net.URL
-import net.liftweb.util.Helpers._
import org.scala_tools.time.Imports._
sealed abstract class Movement { def imgTag: NodeSeq }
@@ -17,7 +16,7 @@ case class HitReport(url: String, percent: Double, hits: Int, hitsPerSec: Double
lazy val referrers = events flatMap { _.referrer }
- lazy val referrerHostCounts = referrers.flatMap(url => tryo { new URL(url).getHost })
+ lazy val referrerHostCounts = referrers.flatMap(url => try { Some(new URL(url).getHost) } catch { case _ => None })
.groupBy(identity).mapValues(_.size).toList.sortBy(_._2).reverse
lazy val referrerPercents: List[(String, Double)] = referrerHostCounts.map { case (host, count) =>
View
@@ -0,0 +1,109 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Index</title>
+ <link href='http://fonts.googleapis.com/css?family=Reenie+Beanie' rel='stylesheet' type='text/css'>
+ <link rel="stylesheet" href='@routes.Assets.at("stylesheets/bootstrap-1.3.0.min.css")'>
+ <link rel="stylesheet" href='@routes.Assets.at("stylesheets/stats.css")'>
+
+ <script src='@routes.Assets.at("js/jquery-1.6.4.min.js")' type="text/javascript"></script>
+
+ <style>
+ body {
+ padding-top: 40px;
+ }
+
+ h1 {
+ font-family: 'Reenie Beanie', cursive;
+ font-size: 80px;
+ }
+ </style>
+</head>
+<body>
+
+<div class="topbar">
+ <div class="fill">
+ <div class="container">
+ <a class="brand" href='@routes.Application.index()'>SEO Dashboard</a>
+ <ul class="nav">
+ <li><a href="@routes.Application.top10()">Big Top 10</a></li>
+ <li><a href="@routes.Application.top20()">Top 20</a></li>
+ </ul>
+ </div>
+ </div>
+</div>
+
+<div class="container">
+ <div class="hero-unit">
+ <h1>The Guardian&rsquo;s SEO Dashboard</h1>
+
+ <p>What's going on right now?</p>
+ </div>
+
+ <div class="row">
+ <div class="span-one-third">
+ <h2>Big Screen Top 10</h2>
+
+ <p>The orignal classic-style dashboard, ideal for people who sit a long way from their screens,
+ on mobile devices, or who can&rsquo;t find their glasses right now.</p>
+
+ <p>Shows the top ten most accessed pages over the last 15 minutes in a single Top of the Pops inspired list.</p>
+
+ <p><a class="btn" href="@routes.Application.top10()">Show Me &raquo;</a></p>
+ </div>
+
+ <div class="span-one-third">
+ <h2>Top 20</h2>
+
+ <p>Designed for local desktop use.</p>
+
+ <p>Shows the top twenty most accessed pages over the last 15 minutes, split into content pages
+ and everything else.</p>
+
+ <p><a class="btn" href="@routes.Application.top20()">Show Me &raquo;</a></p>
+ </div>
+
+ <div class="span-one-third">
+ <p>
+ <span class="label important">Important</span>
+ This dashboard works by reading server logs and is still in relative infancy.
+ Please be aware of its potential limitations:
+ </p>
+
+ <ul>
+ <li>Only traffic to www.guardian.co.uk is monitored.
+ (Specifically, traffic from guardiannews.com is <strong>not</strong> included.)</li>
+ <li>It samples 10% of site traffic. Experience suggests this gives a good overall picture, but could mislead.</li>
+
+ <li>Currently, bot traffic is not excluded. This <em>will</em> mislead. (We&rsquo;re working on this.)</li>
+
+ </ul>
+
+
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="span-one-third">
+ <h2>Overlay View</h2>
+
+ <p><span class="label notice">EXPERIMENTAL</span> Overlay overall hits per second when browsing the live
+ site. Be careful: it shows overall hits for the page the link points at, NOT how many people clicked the link.
+ Use SiteCatalyst's heat map for that!</p>
+
+ <p><a href="https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/">
+ You need to install the Greasemonkey add-on to Firefox first.</a>
+ It doesn't currently work in Chrome, sorry.</p>
+
+ <p><a class="btn" href='@routes.Assets.at("js/gm1.user.js")'>Download &raquo;</a></p>
+ </div>
+ </div>
+
+ <footer>
+ Brought to you by Graham Tackley and others in the Digital Development Team, totally inspired by ideas flowing from
+ Chris Moran and Mary Hamilton.
+ </footer>
+</div>
+
+</body>
+</html>
No changes.
View
@@ -0,0 +1,110 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Top 10</title>
+ <link href='http://fonts.googleapis.com/css?family=News+Cycle' rel='stylesheet' type='text/css'>
+ <link rel="stylesheet" href='@routes.Assets.at("stylesheets/bootstrap-1.3.0.min.css")'>
+ <link rel="stylesheet" href='@routes.Assets.at("stylesheets/stats.css")'>
+
+ <script src='@routes.Assets.at("js/jquery-1.6.4.min.js")' type="text/javascript"></script>
+
+ <style>
+ html, body {
+ background-color: #000;
+ /*color: #f0ffff;*/
+ font-family: 'News Cycle', sans-serif;
+ font-size: 24pt !important;
+ }
+
+ h1 {
+ color: #f0ffff;
+ }
+
+ .top-of-the-pops {
+ }
+
+ .top-of-the-pops a {
+ line-height: 140%;
+ font-size: 24pt;
+ text-decoration: none;
+ }
+
+ table {
+ background-color: #f8f8ff;
+ margin-top: 20px;
+ }
+
+ td {
+ font-size: 18pt !important;
+ }
+
+ .percent, .mover {
+ text-align: center;
+ vertical-align: middle;
+ }
+
+ img {
+ width: 30px;
+ height: 30px;
+ text-align: center;
+ }
+
+ .page-header {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ }
+
+
+ ol {
+ list-style-type: disc;
+ }
+ li {
+ font-size: 14pt;
+ float: left;
+ margin-left: 40px;
+ }
+
+ footer {
+ font-size: 14pt;
+ color: #BFBFBF;
+ }
+
+ footer a {
+ float: right;
+ }
+
+ </style>
+</head>
+<body>
+
+<div class="container-fluid lift:comet?type=TopTen">
+
+ <div class="page-header">
+ <h1>Top 10
+ <small>on www.guardian.co.uk in the last 15 minutes</small>
+ </h1>
+ </div>
+
+
+ <table class="top-of-the-pops">
+ <tr>
+ <td class="mover"><img src="up_arrow_icon.png" alt="Up"></td>
+ <td>
+ <a class="toplink" href="#">/world/middle-east-live/2011/oct/20/syria-libya-middle-east-unrest-live</a>
+ <ol>
+ <li>10% from twitter.com</li>
+ </ol>
+ </td>
+ <td class="percent percent-value">54%</td>
+ </tr>
+ </table>
+
+
+ <footer>
+ Data range: <span class="latest-data">(unknown)</span>
+
+ <a href="details">click for detailed breakdown</a>
+ </footer>
+</div>
+</body>
+</html>
File renamed without changes.
Oops, something went wrong.

0 comments on commit 6d43944

Please sign in to comment.