From 557332e37a7f615bafb767d8ba388c5a3a729944 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Tue, 10 Apr 2012 11:16:13 +0200 Subject: Lafargue: Add desktop notification feature for WebKit-based browsers. --- src/mulk/benki/book_marx.clj | 4 ++-- src/mulk/benki/lazychat.clj | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mulk/benki/book_marx.clj b/src/mulk/benki/book_marx.clj index 80fac1e..5c556c2 100644 --- a/src/mulk/benki/book_marx.clj +++ b/src/mulk/benki/book_marx.clj @@ -87,8 +87,8 @@ (let [marks (bookmarks-visible-by *user*)] (with-dbt (layout bookmarx-list-page "Book Marx" - [:div {:id "login-message" - :class "login-message"} + [:div {:id "notifications" + :class "notifications"} (login-message)] [:div ;;(.toString marks) diff --git a/src/mulk/benki/lazychat.clj b/src/mulk/benki/lazychat.clj index 6865d01..e2caaf8 100644 --- a/src/mulk/benki/lazychat.clj +++ b/src/mulk/benki/lazychat.clj @@ -20,7 +20,8 @@ hiccup.core [lamina.core :as lamina] [aleph.http :as ahttp] - [aleph.formats :as aformats]) + [aleph.formats :as aformats] + [clojure.data.json :as json]) (:import [org.apache.abdera Abdera])) @@ -120,12 +121,17 @@ [:div {:class "lafargue-message-body"} (sanitize-html (markdown->html (:content message)))]])) +(defn render-message-as-json [message] + (json/json-str (assoc message + :html (render-message message) + :date nil))) + (defpage "/lafargue" {} (with-dbt (layout lafargue-list-page "Lafargue Lazy Chat" - [:div {:id "login-message" - :class "login-message"} + [:div {:id "notifications" + :class "notifications"} (login-message)] [:div [:div {:id "lafargue-main-input-box" :class "lafargue-input-box"} @@ -185,7 +191,7 @@ (let [messages (filter* #(may-read? *user* %) lafargue-events)] (receive-all messages (fn [msg] - (async-push conn (render-message msg))))) + (async-push conn (render-message-as-json msg))))) (async-push conn {:status 426}))) (defpage [:any "/lafargue/post"] {content :content, visibility :visibility -- cgit v1.2.3