2 (load-file "/home/eschulte/src/propagator/src/propagator.clj")
4 (use 'ring.adapter.jetty)
5 (use 'clojure.contrib.seq-utils)
6 (import 'java.util.Date 'java.text.SimpleDateFormat)
12 (propagator adder [input names] [names]
13 (when (> (count (seq input)) 0)
14 (set (cons (str input " :1") names))))
18 ;; page to accept input
19 (when (= "/" (:uri req))
21 :headers {"Content-Type" "text/html"
24 "<form name=\"\" action=\"add\" method=\"get\">"
25 "Word: <input type=\"type\" name=\"word\" />"
26 "<input type=\"submit\" value=\"Submit\" />"
28 ;; dump value into "input" cell
29 (when (re-matches #"/add" (:uri req))
30 (set-cell input (second (re-matches #".+=(.+)" (:query-string req))))
31 {:status 303 :headers {"Location" "../list"}})
32 ;; render the value of the "list" cell
33 (when-let [matched (re-matches #"/list" (:uri req))]
35 :headers {"Content-Type" "text/html"}
36 :body (apply str (flatten (list "<ul>"
37 (map #(str "<li>"%"</li>") @names)
39 "<p><a href=\"/\">another word</a></p>")))})))
41 (run-jetty #'app {:port 3000})