@@ 3,10 3,26 @@
[ajax.core :refer [GET POST]]
[oz.core :as oz]))
+;; -------------------------
+;; State and State updates
+
(defonce path (r/atom []))
+(defn response-handler [response] ;; this functionality will be implemented to backend
+ (map-indexed (fn [i v] {:id (inc i)
+ :value (clojure.string/replace v "_" " ")
+ :parent (if (= i 0) nil i)})
+ response))
+
+(defn get-query! [query]
+ (GET "http://localhost:4242/wikisophy"
+ {:content-type :json
+ :api (js/XMLHttpRequest.)
+ :url-params {:query query}
+ :handler #(reset! path (response-handler %))}))
+
;; -------------------------
-;; Views
+;; Components
(defn navbar []
[:nav
@@ 24,19 40,6 @@
[:h3 "Do all paths lead to "
[:a {:href "https://wikipedia.org/wiki/Philosophy"} "Philosophy"] "?"]])
-(defn response-handler [response] ;; this functionality will be implemented to backend
- (map-indexed (fn [i v] {:id (inc i)
- :value (clojure.string/replace v "_" " ")
- :parent (if (= i 0) nil i)})
- response))
-
-(defn get-query! [query]
- (GET "http://localhost:4242/wikisophy"
- {:content-type :json
- :api (js/XMLHttpRequest.)
- :url-params {:query query}
- :handler #(reset! path (response-handler %))}))
-
(defn input []
(let [query (r/atom "")]
(fn []
@@ 126,6 129,9 @@
[:div
[oz/vega (path-tree @path)]])))
+;; -------------------------
+;; Pages
+
(defn front-page []
[:body [navbar]
[header]