1. Steve Losh
  2. newseasons

Commits

Steve Losh  committed e3e497e

Styling and sorting.

  • Participants
  • Parent commits fb4c1da
  • Branches default

Comments (0)

Files changed (5)

File resources/public/css/style.less

View file
 }
 li.show {
     margin-top: 12px;
+    margin-bottom: 20px;
 
     img {
         float: left;
         width: 100px;
         height: 100px;
     }
+    .latest {
+        margin-top: -6px;
+        margin-bottom: 0px;
+        line-height: 1.25;
+    }
 }
+
+// Pages
+.user {
+    li.show {
+        img {
+            width: 60px;
+            height: 60px;
+        }
+        form {
+            margin-top: 17px;
+            margin-bottom: 0;
+            float: right;
+        }
+    }
+}

File src/newseasons/models/users.clj

View file
 (ns newseasons.models.users
   (:use newseasons.models.keys)
+  (:use newseasons.utils)
   (:use [newseasons.models.shows :only (show-get)])
   (:require [noir.util.crypt :as crypt])
   (:use [aleph.redis :only (redis-client)]))
   (let [user (apply hash-map @(r [:hgetall (key-user email)]))]
     (when (not (empty? user))
       (merge {:email (user "email") :pass (user "pass")}
-             {:shows (map show-get @(r [:smembers (key-user-shows email)]))}))))
+             {:shows (sort-maps-by (map show-get
+                                        @(r [:smembers (key-user-shows email)]))
+                                   :title)}))))
 
 (defn user-set-email! [email new-email]
   @(r [:hset (key-user email) "email" new-email]))

File src/newseasons/templates/main.clj

View file
 
 
 ; Layout ----------------------------------------------------------------------
-(defpartial base [& content]
+(defpartial base [body-class & content]
             (html5
               [:head
                (map include-css ["/css/base.css"
                (include-less "/css/style.less")
                (include-js "/js/less.js")
                [:title "New Seasons"]]
-              [:body
+              [:body {:class body-class}
                [:div.container.clearfix
                 [:header.sixteen.columns [:h1 (link-to "/" "New Seasons")]]
                 (when-let [message (sess/flash-get)]
                   (link-to "http://webnoir.org/" "Noir")
                   "."]]]]))
 
-(defpartial inner [title & content]
-            (base
+(defpartial inner [title body-class & content]
+            (base body-class
               [:h2.sixteen.columns.page-title
                [:div.profile
                 (form-to [:post "/logout"]
 
 ; Pages -----------------------------------------------------------------------
 (defpartial home []
-            (base
+            (base "home"
               [:div.six.columns
                [:form {:action "" :method "POST"}
                 (field text-field "email" "Email Address")
 
 (defpartial user-show [show]
             [:li.show.group
+             (form-to [:post "/rem"]
+                      [:input {:type "hidden" :name "artist-id" :value (show :id)}]
+                      (submit-button "Remove"))
              [:img {:src (show :image)}]
              [:h3 (link-to (show :url) (show :title))]
-             [:p.latest "Latest season: " (show :latest)]
-             (form-to [:post "/rem"]
-                      [:input {:type "hidden" :name "artist-id" :value (show :id)}]
-                      (submit-button "Remove"))])
+             [:p.latest "Latest: " (show :latest)]])
 
 (defpartial user [user]
-            (inner (str "Hello, " (:email user))
-                   [:div.eight.columns
+            (inner (str "Hello, " (:email user)) "user"
+                   [:div.seven.columns
                     [:form {:action "/search"}
                      (field text-field
                             "query"
                             "Which show do you want to keep track of?")
                      (submit-button "Search")]]
-                   [:div.eight.columns
+                   [:div.nine.columns
                     (let [shows (:shows user)]
                       (if (empty? shows)
                         [:p "You're not currently watching any shows."]
             [:li.show.group
              [:img {:src (r "artworkUrl100")}]
              [:h3 (link-to (r "artistViewUrl") (r "artistName"))]
-             [:p.latest "Latest season: " (r "collectionName")]
+             [:p.latest "Latest: " (r "collectionName")]
              (form-to [:post "/add"]
                       [:input {:type "hidden" :name "artist-id" :value (r "artistId")}]
                       (submit-button "Add Show to List"))])
 
 (defpartial search [query results]
-            (inner (str "Search results for “" query "”")
+            (inner (str "Search results for “" query "”") "search"
                    [:ul.sixteen.columns.search-results
                     (map result results)]))
 
 
 (defpartial password []
-            (inner "Change Your Password"
+            (inner "Change Your Password" "change-password"
                    [:section.sixteen.columns
                     (form-to [:post ""]
                              (field password-field "password" "New Password")

File src/newseasons/utils.clj

View file
+(ns newseasons.utils)
+
+
+(defn sort-maps-by [coll k]
+  (sort #(compare (%1 k) (%2 k)) coll))
+

File src/newseasons/views/main.clj

View file
 (ns newseasons.views.main
   (:use noir.core)
+  (:use newseasons.utils)
   (:require [noir.response :as resp])
   (:require [noir.session :as sess])
   (:require [noir.util.crypt :as crypt])
 (defn unique-shows [seasons]
   (unique-by (sort-maps-by seasons "releaseDate") "artistId"))
 
-(defn sort-maps-by [coll k]
-  (sort #(compare (%1 k) (%2 k)) coll))
-
-
 ; iTunes ----------------------------------------------------------------------
 (defn itunes-search [params]
   ((parse-string (:body (client/get "http://itunes.apple.com/search"