diff options
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))) |
