 (defn file-name [file]
   (-> (.getName file)
       (fix-file-name)))
+
+(defn date-to-map [date]
+  (let [calendar (Calendar/getInstance)]
+    (.setTime calendar date)
+    {:year (.get calendar Calendar/YEAR)
+     :month (+ 1 (.get calendar Calendar/MONTH))
+     :day (.get calendar Calendar/DAY_OF_MONTH)
+     :hour (.get calendar Calendar/HOUR_OF_DAY)
+     :minute (.get calendar Calendar/MINUTE)
+     :second (.get calendar Calendar/SECOND)}))
+
+(defn date-string [{:keys [year month day]}]
+  (str day "." month "." year))
+
+
+
+(defn last-modified-date [file]
+  (date-to-map (Date. (.lastModified file))))
 
 (defn app []
   (compojure/routes (compojure/GET "/" [] (page [:ul (for [file (.listFiles (File. directory))]


(def directory "/Users/jukka/Downloads/kuntotiedot/68356_kiinteistojen_kuntotiedot_Vaahterakuja-Vaskivuori")

(defn page [& content]
  (hiccup/html [:html
                [:head
                 [:title "Kuntotiedot"]]
                [:body content]]))

(defn fix-file-name [file-name]
  (-> file-name

                    (compojure/GET "/:folder/:file" [folder file] (page [:a {:href (str "/get/" folder "/" file)}
                                                                         (-> file
                                                                             (URLDecoder/decode)
                                                                             (fix-file-name))
                                                                         " "
                                                                         (-> (str directory "/" (URLDecoder/decode folder) "/" (URLDecoder/decode file))
                                                                             (File.)
                                                                             (last-modified-date)
                                                                             (date-string))]
                                                                        like-button
                                                                        disqus))))

(def handler (app))

