diff options
author | Morgan Astra <givengravity@gmail.com> | 2018-11-15 00:04:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-15 00:04:50 -0800 |
commit | f81ef6b889807dd0edbd3249e1069224ab87782a (patch) | |
tree | 99c63b25061e7c6b134fda7ba577a993d183a1a1 /src/pronouns | |
parent | a1f10d3b04b65030f660d41f92be2bf34c230222 (diff) | |
parent | 4e6941768364d3337bff6ac2e2be5c8db5df197b (diff) |
Merge pull request #91 from witch-house/develop
Merge develop into master... for the last time!
Diffstat (limited to 'src/pronouns')
-rw-r--r-- | src/pronouns/config.clj | 4 | ||||
-rw-r--r-- | src/pronouns/pages.clj | 46 | ||||
-rw-r--r-- | src/pronouns/util.clj | 18 | ||||
-rw-r--r-- | src/pronouns/web.clj | 30 |
4 files changed, 74 insertions, 24 deletions
diff --git a/src/pronouns/config.clj b/src/pronouns/config.clj index 19e20f1..3a07c36 100644 --- a/src/pronouns/config.clj +++ b/src/pronouns/config.clj @@ -1,5 +1,5 @@ ;; pronoun.is - a website for pronoun usage examples -;; Copyright (C) 2014 - 2017 Morgan Astra +;; Copyright (C) 2014 - 2018 Morgan Astra ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU Affero General Public License as @@ -12,7 +12,7 @@ ;; GNU Affero General Public License for more details. ;; You should have received a copy of the GNU Affero General Public License -;; along with this program. If not, see <http://www.gnu.org/licenses/> +;; along with this program. If not, see <https://www.gnu.org/licenses/> (ns pronouns.config (:require [pronouns.util :as u])) diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj index 62007bc..1226ea9 100644 --- a/src/pronouns/pages.clj +++ b/src/pronouns/pages.clj @@ -1,5 +1,5 @@ ;; pronoun.is - a website for pronoun usage examples -;; Copyright (C) 2014 - 2017 Morgan Astra +;; Copyright (C) 2014 - 2018 Morgan Astra ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU Affero General Public License as @@ -12,13 +12,14 @@ ;; GNU Affero General Public License for more details. ;; You should have received a copy of the GNU Affero General Public License -;; along with this program. If not, see <http://www.gnu.org/licenses/> +;; along with this program. If not, see <https://www.gnu.org/licenses/> (ns pronouns.pages (:require [clojure.string :as s] [pronouns.config :refer [*pronouns-table*]] [pronouns.util :as u] [hiccup.core :refer :all] + [hiccup.element :as e] [hiccup.util :refer [escape-html]])) (defn prose-comma-list @@ -33,6 +34,8 @@ [url text] [:a {:href url} text]) +;; FIXME morgan.astra <2018-11-14 Wed> +;; use a div for this instead of a plain bold tag (defn wrap-pronoun [pronoun] [:b pronoun]) @@ -89,7 +92,9 @@ (defn usage-block [] [:div {:class "section usage"} [:p "Full usage: " - [:tt "http://pronoun.is/subject-pronoun/object-pronoun/possessive-determiner/possessive-pronoun/reflexive"] + ;; FIXME morgan.astra <2018-11-14 Wed> + ;; This looks really ugly in the browser + [:tt "https://pronoun.is/subject-pronoun/object-pronoun/possessive-determiner/possessive-pronoun/reflexive"] " displays examples of your pronouns."] [:p "This is a bit unwieldy. If we have a good guess we'll let you use" " just the first one or two."]]) @@ -101,7 +106,7 @@ [:p "Written by " (twitter-name "morganastra") ", whose " - (href "http://pronoun.is/ze/zir?or=she" "pronoun.is/ze/zir?or=she")] + (href "https://pronoun.is/she" "pronoun.is/she")] [:p "pronoun.is is free software under the " (href "https://www.gnu.org/licenses/agpl.html" "AGPLv3") "! visit the project on " @@ -114,16 +119,21 @@ (defn format-pronoun-examples [pronoun-declensions] (let [sub-objs (map #(s/join "/" (take 2 %)) pronoun-declensions) - title (str "Pronoun Island: " (prose-comma-list sub-objs) " examples")] + title (str "Pronoun Island: " (prose-comma-list sub-objs) " examples") + examples (map #(apply examples-block %) pronoun-declensions)] (html [:html [:head [:title title] [:meta {:name "viewport" :content "width=device-width"}] + [:meta {:name "description" :content (u/strip-markup examples)}] + [:meta {:name "twitter:card" :content "summary"}] + [:meta {:name "twitter:title" :content title}] + [:meta {:name "twitter:description" :content (u/strip-markup examples)}] [:link {:rel "stylesheet" :href "/pronouns.css"}]] [:body (header-block title) - (map #(apply examples-block %) pronoun-declensions) + examples (footer-block)]]))) (defn lookup-pronouns [pronouns-string] @@ -139,6 +149,25 @@ [:li (href link label)])) (defn front [] + (let [abbreviations (take 6 (u/abbreviate *pronouns-table*)) + links (map make-link abbreviations) + title "Pronoun Island"] + (html + [:html + [:head + [:title title] + [:meta {:name "viewport" :content "width=device-width"}] + [:link {:rel "stylesheet" :href "/pronouns.css"}]] + [:body + (header-block title) + [:div {:class "section table"} + [:p "pronoun.is is a website for personal pronoun usage examples"] + [:p "here are some pronouns the site knows about:"] + [:ul links] + [:p [:small (href "all-pronouns" "see all pronouns in the database")]]]] + (footer-block)]))) + +(defn all-pronouns [] (let [abbreviations (u/abbreviate *pronouns-table*) links (map make-link abbreviations) title "Pronoun Island"] @@ -151,9 +180,8 @@ [:body (header-block title) [:div {:class "section table"} - [:p "pronoun.is is a website for personal pronoun usage examples"] - [:p "here are some pronouns the site knows about:"] - [:ul links]]] + [:p "All pronouns the site knows about:"] + [:ul links]]] (footer-block)]))) (defn not-found [] diff --git a/src/pronouns/util.clj b/src/pronouns/util.clj index a000201..7469dcf 100644 --- a/src/pronouns/util.clj +++ b/src/pronouns/util.clj @@ -1,5 +1,5 @@ ;; pronoun.is - a website for pronoun usage examples -;; Copyright (C) 2014 - 2017 Morgan Astra +;; Copyright (C) 2014 - 2018 Morgan Astra ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU Affero General Public License as @@ -12,15 +12,14 @@ ;; GNU Affero General Public License for more details. ;; You should have received a copy of the GNU Affero General Public License -;; along with this program. If not, see <http://www.gnu.org/licenses/> +;; along with this program. If not, see <https://www.gnu.org/licenses/> (ns pronouns.util (:require [clojure.string :as s])) -(defn print-and-return "for debugging" [x] (println x) x) - -(defn slurp-tabfile [path] - "read a tabfile from a filesystem <path> as a table" +(defn slurp-tabfile + "Read a tabfile from a filesystem <path> as a table" + [path] (let [lines (s/split (slurp path) #"\n")] (map #(s/split % #"\t") lines))) @@ -98,8 +97,13 @@ [table] (map (partial shortest-unambiguous-path table) table)) -(defn vec-coerce [x] +(defn vec-coerce "wrap a value <x> in a vector if it is not already in one. note that if <x> is already in a sequence for which vector? is false, this will add another layer of nesting." + [x] (if (vector? x) x [x])) + +(defn strip-markup [form] + (s/join " " (filter string? (flatten form)))) + diff --git a/src/pronouns/web.clj b/src/pronouns/web.clj index bbbce82..ab887d0 100644 --- a/src/pronouns/web.clj +++ b/src/pronouns/web.clj @@ -1,5 +1,5 @@ ;; pronoun.is - a website for pronoun usage examples -;; Copyright (C) 2014 - 2017 Morgan Astra +;; Copyright (C) 2014 - 2018 Morgan Astra ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU Affero General Public License as @@ -12,18 +12,23 @@ ;; GNU Affero General Public License for more details. ;; You should have received a copy of the GNU Affero General Public License -;; along with this program. If not, see <http://www.gnu.org/licenses/> +;; along with this program. If not, see <https://www.gnu.org/licenses/> (ns pronouns.web (:require [compojure.core :refer [defroutes GET PUT POST DELETE ANY]] [compojure.handler :refer [site]] [compojure.route :as route] - [clojure.java.io :as io] [clojure.string :as s] - [ring.middleware.logger :as logger] + [clojure.java.io :as io] + [ring.adapter.jetty :as jetty] + ;; FIXME morgan.astra <2018-11-14 Wed> + ;; make this logger work or use another one + ;; [ring.middleware.logger :as logger] [ring.middleware.stacktrace :as trace] [ring.middleware.params :as params] - [ring.adapter.jetty :as jetty] + [ring.middleware.resource :refer [wrap-resource]] + [ring.middleware.content-type :refer [wrap-content-type]] + [ring.middleware.not-modified :refer [wrap-not-modified]] [environ.core :refer [env]] [pronouns.util :as u] [pronouns.pages :as pages])) @@ -34,6 +39,12 @@ :headers {"Content-Type" "text/html"} :body (pages/front)}) + (GET "/all-pronouns" [] + {:status 200 + :headers {"Content-Type" "text/html"} + :body (pages/all-pronouns)}) + + (GET "/pronouns.css" [] {:status 200 :headers {"Content-Type" "text/css"} @@ -63,7 +74,14 @@ (def app (-> app-routes - logger/wrap-with-logger + ;; FIXME morgan.astra <2018-11-14 Wed> + ;; use this resource or delete it + ;; (wrap-resource "images") + wrap-content-type + wrap-not-modified + ;; FIXME morgan.astra <2018-11-14 Wed> + ;; make this logger work or use another one + ;logger/wrap-with-logger wrap-error-page wrap-gnu-natalie-nguyen trace/wrap-stacktrace |