diff options
| -rw-r--r-- | src/Hakyll/Core/Compiler.hs | 6 | ||||
| -rw-r--r-- | src/Hakyll/Core/Routes.hs | 34 | ||||
| -rw-r--r-- | src/Hakyll/Core/Runtime.hs | 2 | ||||
| -rw-r--r-- | src/Hakyll/Web/Tags.hs | 2 | ||||
| -rw-r--r-- | web/examples.markdown | 6 | ||||
| -rw-r--r-- | web/tutorials/01-installation.markdown | 15 |
6 files changed, 48 insertions, 17 deletions
diff --git a/src/Hakyll/Core/Compiler.hs b/src/Hakyll/Core/Compiler.hs index a672395..a6814f9 100644 --- a/src/Hakyll/Core/Compiler.hs +++ b/src/Hakyll/Core/Compiler.hs @@ -29,6 +29,7 @@ module Hakyll.Core.Compiler -------------------------------------------------------------------------------- import Control.Applicative ((<$>)) +import Control.Monad (when) import Data.Binary (Binary) import Data.ByteString.Lazy (ByteString) import Data.Typeable (Typeable) @@ -76,8 +77,9 @@ getRoute identifier = do routes <- compilerRoutes <$> compilerAsk -- Note that this makes us dependend on that identifier: when the metadata -- of that item changes, the route may change, hence we have to recompile - compilerTellDependencies [IdentifierDependency identifier] - compilerUnsafeIO $ runRoutes routes provider identifier + (mfp, um) <- compilerUnsafeIO $ runRoutes routes provider identifier + when um $ compilerTellDependencies [IdentifierDependency identifier] + return mfp -------------------------------------------------------------------------------- diff --git a/src/Hakyll/Core/Routes.hs b/src/Hakyll/Core/Routes.hs index fe5fb1f..34a613d 100644 --- a/src/Hakyll/Core/Routes.hs +++ b/src/Hakyll/Core/Routes.hs @@ -27,7 +27,8 @@ -- * If an item matches multiple routes, the first rule will be chosen. {-# LANGUAGE Rank2Types #-} module Hakyll.Core.Routes - ( Routes + ( UsedMetadata + , Routes , runRoutes , idRoute , setExtension @@ -54,23 +55,32 @@ import Hakyll.Core.Util.String -------------------------------------------------------------------------------- +-- | When you ran a route, it's useful to know whether or not this used +-- metadata. This allows us to do more granular dependency analysis. +type UsedMetadata = Bool + + +-------------------------------------------------------------------------------- -- | Type used for a route newtype Routes = Routes - { unRoutes :: Provider -> Identifier -> IO (Maybe FilePath) + { unRoutes :: Provider -> Identifier -> IO (Maybe FilePath, UsedMetadata) } -------------------------------------------------------------------------------- instance Monoid Routes where - mempty = Routes $ \_ _ -> return Nothing + mempty = Routes $ \_ _ -> return (Nothing, False) mappend (Routes f) (Routes g) = Routes $ \p id' -> do - mfp <- f p id' - maybe (g p id') (return . Just) mfp + (mfp, um) <- f p id' + case mfp of + Nothing -> g p id' + Just _ -> return (mfp, um) -------------------------------------------------------------------------------- -- | Apply a route to an identifier -runRoutes :: Routes -> Provider -> Identifier -> IO (Maybe FilePath) +runRoutes :: Routes -> Provider -> Identifier + -> IO (Maybe FilePath, UsedMetadata) runRoutes = unRoutes @@ -109,14 +119,14 @@ setExtension extension = customRoute $ -- otherwise matchRoute :: Pattern -> Routes -> Routes matchRoute pattern (Routes route) = Routes $ \p id' -> - if matches pattern id' then route p id' else return Nothing + if matches pattern id' then route p id' else return (Nothing, False) -------------------------------------------------------------------------------- -- | Create a custom route. This should almost always be used with -- 'matchRoute' customRoute :: (Identifier -> FilePath) -> Routes -customRoute f = Routes $ const $ return . Just . f +customRoute f = Routes $ const $ \id' -> return (Just (f id'), False) -------------------------------------------------------------------------------- @@ -169,5 +179,9 @@ composeRoutes :: Routes -- ^ First route to apply -> Routes -- ^ Second route to apply -> Routes -- ^ Resulting route composeRoutes (Routes f) (Routes g) = Routes $ \p i -> do - mfp <- f p i - maybe (return Nothing) (g p . fromFilePath) mfp + (mfp, um) <- f p i + case mfp of + Nothing -> return (Nothing, um) + Just fp -> do + (mfp', um') <- g p (fromFilePath fp) + return (mfp', um || um') diff --git a/src/Hakyll/Core/Runtime.hs b/src/Hakyll/Core/Runtime.hs index 0e1ceb2..824d11b 100644 --- a/src/Hakyll/Core/Runtime.hs +++ b/src/Hakyll/Core/Runtime.hs @@ -221,7 +221,7 @@ chase trail id' "(you probably want to call makeItem to solve this problem)" -- Write if necessary - mroute <- liftIO $ runRoutes routes provider id' + (mroute, _) <- liftIO $ runRoutes routes provider id' case mroute of Nothing -> return () Just route -> do diff --git a/src/Hakyll/Web/Tags.hs b/src/Hakyll/Web/Tags.hs index bfa83e6..0fa182c 100644 --- a/src/Hakyll/Web/Tags.hs +++ b/src/Hakyll/Web/Tags.hs @@ -16,7 +16,7 @@ -- > its populations have been damaged greatly by Nuclear... -- -- To use categories, use the 'buildCategories' function. Categories are --- determined by the direcetory a page is in, for example, the post +-- determined by the directory a page is in, for example, the post -- -- > posts/coding/2010-01-28-hakyll-categories.markdown -- diff --git a/web/examples.markdown b/web/examples.markdown index 7ec65d1..0014902 100644 --- a/web/examples.markdown +++ b/web/examples.markdown @@ -35,6 +35,12 @@ this list. This list has no particular ordering. [source](https://github.com/irneh/workforpizza) - <http://poleiro.info/>, [source](https://github.com/arthuraa/poleiro) +- <http://www.austinrochford.com/>, + [source](https://github.com/AustinRochford/blog) +- <http://www.regisfoucault.com/>, + [source](https://github.com/regisfoucault/blog) +- <http://www.chaoxuprime.com/>, + [source](https://github.com/Mgccl/blog) - <https://benjeffrey.com/>, [source](https://github.com/jeffbr13/benjeffrey.com) diff --git a/web/tutorials/01-installation.markdown b/web/tutorials/01-installation.markdown index 2066886..fcf9055 100644 --- a/web/tutorials/01-installation.markdown +++ b/web/tutorials/01-installation.markdown @@ -26,15 +26,24 @@ Linux distro packages: Building the example site ------------------------- -Apart from the main Hakyll library, the cabal package also provided you with an +Apart from the main Hakyll library, the cabal package also provides you with an executable `hakyll-init` to create an example site. This is an easy way to get started: $ hakyll-init my-site This creates a folder `my-site` in the current directory, with some example -content and a generic configuration. If `hakyll-init` is not found, you should -make sure `$HOME/.cabal/bin` is in your `$PATH`. +content and a generic configuration. + +If `hakyll-init` is not found, you should make sure `$HOME/.cabal/bin` is in +your `$PATH`. + +(If you're on OS X you may not have a bin directory in `$HOME/.cabal`. In this +case, check `$HOME/Library/Haskell/bin` and put it on your path if you find +`hakyll-init` there. See [here] for more information on installation paths on +OS X.) + +[here]: http://www.haskell.org/haskellwiki/Mac_OS_X_Common_Installation_Paths The file `site.hs` holds the configuration of your site, as an executable haskell program. We can compile and run it like this: |
