diff options
Diffstat (limited to 'src/pronouns/pages.clj')
-rw-r--r-- | src/pronouns/pages.clj | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj index 7d68422..bdcd9d6 100644 --- a/src/pronouns/pages.clj +++ b/src/pronouns/pages.clj @@ -61,33 +61,33 @@ (defn contact-block [] (let [twitter-name (fn [handle] [:a {:href (str "https://www.twitter.com/" handle)} (str "@" handle)])] - [:div {:class "contact"} - [:p - "Written by " - (twitter-name "morganastra") - ", whose " - [:a {:href "http://pronoun.is/ze/zir"} "pronoun.is/ze/zir"] - ". " - "Visit the project on " [:a {:href "https://github.com/witch-house/pronoun.is"} "github!"]]])) + [:div {:class "contact"} + [:p + "Written by " + (twitter-name "morganastra") + ", whose " + [:a {:href "http://pronoun.is/ze/zir"} "pronoun.is/ze/zir"] + ". " + "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] (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 format-pronoun-json [pronouns] + (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 format-pronoun-json [& pronouns] (json/write-str pronouns)) @@ -116,9 +116,9 @@ [:body (title-block title) [:div {:class "table"} - [:p "pronoun.is is a www site for showing people how to use pronouns in English."] - [:p "here are some pronouns the site knows about:"] - [:ul links]]] + [:p "pronoun.is is a www site for showing people how to use pronouns in English."] + [:p "here are some pronouns the site knows about:"] + [:ul links]]] (contact-block)]))) (defn not-found [] @@ -126,10 +126,16 @@ "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 accept] +(defn not-found-json [] + (json/write-str {:error "Not found"})) + +(defn pronouns-page [path pronouns-table format-pronouns not-found] (let [pronouns (parse-pronouns-with-lookup (escape-html path) pronouns-table)] (if pronouns - (if (= accept :json) - (format-pronoun-json pronouns) - (apply format-pronoun-examples pronouns)) + (apply format-pronouns pronouns) (not-found)))) + +(defn pronouns [path pronouns-table accept] + (if (= accept :json) + (pronouns-page path pronouns-table format-pronoun-json not-found-json) + (pronouns-page path pronouns-table format-pronoun-examples not-found))) |