sitepipe 0.2.0.0 → 0.3.0.0
raw patch · 2 files changed
+16/−5 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- SitePipe: copyFiles :: [GlobPattern] -> SiteM ()
+ SitePipe: copyFiles :: [GlobPattern] -> SiteM [Value]
- SitePipe: copyFilesWith :: (FilePath -> FilePath) -> [GlobPattern] -> SiteM ()
+ SitePipe: copyFilesWith :: (FilePath -> FilePath) -> [GlobPattern] -> SiteM [Value]
- SitePipe: liftIO :: MonadIO m => forall a. IO a -> m a
+ SitePipe: liftIO :: MonadIO m => forall a. () => IO a -> m a
- SitePipe.Files: copyFiles :: [GlobPattern] -> SiteM ()
+ SitePipe.Files: copyFiles :: [GlobPattern] -> SiteM [Value]
- SitePipe.Files: copyFilesWith :: (FilePath -> FilePath) -> [GlobPattern] -> SiteM ()
+ SitePipe.Files: copyFilesWith :: (FilePath -> FilePath) -> [GlobPattern] -> SiteM [Value]
Files
- sitepipe.cabal +1/−1
- src/SitePipe/Files.hs +15/−4
sitepipe.cabal view
@@ -1,5 +1,5 @@ name: sitepipe-version: 0.2.0.0+version: 0.3.0.0 synopsis: A simple to understand static site generator homepage: https://github.com/ChrisPenner/sitepipe#readme license: BSD3
src/SitePipe/Files.hs view
@@ -24,7 +24,7 @@ import SitePipe.Templating import SitePipe.Types import qualified System.FilePath.Glob as G-import Data.Aeson+import Data.Aeson as A import Data.Aeson.Lens import Data.Aeson.Types import Control.Lens@@ -100,25 +100,36 @@ -- | Given a list of file or directory globs (see 'srcGlob') -- we copy matching files and directories as-is from the source directory -- to the output directory maintaining their relative filepath.-copyFiles :: [GlobPattern] -> SiteM ()+--+-- For convenience this also returns a list of the files copied as +-- 'Value's with "src" and "url" keys+-- which represent the source path and the url.of the copied file respectively.+copyFiles :: [GlobPattern] -> SiteM [Value] copyFiles = copyFilesWith id -- | Runs 'copyFiles' but using a filepath transforming function to determine -- the output filepath. The filepath transformation accepts and should return -- a relative path.-copyFilesWith :: (FilePath -> FilePath) -> [GlobPattern] -> SiteM ()+--+-- See 'copyFiles' for more information.+copyFilesWith :: (FilePath -> FilePath) -> [GlobPattern] -> SiteM [Value] copyFilesWith transformPath patterns = do Settings{..} <- ask srcFilenames <- concat <$> traverse srcGlob patterns- let destFilenames = (outputDir </>) . transformPath . makeRelative srcDir <$> srcFilenames+ let outputPaths = normalise . transformPath . makeRelative srcDir <$> srcFilenames+ outputURLs = ("/" </>) <$> outputPaths+ destFilenames = (outputDir </>) <$> outputPaths shelly $ do let getDir pth = bool (takeDirectory) (takeDirectory . takeDirectory) (endswith "/" pth) $ pth traverse_ (mkdir_p . fromString . getDir) destFilenames traverse_ copy (zip srcFilenames destFilenames)+ return . fmap (uncurry mkFileValue) $ zip srcFilenames outputURLs where copy (src, dest) = do echo $ T.concat ["Copying ", T.pack src, " to ", T.pack dest] cp_r (fromString src) (fromString dest)++ mkFileValue src url = A.object ["src" A..= src, "url" A..= url] -- | Given a resource reader (see "SitePipe.Readers") -- this function finds all files matching any of the provided list