diff options
| author | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-02-14 10:08:21 +0100 |
|---|---|---|
| committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-02-14 10:08:21 +0100 |
| commit | 61dcb5f454fcbd912b09839021f4c79ca60973fe (patch) | |
| tree | 37b39b20bc3f5325d2c13939c03ce286162eb354 /src/Hakyll/Web | |
| parent | 2912fcd521d0d9fbe93dae37783f5f379893ddb1 (diff) | |
| parent | 02a92d54cdee8299aac0f55cbe4a930ac5060d20 (diff) | |
| download | hakyll-61dcb5f454fcbd912b09839021f4c79ca60973fe.tar.gz | |
Merge branch 'master' into dev-metadata-route
Diffstat (limited to 'src/Hakyll/Web')
| -rw-r--r-- | src/Hakyll/Web/Pandoc/FileType.hs | 46 | ||||
| -rw-r--r-- | src/Hakyll/Web/Tags.hs | 13 | ||||
| -rw-r--r-- | src/Hakyll/Web/Template/Context.hs | 3 |
3 files changed, 31 insertions, 31 deletions
diff --git a/src/Hakyll/Web/Pandoc/FileType.hs b/src/Hakyll/Web/Pandoc/FileType.hs index 1ae4c10..46c8e24 100644 --- a/src/Hakyll/Web/Pandoc/FileType.hs +++ b/src/Hakyll/Web/Pandoc/FileType.hs @@ -8,7 +8,7 @@ module Hakyll.Web.Pandoc.FileType -------------------------------------------------------------------------------- -import System.FilePath (takeExtension) +import System.FilePath (splitExtension) -------------------------------------------------------------------------------- @@ -36,27 +36,31 @@ data FileType -------------------------------------------------------------------------------- -- | Get the file type for a certain file. The type is determined by extension. fileType :: FilePath -> FileType -fileType = fileType' . takeExtension +fileType = uncurry fileType' . splitExtension where - fileType' ".css" = Css - fileType' ".htm" = Html - fileType' ".html" = Html - fileType' ".lhs" = LiterateHaskell Markdown - fileType' ".markdown" = Markdown - fileType' ".md" = Markdown - fileType' ".mdn" = Markdown - fileType' ".mdown" = Markdown - fileType' ".mdwn" = Markdown - fileType' ".mkd" = Markdown - fileType' ".mkdwn" = Markdown - fileType' ".org" = OrgMode - fileType' ".page" = Markdown - fileType' ".rst" = Rst - fileType' ".tex" = LaTeX - fileType' ".text" = PlainText - fileType' ".textile" = Textile - fileType' ".txt" = PlainText - fileType' _ = Binary -- Treat unknown files as binary + fileType' _ ".css" = Css + fileType' _ ".htm" = Html + fileType' _ ".html" = Html + fileType' f ".lhs" = LiterateHaskell $ case fileType f of + -- If no extension is given, default to Markdown + LiterateHaskell + Binary -> Markdown + -- Otherwise, LaTeX + LiterateHaskell or whatever the user specified + x -> x + fileType' _ ".markdown" = Markdown + fileType' _ ".md" = Markdown + fileType' _ ".mdn" = Markdown + fileType' _ ".mdown" = Markdown + fileType' _ ".mdwn" = Markdown + fileType' _ ".mkd" = Markdown + fileType' _ ".mkdwn" = Markdown + fileType' _ ".org" = OrgMode + fileType' _ ".page" = Markdown + fileType' _ ".rst" = Rst + fileType' _ ".tex" = LaTeX + fileType' _ ".text" = PlainText + fileType' _ ".textile" = Textile + fileType' _ ".txt" = PlainText + fileType' _ _ = Binary -- Treat unknown files as binary -------------------------------------------------------------------------------- diff --git a/src/Hakyll/Web/Tags.hs b/src/Hakyll/Web/Tags.hs index 4566db6..fe99e3c 100644 --- a/src/Hakyll/Web/Tags.hs +++ b/src/Hakyll/Web/Tags.hs @@ -41,12 +41,13 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} module Hakyll.Web.Tags - ( Tags + ( Tags (..) , getTags , buildTagsWith , buildTags , buildCategories , tagsRules + , renderTags , renderTagCloud , renderTagList , tagsField @@ -149,7 +150,7 @@ tagsRules tags rules = -------------------------------------------------------------------------------- --- | Render tags in HTML +-- | Render tags in HTML (the flexible higher-order function) renderTags :: (String -> String -> Int -> Int -> Int -> String) -- ^ Produce a tag item: tag, url, count, min count, max count -> ([String] -> String) @@ -218,13 +219,9 @@ renderTagList = renderTags makeLink (intercalate ", ") -------------------------------------------------------------------------------- --- | Render tags with links with custom function to get tags. It is typically --- together with 'getTags' like this: --- --- > renderTagsFieldWith (customFunction . getTags) --- > "tags" (fromCapture "tags/*") +-- | Render tags with links with custom function to get tags tagsFieldWith :: (Identifier -> Compiler [String]) -- ^ Get the tags - -> String -- ^ Destination key + -> String -- ^ Destination field -> Tags -- ^ Tags structure -> Context a -- ^ Resulting context tagsFieldWith getTags' key tags = field key $ \item -> do diff --git a/src/Hakyll/Web/Template/Context.hs b/src/Hakyll/Web/Template/Context.hs index fcb527a..8aab989 100644 --- a/src/Hakyll/Web/Template/Context.hs +++ b/src/Hakyll/Web/Template/Context.hs @@ -207,8 +207,7 @@ modificationTimeFieldWith :: TimeLocale -- ^ Time output locale -> Context a -- ^ Resulting context modificationTimeFieldWith locale key fmt = field key $ \i -> do provider <- compilerProvider <$> compilerAsk - mtime <- compilerUnsafeIO $ - resourceModificationTime provider $ itemIdentifier i + let mtime = resourceModificationTime provider $ itemIdentifier i return $ formatTime locale fmt mtime |
