diff options
| author | Scott Ostler <scottbot9000@gmail.com> | 2010-09-09 20:48:58 -0400 |
|---|---|---|
| committer | Scott Ostler <scottbot9000@gmail.com> | 2010-09-09 20:48:58 -0400 |
| commit | 83371f2fd3e885f808d79cabfd987434227818e6 (patch) | |
| tree | 671e6d4dc1d8d2cd703cffdbfe599dd1a74c5149 /src/site.clj | |
| parent | e5a9cd50f96c8a96d180280aa1ab32e028cc2538 (diff) | |
Fixed dumpfm.dump.fm links in user logs
Diffstat (limited to 'src/site.clj')
| -rw-r--r-- | src/site.clj | 26 |
1 files changed, 9 insertions, 17 deletions
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]
|
