diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pronouns/pages.clj | 19 | ||||
-rw-r--r-- | src/pronouns/util.clj | 12 | ||||
-rw-r--r-- | src/pronouns/web.clj | 14 |
3 files changed, 35 insertions, 10 deletions
diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj index 62007bc..56830d0 100644 --- a/src/pronouns/pages.clj +++ b/src/pronouns/pages.clj @@ -19,6 +19,7 @@ [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 @@ -70,7 +71,7 @@ (defn header-block [header] [:div {:class "section title"} - (href "/" [:h1 header])]) + (href "/" [:h1 (e/image "/purple-flag64.png" "flag logo") header])]) (defn examples-block [subject object possessive-determiner possessive-pronoun reflexive] @@ -111,19 +112,31 @@ (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) - 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] diff --git a/src/pronouns/util.clj b/src/pronouns/util.clj index a000201..01571b6 100644 --- a/src/pronouns/util.clj +++ b/src/pronouns/util.clj @@ -19,8 +19,9 @@ (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 +99,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..ab4bbb6 100644 --- a/src/pronouns/web.clj +++ b/src/pronouns/web.clj @@ -18,12 +18,15 @@ (: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] + ;[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])) @@ -63,7 +66,10 @@ (def app (-> app-routes - logger/wrap-with-logger + (wrap-resource "images") + wrap-content-type + wrap-not-modified + ;logger/wrap-with-logger wrap-error-page wrap-gnu-natalie-nguyen trace/wrap-stacktrace |