   public rough sad safe secret short shut simple slow small soft solid
   special strange thin white wrong")
 
-(defonce app-state (atom {:items ["foo"
-                                  "Basic English is an English-based controlled language created by linguist and philosopher Charles Kay Ogden as an international auxiliary language, and as an aid for teaching English as a second language. Basic English is, in essence, a simplified subset of regular English. It was presented in Ogden's book Basic English: A General Introduction with Rules and Grammar (1930).
-
-Ogden's Basic, and the concept of a simplified English, gained its greatest publicity just after the Allied victory in World War II as a means for world peace. Although Basic English was not built into a program, similar simplifications have been devised for various international uses. Ogden's associate I. A. Richards promoted its use in schools in China.[1] More recently, it has influenced the creation of Voice of America's Special English for news broadcasting, and Simplified English, another English-based controlled language designed to write technical manuals."
-                                  #_"Foobar [[foo|blitz]] lolophone hoptigoff."]}))
+;; TODO: Move this too.
+;; Old with link "Foobar [[foo|blitz]] lolophone hoptigoff."
+
+(defonce app-state (atom {:search "Foobar"
+                          :word-map {"Ogden" [0]}
+                          :visible [0]
+                          :items [[0 "Basic English is an English-based controlled language created by linguist and philosopher Charles Kay Ogden as an international auxiliary language, and as an aid for teaching English as a second language. Basic English is, in essence, a simplified subset of regular English. It was presented in Ogden's book Basic English: A General Introduction with Rules and Grammar (1930).
+
+Ogden's Basic, and the concept of a simplified English, gained its greatest publicity just after the Allied victory in World War II as a means for world peace. Although Basic English was not built into a program, similar simplifications have been devised for various international uses. Ogden's associate I. A. Richards promoted its use in schools in China. More recently, it has influenced the creation of Voice of America's Special English for news broadcasting, and Simplified English, another English-based controlled language designed to write technical manuals."]
+                                  [1 "Foo"]
+                                  [2 "Hello there"]]}))
+
+;; before items looked like this
+;; :items [{:id "foo" :text "bar"}] ;; dammit!
+
+(def id-atom (atom 0))
+(swap! id-atom inc) ;; first item
+(swap! id-atom inc) ;; second item
 
 (defn add-item [app owner]
-  (let [new-item (-> (om/get-node owner "new-item")
-                     .-value)]
+  (let [new-item-text (-> (om/get-node owner "new-item")
+                     .-value)
+        new-item {:id (swap! id-atom inc) :text new-item-text}]
     (when new-item
       (om/transact! app :items #(conj % new-item)))))
-
-(defn handle-change [e owner {:keys [text]}]
+;; Do this when adding
+;;(str (naive-key-extractor item) ", ")
+
+(defn search [app owner]
+  (let [search (-> (om/get-node owner "search")
+                   .-value)]
+    (when search
+      (om/transact! app :search (fn [] search)))))
+
+;; also filter views?
+
+;; TODO: when adding note, add/merge words-item to word-map
+
+(defn handle-item-change [e owner {:keys [text]}]
   (let [value (.. e -target -value)
         count (count value)]
     (om/set-state! owner :count count)

    (link (get-href x) (get-title x))
    (str " " x " ")))

(defn prepare-item [s] (vec (map str-or-link (split-words s))))

;; td-idf, 1-gram
;; now with basic-list! (or not, does that help here - more like remove those?)
;; and go to lower-case?
;; should also have id in it
#_(defn naive-key-extractor [str]
    (vec (map first
              (filter #(= (second %) 1)
                      (frequencies (split-words str))))))

(defn make-word-map [str id]
  (zipmap (map first

      (om/set-state! owner :text text)
      (om/set-state! owner :text value))))

;; This doesn't change the actual thing
(defn handle-search-change [e owner {:keys [text]}]
  (let [value (.. e -target -value)]
    (om/set-state! owner :text text)))

(def link-re #"\[\[([a-z]+)\|([a-z]+)\]\]")
(defn link [href str] (dom/a #js {:href href} str))
(defn link? [s] (if (re-find link-re s) true false))
