From 0c73d91f9469d484147ef5db2699fd28182c86b0 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 9 Mar 2012 18:52:31 +0000 Subject: [PATCH] web: fix static file embedding in non-dev builds --- hledger-web/Hledger/Web/Application.hs | 9 --------- hledger-web/Hledger/Web/Settings/StaticFiles.hs | 9 +++++++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/hledger-web/Hledger/Web/Application.hs b/hledger-web/Hledger/Web/Application.hs index 71581db64..ead279cc9 100644 --- a/hledger-web/Hledger/Web/Application.hs +++ b/hledger-web/Hledger/Web/Application.hs @@ -55,12 +55,3 @@ getApplicationDev = loader = loadConfig (configSettings Development) { csParseExtra = parseExtra } - --- #ifdef PRODUCTION --- putStrLn $ "Production mode, using embedded web files" --- let s = $(embed staticDir) --- #else --- putStrLn $ "Not in production mode, using web files from " ++ staticDir ++ "/" --- s <- staticDevel staticDir --- #endif - diff --git a/hledger-web/Hledger/Web/Settings/StaticFiles.hs b/hledger-web/Hledger/Web/Settings/StaticFiles.hs index 00054bcb7..c87fac67a 100644 --- a/hledger-web/Hledger/Web/Settings/StaticFiles.hs +++ b/hledger-web/Hledger/Web/Settings/StaticFiles.hs @@ -12,20 +12,25 @@ This is a separate module to satisfy template haskell requirements. module Hledger.Web.Settings.StaticFiles where import Prelude (IO) +import System.IO import Yesod.Static import qualified Yesod.Static as Static +import Prelude import Hledger.Web.Settings (staticDir) -- | use this to create your static file serving site staticSite :: IO Static.Static -staticSite = +staticSite = do #ifdef DEVELOPMENT + putStrLn ("using web files from: " ++ staticDir ++ "/") >> hFlush stdout Static.staticDevel staticDir #else - Static.static staticDir + putStrLn "using embedded web files" >> hFlush stdout + return $(Static.embed staticDir) #endif + -- | This generates easy references to files in the static directory at compile time, -- giving you compile-time verification that referenced files exist. -- Warning: any files added to your static directory during run-time can't be