tiny/Foundation uses addStaticContentExternal
This commit is contained in:
parent
bb7f7c82f2
commit
9815fe8891
@ -15,17 +15,14 @@ module Foundation
|
|||||||
|
|
||||||
import Yesod.Core
|
import Yesod.Core
|
||||||
import Yesod.Default.Config
|
import Yesod.Default.Config
|
||||||
|
import Yesod.Default.Util (addStaticContentExternal)
|
||||||
import Yesod.Static (Static, base64md5, StaticRoute(..))
|
import Yesod.Static (Static, base64md5, StaticRoute(..))
|
||||||
import Settings.StaticFiles
|
import Settings.StaticFiles
|
||||||
import Yesod.Logger (Logger, logLazyText)
|
import Yesod.Logger (Logger, logLazyText)
|
||||||
import qualified Settings
|
import qualified Settings
|
||||||
import System.Directory
|
|
||||||
import qualified Data.ByteString.Lazy as L
|
|
||||||
import Settings (hamletFile, cassiusFile, luciusFile, juliusFile, widgetFile)
|
import Settings (hamletFile, cassiusFile, luciusFile, juliusFile, widgetFile)
|
||||||
import Control.Monad (unless)
|
|
||||||
import Control.Monad.Trans.Class (lift)
|
import Control.Monad.Trans.Class (lift)
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import qualified Data.Text as T
|
|
||||||
import Web.ClientSession (getKey)
|
import Web.ClientSession (getKey)
|
||||||
|
|
||||||
-- | The site argument for your application. This can be a good place to
|
-- | The site argument for your application. This can be a good place to
|
||||||
@ -88,11 +85,4 @@ instance Yesod ~sitearg~ where
|
|||||||
-- and names them based on a hash of their content. This allows
|
-- and names them based on a hash of their content. This allows
|
||||||
-- expiration dates to be set far in the future without worry of
|
-- expiration dates to be set far in the future without worry of
|
||||||
-- users receiving stale content.
|
-- users receiving stale content.
|
||||||
addStaticContent ext' _ content = do
|
addStaticContent = addStaticContentExternal (const $ Left ()) base64md5 Settings.staticDir (StaticR . flip StaticRoute [])
|
||||||
let fn = base64md5 content ++ '.' : T.unpack ext'
|
|
||||||
let statictmp = Settings.staticDir ++ "/tmp/"
|
|
||||||
liftIO $ createDirectoryIfMissing True statictmp
|
|
||||||
let fn' = statictmp ++ fn
|
|
||||||
exists <- liftIO $ doesFileExist fn'
|
|
||||||
unless exists $ liftIO $ L.writeFile fn' content
|
|
||||||
return $ Just $ Right (StaticR $ StaticRoute ["tmp", T.pack fn] [], [])
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user