about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pronouns/pages.clj19
-rw-r--r--src/pronouns/util.clj4
-rw-r--r--src/pronouns/web.clj8
3 files changed, 27 insertions, 4 deletions
diff --git a/src/pronouns/pages.clj b/src/pronouns/pages.clj
index a9301e3..e33893f 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]
@@ -115,19 +116,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..3db3c35 100644
--- a/src/pronouns/util.clj
+++ b/src/pronouns/util.clj
@@ -103,3 +103,7 @@
   <x> is already in a sequence for which vector? is false, this will add
   another layer of nesting."
   (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 e57d7ec..69ad6ae 100644
--- a/src/pronouns/web.clj
+++ b/src/pronouns/web.clj
@@ -18,11 +18,14 @@
   (: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]
+            [clojure.java.io :as io]
             [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]
@@ -58,6 +61,9 @@
 
 (def app
   (-> app-routes
+      (wrap-resource "images")
+      wrap-content-type
+      wrap-not-modified
       logger/wrap-with-logger
       wrap-error-page
       trace/wrap-stacktrace