From 83371f2fd3e885f808d79cabfd987434227818e6 Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Thu, 9 Sep 2010 20:48:58 -0400 Subject: Fixed dumpfm.dump.fm links in user logs --- src/site.clj | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/site.clj b/src/site.clj index 560565a..838923c 100644 --- a/src/site.clj +++ b/src/site.clj @@ -63,32 +63,24 @@ ;; Output -;; http://snippets.dzone.com/posts/show/6995 -(def url-regex #"(?i)^((http\:\/\/|https\:\/\/|ftp\:\/\/)|(www\.))+(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$") -(def pic-regex #"(?i)\.(jpg|jpeg|png|gif|bmp|svg)(\?|&|$)") - -(defn is-image? [word] - (and (re-find url-regex word) - (re-find pic-regex word))) - -(defn classify-msg [msg] - (let [words (.split msg " ") - imgs (map is-image? words)] - (cond (every? boolean imgs) :image - (some boolean imgs) :mixed - :else :text))) - (defn strip-empty-vals [m] (into {} (filter (fn [[k v]] (non-empty-string? v)) m))) (defn process-message-for-json [d] (assoc d :created_on (.getTime (d :created_on)))) +(defn message-room-link [m] + (if (= (:key m) "dumpfm") + "http://dump.fm/chat" + (format "http://%s.dump.fm" (:key m)))) + (defn process-message-for-output [d] (escape-html-deep (strip-empty-vals - (if (contains? d :created_on) - (assoc d :created_on (format-timestamp (d :created_on))) + (if (contains? d :created_on) + (assoc d + :created_on (format-timestamp (d :created_on)) + :roomlink (message-room-link d)) d)))) (defn new-messages [room ts] -- cgit v1.2.3-70-g09d2