Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View optimus.clj
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
(defn optify
"Helper that examines paths with the supplied prefix and either subs
in their cache-busting URLs or returns them unchanged."
[req prefix]
(fn [^String src]
(or (and (.startsWith src prefix)
(not-empty (link/file-path req src)))
src)))
 
 
;; Any html transformation you pass in via `main` gets its img tags rewritten with no extra work!
(deftemplate base-layout
base-template
[request main]
[:head :link] #(update-in % [:attrs :href] (optify request "/img/")) ;; for favicon.ico
[:.main] main
[:img] #(update-in % [:attrs :src] (optify request "/img/"))
[:div#google-analytics] (if-let [code (conf/get-config :analytics)]
(append (google-analytics code))
identity))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.