59dfc7067b772655e2c2aebe4a96b694ef1cd4da — bendersteed 3 years ago 4423776
Add: skeleton of basic functionality
1 files changed, 39 insertions(+), 8 deletions(-)

M src/wikisophy/core.cljs
M src/wikisophy/core.cljs => src/wikisophy/core.cljs +39 -8
@@ 1,21 1,52 @@
(ns wikisophy.core
      [reagent.core :as r]))
    (:require [reagent.core :as r]
              [ajax.core :refer [GET POST]]))

(def path (r/atom []))

;; -------------------------
;; Views

(defn home-page []
  [:div [:h2 "Welcome to Reagent"]
   [:p "This was so fucking shitty, for real I hate this stuff."]
   [:p "Testing if figwheel still works..."]
   [:p "It does actually! Nice. Let's get to work then!"]])
(defn header []
   [:h1 "WIKISOPHY"] 
   [:h2 "Do all paths lead to "
    [:a {:href "https://wikipedia.org/wiki/Philosophy"} "Philosophy"] "?"]])

(defn get-query! [query]
  (GET "http://localhost:4242/wikisophy"
       {:content-type :json
        :api (js/XMLHttpRequest.)
        :url-params {:query query}
        :handler #(reset! path %)}))

(defn input []
  (let [query (r/atom "Search wikipedia..")]
    (fn []
       [:p "The value is: " @query]
       [:input {:type "text"
                :value @query
                :on-change #(reset! query (-> % .-target .-value))}]
       [:input {:type "submit"
                :on-click #(get-query! @query)}]])))

(defn graph []
   [:ol (for [node @path]
          ^{:key node} [:li node])]])

(defn front-page []
  [:body [header]

;; -------------------------
;; Initialize app

(defn mount-root []
  (r/render [home-page] (.getElementById js/document "app")))
  (r/render [front-page] (.getElementById js/document "app")))

(defn init! []