Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit

  • Loading branch information...
commit be9928e179c66bfa01218dcca651ebbabc1749be 0 parents
@videlalvaro authored
7 .gitignore
@@ -0,0 +1,7 @@
+pom.xml
+*jar
+/lib/
+/classes/
+.lein-deps-sum
+.cake
+target
19 README.md
@@ -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.
+
8 project.clj
@@ -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"]])
11 src/clojure_demo/server.clj
@@ -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})))
+
12 src/clojure_demo/views/common.clj
@@ -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]]))
61 src/clojure_demo/views/services.clj
@@ -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)
+ ])))
Please sign in to comment.
Something went wrong with that request. Please try again.