diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-02-28 13:25:21 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2012-02-28 13:25:21 +0100 |
commit | 54ef041091b8b2518f73459762d229b63ce6113e (patch) | |
tree | 2152a7801da94def793710d4ba8f99d179d39c10 /src | |
parent | 168dd2fa9a7a37c0e0dc299a15577c3ec7c0ba33 (diff) |
Book Marx: Show the login status in the upper right-hand corner.
Diffstat (limited to 'src')
-rw-r--r-- | src/mulk/benki/book_marx.clj | 7 | ||||
-rw-r--r-- | src/mulk/benki/util.clj | 6 | ||||
-rw-r--r-- | src/mulk/benki/webutil.clj | 22 |
3 files changed, 32 insertions, 3 deletions
diff --git a/src/mulk/benki/book_marx.clj b/src/mulk/benki/book_marx.clj index 0f6553b..873bef4 100644 --- a/src/mulk/benki/book_marx.clj +++ b/src/mulk/benki/book_marx.clj @@ -7,7 +7,7 @@ [hiccup.core :only [escape-html]] [ring.util.codec :only [url-encode]] noir.core - [mulk.benki util db auth config]) + [mulk.benki util db auth config webutil]) (:require [clojure.algo.monads :as m] [clojure.java.jdbc :as sql] [clojure.string :as string] @@ -79,7 +79,10 @@ marks (bookmarks-visible-by user)] (with-dbt (layout bookmarx-list-page "Book Marx" - [:p + [:div {:id "login-message" + :class "login-message"} + (login-message)] + [:div ;;(.toString marks) [:ul {:class "bookmarx-list"} (for [mark @marks] diff --git a/src/mulk/benki/util.clj b/src/mulk/benki/util.clj index 0d5136b..941dc91 100644 --- a/src/mulk/benki/util.clj +++ b/src/mulk/benki/util.clj @@ -5,7 +5,8 @@ noir.core) (:require [noir.session :as session] [noir.request :as request] - [noir.response :as response]) + [noir.response :as response] + [clojure.java.jdbc :as sql]) (:import [java.text DateFormat])) @@ -31,6 +32,9 @@ ;; jQuery [:script {:type "text/javascript" :src (resolve-uri "/3rdparty/jquery/jquery-1.7.min.js")}] + [:link {:type "text/css" + :rel "stylesheet" + :href (resolve-uri "/style/benki.css")}] (:head kind)] [:body [:h1 title] content diff --git a/src/mulk/benki/webutil.clj b/src/mulk/benki/webutil.clj new file mode 100644 index 0000000..37b93a3 --- /dev/null +++ b/src/mulk/benki/webutil.clj @@ -0,0 +1,22 @@ +(ns mulk.benki.webutil + (:refer-clojure) + (:use [hiccup core page-helpers] + [clojure.core.match :only [match]] + noir.core + [mulk.benki db util]) + (:require [noir.session :as session] + [noir.request :as request] + [noir.response :as response] + [clojure.java.jdbc :as sql]) + (:import [java.text DateFormat])) + + +(defpartial login-message [] + (let [user-id (session/get :user) + user (and user-id + (with-dbt (sql/with-query-results results + ["SELECT * FROM users WHERE id = ?" user-id] + (first results))))] + (if user-id + [:div {:class "logged-in-as"} (:first_name user) " " (:last_name user)] + [:div {:class "not-logged-in"} [:a {:href (link :login)} "Log in"]]))) |