diff options
| author | Scott Ostler <scottbot9000@gmail.com> | 2010-08-23 20:00:49 -0400 |
|---|---|---|
| committer | Scott Ostler <scottbot9000@gmail.com> | 2010-08-23 20:00:49 -0400 |
| commit | a70175759c5761f7aa4280280afa44fcb3f85c3b (patch) | |
| tree | b0902ed6de678cae1a0e64517d8066da64a953f5 /src/utils.clj | |
| parent | 178bce3e5937d1a4fe17e4bf57e2737aaa483668 (diff) | |
Use rooms/ subdirectory for templates; add per-room templates
Diffstat (limited to 'src/utils.clj')
| -rwxr-xr-x | src/utils.clj | 30 |
1 files changed, 17 insertions, 13 deletions
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))) |
