packages feed

hakyll 3.1.2.6 → 3.1.2.7

raw patch · 5 files changed

+52/−108 lines, 5 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Hakyll.Web.Page: pageCompilerWithPandoc :: ParserState -> WriterOptions -> (Pandoc -> Pandoc) -> Compiler Resource (Page String)

Files

hakyll.cabal view
@@ -1,5 +1,5 @@ Name:               hakyll-Version:            3.1.2.6+Version:            3.1.2.7  Synopsis:           A simple static site generator library. Description:        A simple static site generator library, mainly aimed at@@ -17,8 +17,6 @@                     templates/atom-item.xml                     templates/rss.xml                     templates/rss-item.xml-extra-source-files: src-inotify/Hakyll/Web/Preview/Poll.hs-                    src-interval/Hakyll/Web/Preview/Poll.hs  build-type:         Simple @@ -26,23 +24,9 @@   type:             git   location:         git://github.com/jaspervdj/hakyll.git --- Disabled while inotify is broken with GHC 7. If you're interested in fixing,--- contact me!------ flag inotify---   description:      Use the inotify bindings for the preview server. Better,---                     but only works on Linux.---   default:          False- library   ghc-options:        -Wall   hs-source-dirs:     src----  if flag(inotify)---    hs-source-dirs:   src-inotify---    build-depends:    hinotify >= 0.3---  else-  hs-source-dirs:   src-interval    build-depends:      base >= 4 && < 5,                       filepath == 1.*,
− src-inotify/Hakyll/Web/Preview/Poll.hs
@@ -1,50 +0,0 @@--- | Filesystem polling with an inotify backend. Works only on linux.----module Hakyll.Web.Preview.Poll-    ( previewPoll-    ) where--import Control.Monad (forM_, when)-import Data.Set (Set)-import qualified Data.Set as S-import System.FilePath (takeDirectory, (</>))-import Data.List (isPrefixOf)--import System.INotify--import Hakyll.Core.Configuration-import Hakyll.Core.Resource---- | Calls the given callback when the directory tree changes----previewPoll :: HakyllConfiguration  -- ^ Configuration-            -> Set Resource         -- ^ Resources to watch-            -> IO ()                -- ^ Action called when something changes-            -> IO ()                -- ^ Can block forever-previewPoll _ resources callback = do-    -- Initialize inotify-    inotify <- initINotify--    let -- A set of file paths-        paths = S.map unResource resources--        -- A list of directories. Run it through a set so we have every-        -- directory only once.-        directories = S.toList $ S.map (notEmpty . takeDirectory) paths--        -- Problem: we can't add a watcher for "". So we make sure a directory-        -- name is not empty-        notEmpty "" = "."-        notEmpty x  = x--        -- Execute the callback when path is known-        ifResource path =-            let path' = if "./" `isPrefixOf` path then drop 2 path else path-            in when (path' `S.member` paths) callback--    -- Add a watcher for every directory-    forM_ directories $ \directory -> do-        _ <- addWatch inotify [Modify] directory $ \e -> case e of-            (Modified _ (Just p)) -> ifResource $ directory </> p-            _                     -> return ()-        return ()
− src-interval/Hakyll/Web/Preview/Poll.hs
@@ -1,35 +0,0 @@--- | Interval-based implementation of preview polling, for the platforms which--- are not supported by inotify.----module Hakyll.Web.Preview.Poll-    ( previewPoll-    ) where--import Control.Applicative ((<$>))-import Control.Concurrent (threadDelay)-import Control.Monad (filterM)-import System.Time (getClockTime)-import System.Directory (getModificationTime, doesFileExist)--import Hakyll.Core.Configuration---- | A preview thread that periodically recompiles the site.----previewPoll :: HakyllConfiguration  -- ^ Configuration-            -> IO [FilePath]        -- ^ Updating action-            -> IO ()                -- ^ Can block forever-previewPoll _ update = do-    time <- getClockTime-    loop time =<< update-  where-    delay = 1000000-    loop time files = do-        threadDelay delay-        files' <- filterM doesFileExist files-        filesTime <- case files' of-            []  -> return time-            _   -> maximum <$> mapM getModificationTime files'--        if filesTime > time || files' /= files-            then loop filesTime =<< update-            else loop time files'
src/Hakyll/Web/Page.hs view
@@ -54,6 +54,7 @@     , readPageCompiler     , pageCompiler     , pageCompilerWith+    , pageCompilerWithPandoc     , addDefaultFields     , sortByBaseName     ) where@@ -66,7 +67,7 @@ import Data.List (sortBy) import Data.Ord (comparing) -import Text.Pandoc (ParserState, WriterOptions)+import Text.Pandoc (Pandoc, ParserState, WriterOptions)  import Hakyll.Core.Identifier import Hakyll.Core.Compiler@@ -91,16 +92,26 @@ -- | Read a page, add default fields, substitute fields and render using pandoc -- pageCompiler :: Compiler Resource (Page String)-pageCompiler = cached "Hakyll.Web.Page.pageCompiler" $-    readPageCompiler >>> addDefaultFields >>> arr applySelf >>> pageRenderPandoc+pageCompiler =+    pageCompilerWith defaultHakyllParserState defaultHakyllWriterOptions  -- | A version of 'pageCompiler' which allows you to specify your own pandoc -- options ---pageCompilerWith :: ParserState -> WriterOptions -> Compiler Resource (Page String)-pageCompilerWith state options = cached "pageCompilerWith" $+pageCompilerWith :: ParserState -> WriterOptions+                 -> Compiler Resource (Page String)+pageCompilerWith state options = pageCompilerWithPandoc state options id++-- | An extension of 'pageCompilerWith' which allows you to specify a custom+-- pandoc transformer for the content+--+pageCompilerWithPandoc :: ParserState -> WriterOptions+                       -> (Pandoc -> Pandoc)+                       -> Compiler Resource (Page String)+pageCompilerWithPandoc state options f = cached "pageCompilerWithPandoc" $     readPageCompiler >>> addDefaultFields >>> arr applySelf-                     >>> pageRenderPandocWith state options+                     >>> pageReadPandocWith state+                     >>> arr (fmap (writePandocWith options . f))  -- | Add a number of default metadata fields to a page. These fields include: --
+ src/Hakyll/Web/Preview/Poll.hs view
@@ -0,0 +1,34 @@+-- | Interval-based implementation of preview polling+--+module Hakyll.Web.Preview.Poll+    ( previewPoll+    ) where++import Control.Applicative ((<$>))+import Control.Concurrent (threadDelay)+import Control.Monad (filterM)+import System.Time (getClockTime)+import System.Directory (getModificationTime, doesFileExist)++import Hakyll.Core.Configuration++-- | A preview thread that periodically recompiles the site.+--+previewPoll :: HakyllConfiguration  -- ^ Configuration+            -> IO [FilePath]        -- ^ Updating action+            -> IO ()                -- ^ Can block forever+previewPoll _ update = do+    time <- getClockTime+    loop time =<< update+  where+    delay = 1000000+    loop time files = do+        threadDelay delay+        files' <- filterM doesFileExist files+        filesTime <- case files' of+            []  -> return time+            _   -> maximum <$> mapM getModificationTime files'++        if filesTime > time || files' /= files+            then loop filesTime =<< update+            else loop time files'