Code review fixes for #1404

This commit is contained in:
Ian Duncan 2017-06-07 20:11:01 +09:00
parent ded136513c
commit 274b5445a1
No known key found for this signature in database
GPG Key ID: CC6C9D28854569E7
3 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,8 @@
## 1.5.3
* Add `staticFilesMap` function
* Add `staticFilesMergeMap` function
## 1.5.2
* Fix test case for CRLF line endings

View File

@ -276,8 +276,10 @@ staticFilesList dir fs =
publicFiles :: FilePath -> Q [Dec]
publicFiles dir = mkStaticFiles' dir False
-- | Similar to 'staticFilesList', but takes a manifest mapping
-- | Similar to 'staticFilesList', but takes a mapping of
-- unmunged names to fingerprinted file names.
--
-- @since 1.5.3
staticFilesMap :: FilePath -> M.Map FilePath FilePath -> Q [Dec]
staticFilesMap fp m = mkStaticFilesList' fp (map splitBoth mapList) True
where
@ -289,6 +291,11 @@ staticFilesMap fp m = mkStaticFilesList' fp (map splitBoth mapList) True
let (a, b) = break (== '/') x
in a : split (drop 1 b)
-- | Similar to 'staticFilesMergeMap', but also generates identifiers
-- for all files in the specified directory that don't have a
-- fingerprinted version.
--
-- @since 1.5.3
staticFilesMergeMap :: FilePath -> M.Map FilePath FilePath -> Q [Dec]
staticFilesMergeMap fp m = do
fs <- qRunIO $ getFileListPieces fp
@ -305,6 +312,9 @@ staticFilesMergeMap fp m = do
split x =
let (a, b) = break (== '/') x
in a : split (drop 1 b)
-- We want to keep mappings for all files that are pre-fingerprinted,
-- so this function checks against all of the existing fingerprinted files and
-- only inserts a new mapping if it's not a fingerprinted file.
checkedInsert
:: M.Map FilePath FilePath -- inverted dictionary
-> M.Map FilePath FilePath -- accumulating state

View File

@ -1,5 +1,5 @@
name: yesod-static
version: 1.5.2
version: 1.5.3
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>