 (defroutes app-routes 
   (GET "/" {params :params} (index params))
   (POST "/" {params :params} (index params))
-  (GET "/backend" req (if-let [identity (friend/identity req)] (backend req) "Doh!"))
+  (GET "/backend" req (if-let [identity (friend/identity req)] (backend) "Doh!"))
   (POST "/process" {params :params} (process params))
   (GET "/login" [] (login-form))
   (GET "/logout" req (friend/logout* (resp/redirect (str (:context req) "/"))))


(defn- backend
  "interface to select which lang/country to store"
  [req]
  (h/html5
   [:head (h/include-css "/css/admin.css")]
   [:body

    (doseq [m (:monuments res)]
      (when (and (not (nil? (:lat m)))
                 (not (nil? (:lon m)))
                 (not (= "" (:name m)))
                 (not (= "" (:image m))))
        (let [reg (:registrant_url m)
              id (:id m)
              nam (cleanup-name (:name m))
              imc (:image m)
              img (codec/url-encode imc)
              lng (:lang m)
              emb (str "<img src=\"https://commons.wikimedia.org/w/index.php?title=Special%3AFilePath&file=" img "&width=250\" />")
              ilk (when (not (= imc "")) (str "<a href=\"http://commons.wikimedia.org/wiki/File:" img "\" target=\"_blank\">" emb "</a>"))
              art (:monument_article m)
              lnk "<a href=\"http://%s.wikipedia.org/wiki/%s\" target=\"_blank\">%s</a>"
              arl (format lnk lng (codec/url-encode art) art)
              src (format "Source: <a href=\"%s\" target=\"_blank\">%s</a>" reg id)
              all (str "<h3>" nam "</h3>"
                                      (when (not (= "" imc)) (str ilk "<br/>"))
                                      (when (not (= "" art)) (str arl "<br/>"))
                                      (when (not (= "" reg)) src))]
          (wcar* (car/hset rset (:id m) (list (list (:lat m) (:lon m)) all))))))
    (let [card (count (wcar* (car/hvals rset)))]
      (wcar* (car/hmset (str "s" rset)
                        "size" card
