Really ugly template thing, also formatting

This commit is contained in:
Morgan 2015-03-03 10:30:48 +00:00
parent 2347c4b1a3
commit 945fa4e9a6

View File

@ -13,6 +13,15 @@
(def config {:default-server-port 5000}) (def config {:default-server-port 5000})
(defn render-examples-page
[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)]))
(defroutes app-routes (defroutes app-routes
(GET "/" [] (GET "/" []
{:status 200 {:status 200
@ -21,7 +30,15 @@
(GET "/:subject/:object/:possessive-determiner/:possessive-pronoun/:reflexive" {params :params} (GET "/:subject/:object/:possessive-determiner/:possessive-pronoun/:reflexive" {params :params}
{:status 200 {:status 200
:headers {"Content-Type" "text/plain"} :headers {"Content-Type" "text/plain"}
:body (str (:subject params) " goes to the park")}) ;; ew this is super gross there's certainly a better way
:body (let [{:keys
[subject object possessive-determiner possessive-pronoun reflexive]}
params]
(render-examples-page subject
object
possessive-determiner
possessive-pronoun
reflexive))})
(ANY "*" [] (ANY "*" []
(route/not-found (slurp (io/resource "404.html"))))) (route/not-found (slurp (io/resource "404.html")))))
@ -40,8 +57,8 @@
trace/wrap-stacktrace)) trace/wrap-stacktrace))
(defn -main [] (defn -main []
(let [port (Integer. (env :port (:default-server-port config))) (let [port (Integer. (:port env
] (:default-server-port config)))]
(jetty/run-jetty app {:port port}))) (jetty/run-jetty app {:port port})))
;; For interactive development: ;; For interactive development: