 (deftemplate navbar "templates/tool.html"
   [owner {:keys [current-user search-text login-user-text search-placeholder login-fn]}]
   {#_[:#nav-input-field] #_(do-> (set-attr :placeholder search-placeholder)
-                             (content search-text)
-                             (listen :on-change #(handle-text-change % owner :search-text)))
+                                 (content search-text)
+                                 (listen :on-change #(handle-text-change % owner :search-text)))
    [:#nav-current-user] (do-> (content current-user)
                               (listen :on-change #(.log js/console (.. % -target -value))))
    [:#login-user-input] (do-> (set-attr :value login-user-text)

  {[:.topiq] (set-attr "id" (str "topiq-" (:id topiq)))
   [:.argument-counter] (content (-> (get-arguments (:id topiq) app) count))
   [:.argument-ref] (do->
                    (set-attr :href (str "#" (:id topiq)))
                    (listen :on-click #(om/set-state! owner :selected-topiq (:id topiq))))
   [:.topiq-text] (html-content
                   (let [text (replace-hashtags (:title topiq))]
                     (if (:detail-url topiq)
                       (clojure.string/replace
                        text
                        (re-pattern (:detail-url topiq))
                        (str "<a href='" (:detail-url topiq) "' target='_blank'> "(:detail-url topiq) " </a>"))
                       text)))
   [:.topiq-author] (content (:author topiq))
   [:.topiq-ts] (content (compute-time-diff (:ts topiq)))
   [:.topiq-vote-group] (substitute (topiq-vote-group (om/get-state owner :stage)

(ns topiq.view
  (:require [topiq.db :refer [get-topiq get-topiqs get-arguments vote-count
                                        add-topiq add-argument add-vote url-regexp]]
            [topiq.plugins :refer [render-content replace-hashtags]]
            [kioo.om :refer [html-content content after set-attr do-> substitute
                             listen prepend append html remove-class add-class]]
