about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README.md18
-rw-r--r--project.clj18
-rwxr-xr-xquickstart.sh5
-rw-r--r--src/pronouns/config.clj5
-rw-r--r--src/pronouns/pages.clj21
-rw-r--r--src/pronouns/util.clj13
-rw-r--r--src/pronouns/web.clj23
7 files changed, 48 insertions, 55 deletions
diff --git a/README.md b/README.md
index d061e39..900405d 100644
--- a/README.md
+++ b/README.md
@@ -33,20 +33,20 @@ Ctrl+q <tab>
 ### Running the app in a dev environment
 
 You can launch the app on your own computer by running the following
-commands:
+command:
 
 ```
-$ lein uberjar
-$ java -cp target/pronouns-standalone.jar clojure.main -m pronouns.web
+$ lein ring server
 ```
 
-Then browse to localhost:5000
+This will launch a server running the app and open your default web browser to the index page. The server will automatically reload files as you edit them.
 
-You can also just run quickstart.sh which will do all of these things for you. Do it like this to get an example running on port 666
+## Philosophy on pronoun inclusion
+
+Pronoun.is aims foremost and exclusively to be a useful resource for people to communicate the personal pronoun they use for themselves.
+
+It is possible to use these example sentences to demonstrate the usage of words that are not personal pronouns, or even cleverly insert an [entire story](http://pronoun.is/she/or%20they,%20those%20ships%20who%20were%20docked%20and%20still%20equipped%20with%20ancillaries,%20arranged%20to%20share%20the%20duty%20of%20monitoring%20our%20guest%20as%20it%20fit%20into%20their%20routines;%20that%20was%20the%20agreement,%20despite%20it%20being%20less%20convenient%20for%20me%20to%20participate%20at%20all,%20on%20the%20grounds%20that%20certain%20visitors%20might%20prefer%20a%20constant%20individual%20companion%20to%20what%20might%20seem,%20depending%20on%20their%20past%20experiences,%20to%20be%20undue%20attention%20from%20every%20soldier%20they%20passed.%20As%20usual,%20then,%20I%20took%20the%20first%20shift/the%20one%20possession%20of%20hers%20that%20Station%20Security%20hadn't%20confiscated,%20a/knowingly%20left%20with%20her.%20What%20a%20Presger%20frisbee%20might%20do%20or%20even%20look%20like%20I%20couldn't%20say.%20She%20hadn't%20seemed%20the%20sort%20to%20have%20alien%20technology,%20but,%20then%20again,%20neither%20had%20I/another%20unremarkable%20stranger,%20quite%20a%20ways%20down%20the%20concourse,%20who%20caught%20it%20with%20a%20degree%20of%20coordination%20that%20most%20would%20have%20overlooked.%20It%20did%20not%20escape%20my%20notice,%20however.%20"Cousin,"%20I%20said,%20enough%20to%20convey%20-%20unless%20our%20visitor%20were%20quite%20ignorant,%20but,%20of%20course,%20at%20this%20point%20I%20was%20certain%20that%20she%20couldn't%20be%20-%20both%20that%20I%20knew%20what%20she%20was%20not%20and%20that%20I%20was%20giving%20her%20the%20benefit%20of%20the%20doubt%20as%20to%20what,%20or%20who,%20she%20was)! However, as a policy we will not include such entries in the database.
 
-```
-$ ./quickstart.sh 666
-```
 
 ## License
-Copyright © 2014-2015 Morgan Astra <m@morganastra.me>
+Copyright © 2014-2016 Morgan Astra <m@morganastra.me>
diff --git a/project.clj b/project.clj
index 961c733..ac5653d 100644
--- a/project.clj
+++ b/project.clj
@@ -1,19 +1,17 @@
-(defproject pronouns "1.0.0-SNAPSHOT"
-  :description "FIXME: write description"
-  :url "http://pronouns.herokuapp.com"
-  :license {:name "FIXME: choose"
-            :url "http://example.com/FIXME"}
+(defproject witch-house/pronouns "1.9.0-SNAPSHOT"
+  :description "Pronoun.is is a web app for showing usage examples of personal pronouns in English."
+  :url "http://pronoun.is"
   :dependencies [[org.clojure/clojure "1.6.0"]
                  [compojure "1.1.8"]
                  [ring/ring-jetty-adapter "1.2.2"]
                  [ring.middleware.logger "0.5.0"]
                  [ring/ring-devel "1.2.2"]
-                 [ring-basic-authentication "1.0.5"]
                  [environ "0.5.0"]
-                 [hiccup "1.0.5"]
-                 [com.cemerick/drawbridge "0.0.6"]]
+                 [hiccup "1.0.5"]]
   :min-lein-version "2.0.0"
-  :plugins [[environ/environ.lein "0.2.1"]]
+  :plugins [[environ/environ.lein "0.2.1"]
+            [lein-ring "0.9.7"]]
   :hooks [environ.leiningen.hooks]
   :uberjar-name "pronouns-standalone.jar"
-  :profiles {:production {:env {:production true}}})
+  :profiles {:production {:env {:production true}}}
+  :ring {:handler pronouns.web/app})
diff --git a/quickstart.sh b/quickstart.sh
deleted file mode 100755
index 8969778..0000000
--- a/quickstart.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-export PORT=6666
-lein uberjar
-java -cp target/pronouns-standalone.jar clojure.main -m pronouns.web
diff --git a/src/pronouns/config.clj b/src/pronouns/config.clj
new file mode 100644
index 0000000..fdb4c97
--- /dev/null
+++ b/src/pronouns/config.clj
@@ -0,0 +1,5 @@
+(ns pronouns.config
+  (:require [pronouns.util :as u]))
+
+(def ^:dynamic *pronouns-table*
+  (u/slurp-tabfile "resources/pronouns.tab"))
diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj
index bf67f75..708d912 100644
--- a/src/pronouns/pages.clj
+++ b/src/pronouns/pages.clj
@@ -1,5 +1,6 @@
 (ns pronouns.pages
   (:require [clojure.string :as s]
+            [pronouns.config :refer [*pronouns-table*]]
             [pronouns.util :as u]
             [hiccup.core :refer :all]
             [hiccup.util :refer [escape-html]]))
