From a70175759c5761f7aa4280280afa44fcb3f85c3b Mon Sep 17 00:00:00 2001 From: Scott Ostler Date: Mon, 23 Aug 2010 20:00:49 -0400 Subject: Use rooms/ subdirectory for templates; add per-room templates --- src/utils.clj | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/utils.clj') diff --git a/src/utils.clj b/src/utils.clj index 4a3343f..1dc4a2c 100755 --- a/src/utils.clj +++ b/src/utils.clj @@ -263,22 +263,26 @@ ;; Templates (def template-group (new StringTemplateGroup "dumpfm" "template")) -(.setRefreshInterval template-group 3) +(.setRefreshInterval template-group 10) + +(defn initialize-template [st session] + (if (session :nick) + (doto st + (.setAttribute "user_email" (session :email)) + (.setAttribute "user_nick" (session :nick)) + (.setAttribute "user_avatar" (if (non-empty-string? (session :avatar)) + (session :avatar) nil)) + (.setAttribute "isadmin" (session :is_admin)) + (.setAttribute "domain" config/*server-url*)) + (doto st + (.setAttribute "domain" config/*server-url*)))) (defn fetch-template [template session] (try (let [st (.getInstanceOf template-group template)] - (if (session :nick) - (doto st - (.setAttribute "user_email" (session :email)) - (.setAttribute "user_nick" (session :nick)) - (.setAttribute "user_avatar" (if (non-empty-string? (session :avatar)) - (session :avatar) nil)) - (.setAttribute "isadmin" (session :is_admin)) - (.setAttribute "domain" config/*server-url*)) - (doto st - (.setAttribute "domain" config/*server-url*)))) - (catch Exception e nil))) + (initialize-template st session)) + (catch Exception e + nil))) (defn fetch-template-fragment [template] (.getInstanceOf template-group template)) @@ -305,6 +309,6 @@ `(if (is-vip? ~'session) ~e (unknown-page))) (defmacro if-super-vip [e] - "Evaluates expr if user is vip otherwise returns 404. Can only be used + "Evaluates expr if user is super-vip otherwise returns 404. Can only be used where session is defined." `(if (is-super-vip? ~'session) ~e (unknown-page))) -- cgit v1.2.3-70-g09d2