Skip to content
Browse files

Merge pull request #95 from Fewbytes/issues/94

Fixed logger plugin to play nice with other plugins routes
  • Loading branch information...
2 parents d32c2ea + 79ce86b commit 74362904450675cf7d9edf6a873f01b00af166c3 @amalloy amalloy committed Nov 22, 2013
Showing with 9 additions and 12 deletions.
  1. +9 −12 src/lazybot/plugins/logger.clj
View
21 src/lazybot/plugins/logger.clj
@@ -4,7 +4,9 @@
[clj-time.format :only [unparse formatters]]
[clojure.java.io :only [file]]
[clojure.string :only [join]]
- [compojure.core :only [routes]]
+ [compojure.core :only [context]]
+ [compojure.route :only [not-found]]
+ [hiccup.util :only [url-encode]]
[hiccup.page :only [html5]])
(:require [compojure.core :refer [GET]]
[clj-http.util])
@@ -78,11 +80,6 @@
(map clj-http.util/url-encode parts)))]
[:a {:href uri} name]))
-(def error-404
- {:status 404
- :headers {}
- :body "These are not the logs you're looking for."})
-
(defn layout
"Takes a hiccup document, wraps it with the layout, and renders the resulting
HTML to a string. Passes through hashmaps directly."
@@ -137,23 +134,23 @@
(def pathreg #"[^\/]+")
(defplugin
- (:routes (routes
- (GET "/logger" req (index req))
- (GET ["/logger/:server" :server pathreg] [server]
+ (:routes (context "/logger" []
+ (GET "/" req (index req))
+ (GET ["/:server" :server pathreg] [server]
(layout server (server-index server)))
- (GET ["/logger/:server/:channel"
+ (GET ["/:server/:channel"
:server pathreg
:channel pathreg]
[server channel]
(layout (str server channel)
(channel-index server channel)))
- (GET ["/logger/:server/:channel/:file"
+ (GET ["/:server/:channel/:file"
:server pathreg
:channel pathreg
:file pathreg]
[server channel file]
(file-index server channel file))
- (constantly error-404)))
+ (not-found "These are not the logs you're looking for.")))
(:hook :on-message #'log-message)
(:hook
:on-send-message

0 comments on commit 7436290

Please sign in to comment.
Something went wrong with that request. Please try again.