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