summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-02-28 13:25:21 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-02-28 13:25:21 +0100
commit54ef041091b8b2518f73459762d229b63ce6113e (patch)
tree2152a7801da94def793710d4ba8f99d179d39c10
parent168dd2fa9a7a37c0e0dc299a15577c3ec7c0ba33 (diff)
Book Marx: Show the login status in the upper right-hand corner.
-rw-r--r--src/mulk/benki/book_marx.clj7
-rw-r--r--src/mulk/benki/util.clj6
-rw-r--r--src/mulk/benki/webutil.clj22
-rw-r--r--static/style/benki.css19
4 files changed, 51 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"]])))
diff --git a/static/style/benki.css b/static/style/benki.css
new file mode 100644
index 0000000..3904f47
--- /dev/null
+++ b/static/style/benki.css
@@ -0,0 +1,19 @@
+#login-message {
+ text-align: right;
+ position: absolute;
+ right: 0;
+ top: 0;
+ outline: solid 1px #000;
+ margin: 1em;
+ font-style: oblique;
+}
+
+.logged-in-as {
+ padding: 0.5em 1em 0.5em 1em;
+ background-color: green;
+}
+
+.not-logged-in {
+ padding: 0.5em 1em 0.5em 1em;
+ background-color: yellow;
+}