Merge branch 'feature/multi-pronouns' into develop fixes #38
This commit is contained in:
commit
1a9fbedc1f
@ -43,13 +43,17 @@
|
|||||||
|
|
||||||
(defn examples-block
|
(defn examples-block
|
||||||
[subject object possessive-determiner possessive-pronoun reflexive]
|
[subject object possessive-determiner possessive-pronoun reflexive]
|
||||||
|
(let [sub-obj (str subject "/" object)
|
||||||
|
header-str (str "Here are some usage examples for my "
|
||||||
|
sub-obj
|
||||||
|
" pronouns")]
|
||||||
[:div {:class "examples"}
|
[:div {:class "examples"}
|
||||||
[:p [:h2 "Here are some usage examples for my pronouns:"]]
|
[:p [:h2 header-str]]
|
||||||
(subject-example subject)
|
(subject-example subject)
|
||||||
(object-example object)
|
(object-example object)
|
||||||
(posessive-determiner-example subject possessive-determiner)
|
(posessive-determiner-example subject possessive-determiner)
|
||||||
(possessive-pronoun-example possessive-pronoun)
|
(possessive-pronoun-example possessive-pronoun)
|
||||||
(reflexive-example subject reflexive)])
|
(reflexive-example subject reflexive)]))
|
||||||
|
|
||||||
(defn about-block []
|
(defn about-block []
|
||||||
[:div {:class "about"}
|
[:div {:class "about"}
|
||||||
@ -71,7 +75,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn format-pronoun-examples
|
(defn format-pronoun-examples
|
||||||
[subject object possessive-determiner possessive-pronoun reflexive]
|
[pronoun-declension alternates]
|
||||||
(let [title "Pronoun Island: English Language Examples"]
|
(let [title "Pronoun Island: English Language Examples"]
|
||||||
(html
|
(html
|
||||||
[:html
|
[:html
|
||||||
@ -81,12 +85,12 @@
|
|||||||
[:link {:rel "stylesheet" :href "/pronouns.css"}]]
|
[:link {:rel "stylesheet" :href "/pronouns.css"}]]
|
||||||
[:body
|
[:body
|
||||||
(title-block title)
|
(title-block title)
|
||||||
(examples-block subject object possessive-determiner possessive-pronoun reflexive)
|
(apply examples-block pronoun-declension)
|
||||||
|
(map #(apply examples-block %) alternates)
|
||||||
(about-block)
|
(about-block)
|
||||||
(contact-block)]])))
|
(contact-block)]])))
|
||||||
|
|
||||||
|
(defn lookup-pronouns [pronouns-string pronouns-table]
|
||||||
(defn parse-pronouns-with-lookup [pronouns-string pronouns-table]
|
|
||||||
(let [inputs (s/split pronouns-string #"/")
|
(let [inputs (s/split pronouns-string #"/")
|
||||||
n (count inputs)]
|
n (count inputs)]
|
||||||
(if (>= n 5)
|
(if (>= n 5)
|
||||||
@ -121,8 +125,14 @@
|
|||||||
"add them, or issue a pull request at "
|
"add them, or issue a pull request at "
|
||||||
"https://github.com/witch-house/pronoun.is/blob/master/resources/pronouns.tab"))
|
"https://github.com/witch-house/pronoun.is/blob/master/resources/pronouns.tab"))
|
||||||
|
|
||||||
(defn pronouns [path pronouns-table]
|
(defn pronouns [params pronouns-table]
|
||||||
(let [pronouns (parse-pronouns-with-lookup (escape-html path) pronouns-table)]
|
(let [path (params :*)
|
||||||
(if pronouns
|
ors (u/vec-coerce (params "or"))
|
||||||
(apply format-pronoun-examples pronouns)
|
pronoun-declension (lookup-pronouns (escape-html path)
|
||||||
|
pronouns-table)
|
||||||
|
alternates (map #(lookup-pronouns (escape-html %)
|
||||||
|
pronouns-table)
|
||||||
|
ors)]
|
||||||
|
(if pronoun-declension
|
||||||
|
(format-pronoun-examples pronoun-declension alternates)
|
||||||
(not-found))))
|
(not-found))))
|
||||||
|
@ -29,3 +29,6 @@
|
|||||||
"given a list of pronoun rows, return a list of minimum unabiguous paths"
|
"given a list of pronoun rows, return a list of minimum unabiguous paths"
|
||||||
[pronouns-table]
|
[pronouns-table]
|
||||||
(map (partial minimum-unambiguous-path pronouns-table) pronouns-table))
|
(map (partial minimum-unambiguous-path pronouns-table) pronouns-table))
|
||||||
|
|
||||||
|
(defn vec-coerce [x]
|
||||||
|
(if (vector? x) x [x]))
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
[clojure.string :as s]
|
[clojure.string :as s]
|
||||||
[ring.middleware.logger :as logger]
|
[ring.middleware.logger :as logger]
|
||||||
[ring.middleware.stacktrace :as trace]
|
[ring.middleware.stacktrace :as trace]
|
||||||
[ring.middleware.session :as session]
|
[ring.middleware.params :as params]
|
||||||
[ring.middleware.session.cookie :as cookie]
|
|
||||||
[ring.adapter.jetty :as jetty]
|
[ring.adapter.jetty :as jetty]
|
||||||
[environ.core :refer [env]]
|
[environ.core :refer [env]]
|
||||||
[pronouns.util :as u]
|
[pronouns.util :as u]
|
||||||
@ -23,7 +22,7 @@
|
|||||||
:headers {"Content-Type" "text/html"}
|
:headers {"Content-Type" "text/html"}
|
||||||
:body (pages/front pronouns-table)})
|
:body (pages/front pronouns-table)})
|
||||||
|
|
||||||
(GET "/pronouns.css" {params :params}
|
(GET "/pronouns.css" []
|
||||||
{:status 200
|
{:status 200
|
||||||
:headers {"Content-Type" "text/css"}
|
:headers {"Content-Type" "text/css"}
|
||||||
:body (slurp (io/resource "pronouns.css"))})
|
:body (slurp (io/resource "pronouns.css"))})
|
||||||
@ -31,7 +30,7 @@
|
|||||||
(GET "/*" {params :params}
|
(GET "/*" {params :params}
|
||||||
{:status 200
|
{:status 200
|
||||||
:headers {"Content-Type" "text/html"}
|
:headers {"Content-Type" "text/html"}
|
||||||
:body (pages/pronouns (:* params) pronouns-table)})
|
:body (pages/pronouns params pronouns-table)})
|
||||||
|
|
||||||
(ANY "*" []
|
(ANY "*" []
|
||||||
(route/not-found (slurp (io/resource "404.html")))))
|
(route/not-found (slurp (io/resource "404.html")))))
|
||||||
@ -48,7 +47,8 @@
|
|||||||
(-> app-routes
|
(-> app-routes
|
||||||
logger/wrap-with-logger
|
logger/wrap-with-logger
|
||||||
wrap-error-page
|
wrap-error-page
|
||||||
trace/wrap-stacktrace))
|
trace/wrap-stacktrace
|
||||||
|
params/wrap-params))
|
||||||
|
|
||||||
(defn -main []
|
(defn -main []
|
||||||
(let [port (Integer. (:port env
|
(let [port (Integer. (:port env
|
||||||
|
Loading…
Reference in New Issue
Block a user