 (ns golden-kestrel.core
   (:require
+    [clojure.string :as string]
+    [clojure.set :as set]
     [om.core :as om :include-macros true]
     [om.dom :as dom :include-macros true]))
 

      (om/root
        app-state
        (fn [app owner]
          (run-altmetric-embeds)
          (om/component (embed app)))
        embed-element))))

(init)

    (om/update! data (fn [state]
                       (apply assoc state all-vals)))))

(defn attributes-for-embed
  [data]
  (into
    {}
    (remove
      (comp string/blank? second)
      {:className "altmetric-embed"
       :data-badge-popover (:popover data)
       :data-badge-details (:badge-details data)
       :data-badge-type (:badge-type data)
       :data-doi (:doi data)
       :data-hide-no-mentions (:hide-no-mentions data)})))

(defn pair-as-attribute
  [[k v]]
  (str (name k) "=\"" v "\""))

(defn attributes-for-pre
  [data]
  (->> (set/rename-keys (attributes-for-embed data)
                        {:className :class})
       (map pair-as-attribute)
       (string/join " ")))

(defn embed-code
  [data]
  (dom/pre #js {:className "prettyprint"}
           (str "<div " (attributes-for-pre data) "></div>")))

(defn embed
  [data]
  (dom/div (clj->js (attributes-for-embed data)) nil))

(defn embed-form
  [data owner]
  (let [change-data (partial update-app data)]
    (dom/form
      nil
