about summary refs log tree commit diff
path: root/src/pronouns/pages.clj
diff options
context:
space:
mode:
authorMorgan Astra <m@morganastra.me>2016-09-24 00:32:23 -0700
committerMorgan Astra <m@morganastra.me>2016-09-24 00:32:23 -0700
commitcf48e336dabbbb9bbe20397c37ce1bb3257c49cc (patch)
tree2893891f61a6670277adfb6c56e99bf6d308beec /src/pronouns/pages.clj
parent6739eadea33d8f6cfd1baf9b1265735b0c02fee4 (diff)
include pronouns in page titles (re #56)
Diffstat (limited to 'src/pronouns/pages.clj')
-rw-r--r--src/pronouns/pages.clj28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj
index 6f08e98..5b2ad36 100644
--- a/src/pronouns/pages.clj
+++ b/src/pronouns/pages.clj
@@ -21,6 +21,14 @@
             [hiccup.core :refer :all]
             [hiccup.util :refer [escape-html]]))
 
+(defn prose-comma-list
+  [items]
+  (let [c (count items)]
+    (cond
+      (<= c 1) (first items)
+      (= c 2) (s/join " and " items)
+      :else (str (s/join ", " (butlast items)) ", and " (last items)))))
+
 (defn href
   [url text]
   [:a {:href url} text])
@@ -49,7 +57,9 @@
 
 (defn possessive-pronoun-example
   [possessive-pronoun]
-  (render-sentence "At least I think it was " (wrap-pronoun possessive-pronoun) "."))
+  (render-sentence "At least I think it was "
+                   (wrap-pronoun possessive-pronoun)
+                   "."))
 
 (defn reflexive-example
   [subject reflexive]
@@ -58,16 +68,16 @@
                    (wrap-pronoun reflexive)
                    "."))
 
-(defn title-block [title]
+(defn header-block [header]
   [:div {:class "section title"}
-   [:h1 title]])
+   (href "/" [:h1 header])])
 
 (defn examples-block
   [subject object possessive-determiner possessive-pronoun reflexive]
-  (let [sub-obj (str subject "/" object)
-        header-str (str "Here are some usage examples for my "
+  (let [sub-obj (s/join "/" [subject object])
+        header-str (str "Here are some example sentences using my "
                         sub-obj
-                        " pronouns")]
+                        " pronouns:")]
     [:div {:class "section examples"}
      [:h2 header-str]
      [:p (subject-example subject)
@@ -81,7 +91,8 @@
    [:p "Full usage: "
        [:tt "http://pronoun.is/subject-pronoun/object-pronoun/possessive-determiner/possessive-pronoun/reflexive"]
        " displays examples of your pronouns."]
-   [:p "This is a bit unwieldy. If we have a good guess we'll let you use just the first one or two."]])
+   [:p "This is a bit unwieldy. If we have a good guess we'll let you use"
+       " just the first one or two."]])
 
 (defn contact-block []
   (let [twitter-name (fn [handle] (href (str "https://www.twitter.com/" handle)
@@ -102,7 +113,8 @@
 
 (defn format-pronoun-examples
   [pronoun-declensions]
-  (let [title "Pronoun Island: English Language Examples"]
+  (let [sub-objs (map #(s/join "/" (take 2 %)) pronoun-declensions)
+        title (str "Pronoun Island: " (prose-comma-list sub-objs) " examples")]
     (html
      [:html
       [:head