summaryrefslogtreecommitdiff
path: root/src/admin.clj
diff options
context:
space:
mode:
authorScott Ostler <scottbot9000@gmail.com>2010-07-10 01:34:12 -0400
committerScott Ostler <scottbot9000@gmail.com>2010-07-10 01:34:12 -0400
commit0c9cbc22f710237166445e8869545ad8152c7039 (patch)
tree085ca1b60cf68ebc2b9b17b6421736b5b8fef219 /src/admin.clj
parent1847fd22d50433184eaaeafce9e47874f7c8c36f (diff)
added report viewer
Diffstat (limited to 'src/admin.clj')
-rw-r--r--src/admin.clj25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/admin.clj b/src/admin.clj
index 4e90bad..7c7721e 100644
--- a/src/admin.clj
+++ b/src/admin.clj
@@ -217,3 +217,28 @@ AND cancelled = false
(format-unknown-action action))]
[(flash-assoc :msg msg)
(redirect-to "/debug")])))
+
+(def report-dir "/var/reports")
+
+(defn get-reports []
+ (reverse
+ (sort
+ (for [f (.listFiles (new File report-dir))]
+ (.replaceAll (.getName f) ".html" "")))))
+
+(defn list-reports-dir [session]
+ (if-super-vip
+ (let [reports (get-reports)]
+ (html
+ [:html
+ [:head [:title "dump.fm reports"]]
+ [:body
+ [:ul
+ (for [r reports]
+ [:li [:a {:href (str "/reports/" r)} r]])]]]))))
+
+(defn show-report [session f]
+ (if-super-vip
+ (if (contains? (set (get-reports)) f)
+ (serve-file report-dir (str f ".html"))
+ "ERROR")))