      :else (when (= (. status-el textContent) slug-not-unique-err)
              (ui/remove-error status-el slug-el slug-label-el)))))
 
-(def *feed* (atom {:default-slug-format "/{feed-name}/{document-title}"}))
-
-(defn fetch-feed-details! [e]
-  (let [xhr (.target e)
-        status (. xhr (getStatus))]
-    (when (= status 200)
-      (let [json (js->clj (. xhr (getResponseJson)))]
-        (swap! *feed* assoc :name ("name" json)
-                            :default-slug-format ("default-slug-format" json))))))
-
 (defn create-document-title-token [title]
   (string/join "-" (filter #(not (string/blank? %)) (.split title #"[^a-zA-Z0-9]"))))
 
-(defn create-slug [title]
+(defn create-slug [feed title]
   (let [today (util/date-now)]
-    (loop [slug (:default-slug-format @*feed*)
+    (loop [slug (:default-slug-format feed)
            substitutions [["{document-title}" (create-document-title-token title)]
-                          ["{feed-name}" (:name @*feed*)]
+                          ["{feed-name}" (:name feed)]
                           ["{year}" (:year today)]
                           ["{month}" (:month today)]
                           ["{day}" (:day today)]

        (ui/remove-error (dom/getElement "status-message")
                           slug-el
                           (dom/getElement "slug-label"))
        (sync-slug-with-title)))))

(defn validate-slug []
  (if (.checked (dom/getElement "custom-slug"))

               (rest substitutions))
        slug))))

(defn sync-slug-with-title [feed]
  (when-not (.checked (dom/getElement "custom-slug"))
    (let [title (.value (dom/getElement "title"))
          slug-el (dom/getElement "slug")]
      (ui/set-form-value slug-el (create-slug feed title))
      (document/get-doc (.value slug-el) handle-duplicate-slug-callback))))

(defn toggle-custom-slug [feed]
  (let [slug-el (dom/getElement "slug")]
    (if (.checked (dom/getElement "custom-slug"))
      (ui/enable-element slug-el)
