Created
December 4, 2013 20:12
-
-
Save sritchie/7794646 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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