Make the pronouns table an atom and add reload-table!
This is useful primarily for repl development
This commit is contained in:
parent
04d94c8935
commit
0581a381ae
@ -17,5 +17,13 @@
|
|||||||
(ns pronouns.config
|
(ns pronouns.config
|
||||||
(:require [pronouns.util :as u]))
|
(:require [pronouns.util :as u]))
|
||||||
|
|
||||||
(def ^:dynamic *pronouns-table*
|
(def pronouns-table
|
||||||
(u/slurp-tabfile "resources/pronouns.tab"))
|
(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")))
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
(ns pronouns.pages
|
(ns pronouns.pages
|
||||||
(:require [clojure.string :as s]
|
(:require [clojure.string :as s]
|
||||||
[pronouns.config :refer [*pronouns-table*]]
|
[pronouns.config :refer [pronouns-table]]
|
||||||
[pronouns.util :as u]
|
[pronouns.util :as u]
|
||||||
[hiccup.core :refer :all]
|
[hiccup.core :refer :all]
|
||||||
[hiccup.element :as e]
|
[hiccup.element :as e]
|
||||||
@ -141,7 +141,7 @@
|
|||||||
n (count inputs)]
|
n (count inputs)]
|
||||||
(if (>= n 5)
|
(if (>= n 5)
|
||||||
(take 5 inputs)
|
(take 5 inputs)
|
||||||
(u/table-lookup inputs *pronouns-table*))))
|
(u/table-lookup inputs @pronouns-table))))
|
||||||
|
|
||||||
(defn make-link [path]
|
(defn make-link [path]
|
||||||
(let [link (str "/" path)
|
(let [link (str "/" path)
|
||||||
@ -149,7 +149,7 @@
|
|||||||
[:li (href link label)]))
|
[:li (href link label)]))
|
||||||
|
|
||||||
(defn front []
|
(defn front []
|
||||||
(let [abbreviations (take 6 (u/abbreviate *pronouns-table*))
|
(let [abbreviations (take 6 (u/abbreviate @pronouns-table))
|
||||||
links (map make-link abbreviations)
|
links (map make-link abbreviations)
|
||||||
title "Pronoun Island"]
|
title "Pronoun Island"]
|
||||||
(html
|
(html
|
||||||
@ -168,7 +168,7 @@
|
|||||||
(footer-block)])))
|
(footer-block)])))
|
||||||
|
|
||||||
(defn all-pronouns []
|
(defn all-pronouns []
|
||||||
(let [abbreviations (u/abbreviate *pronouns-table*)
|
(let [abbreviations (u/abbreviate @pronouns-table)
|
||||||
links (map make-link abbreviations)
|
links (map make-link abbreviations)
|
||||||
title "Pronoun Island"]
|
title "Pronoun Island"]
|
||||||
(html
|
(html
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
:headers {"Content-Type" "text/html"}
|
:headers {"Content-Type" "text/html"}
|
||||||
:body (pages/all-pronouns)})
|
:body (pages/all-pronouns)})
|
||||||
|
|
||||||
|
|
||||||
(GET "/pronouns.css" []
|
(GET "/pronouns.css" []
|
||||||
{:status 200
|
{:status 200
|
||||||
:headers {"Content-Type" "text/css"}
|
:headers {"Content-Type" "text/css"}
|
||||||
|
Loading…
Reference in New Issue
Block a user