diff --git a/yesod-static/ChangeLog.md b/yesod-static/ChangeLog.md new file mode 100644 index 00000000..96770c38 --- /dev/null +++ b/yesod-static/ChangeLog.md @@ -0,0 +1,3 @@ +## 1.4.0.3 + +Fix bug when `StaticRoute` constructor is not imported. diff --git a/yesod-static/Yesod/Static.hs b/yesod-static/Yesod/Static.hs index 725ebf40..a18d88ef 100644 --- a/yesod-static/Yesod/Static.hs +++ b/yesod-static/Yesod/Static.hs @@ -247,7 +247,7 @@ staticFiles dir = mkStaticFiles dir -- files, but only need to refer to a few of them from Haskell. staticFilesList :: Prelude.FilePath -> [Prelude.FilePath] -> Q [Dec] staticFilesList dir fs = - mkStaticFilesList dir (map split fs) "StaticRoute" True + mkStaticFilesList dir (map split fs) True where split :: Prelude.FilePath -> [String] split [] = [] @@ -266,7 +266,7 @@ staticFilesList dir fs = -- contents, however they'll need send a request to the server to -- see if their copy is up-to-date. publicFiles :: Prelude.FilePath -> Q [Dec] -publicFiles dir = mkStaticFiles' dir "StaticRoute" False +publicFiles dir = mkStaticFiles' dir False mkHashMap :: Prelude.FilePath -> IO (M.Map F.FilePath S8.ByteString) @@ -311,23 +311,21 @@ cachedETagLookup dir = do return $ (\f -> return $ M.lookup f etags) mkStaticFiles :: Prelude.FilePath -> Q [Dec] -mkStaticFiles fp = mkStaticFiles' fp "StaticRoute" True +mkStaticFiles fp = mkStaticFiles' fp True mkStaticFiles' :: Prelude.FilePath -- ^ static directory - -> String -- ^ route constructor "StaticRoute" -> Bool -- ^ append checksum query parameter -> Q [Dec] -mkStaticFiles' fp routeConName makeHash = do +mkStaticFiles' fp makeHash = do fs <- qRunIO $ getFileListPieces fp - mkStaticFilesList fp fs routeConName makeHash + mkStaticFilesList fp fs makeHash mkStaticFilesList :: Prelude.FilePath -- ^ static directory -> [[String]] -- ^ list of files to create identifiers for - -> String -- ^ route constructor "StaticRoute" -> Bool -- ^ append checksum query parameter -> Q [Dec] -mkStaticFilesList fp fs routeConName makeHash = do +mkStaticFilesList fp fs makeHash = do concat `fmap` mapM mkRoute fs where replace' c @@ -345,16 +343,15 @@ mkStaticFilesList fp fs routeConName makeHash = do | isLower (head name') -> name' | otherwise -> '_' : name' f' <- [|map pack $(TH.lift f)|] - let route = mkName routeConName pack' <- [|pack|] qs <- if makeHash then do hash <- qRunIO $ base64md5File $ pathFromRawPieces fp f [|[(pack "etag", pack $(TH.lift hash))]|] else return $ ListE [] return - [ SigD routeName $ ConT route + [ SigD routeName $ ConT ''StaticRoute , FunD routeName - [ Clause [] (NormalB $ (ConE route) `AppE` f' `AppE` qs) [] + [ Clause [] (NormalB $ (ConE 'StaticRoute) `AppE` f' `AppE` qs) [] ] ] diff --git a/yesod-static/yesod-static.cabal b/yesod-static/yesod-static.cabal index 1e59ff6e..0396d637 100644 --- a/yesod-static/yesod-static.cabal +++ b/yesod-static/yesod-static.cabal @@ -1,5 +1,5 @@ name: yesod-static -version: 1.4.0.2 +version: 1.4.0.3 license: MIT license-file: LICENSE author: Michael Snoyman @@ -22,6 +22,7 @@ extra-source-files: test/embed-dir/foo test/embed-dir/lorem.txt test/embed-dir/abc/def.txt + ChangeLog.md library build-depends: base >= 4 && < 5