on master help sign in
Merge branch 'master' into type-safe-identifiers
commit01a8ab20d6ee5595da12601754931994865f09e6 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSat 28 May 2011, 10:43 (15 years ago) parent73c93cc6ab5943
4 files changed+1−76
examples/hakyll/tutorial.markdown−10 hakyll.cabal−14 src-inotify/Hakyll/Web/Preview/Poll.hs−50 src-interval/Hakyll/Web/Preview/Poll.hs → src/Hakyll/Web/Preview/Poll.hs+1−2
examples/hakyll/tutorial.markdown−10
@@ -262,16 +262,6 @@ this can generate more traffic than necessary, since it is possible that some
262262files were not actually modified. If you use `rsync`, you can counter this using
263263the `--checksum` option.
264264
265−### Using inotify for the preview server
266−
267−Hakyll is able to use [inotify] to power the preview server. This is generally
268−faster and uses less resources than the default. However, [inotify] is only
269−supported on linux systems. You can enable the bindings using:
270−
271− [jasper@phoenix] cabal install -finotify hakyll
272−
273−[inotify]: http://inotify.aiken.cz/
274−
275265Problems
276266--------
277267
hakyll.cabal−14
@@ -26,24 +26,10 @@ source-repository head
2626 type: git
2727 location: git://github.com/jaspervdj/hakyll.git
2828
29−-- Disabled while inotify is broken with GHC 7. If you're interested in fixing,
30−-- contact me!
31−--
32−-- flag inotify
33−-- description: Use the inotify bindings for the preview server. Better,
34−-- but only works on Linux.
35−-- default: False
36−
3729library
3830 ghc-options: -Wall
3931 hs-source-dirs: src
4032
41− if flag(inotify)
42− hs-source-dirs: src-inotify
43− build-depends: hinotify >= 0.3
44− else
45− hs-source-dirs: src-interval
46−
4733 build-depends: base >= 4 && < 5,
4834 filepath == 1.*,
4935 directory == 1.*,
src-inotify/Hakyll/Web/Preview/Poll.hsdeleted−50
@@ -1,50 +0,0 @@
1−-- | Filesystem polling with an inotify backend. Works only on linux.
2−--
3−module Hakyll.Web.Preview.Poll
4− ( previewPoll
5− ) where
6−
7−import Control.Monad (forM_, when)
8−import Data.Set (Set)
9−import qualified Data.Set as S
10−import System.FilePath (takeDirectory, (</>))
11−import Data.List (isPrefixOf)
12−
13−import System.INotify
14−
15−import Hakyll.Core.Configuration
16−import Hakyll.Core.Resource
17−
18−-- | Calls the given callback when the directory tree changes
19−--
20−previewPoll :: HakyllConfiguration -- ^ Configuration
21− -> Set Resource -- ^ Resources to watch
22− -> IO () -- ^ Action called when something changes
23− -> IO () -- ^ Can block forever
24−previewPoll _ resources callback = do
25− -- Initialize inotify
26− inotify <- initINotify
27−
28− let -- A set of file paths
29− paths = S.map unResource resources
30−
31− -- A list of directories. Run it through a set so we have every
32− -- directory only once.
33− directories = S.toList $ S.map (notEmpty . takeDirectory) paths
34−
35− -- Problem: we can't add a watcher for "". So we make sure a directory
36− -- name is not empty
37− notEmpty "" = "."
38− notEmpty x = x
39−
40− -- Execute the callback when path is known
41− ifResource path =
42− let path' = if "./" `isPrefixOf` path then drop 2 path else path
43− in when (path' `S.member` paths) callback
44−
45− -- Add a watcher for every directory
46− forM_ directories $ \directory -> do
47− _ <- addWatch inotify [Modify] directory $ \e -> case e of
48− (Modified _ (Just p)) -> ifResource $ directory </> p
49− _ -> return ()
50− return ()
src-interval/Hakyll/Web/Preview/Poll.hs → src/Hakyll/Web/Preview/Poll.hsrenamed+1−2
@@ -1,5 +1,4 @@
1−-- | Interval-based implementation of preview polling, for the platforms which
2−-- are not supported by inotify.
1+-- | Interval-based implementation of preview polling
32--
43module Hakyll.Web.Preview.Poll
54 ( previewPoll