Skip to content

Commit

Permalink
generating the books.
Browse files Browse the repository at this point in the history
  • Loading branch information
JackDanger committed Sep 22, 2012
1 parent 34e6e52 commit 22cd667
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
8 changes: 4 additions & 4 deletions clojure/src/feminizer/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@
(testing "forget"
(learn "lady" "gentleman")
(learn "gentleman" "lady")
(is (= "this lady is crazy for that gentleman"
(feminize "this gentleman is crazy for that lady")))
(is (= "this lady and that lady are crazy for that gentleman"
(feminize "this gentleman and that gentleman are crazy for that lady")))
(forget "lady")
(forget "gentleman")
(is (= "this lady is crazy for that gentleman"
(feminize "this lady is crazy for that gentleman"))))
(is (= "this lady and that lady are crazy for that gentleman"
(feminize "this lady and that lady are crazy for that gentleman"))))
(testing "whitespace"
(is (= " 3 spaces preceed and two newlines follow\n\n"
(feminize " 3 spaces preceed and two newlines follow\n\n")))))
Expand Down
4 changes: 0 additions & 4 deletions clojure/src/silentvoicesbible/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@
(:use silentvoicesbible.books))

(defn- -gets [prompt]
(println "in -gets")
(println prompt)
(let [reader (java.io.BufferedReader. (java.io.InputStreamReader. (System/in)))]
(println "in let")
(loop [_ nil]
(print ".")
(if (.ready reader)
(.readLine reader)
(recur (Thread/sleep 10))))))

(defn- browse []
(println "in browse")
(-gets "click any key to start reading the Silent Voices Tanakh")
(doseq [verse (:verses (first tanakh))]
(print (-gets "") (.text verse))))
Expand Down
29 changes: 21 additions & 8 deletions clojure/src/silentvoicesbible/html.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,34 @@
(:use silentvoicesbible.books))

(def output-directory "_site")

(defn- filename [book]
(str output-directory "/"
(clojure.string/replace (:name book) #"[^\d\w-_]" "-")
".html"))
(clojure.string/replace (.toLowerCase (:name book))
#"[^\d\w-_]"
"-"))
(defn- path [book]
(str output-directory "/" (filename book) ".html"))

(defn- write [book lines]
(with-open [writer (clojure.java.io/writer (filename book))]
(defn- write-to [path lines]
(.mkdir (java.io.File. output-directory))
(with-open [writer (clojure.java.io/writer path)]
(doseq [line lines] (.write writer line))))

(defn- home [])
(defn- index []
(write-to
(str output-directory "/index.html")
(concat ["<h1>Silent Voices Tanakh</h1>"]
["<ul>"]
(map #(str "<li><a href=" (filename %1) ".html>"
(:name %1)
"</a></li>")
tanakh)
["<ul>"])))

(defn- book-html [book]
(concat ["<h2>" (:name book) "</h1>"]
(map #(str (.html %) " ") (.verses book))))

(defn generate [args]
(home)
(doseq [b tanakh] (write b (book-html b))))
(index)
(doseq [b tanakh] (write-to (path b) (book-html b))))

0 comments on commit 22cd667

Please sign in to comment.