add experimental support for multiple pronoun sets
This commit is contained in:
parent
c3687318b1
commit
f0f6c207da
@ -71,7 +71,9 @@
|
||||
|
||||
|
||||
(defn format-pronoun-examples
|
||||
[subject object possessive-determiner possessive-pronoun reflexive]
|
||||
[pronoun-declension alternates]
|
||||
(println pronoun-declension)
|
||||
(println alternates)
|
||||
(let [title "Pronoun Island: English Language Examples"]
|
||||
(html
|
||||
[:html
|
||||
@ -81,11 +83,11 @@
|
||||
[:link {:rel "stylesheet" :href "/pronouns.css"}]]
|
||||
[:body
|
||||
(title-block title)
|
||||
(examples-block subject object possessive-determiner possessive-pronoun reflexive)
|
||||
(apply examples-block pronoun-declension)
|
||||
(map #(apply examples-block %) alternates)
|
||||
(about-block)
|
||||
(contact-block)]])))
|
||||
|
||||
|
||||
(defn parse-pronouns-with-lookup [pronouns-string pronouns-table]
|
||||
(let [inputs (s/split pronouns-string #"/")
|
||||
n (count inputs)]
|
||||
@ -121,8 +123,18 @@
|
||||
"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]
|
||||
(println params)
|
||||
(let [path (params :*)
|
||||
ors (u/vec-coerce (params "or"))
|
||||
a (println path)
|
||||
pronoun-declension (parse-pronouns-with-lookup (escape-html path)
|
||||
pronouns-table)
|
||||
alternates (map #(parse-pronouns-with-lookup (escape-html %)
|
||||
pronouns-table)
|
||||
ors)
|
||||
]
|
||||
(println pronoun-declension)
|
||||
(if pronoun-declension
|
||||
(format-pronoun-examples pronoun-declension alternates)
|
||||
(not-found))))
|
||||
|
@ -29,3 +29,6 @@
|
||||
"given a list of pronoun rows, return a list of minimum unabiguous paths"
|
||||
[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]
|
||||
[ring.middleware.logger :as logger]
|
||||
[ring.middleware.stacktrace :as trace]
|
||||
[ring.middleware.session :as session]
|
||||
[ring.middleware.session.cookie :as cookie]
|
||||
[ring.middleware.params :as params]
|
||||
[ring.adapter.jetty :as jetty]
|
||||
[environ.core :refer [env]]
|
||||
[pronouns.util :as u]
|
||||
@ -23,7 +22,7 @@
|
||||
:headers {"Content-Type" "text/html"}
|
||||
:body (pages/front pronouns-table)})
|
||||
|
||||
(GET "/pronouns.css" {params :params}
|
||||
(GET "/pronouns.css" []
|
||||
{:status 200
|
||||
:headers {"Content-Type" "text/css"}
|
||||
:body (slurp (io/resource "pronouns.css"))})
|
||||
@ -31,7 +30,7 @@
|
||||
(GET "/*" {params :params}
|
||||
{:status 200
|
||||
:headers {"Content-Type" "text/html"}
|
||||
:body (pages/pronouns (:* params) pronouns-table)})
|
||||
:body (pages/pronouns params pronouns-table)})
|
||||
|
||||
(ANY "*" []
|
||||
(route/not-found (slurp (io/resource "404.html")))))
|
||||
@ -48,7 +47,8 @@
|
||||
(-> app-routes
|
||||
logger/wrap-with-logger
|
||||
wrap-error-page
|
||||
trace/wrap-stacktrace))
|
||||
trace/wrap-stacktrace
|
||||
params/wrap-params))
|
||||
|
||||
(defn -main []
|
||||
(let [port (Integer. (:port env
|
||||
|
Loading…
Reference in New Issue
Block a user