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 be9928e
Showing
6 changed files
with
118 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,7 @@ | ||
pom.xml | ||
*jar | ||
/lib/ | ||
/classes/ | ||
.lein-deps-sum | ||
.cake | ||
target |
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,19 @@ | ||
# clojure-demo | ||
|
||
A website written in noir. | ||
|
||
## Usage | ||
|
||
If you use cake, substitute 'lein' with 'cake' below. Everything should work fine. | ||
|
||
```bash | ||
lein deps | ||
lein run | ||
``` | ||
|
||
## License | ||
|
||
Copyright (C) 2011 FIXME | ||
|
||
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,8 @@ | ||
(defproject clojure-demo "0.1.0-SNAPSHOT" | ||
:description "FIXME: write this!" | ||
:dependencies [[org.clojure/clojure "1.4.0"] | ||
[noir "1.3.0-beta3"] | ||
[claude "0.2.0-snapshot"]] | ||
:profiles {:dev {:resource-paths ["test/resources"]}} | ||
:main clojure-demo.server | ||
:plugins [[lein-swank "1.4.4"]]) |
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,11 @@ | ||
(ns clojure-demo.server | ||
(:require [noir.server :as server])) | ||
|
||
(server/load-views-ns 'clojure-demo.views) | ||
|
||
(defn -main [& m] | ||
(let [mode (keyword (or (first m) :dev)) | ||
port (Integer. (get (System/getenv) "PORT" "8080"))] | ||
(server/start port {:mode mode | ||
:ns 'clojure-demo}))) | ||
|
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,12 @@ | ||
(ns clojure-demo.views.common | ||
(:use [noir.core :only [defpartial]] | ||
[hiccup.page :only [include-css html5]])) | ||
|
||
(defpartial layout [& content] | ||
(html5 | ||
[:head | ||
[:title "clojure-demo"] | ||
(include-css "/css/reset.css" "/css/bootstrap.css")] | ||
[:body | ||
[:div#wrapper | ||
content]])) |
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,61 @@ | ||
(ns clojure-demo.views.services | ||
(:require [clojure-demo.views.common :as common] | ||
[noir.content.getting-started] | ||
[claude mongodb rabbitmq postgresql redis blob mysql]) | ||
(:use [noir.core :only [defpage defpartial]] | ||
claude.core)) | ||
|
||
(defn mock-vcap-env [] | ||
(constantly (slurp (clojure.java.io/resource "json/1.json")))) | ||
|
||
(defn get-service-prop [service prop] | ||
((ns-resolve service (symbol prop)))) | ||
|
||
(defpartial service-prop [prop value] | ||
[:dt prop] | ||
[:dd value]) | ||
|
||
(defpartial service-info [service props] | ||
[:div | ||
[:h3 (str "Service: " service)] | ||
[:dl (for [p props] | ||
(service-prop p (get-service-prop service p)))]]) | ||
|
||
(defpartial mongodb-info [] | ||
(service-info 'claude.mongodb | ||
["host" "port" "username" "password" | ||
"name" "db" "hostname" "url"])) | ||
|
||
(defpartial blob-info [] | ||
(service-info 'claude.blob | ||
["hostname" "host" "port" "username" "password" "name"])) | ||
|
||
(defpartial mysql-info [] | ||
(service-info 'claude.mysql | ||
["name" "hostname" "host" "port" "user" | ||
"username" "password" "db" "url"])) | ||
|
||
(defpartial rabbitmq-info [] | ||
(service-info 'claude.rabbitmq | ||
["name" "hostname" "host" "port" "vhost" | ||
"username" "user" "password" "pass" "url"])) | ||
|
||
(defpartial redis-info [] | ||
(service-info 'claude.redis | ||
["hostname" "host" "port" "password" "name"])) | ||
|
||
(defpartial postgresql-info [] | ||
(service-info 'claude.postgresql | ||
["name" "host" "hostname" "port" "user" | ||
"username" "password"])) | ||
|
||
(defpage "/services" [] | ||
(with-redefs [get-vcap-env (mock-vcap-env)] | ||
(common/layout [:div | ||
(mongodb-info) | ||
(rabbitmq-info) | ||
(mysql-info) | ||
(postgresql-info) | ||
(redis-info) | ||
(blob-info) | ||
]))) |