diff --git a/src/blarg/models/files.clj b/src/blarg/models/files.clj index a666626..3839f2d 100644 --- a/src/blarg/models/files.clj +++ b/src/blarg/models/files.clj @@ -1,5 +1,6 @@ (ns blarg.models.files - (:use [blarg.models.db]) + (:use [blarg.models.db] + [blarg.datetime]) (:require [com.ashafa.clutch :as couch] [clojure.java.io :as io])) @@ -17,9 +18,18 @@ attachment-info)))))) (defn list-files [path] - (->view-values - (couch/with-db files - (couch/get-view "files" "listPublishedByPath" {:key path})))) + (if-let [file-list (->view-values + (couch/with-db files + (couch/get-view "files" "listPublishedByPath" {:key path})))] + (map + (fn [f] + (let [attachment (second (first (:_attachments f)))] + {:id (:_id f) + :filename (:filename f) + :last_modified (parse-timestamp (:last_modified_at f)) + :content-type (:content_type attachment) + :size (:length attachment)})) + file-list))) (defn get-tree [] (->view-keys diff --git a/src/blarg/routes/files.clj b/src/blarg/routes/files.clj index 9af2d89..6101986 100644 --- a/src/blarg/routes/files.clj +++ b/src/blarg/routes/files.clj @@ -9,7 +9,10 @@ (defn list-files [path] (layout/render - "files/list.html" {:files (files/list-files path)})) + "files/list.html" {:html-title (->html-title [(str "Files in " path)]) + :path path + :files (files/list-files path) + :tree (files/get-tree)})) (defn get-file [path] (if-let [file (files/get-file path)] diff --git a/src/blarg/views/templates/base.html b/src/blarg/views/templates/base.html index 4f0183e..621cf18 100644 --- a/src/blarg/views/templates/base.html +++ b/src/blarg/views/templates/base.html @@ -42,6 +42,7 @@