-
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
Showing
4 changed files
with
145 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,38 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>LAMP++</title> | ||
<link href="style.css" type="text/css" rel="stylesheet" /> | ||
</head> | ||
<body> | ||
<center> | ||
<h1>LAMP<sup>++</sup> deployed by SlipStream</h1> | ||
<div class="instructions"> | ||
This test page allows you to issue read and write requests to the Apache/PHP layer | ||
which in turn gets persisted in the MongoDB layer. The read request retrieve routing | ||
information, such that you can check correct routing as elements of the LAMP stack | ||
are disabled and re-enabled. For this simply SSH into the corresponding machine and | ||
stop services. | ||
</div> | ||
</center> | ||
<div id="buttons"> | ||
<button id="read">Read</button> | ||
<button id="write">Write</button> | ||
</div> | ||
<div id="results"> | ||
<div id="db"></div> | ||
<ul id="writers"></ul> | ||
</div> | ||
<center> | ||
<img src="http://scienceblogs.com/gregladen/files/2013/02/Linux.jpg" /> | ||
<img src="http://www.syscrunch.com/blog/wp-content/uploads/2013/04/apache-server.jpg" /> | ||
<img src="http://upload.wikimedia.org/wikipedia/en/e/eb/MongoDB_Logo.png" /> | ||
<img src="http://brianlasher.com/wp-content/uploads/2011/09/2000px-php-logo-svg_.png" /> | ||
</center> | ||
<!-- <script src="http://code.jquery.com/jquery-1.11.1.js" type="text/javascript"></script> | ||
<script src="out/toto.js" type="text/javascript"></script> --> | ||
<script src="out/goog/base.js" type="text/javascript"></script> | ||
<script src="lamp.js" type="text/javascript"></script> | ||
<script type="text/javascript">goog.require("lamp.core");</script> | ||
</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,20 @@ | ||
(defproject lamp "0.1.0-SNAPSHOT" | ||
:description "FIXME: write this!" | ||
:url "http://example.com/FIXME" | ||
|
||
:dependencies [[org.clojure/clojure "1.5.1"] | ||
[org.clojure/clojurescript "0.0-2173"] | ||
[org.clojure/core.async "0.1.256.0-1bf8cf-alpha"]] | ||
|
||
:plugins [[lein-cljsbuild "1.0.2"]] | ||
|
||
:source-paths ["src"] | ||
|
||
:cljsbuild { | ||
:builds [{:id "lamp" | ||
:source-paths ["src"] | ||
:compiler { | ||
:output-to "lamp.js" | ||
:output-dir "out" | ||
:optimizations :none | ||
:source-map true}}]}) |
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,72 @@ | ||
(ns lamp.core | ||
(:require-macros [cljs.core.async.macros :refer [go]]) | ||
(:require [goog.dom :as dom] | ||
[goog.events :as events] | ||
[cljs.core.async :refer [<! put! chan]]) | ||
(:import [goog.net Jsonp] | ||
[goog Uri])) | ||
|
||
(def lb-url-read | ||
"http://154.48.152.227/mongoRead.php") | ||
|
||
(def lb-url-write | ||
"http://154.48.152.227/mongoWrite.php") | ||
|
||
(defn listen [el type] | ||
(let [out (chan)] | ||
(events/listen el type | ||
(fn [e] (put! out e))) | ||
out)) | ||
|
||
(defn error | ||
[] | ||
(.log js/console "oops")) | ||
|
||
(defn jsonp [uri] | ||
(let [out (chan) | ||
req (Jsonp. (Uri. uri))] | ||
(.send req nil (fn [res] (put! out (js->clj res)))) | ||
out)) | ||
|
||
(defn render-db | ||
[result] | ||
(let [db (result "db")] | ||
(set! | ||
(.-innerHTML | ||
(dom/getElement "db")) | ||
(str "Database instance: " db)))) | ||
|
||
(defn render-read | ||
[result] | ||
(let [writers (result "writers") | ||
sorted (sort writers) | ||
filtered (filter #(> (val %) 0) writers)] | ||
(render-db result) | ||
(set! | ||
(.-innerHTML | ||
(dom/getElement "writers")) | ||
(apply str | ||
(for [[k v] filtered] | ||
(str "<li>" k ": " v "</li>")))))) | ||
|
||
(defn render-write | ||
[result] | ||
(render-db result) | ||
(set! | ||
(.-innerHTML | ||
(dom/getElement "writers")) | ||
"")) | ||
|
||
(defn init [] | ||
(let [read (listen (dom/getElement "read") "click") | ||
write (listen (dom/getElement "write") "click")] | ||
(go (while true | ||
(<! read) | ||
(let [result (<! (jsonp lb-url-read))] | ||
(render-read result)))) | ||
(go (while true | ||
(<! write) | ||
(let [result (<! (jsonp lb-url-write))] | ||
(render-write result)))))) | ||
|
||
(init) |
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,15 @@ | ||
img { | ||
width: 200px; | ||
} | ||
|
||
.instructions { | ||
margin: 20px 200px; | ||
} | ||
|
||
#buttons, #results { | ||
margin: 20px 200px; | ||
} | ||
|
||
#results { | ||
height: 100px; | ||
} |