fb4c1da11613

Store latest seasons.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 03 Oct 2011 20:00:02 -0400
parents 991807da55ff
children e3e497ef8f62
branches/tags (none)
files resources/public/css/style.less src/newseasons/models/shows.clj src/newseasons/templates/main.clj src/newseasons/views/main.clj

Changes

--- a/resources/public/css/style.less	Mon Oct 03 19:52:37 2011 -0400
+++ b/resources/public/css/style.less	Mon Oct 03 20:00:02 2011 -0400
@@ -110,7 +110,7 @@
         margin-right: 20px;
         padding: 4px;
         border: 1px solid #ccc;
-        width: 60px;
-        height: 60px;
+        width: 100px;
+        height: 100px;
     }
 }
--- a/src/newseasons/models/shows.clj	Mon Oct 03 19:52:37 2011 -0400
+++ b/src/newseasons/models/shows.clj	Mon Oct 03 20:00:02 2011 -0400
@@ -12,6 +12,7 @@
 ; shows:<iTunes artist ID> = {
 ;     id: show id
 ;     title: show tile
+;     latest: description of the latest season
 ;     image: url to show's image
 ;     url: url to view the show on iTunes
 ; }
@@ -24,6 +25,7 @@
       {:id (show "id")
        :title (show "title")
        :image (show "image")
+       :latest (show "latest")
        :url (show "url")})))
 
 (defn show-set-id! [id new-id]
@@ -32,6 +34,9 @@
 (defn show-set-title! [id new-title]
   @(r [:hset (key-show id) "title" new-title]))
 
+(defn show-set-latest! [id new-latest]
+  @(r [:hset (key-show id) "latest" new-latest]))
+
 (defn show-set-image! [id new-image]
   @(r [:hset (key-show id) "image" new-image]))
 
--- a/src/newseasons/templates/main.clj	Mon Oct 03 19:52:37 2011 -0400
+++ b/src/newseasons/templates/main.clj	Mon Oct 03 20:00:02 2011 -0400
@@ -78,6 +78,7 @@
             [:li.show.group
              [: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"))])
@@ -108,6 +109,7 @@
             [:li.show.group
              [:img {:src (r "artworkUrl100")}]
              [:h3 (link-to (r "artistViewUrl") (r "artistName"))]
+             [:p.latest "Latest season: " (r "collectionName")]
              (form-to [:post "/add"]
                       [:input {:type "hidden" :name "artist-id" :value (r "artistId")}]
                       (submit-button "Add Show to List"))])
--- a/src/newseasons/views/main.clj	Mon Oct 03 19:52:37 2011 -0400
+++ b/src/newseasons/views/main.clj	Mon Oct 03 20:00:02 2011 -0400
@@ -44,7 +44,7 @@
   (vals (reduce merge {} (map #(vector (select-keys % ks) %) coll))))
 
 (defn unique-shows [seasons]
-  (unique-by seasons "artistId"))
+  (unique-by (sort-maps-by seasons "releaseDate") "artistId"))
 
 (defn sort-maps-by [coll k]
   (sort #(compare (%1 k) (%2 k)) coll))
@@ -126,6 +126,7 @@
   (let [id (show "artistId")]
     (shows/show-set-id! id id)
     (shows/show-set-title! id (show "artistName"))
+    (shows/show-set-latest! id (show "collectionName"))
     (shows/show-set-image! id (show "artworkUrl100"))
     (shows/show-set-url! id (show "artistViewUrl"))))