From 6689a5fce19f425aa6442463f3ba16a736fc10f7 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sat, 24 Apr 2010 08:59:28 -0600 Subject: [PATCH] some general cleanup --- propagator.org | 66 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/propagator.org b/propagator.org index dd9061e..2ffd07e 100644 --- a/propagator.org +++ b/propagator.org @@ -62,6 +62,7 @@ ** graphs of the propagator network draw a graph in a JFrame #+begin_src clojure + (in-ns 'propagator) (use 'vijual) (import '(javax.swing JFrame JPanel) '(java.awt Color Graphics) @@ -80,10 +81,7 @@ draw a graph in a JFrame (paint [g] (.drawImage g img offset offset nil))))] (doto frame (.add panel) .pack (.setSize (+ offset width) (+ offset height)).show))) -#+end_src -pull a graph from a the propagators saved in the =prop-graph= variable -#+begin_src clojure (defn graph-propagators [] (vec (set (apply concat @@ -93,6 +91,8 @@ pull a graph from a the propagators saved in the =prop-graph= variable (map #(vec (list % (name key))) (get hsh :in-cells)) (map #(vec (list (name key) %)) (get hsh :out-cells))))) (keys prop-graph)))))) + + (view (draw-directed-graph-image (graph-propagators))) #+end_src * usage @@ -134,6 +134,7 @@ at the end of the url, then there can be a couple of output cells which will render different views of the related data. #+begin_src clojure + (load-file "/home/eschulte/src/propagator/src/propagator.clj") (in-ns 'propagator) (use 'ring.adapter.jetty) (use 'clojure.contrib.seq-utils) @@ -143,38 +144,35 @@ which will render different views of the related data. (cell names '()) (cell input "") - ;; propagator -- adds value of input to names (propagator adder [input names] [names] - (when (> (count (seq input)) 0) (set (cons input names)))) - - ;; web wrapping - (let [out *out*] - (defn app [req] - (binding [*out* out] (println (:uri req))) - (or - ;; page to accept input - (when (= "/" (:uri req)) - {:status 200 - :headers {"Content-Type" "text/html"} - :body (apply str - "
" - "Word: " - "" - "
")}) - ;; dump value into "input" cell - (when (re-matches #"/add" (:uri req)) - (set-cell input (second (re-matches #".+=(.+)" (:query-string req)))) - {:status 303 :headers {"Location" "../list"}}) - ;; render the value of the "list" cell - (when-let [matched (re-matches #"/list" (:uri req))] - {:status 200 - :headers {"Content-Type" "text/html"} - :body (apply str (flatten (list "" - "

another word

")))})))) - - (run-jetty app {:port 3000}) + (when (> (count (seq input)) 0) (set (cons (str input " :1") names)))) + + (defn app [req] + (or + ;; page to accept input + (when (= "/" (:uri req)) + {:status 200 + :headers {"Content-Type" "text/html" + "Title" "3000"} + :body (apply str + "
" + "Word: " + "" + "
")}) + ;; dump value into "input" cell + (when (re-matches #"/add" (:uri req)) + (set-cell input (second (re-matches #".+=(.+)" (:query-string req)))) + {:status 303 :headers {"Location" "../list"}}) + ;; render the value of the "list" cell + (when-let [matched (re-matches #"/list" (:uri req))] + {:status 200 + :headers {"Content-Type" "text/html"} + :body (apply str (flatten (list "" + "

another word

")))}))) + + (run-jetty #'app {:port 3000}) #+end_src * notes -- 2.11.4.GIT