about summary refs log tree commit diff
path: root/src/pronouns
diff options
context:
space:
mode:
authorMorgan Astra <m@morganastra.me>2018-11-15 19:07:12 -0800
committerMorgan Astra <m@morganastra.me>2018-11-15 19:07:12 -0800
commit0581a381ae09b5a09ef97e23abdb38ac9e03c166 (patch)
tree7235483e71a125f03e28bfe25cbd58ab3e8c1f9d /src/pronouns
parent04d94c8935377e68292f78671428d564395b1641 (diff)
Make the pronouns table an atom and add `reload-table!`
This is useful primarily for repl development
Diffstat (limited to 'src/pronouns')
-rw-r--r--src/pronouns/config.clj12
-rw-r--r--src/pronouns/pages.clj8
-rw-r--r--src/pronouns/web.clj1
3 files changed, 14 insertions, 7 deletions
diff --git a/src/pronouns/config.clj b/src/pronouns/config.clj
index 3a07c36..e35ac7e 100644
--- a/src/pronouns/config.clj
+++ b/src/pronouns/config.clj
@@ -17,5 +17,13 @@
 (ns pronouns.config
   (:require [pronouns.util :as u]))
 
-(def ^:dynamic *pronouns-table*
-  (u/slurp-tabfile "resources/pronouns.tab"))
+(def pronouns-table
+  (atom (u/slurp-tabfile "resources/pronouns.tab")))
+
+(defn replace-value [old new] new)
+
+(defn reload-table! []
+  (swap! pronouns-table
+         replace-value
+         (u/slurp-tabfile "resources/pronouns.tab")))
+
diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj
index 1226ea9..ac67970 100644
--- a/src/pronouns/pages.clj
+++ b/src/pronouns/pages.clj
@@ -16,7 +16,7 @@
 
 (ns pronouns.pages
   (:require [clojure.string :as s]
-            [pronouns.config :refer [*pronouns-table*]]
+            [pronouns.config :refer [pronouns-table]]
             [pronouns.util :as u]
             [hiccup.core :refer :all]
             [hiccup.element :as e]
@@ -141,7 +141,7 @@
         n (count inputs)]
     (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)
@@ -149,7 +149,7 @@
     [:li (href link label)]))
 
 (defn front []
-  (let [abbreviations (take 6 (u/abbreviate *pronouns-table*))
+  (let [abbreviations (take 6 (u/abbreviate @pronouns-table))
         links (map make-link abbreviations)
         title "Pronoun Island"]
     (html
@@ -168,7 +168,7 @@
       (footer-block)])))
 
 (defn all-pronouns []
-  (let [abbreviations (u/abbreviate *pronouns-table*)
+  (let [abbreviations (u/abbreviate @pronouns-table)
         links (map make-link abbreviations)
         title "Pronoun Island"]
     (html
diff --git a/src/pronouns/web.clj b/src/pronouns/web.clj
index 25f8a78..2c348c0 100644
--- a/src/pronouns/web.clj
+++ b/src/pronouns/web.clj
@@ -42,7 +42,6 @@
         :headers {"Content-Type" "text/html"}
         :body (pages/all-pronouns)})
 
-
   (GET "/pronouns.css" []
      {:status 200
      :headers {"Content-Type" "text/css"}