about summary refs log tree commit diff
path: root/src/pronouns/pages.clj
diff options
context:
space:
mode:
authorMorgan <m@morganastra.me>2015-03-10 09:29:58 +0000
committerMorgan <m@morganastra.me>2015-03-10 09:29:58 +0000
commitd88f645e267078572c19cbe37b37acc9798ad532 (patch)
treec0d80c9a50176d731d56a968ad0354d542d958fd /src/pronouns/pages.clj
parent1ff93e23bce924ab516a24fcd279d3e232f36954 (diff)
factor out pages and util namespaces per #6
Diffstat (limited to 'src/pronouns/pages.clj')
-rw-r--r--src/pronouns/pages.clj33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj
new file mode 100644
index 0000000..f1f8b67
--- /dev/null
+++ b/src/pronouns/pages.clj
@@ -0,0 +1,33 @@
+(ns pronouns.pages
+  (:require [clojure.string :as s]
+            [pronouns.util :as u]))
+
+(defn format-pronoun-examples
+  [subject object possessive-determiner possessive-pronoun reflexive]
+  (s/join "\n"
+          [(str subject " went to the park")
+           (str "I went with " object)
+           (str subject " brought " possessive-determiner " frisbee")
+           (str "at least I think it was " possessive-pronoun)
+           (str subject " threw it to " reflexive)]))
+
+(defn parse-pronouns-with-lookup [pronouns-string pronouns-table]
+  (let [inputs (s/split pronouns-string #"/")
+        n (count inputs)]
+    (if (>= n 5)
+      (take 5 inputs)
+      (u/table-lookup inputs pronouns-table))))
+
+(defn front []
+  (str "pronoun.is is a www site for showing people how to use pronouns"))
+
+(defn not-found []
+  (str "We couldn't find those pronouns in our database, please ask us to "
+       "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 path pronouns-table)]
+    (if pronouns
+      (apply format-pronoun-examples pronouns)
+      (not-found))))