Permalink
Browse files

Daten auf der Profilseite anzeigen und with-user wrapper hinzugefügt

  • Loading branch information...
1 parent 4945449 commit 71463677efc7e5cf7825c5ac915baa7db70958b4 @FossiFoo FossiFoo committed Aug 17, 2011
Showing with 16 additions and 3 deletions.
  1. +1 −1 src/clj_hh/core.clj
  2. +6 −2 src/clj_hh/handler/profile.clj
  3. +5 −0 src/clj_hh/session.clj
  4. +4 −0 src/templates/profile.html
View
@@ -12,7 +12,7 @@
(compojure/defroutes clj-hh-routes
(compojure/GET "/" _ index-handler/show-index)
- (compojure/GET "/profile" _ (session/only-logged-in profile-handler/show-profile))
+ (compojure/GET "/profile" _ (session/only-logged-in (session/with-user profile-handler/show-profile)))
(compojure/GET "/login" _ login-handler/handle-login)
(compojure/GET "/logout" _ login-handler/handle-logout)
(compojure/GET "/test/login" _ (session/only-logged-in
@@ -1,6 +1,10 @@
(ns clj-hh.handler.profile
(:require
- [net.cgrand.enlive-html :as html]))
+ [net.cgrand.enlive-html :as html]
+ [clj-hh.session :as session]))
(html/deftemplate show-profile "templates/profile.html"
- [request])
+ [request user]
+ [:span.name] (html/content (:name user))
+ [:span.email] (html/content (:email user)))
+
View
@@ -90,6 +90,11 @@
(apply f request params)
(response/redirect (url-utils/with-continue-url "/login" (:uri request))))))
+(defn with-user
+ [f & params]
+ (fn [request]
+ (apply f request (current-user request) params)))
+
(defn ^{:added 0.1
:doc "Wraps the application with a session stored in an encrypted cookie."}
wrap-session
@@ -11,6 +11,10 @@
<section id="header">
</section>
<h1>Profile</h1>
+
+ <div><span>Name: </span><span class="name"></span></div>
+ <div><span>Email: </span><span class="email"></span></div>
+
<script type="text/javascript">
livereload.run();
</script>

0 comments on commit 7146367

Please sign in to comment.