about summary refs log tree commit diff
path: root/src/pronouns/pages.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/pronouns/pages.clj')
-rw-r--r--src/pronouns/pages.clj62
1 files changed, 35 insertions, 27 deletions
diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj
index 3e63437..f73a12e 100644
--- a/src/pronouns/pages.clj
+++ b/src/pronouns/pages.clj
@@ -43,13 +43,17 @@
 
 (defn examples-block
   [subject object possessive-determiner possessive-pronoun reflexive]
-  [:div {:class "examples"}
-   [:p [:h2 "Here are some usage examples for my pronouns:"]]
-   (subject-example subject)
-   (object-example object)
-   (posessive-determiner-example subject possessive-determiner)
-   (possessive-pronoun-example possessive-pronoun)
-   (reflexive-example subject reflexive)])
+  (let [sub-obj (str subject "/" object)
+        header-str (str "Here are some usage examples for my "
+                        sub-obj
+                        " pronouns")]
+    [:div {:class "examples"}
+     [:p [:h2 header-str]]
+     (subject-example subject)
+     (object-example object)
+     (posessive-determiner-example subject possessive-determiner)
+     (possessive-pronoun-example possessive-pronoun)
+     (reflexive-example subject reflexive)]))
 
 (defn about-block []
   [:div {:class "about"}
@@ -65,28 +69,27 @@
     "Written by "
     (twitter-name "morganastra")
     ", whose "
-    [:a {:href "http://pronoun.is/ze/zir"} "pronoun.is/ze/zir"]
+    [:a {:href "http://pronoun.is/ze/zir?or=she"} "pronoun.is/ze/zir?or=she"]
     ". "
    "Visit the project on " [:a {:href "https://github.com/witch-house/pronoun.is"} "github!"]]]))
 
 
 (defn format-pronoun-examples
-  [subject object possessive-determiner possessive-pronoun reflexive]
+  [pronoun-declensions]
   (let [title "Pronoun Island: English Language Examples"]
-  (html
-   [:html
-    [:head
-     [:title title]
-     [:meta {:name "viewport" :content "width=device-width"}]
-     [:link {:rel "stylesheet" :href "/pronouns.css"}]]
-    [:body
-     (title-block title)
-     (examples-block subject object possessive-determiner possessive-pronoun reflexive)
-     (about-block)
-     (contact-block)]])))
-
-
-(defn parse-pronouns-with-lookup [pronouns-string pronouns-table]
+    (html
+     [:html
+      [:head
+       [:title title]
+       [:meta {:name "viewport" :content "width=device-width"}]
+       [:link {:rel "stylesheet" :href "/pronouns.css"}]]
+      [:body
+       (title-block title)
+       (map #(apply examples-block %) pronoun-declensions)
+       (about-block)
+       (contact-block)]])))
+
+(defn lookup-pronouns [pronouns-string pronouns-table]
   (let [inputs (s/split pronouns-string #"/")
         n (count inputs)]
     (if (>= n 5)
@@ -121,8 +124,13 @@
        "add them, or issue a pull request at "
        "https://github.com/witch-house/pronoun.is/blob/master/resources/pronouns.tab"))
 
-(defn pronouns [path pronouns-table]
-  (let [pronouns (parse-pronouns-with-lookup (escape-html path) pronouns-table)]
-    (if pronouns
-      (apply format-pronoun-examples pronouns)
+(defn pronouns [params pronouns-table]
+  (let [path (params :*)
+        alts (or (params "or") [])
+        pronouns (concat [path] (u/vec-coerce alts))
+        pronoun-declensions (map #(lookup-pronouns (escape-html %)
+                                          pronouns-table)
+                        pronouns)]
+    (if pronoun-declensions
+      (format-pronoun-examples pronoun-declensions)
       (not-found))))