 (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))]

                    (compojure/GET "/:folder/:file" [folder file] (page [:a {:href (str "/get/" folder "/" file)}
                                                                         (-> file
                                                                             (URLDecoder/decode)
                                                                             (fix-file-name))]))))

(def handler (app))



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

(def facebook-sdk [[:div {:id "fb-root"}]
                   [:script "(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = \"//connect.facebook.net/fi_FI/sdk.js#xfbml=1&version=v2.3\";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));"]])

(def like-button [:div {:class "fb-like"
                        :data-href="https://developers.facebook.com/docs/plugins/"
                        :data-layout="standard"
                        :data-action="like"
                        :data-show-faces="true"
                        :data-share="true"}])

(def disqus "<div id=\"disqus_thread\"></div>
  <script type=\"text/javascript\">
  /* * * CONFIGURATION VARIABLES * * */
  var disqus_shortname = 'kuntotiedot';
  
  /* * * DON'T EDIT BELOW THIS LINE * * */
  (function() {
  var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
  dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
  </script>
<noscript>Please enable JavaScript to view the <a href=\"https://disqus.com/?ref_noscript\" rel=\"nofollow\">comments powered by Disqus.</a></noscript>")

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



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