@@ -89,20 +90,22 @@
        (about-block)
        (contact-block)]])))
 
-(defn lookup-pronouns [pronouns-string pronouns-table]
+(defn lookup-pronouns [pronouns-string]
   (let [inputs (s/split pronouns-string #"/")
         n (count inputs)]
+    (println *pronouns-table*)
     (if (>= n 5)
       (take 5 inputs)
-      (u/table-lookup inputs pronouns-table))))
+      (u/table-lookup inputs *pronouns-table*))))
 
 (defn make-link [path]
   (let [link (str "/" path)
         label path]
     [:li [:a {:href link} label]]))
 
-(defn front [pronouns-table]
-  (let [abbreviations (u/abbreviate pronouns-table)
+(defn front []
+  (let [blah (println *pronouns-table*)
+        abbreviations (u/abbreviate *pronouns-table*)
         links (map make-link abbreviations)
         title "Pronoun Island"]
     (html
@@ -135,15 +138,13 @@
        (about-block)
        (contact-block)]])))
 
-(defn pronouns [params pronouns-table]
+(defn pronouns [params]
   (let [path (params :*)
         alts (or (params "or") [])
         pronouns (concat [path] (u/vec-coerce alts))
-        pronoun-declensions (filter some? (map #(lookup-pronouns (escape-html %)
-                                                                pronouns-table)
-                                              pronouns))]
-    (println path)
-    (println pronoun-declensions)
+        pronoun-declensions (filter some? (map #(lookup-pronouns
+                                                 (escape-html %))
+                                               pronouns))]
     (if (seq pronoun-declensions)
       (format-pronoun-examples pronoun-declensions)
       (not-found))))
diff --git a/src/pronouns/util.clj b/src/pronouns/util.clj
index 3a4bf10..ef353a8 100644
--- a/src/pronouns/util.clj
+++ b/src/pronouns/util.clj
@@ -16,19 +16,20 @@
   (table-lookup query-key (slurp-tabfile tabfile)))
 
 (defn minimum-unambiguous-path
-  ([pronouns-table sections] (minimum-unambiguous-path pronouns-table sections 1))
-  ([pronouns-table sections number-of-sections]
+  ([table sections] (minimum-unambiguous-path table sections 1))
+  ([table sections number-of-sections]
     (let [sections-subset (take number-of-sections sections)
-          results (filter #(= (take number-of-sections %) sections-subset) pronouns-table)]
+          results (filter #(= (take number-of-sections %) sections-subset)
+                          table)]
       (case (count results)
         0 nil
         1 (clojure.string/join "/" sections-subset)
-        (recur pronouns-table sections (+ number-of-sections 1))))))
+        (recur table sections (+ number-of-sections 1))))))
 
 (defn abbreviate
   "given a list of pronoun rows, return a list of minimum unabiguous paths"
-  [pronouns-table]
-  (map (partial minimum-unambiguous-path pronouns-table) pronouns-table))
+  [table]
+  (map (partial minimum-unambiguous-path table) table))
 
 (defn vec-coerce [x]
   (if (vector? x) x [x]))
diff --git a/src/pronouns/web.clj b/src/pronouns/web.clj
index cb5e6c9..6c758fe 100644
--- a/src/pronouns/web.clj
+++ b/src/pronouns/web.clj
@@ -12,15 +12,11 @@
             [pronouns.util :as u]
             [pronouns.pages :as pages]))
 
-(def config {:default-server-port 5000
-             :pronoun-table-path "resources/pronouns.tab"})
-(def pronouns-table (u/slurp-tabfile (:pronoun-table-path config)))
-
 (defroutes app-routes
   (GET "/" []
        {:status 200
         :headers {"Content-Type" "text/html"}
-        :body (pages/front pronouns-table)})
+        :body (pages/front)})
 
   (GET "/pronouns.css" []
      {:status 200
@@ -30,7 +26,7 @@
   (GET "/*" {params :params}
        {:status 200
         :headers {"Content-Type" "text/html"}
-        :body (pages/pronouns params pronouns-table)})
+        :body (pages/pronouns params)})
 
   (ANY "*" []
        (route/not-found (slurp (io/resource "404.html")))))
@@ -39,9 +35,11 @@
   (fn [req]
     (try (handler req)
          (catch Exception e
-           {:status 500
-            :headers {"Content-Type" "text/html"}
-            :body (slurp (io/resource "500.html"))}))))
+           (binding [*out* *err*]
+             (println e)
+             {:status 500
+              :headers {"Content-Type" "text/html"}
+              :body (slurp (io/resource "500.html"))})))))
 
 (def app
   (-> app-routes
@@ -51,10 +49,5 @@
       params/wrap-params))
 
 (defn -main []
-  (let [port (Integer. (:port env
-                              (:default-server-port config)))]
+  (let [port (Integer. (:port env))]
     (jetty/run-jetty app {:port port})))
-
-;; For interactive development:
-;; (.stop server)
-;; (def server (-main))