Hello community, here is the log from the commit of package ghc-yesod-static for openSUSE:Factory checked in at 2017-06-21 13:56:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-yesod-static (Old) and /work/SRC/openSUSE:Factory/.ghc-yesod-static.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-yesod-static" Wed Jun 21 13:56:46 2017 rev:7 rq:504685 version:1.5.3 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-yesod-static/ghc-yesod-static.changes 2017-04-11 09:44:18.472330488 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-yesod-static.new/ghc-yesod-static.changes 2017-06-21 13:56:48.430624082 +0200 @@ -1,0 +2,5 @@ +Mon Jun 12 09:41:36 UTC 2017 - psim...@suse.com + +- Update to version 1.5.3. + +------------------------------------------------------------------- Old: ---- yesod-static-1.5.2.tar.gz New: ---- yesod-static-1.5.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-yesod-static.spec ++++++ --- /var/tmp/diff_new_pack.N8p7ek/_old 2017-06-21 13:56:51.698163168 +0200 +++ /var/tmp/diff_new_pack.N8p7ek/_new 2017-06-21 13:56:51.702162604 +0200 @@ -19,7 +19,7 @@ %global pkg_name yesod-static %bcond_with tests Name: ghc-%{pkg_name} -Version: 1.5.2 +Version: 1.5.3 Release: 0 Summary: Static file serving subsite for Yesod Web Framework License: MIT ++++++ yesod-static-1.5.2.tar.gz -> yesod-static-1.5.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yesod-static-1.5.2/ChangeLog.md new/yesod-static-1.5.3/ChangeLog.md --- old/yesod-static-1.5.2/ChangeLog.md 2017-02-08 10:18:54.000000000 +0100 +++ new/yesod-static-1.5.3/ChangeLog.md 2017-06-07 15:01:59.000000000 +0200 @@ -1,3 +1,8 @@ +## 1.5.3 + +* Add `staticFilesMap` function +* Add `staticFilesMergeMap` function + ## 1.5.2 * Fix test case for CRLF line endings diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yesod-static-1.5.2/Yesod/Static.hs new/yesod-static-1.5.3/Yesod/Static.hs --- old/yesod-static-1.5.2/Yesod/Static.hs 2017-02-05 13:38:01.000000000 +0100 +++ new/yesod-static-1.5.3/Yesod/Static.hs 2017-06-07 15:01:59.000000000 +0200 @@ -51,6 +51,8 @@ -- * Template Haskell helpers , staticFiles , staticFilesList + , staticFilesMap + , staticFilesMergeMap , publicFiles -- * Hashing , base64md5 @@ -62,6 +64,7 @@ ) where import System.Directory +import qualified System.FilePath as FP import Control.Monad import Data.FileEmbed (embedDir) @@ -246,7 +249,7 @@ -- files @\"static\/js\/jquery.js\"@ and -- @\"static\/css\/normalize.css\"@, you would use: -- --- > staticFilesList \"static\" [\"js\/jquery.js\", \"css\/normalize.css\"] +-- > staticFilesList "static" ["js/jquery.js", "css/normalize.css"] -- -- This can be useful when you have a very large number of static -- files, but only need to refer to a few of them from Haskell. @@ -273,6 +276,53 @@ publicFiles :: FilePath -> Q [Dec] publicFiles dir = mkStaticFiles' dir False +-- | 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 + splitBoth (k, v) = (split k, split v) + mapList = M.toList m + split :: FilePath -> [String] + split [] = [] + split x = + 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 + let filesList = map FP.joinPath fs + mergedMapList = M.toList $ foldl' (checkedInsert invertedMap) m filesList + mkStaticFilesList' fp (map splitBoth mergedMapList) True + where + splitBoth (k, v) = (split k, split v) + swap (x, y) = (y, x) + mapList = M.toList m + invertedMap = M.fromList $ map swap mapList + split :: FilePath -> [String] + split [] = [] + 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 + -> FilePath + -> M.Map FilePath FilePath + checkedInsert iDict st p = if M.member p iDict + then st + else M.insert p p st mkHashMap :: FilePath -> IO (M.Map FilePath S8.ByteString) mkHashMap dir = do @@ -330,7 +380,16 @@ -> [[String]] -- ^ list of files to create identifiers for -> Bool -- ^ append checksum query parameter -> Q [Dec] -mkStaticFilesList fp fs makeHash = do +mkStaticFilesList fp fs makeHash = mkStaticFilesList' fp (zip fs fs) makeHash + +mkStaticFilesList' + :: FilePath -- ^ static directory + -> [([String], [String])] -- ^ list of files to create identifiers for, where + -- the first argument of the tuple is the identifier + -- alias and the second is the actual file name + -> Bool -- ^ append checksum query parameter + -> Q [Dec] +mkStaticFilesList' fp fs makeHash = do concat `fmap` mapM mkRoute fs where replace' c @@ -338,8 +397,8 @@ | 'a' <= c && c <= 'z' = c | '0' <= c && c <= '9' = c | otherwise = '_' - mkRoute f = do - let name' = intercalate "_" $ map (map replace') f + mkRoute (alias, f) = do + let name' = intercalate "_" $ map (map replace') alias routeName = mkName $ case () of () diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yesod-static-1.5.2/yesod-static.cabal new/yesod-static-1.5.3/yesod-static.cabal --- old/yesod-static-1.5.2/yesod-static.cabal 2017-02-08 10:18:58.000000000 +0100 +++ new/yesod-static-1.5.3/yesod-static.cabal 2017-06-07 15:01:59.000000000 +0200 @@ -1,5 +1,5 @@ name: yesod-static -version: 1.5.2 +version: 1.5.3 license: MIT license-file: LICENSE author: Michael Snoyman <mich...@snoyman.com>