diff options
author | Morgan Astra <givengravity@gmail.com> | 2018-11-15 12:19:10 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-15 12:19:10 -0800 |
commit | 4ec5220185cda5a2fd81234ad4dcb444ab2ac4c0 (patch) | |
tree | 82fe697357ef609dbf2fad0e566a083f21d79052 /src/pronouns | |
parent | 7d0d3a445b4a55406edef4720251c9be747d301b (diff) | |
parent | 04d94c8935377e68292f78671428d564395b1641 (diff) |
Merge branch 'master' into feature/slash-or
Diffstat (limited to 'src/pronouns')
-rw-r--r-- | src/pronouns/config.clj | 4 | ||||
-rw-r--r-- | src/pronouns/pages.clj | 51 | ||||
-rw-r--r-- | src/pronouns/util.clj | 14 | ||||
-rw-r--r-- | src/pronouns/web.clj | 22 |
4 files changed, 58 insertions, 33 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 d1a5574..06d93b7 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,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.pages (:require [clojure.string :as s] @@ -34,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]) @@ -71,7 +73,7 @@ (defn header-block [header] [:div {:class "section title"} - (href "/" [:h1 (e/image "/purple-flag64.png" "flag logo") header])]) + (href "/" [:h1 header])]) (defn examples-block [subject object possessive-determiner possessive-pronoun reflexive] @@ -90,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."]]) @@ -102,11 +106,7 @@ [:p "Written by " (twitter-name "morganastra") ", whose " - (href "http://pronoun.is/ze/zir?or=she" "pronoun.is/ze/zir?or=she")] - [:p "Want to support this and similar websites? " - "Join us on " - (href "https://www.patreon.com/user?u=5238484" "Patreon") - "!"] + (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 " @@ -116,13 +116,6 @@ (defn footer-block [] [:footer (usage-block) (contact-block)]) -;; <meta name="twitter:card" content="summary" /> -;; <meta name="twitter:site" content="@flickr" /> -;; <meta name="twitter:title" content="Small Island Developing States Photo Submission" /> -;; <meta name="twitter:description" content="View the album on Flickr." /> -;; <meta name="twitter:image" content="https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg" /> -;; not all of these are required! - (defn format-pronoun-examples [pronoun-declensions] (let [sub-objs (map #(s/join "/" (take 2 %)) pronoun-declensions) @@ -156,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"] @@ -168,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 [] @@ -184,7 +195,7 @@ [:body (header-block title) [:div {:class "section examples"} - [:p [:h2 (str "We couldn't find those pronouns in our database." + [:p [:h2 (str "We couldn't find those pronouns in our database. " "If you think we should have them, please reach out!")]]] (footer-block)]]))) diff --git a/src/pronouns/util.clj b/src/pronouns/util.clj index 3db3c35..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,10 +97,11 @@ [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] diff --git a/src/pronouns/web.clj b/src/pronouns/web.clj index 69ad6ae..25f8a78 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,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.web (:require [compojure.core :refer [defroutes GET PUT POST DELETE ANY]] @@ -20,13 +20,13 @@ [compojure.route :as route] [clojure.string :as s] [clojure.java.io :as io] + [ring.adapter.jetty :as jetty] [ring.middleware.logger :as logger] [ring.middleware.stacktrace :as trace] [ring.middleware.params :as params] [ring.middleware.resource :refer [wrap-resource]] [ring.middleware.content-type :refer [wrap-content-type]] [ring.middleware.not-modified :refer [wrap-not-modified]] - [ring.adapter.jetty :as jetty] [environ.core :refer [env]] [pronouns.util :as u] [pronouns.pages :as pages])) @@ -37,6 +37,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"} @@ -50,6 +56,11 @@ (ANY "*" [] (route/not-found (slurp (io/resource "404.html"))))) +(defn wrap-gnu-natalie-nguyen [handler] + (fn [req] + (when-let [resp (handler req)] + (assoc-in resp [:headers "X-Clacks-Overhead"] "GNU Natalie Nguyen")))) + (defn wrap-error-page [handler] (fn [req] (try (handler req) @@ -61,11 +72,14 @@ (def app (-> app-routes - (wrap-resource "images") + ;; FIXME morgan.astra <2018-11-14 Wed> + ;; use this resource or delete it + ;; (wrap-resource "images") wrap-content-type wrap-not-modified logger/wrap-with-logger wrap-error-page + wrap-gnu-natalie-nguyen trace/wrap-stacktrace params/wrap-params)) |