Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2206f44152
Fetching contributors…

Cannot retrieve contributors at this time

file 41 lines (34 sloc) 1.334 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
(ns seajure.web
  (:use [net.cgrand.enlive-html :only [deftemplate content set-attr do->
                                       clone-for]]
        [clojure.java.io :only [copy file]]))

(def assets ["style.css" "logo.png"])

(defn get-resource-stream [path]
  (.getResourceAsStream (clojure.lang.RT/baseLoader) path))

(defn read-resource [path]
  (-> (get-resource-stream path)
      (java.io.InputStreamReader.)
      (java.io.PushbackReader.)
      (read)))

(defn member-links [members]
  (clone-for [{:keys [name url projects]} members]
    [:a] (do-> (content name)
               (set-attr :href url))))

(defn project-links [projects]
  (clone-for [[anchor {:keys [name url description]}] projects]
    [:dt :a] (do-> (content name)
               (set-attr :name anchor)
               (set-attr :href url))
    [:dd] (content description)))

(deftemplate index "index.html" [members projects]
  [:ul.members :li] (member-links members)
  [:dl.projects] (project-links projects))

(defn -main
  ([out]
     (.mkdirs (file out))
     (let [members (read-resource "members.clj")
           projects (read-resource "projects.clj")
           lines (index members projects)]
       (doseq [f assets] (copy (get-resource-stream f) (file out f)))
       (spit (file out "index.html") (apply str lines))))
  ([] (-main "public")))
Something went wrong with that request. Please try again.