diff options
Diffstat (limited to 'src/Hakyll/Web')
-rw-r--r-- | src/Hakyll/Web/Pandoc/Biblio.hs | 17 | ||||
-rw-r--r-- | src/Hakyll/Web/Tags.hs | 12 | ||||
-rw-r--r-- | src/Hakyll/Web/Template/Context.hs | 10 |
3 files changed, 17 insertions, 22 deletions
diff --git a/src/Hakyll/Web/Pandoc/Biblio.hs b/src/Hakyll/Web/Pandoc/Biblio.hs index 53e3419..dfe6d93 100644 --- a/src/Hakyll/Web/Pandoc/Biblio.hs +++ b/src/Hakyll/Web/Pandoc/Biblio.hs @@ -23,22 +23,19 @@ module Hakyll.Web.Pandoc.Biblio -------------------------------------------------------------------------------- -import Control.Applicative ((<$>)) -import Control.Monad (replicateM, liftM) -import Data.Binary (Binary (..)) -import Data.Default (def) -import Data.Typeable (Typeable) -import qualified Text.CSL as CSL -import Text.CSL.Pandoc (processCites) -import Text.Pandoc (Pandoc, ReaderOptions (..)) - --------------------------------------------------------------------------------- +import Control.Monad (liftM, replicateM) +import Data.Binary (Binary (..)) +import Data.Default (def) +import Data.Typeable (Typeable) import Hakyll.Core.Compiler import Hakyll.Core.Identifier import Hakyll.Core.Item import Hakyll.Core.Writable import Hakyll.Web.Pandoc import Hakyll.Web.Pandoc.Binary () +import qualified Text.CSL as CSL +import Text.CSL.Pandoc (processCites) +import Text.Pandoc (Pandoc, ReaderOptions (..)) -------------------------------------------------------------------------------- diff --git a/src/Hakyll/Web/Tags.hs b/src/Hakyll/Web/Tags.hs index 0887856..b5b44fc 100644 --- a/src/Hakyll/Web/Tags.hs +++ b/src/Hakyll/Web/Tags.hs @@ -63,13 +63,12 @@ module Hakyll.Web.Tags -------------------------------------------------------------------------------- import Control.Arrow ((&&&)) -import Control.Monad (foldM, forM, forM_) +import Control.Monad (foldM, forM, forM_, mplus) import Data.Char (toLower) import Data.List (intercalate, intersperse, sortBy) import qualified Data.Map as M import Data.Maybe (catMaybes, fromMaybe) -import Data.Monoid (mconcat) import Data.Ord (comparing) import qualified Data.Set as S import System.FilePath (takeBaseName, takeDirectory) @@ -88,8 +87,8 @@ import Hakyll.Core.Item import Hakyll.Core.Metadata import Hakyll.Core.Rules import Hakyll.Core.Util.String -import Hakyll.Web.Template.Context import Hakyll.Web.Html +import Hakyll.Web.Template.Context -------------------------------------------------------------------------------- @@ -103,11 +102,14 @@ data Tags = Tags -------------------------------------------------------------------------------- -- | Obtain tags from a page in the default way: parse them from the @tags@ --- metadata field. +-- metadata field. This can either be a list or a comma-separated string. getTags :: MonadMetadata m => Identifier -> m [String] getTags identifier = do metadata <- getMetadata identifier - return $ maybe [] (map trim . splitAll ",") $ M.lookup "tags" metadata + return $ fromMaybe [] $ + (lookupStringList "tags" metadata) `mplus` + (map trim . splitAll "," <$> lookupString "tags" metadata) + -------------------------------------------------------------------------------- -- | Obtain categories from a page. diff --git a/src/Hakyll/Web/Template/Context.hs b/src/Hakyll/Web/Template/Context.hs index 6879187..efe808a 100644 --- a/src/Hakyll/Web/Template/Context.hs +++ b/src/Hakyll/Web/Template/Context.hs @@ -31,18 +31,13 @@ module Hakyll.Web.Template.Context -------------------------------------------------------------------------------- -import Control.Applicative (Alternative (..), pure, (<$>)) +import Control.Applicative (Alternative (..)) import Control.Monad (msum) import Data.List (intercalate) -import qualified Data.Map as M -import Data.Monoid (Monoid (..)) import Data.Time.Clock (UTCTime (..)) import Data.Time.Format (formatTime) import qualified Data.Time.Format as TF import Data.Time.Locale.Compat (TimeLocale, defaultTimeLocale) -import System.FilePath (splitDirectories, takeBaseName) - --------------------------------------------------------------------------------- import Hakyll.Core.Compiler import Hakyll.Core.Compiler.Internal import Hakyll.Core.Identifier @@ -51,6 +46,7 @@ import Hakyll.Core.Metadata import Hakyll.Core.Provider import Hakyll.Core.Util.String (needlePrefix, splitAll) import Hakyll.Web.Html +import System.FilePath (splitDirectories, takeBaseName) -------------------------------------------------------------------------------- @@ -274,7 +270,7 @@ getItemUTC :: MonadMetadata m -> m UTCTime -- ^ Parsed UTCTime getItemUTC locale id' = do metadata <- getMetadata id' - let tryField k fmt = M.lookup k metadata >>= parseTime' fmt + let tryField k fmt = lookupString k metadata >>= parseTime' fmt paths = splitDirectories $ toFilePath id' maybe empty' return $ msum $ |