From 9fea238a6d4fa31cbbe28e84eec53943e71d9fbe Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Wed, 26 Dec 2012 18:13:02 +0200 Subject: [PATCH] Prepend autogen for development mode (fixes #293) --- yesod/hsfiles/mongo.hsfiles | 8 +++++++- yesod/hsfiles/mysql.hsfiles | 8 +++++++- yesod/hsfiles/postgres.hsfiles | 8 +++++++- yesod/hsfiles/simple.hsfiles | 8 +++++++- yesod/hsfiles/sqlite.hsfiles | 8 +++++++- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/yesod/hsfiles/mongo.hsfiles b/yesod/hsfiles/mongo.hsfiles index 48005d0a..fb22b601 100644 --- a/yesod/hsfiles/mongo.hsfiles +++ b/yesod/hsfiles/mongo.hsfiles @@ -170,7 +170,13 @@ instance Yesod App where -- and names them based on a hash of their content. This allows -- expiration dates to be set far in the future without worry of -- users receiving stale content. - addStaticContent = addStaticContentExternal minifym base64md5 Settings.staticDir (StaticR . flip StaticRoute []) + addStaticContent = + addStaticContentExternal minifym genFileName Settings.staticDir (StaticR . flip StaticRoute []) + where + -- Generate a unique filename based on the content itself + genFileName lbs + | development = "autogen-" ++ base64md5 lbs + | otherwise = base64md5 lbs -- Place Javascript at bottom of the body tag so the rest of the page loads first jsLoader _ = BottomOfBody diff --git a/yesod/hsfiles/mysql.hsfiles b/yesod/hsfiles/mysql.hsfiles index d3a0fb33..4a3d9d62 100644 --- a/yesod/hsfiles/mysql.hsfiles +++ b/yesod/hsfiles/mysql.hsfiles @@ -172,7 +172,13 @@ instance Yesod App where -- and names them based on a hash of their content. This allows -- expiration dates to be set far in the future without worry of -- users receiving stale content. - addStaticContent = addStaticContentExternal minifym base64md5 Settings.staticDir (StaticR . flip StaticRoute []) + addStaticContent = + addStaticContentExternal minifym genFileName Settings.staticDir (StaticR . flip StaticRoute []) + where + -- Generate a unique filename based on the content itself + genFileName lbs + | development = "autogen-" ++ base64md5 lbs + | otherwise = base64md5 lbs -- Place Javascript at bottom of the body tag so the rest of the page loads first jsLoader _ = BottomOfBody diff --git a/yesod/hsfiles/postgres.hsfiles b/yesod/hsfiles/postgres.hsfiles index 86cba297..1eef35ff 100644 --- a/yesod/hsfiles/postgres.hsfiles +++ b/yesod/hsfiles/postgres.hsfiles @@ -172,7 +172,13 @@ instance Yesod App where -- and names them based on a hash of their content. This allows -- expiration dates to be set far in the future without worry of -- users receiving stale content. - addStaticContent = addStaticContentExternal minifym base64md5 Settings.staticDir (StaticR . flip StaticRoute []) + addStaticContent = + addStaticContentExternal minifym genFileName Settings.staticDir (StaticR . flip StaticRoute []) + where + -- Generate a unique filename based on the content itself + genFileName lbs + | development = "autogen-" ++ base64md5 lbs + | otherwise = base64md5 lbs -- Place Javascript at bottom of the body tag so the rest of the page loads first jsLoader _ = BottomOfBody diff --git a/yesod/hsfiles/simple.hsfiles b/yesod/hsfiles/simple.hsfiles index 4659b819..d2abbe12 100644 --- a/yesod/hsfiles/simple.hsfiles +++ b/yesod/hsfiles/simple.hsfiles @@ -152,7 +152,13 @@ instance Yesod App where -- and names them based on a hash of their content. This allows -- expiration dates to be set far in the future without worry of -- users receiving stale content. - addStaticContent = addStaticContentExternal minifym base64md5 Settings.staticDir (StaticR . flip StaticRoute []) + addStaticContent = + addStaticContentExternal minifym genFileName Settings.staticDir (StaticR . flip StaticRoute []) + where + -- Generate a unique filename based on the content itself + genFileName lbs + | development = "autogen-" ++ base64md5 lbs + | otherwise = base64md5 lbs -- Place Javascript at bottom of the body tag so the rest of the page loads first jsLoader _ = BottomOfBody diff --git a/yesod/hsfiles/sqlite.hsfiles b/yesod/hsfiles/sqlite.hsfiles index c7c58eeb..5feb86b1 100644 --- a/yesod/hsfiles/sqlite.hsfiles +++ b/yesod/hsfiles/sqlite.hsfiles @@ -172,7 +172,13 @@ instance Yesod App where -- and names them based on a hash of their content. This allows -- expiration dates to be set far in the future without worry of -- users receiving stale content. - addStaticContent = addStaticContentExternal minifym base64md5 Settings.staticDir (StaticR . flip StaticRoute []) + addStaticContent = + addStaticContentExternal minifym genFileName Settings.staticDir (StaticR . flip StaticRoute []) + where + -- Generate a unique filename based on the content itself + genFileName lbs + | development = "autogen-" ++ base64md5 lbs + | otherwise = base64md5 lbs -- Place Javascript at bottom of the body tag so the rest of the page loads first jsLoader _ = BottomOfBody