822c779f0d53

Formatting mostly.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 28 Sep 2011 20:48:45 -0400
parents c4dd32a41ba8
children e10e3e94781d
branches/tags (none)
files src/newseasons/templates/main.clj src/newseasons/views/main.clj

Changes

--- a/src/newseasons/templates/main.clj	Wed Sep 28 20:41:47 2011 -0400
+++ b/src/newseasons/templates/main.clj	Wed Sep 28 20:48:45 2011 -0400
@@ -4,6 +4,8 @@
         hiccup.page-helpers
         hiccup.form-helpers))
 
+
+; Utils -----------------------------------------------------------------------
 (defn include-less [href]
   [:link {:rel "stylesheet/less" :type "text/css" :href href}])
 
@@ -12,6 +14,7 @@
         (fieldfn field-name)))
 
 
+; Layout ----------------------------------------------------------------------
 (defpartial base [& content]
             (html5
               [:head
@@ -36,6 +39,8 @@
               [:h2.sixteen.columns title]
               content))
 
+
+; Pages -----------------------------------------------------------------------
 (defpartial home []
             (base
               [:div.six.columns
@@ -61,6 +66,7 @@
                    [:div.eight.columns
                     [:p "You're not currently waiting for any shows."]]))
 
+
 (defpartial result [r]
             [:li
              [:h3 (link-to (r "artistViewUrl") (r "artistName"))]
--- a/src/newseasons/views/main.clj	Wed Sep 28 20:41:47 2011 -0400
+++ b/src/newseasons/views/main.clj	Wed Sep 28 20:48:45 2011 -0400
@@ -5,28 +5,39 @@
   (:require [clj-http.client :as client])
   (:use [cheshire.core :only (parse-string)]))
 
+
 (def email-regex #"[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}")
 
+; Home ------------------------------------------------------------------------
 (defpage [:get "/"] []
          (t/home))
 
 (defpage [:post "/"] []
          (t/home))
 
+
+; User ------------------------------------------------------------------------
 (defpage [:get ["/:email" :email email-regex]] {:keys [email]}
          (t/user email))
 
-; TODO: Images.
+
+; Search ----------------------------------------------------------------------
+(defn search-itunes [query]
+  ((parse-string (:body (client/get "http://itunes.apple.com/search"
+                                    {:query-params {"term" query
+                                                    "media" "tvShow"
+                                                    "entity" "tvSeason"
+                                                    "attribute" "showTerm"}})))
+     "results"))
+
 (defpage [:get "/search"] {:keys [query]}
-         (let [results ((parse-string (:body (client/get "http://itunes.apple.com/search"
-                                                         {:query-params {"term" query
-                                                                         "media" "tvShow"
-                                                                         "entity" "tvSeason"
-                                                                         "attribute" "showTerm"}})))
-                          "results")
+         ; TODO: Images.
+         (let [results (search-itunes query)
                artists (distinct (map #(select-keys % ["artistName" "artistId" "artistViewUrl"])
                                       results))]
            (t/search query artists)))
 
+
+; Add -------------------------------------------------------------------------
 (defpage [:post "/add"] {:as show}
          (resp/redirect "/"))