             [clj-time.local :as local])
   (:use [statuses.backend.persistence :only [db get-save-time]]
         [noir.core :only [defpage defpartial render]]
-        [noir.response :only [redirect set-headers content-type]]
+        [noir.response :only [redirect set-headers]]
         [noir.request :only [ring-request]]
         [hiccup.element]
         [hiccup.form]

  (str (:time item)))

(defn list-page [items next]
  (set-headers {"etag" (make-etag (first items))}
   (common/layout
     (list [:div (entry-form)]
           [:div [:ul.updates (map (fn [item] [:li.post (update item)]) items)]]

    [q lmt off next]))

(defpage "/statuses/authors/:author" {:keys [author] :as req}
  (let [[query limit offset next] (parse-args req)]
    (let [current-etag (make-etag (first (core/get-latest @db 1 offset author)))
          last-etag (get-in (ring-request) [:headers "if-none-match"])]
      (println "Current ETag:" current-etag "Last ETag: " last-etag)
      (if (not= current-etag last-etag)
        (list-page (core/get-latest @db limit offset author) next)
        (redirect (:uri (ring-request)) :not-modified)))))


(defpage "/statuses/search" {:as req}
