This repository has been archived by the owner on Mar 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 833712d
Showing
8 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pom.xml | ||
*jar | ||
/lib/ | ||
/classes/ | ||
.lein-deps-sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: lein run -m nos-tour-comments.core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# nos-tour-comments | ||
|
||
Small ring app to allow following NOS tour comments on my mobile. | ||
|
||
## Usage | ||
|
||
lein run -m nos-tour-comments.core | ||
|
||
## License | ||
|
||
Copyright (C) 2011 Remco van 't Veer | ||
|
||
Distributed under the Eclipse Public License, the same as Clojure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(defproject nos-tour-comments "1.0.0-SNAPSHOT" | ||
:description "Simple NOS Tour de France comments only site." | ||
:dependencies [[org.clojure/clojure "1.2.1"] | ||
[hiccup "0.3.6"] | ||
[ring/ring-core "0.3.10"] | ||
[ring/ring-jetty-adapter "0.3.10"]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ul, li { list-style: none; padding: 0; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="nl-nl"> | ||
<head> | ||
<title>NOS Tour Commentaar</title> | ||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport"> | ||
<link type="text/css" rel="stylesheet" media="screen" href="app.css"> | ||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | ||
<script src="app.js"></script> | ||
</head> | ||
<body> | ||
<h1>NOS Tour Commentaar</h1> | ||
<h2 id="date">Even geduld A.U.B.</h2> | ||
<ul id="comments"> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var updater = function() { | ||
$.getJSON("/feed?" + Math.floor(Math.random()*999999999), | ||
function(data) { | ||
setTimeout(updater, 5000) | ||
|
||
$("#date").html(data.report[0].published_at.substr(0, 11)) | ||
var html = '' | ||
$.each(data.report, function() { | ||
html += '<li><strong>' + this.published_at.substr(11,5) + ' ' + this.title + '</strong><p>' + this.comment + '</p></li>' | ||
}) | ||
$("#comments").html(html) | ||
}) | ||
} | ||
updater() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(ns nos-tour-comments.core | ||
(:use hiccup.core | ||
ring.middleware.file | ||
ring.middleware.file-info | ||
ring.adapter.jetty)) | ||
|
||
(def *url* "http://nos.nl/data/livestream/report/comments_0.js") | ||
(def *interval* 5000) | ||
(defn fetch [] (try (slurp *url*) (catch Exception _))) | ||
(def data (agent (fetch))) | ||
(defn updater [_] | ||
(Thread/sleep *interval*) | ||
(send-off data updater) | ||
(fetch)) | ||
(send-off data updater) | ||
|
||
(defn handler [req] | ||
(case (:uri req) | ||
"/feed" {:status 200 | ||
:headers {"Content-Type" "application/javascript"} | ||
:body @data} | ||
"/" {:status 301 | ||
:headers {"Location" "/app.html"}} | ||
nil)) | ||
|
||
(def app (-> handler (wrap-file "public") (wrap-file-info))) | ||
|
||
(defn -main [] | ||
(let [port (Integer/parseInt (get (System/getenv) "PORT" "8080"))] | ||
(run-jetty #'app {:port port}))) |