packages feed

hakyll 3.2.0.5 → 3.2.0.6

raw patch · 11 files changed

+119/−115 lines, 11 filesdep +cryptohashdep −hopenssl

Dependencies added: cryptohash

Dependencies removed: hopenssl

Files

data/templates/atom-item.xml view
@@ -2,6 +2,6 @@     <title>$title$</title>     <link href="$root$$url$" />     <id>$root$$url$</id>-    <updated>$timestamp$</updated>+    <published>$timestamp$</published>     <summary type="html"><![CDATA[$description$]]></summary> </entry>
hakyll.cabal view
@@ -1,5 +1,5 @@ Name:    hakyll-Version: 3.2.0.5+Version: 3.2.0.6  Synopsis: A static website compiler library Description:@@ -64,10 +64,10 @@     blaze-html  >= 0.4   && < 0.6,     bytestring  >= 0.9   && < 1.0,     containers  >= 0.3   && < 1.0,+    cryptohash  >= 0.7   && < 0.8,     directory   >= 1.0   && < 1.3,     filepath    >= 1.0   && < 2.0,     hamlet      >= 0.7   && < 0.9,-    hopenssl    >= 1.4   && < 1.7,     mtl         >= 1     && < 3.0,     old-locale  >= 1.0   && < 2.0,     old-time    >= 1.0   && < 1.3,@@ -115,12 +115,12 @@     Hakyll.Web.Page.Read     Hakyll.Web.Pandoc     Hakyll.Web.Pandoc.FileType-    Hakyll.Web.RelativizeUrls     Hakyll.Web.Tags     Hakyll.Web.Template     Hakyll.Web.Template.Read+    Hakyll.Web.Urls+    Hakyll.Web.Urls.Relativize     Hakyll.Web.Util.Html-    Hakyll.Web.Util.Url    Other-Modules:     Hakyll.Core.Compiler.Internal
src/Hakyll.hs view
@@ -26,11 +26,11 @@     , module Hakyll.Web.Page.Read     , module Hakyll.Web.Pandoc     , module Hakyll.Web.Pandoc.FileType-    , module Hakyll.Web.RelativizeUrls+    , module Hakyll.Web.Urls+    , module Hakyll.Web.Urls.Relativize     , module Hakyll.Web.Tags     , module Hakyll.Web.Template     , module Hakyll.Web.Util.Html-    , module Hakyll.Web.Util.Url     ) where  import Hakyll.Core.Compiler@@ -58,8 +58,8 @@ import Hakyll.Web.Page.Read import Hakyll.Web.Pandoc import Hakyll.Web.Pandoc.FileType-import Hakyll.Web.RelativizeUrls+import Hakyll.Web.Urls+import Hakyll.Web.Urls.Relativize import Hakyll.Web.Tags import Hakyll.Web.Template import Hakyll.Web.Util.Html-import Hakyll.Web.Util.Url
src/Hakyll/Core/Resource/Provider.hs view
@@ -20,14 +20,12 @@  import Control.Applicative ((<$>)) import Control.Concurrent (MVar, readMVar, modifyMVar_, newMVar)-import Control.Monad ((<=<))-import Data.Word (Word8) import Data.Map (Map) import qualified Data.Map as M +import qualified Crypto.Hash.MD5 as MD5+import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as LB-import OpenSSL.Digest.ByteString.Lazy (digest)-import OpenSSL.Digest (MessageDigest (MD5))  import Hakyll.Core.Store import Hakyll.Core.Resource@@ -60,8 +58,8 @@  -- | Retrieve a digest for a given resource ---resourceDigest :: ResourceProvider -> Resource -> IO [Word8]-resourceDigest provider = digest MD5 <=< resourceLBS provider+resourceDigest :: ResourceProvider -> Resource -> IO B.ByteString+resourceDigest provider = fmap MD5.hashlazy . resourceLBS provider  -- | Check if a resource was modified --
src/Hakyll/Web/Feed.hs view
@@ -33,7 +33,7 @@ import Hakyll.Web.Page.Metadata import Hakyll.Web.Template import Hakyll.Web.Template.Read.Hakyll (readTemplate)-import Hakyll.Web.Util.Url+import Hakyll.Web.Urls  import Paths_hakyll 
src/Hakyll/Web/Page.hs view
@@ -78,7 +78,7 @@ import Hakyll.Web.Page.Metadata import Hakyll.Web.Pandoc import Hakyll.Web.Template-import Hakyll.Web.Util.Url+import Hakyll.Web.Urls  -- | Create a page from a body, without metadata --
− src/Hakyll/Web/RelativizeUrls.hs
@@ -1,62 +0,0 @@--- | This module exposes a function which can relativize URL's on a webpage.------ This means that one can deploy the resulting site on--- @http:\/\/example.com\/@, but also on @http:\/\/example.com\/some-folder\/@--- without having to change anything (simply copy over the files).------ To use it, you should use absolute URL's from the site root everywhere. For--- example, use------ > <img src="/images/lolcat.png" alt="Funny zomgroflcopter" />------ in a blogpost. When running this through the relativize URL's module, this--- will result in (suppose your blogpost is located at @\/posts\/foo.html@:------ > <img src="../images/lolcat.png" alt="Funny zomgroflcopter" />----module Hakyll.Web.RelativizeUrls-    ( relativizeUrlsCompiler-    , relativizeUrls-    ) where--import Prelude hiding (id)-import Control.Category (id)-import Control.Arrow ((&&&), (>>^))-import Data.List (isPrefixOf)-import qualified Data.Set as S--import Text.HTML.TagSoup--import Hakyll.Core.Compiler-import Hakyll.Web.Page-import Hakyll.Web.Util.Url---- | Compiler form of 'relativizeUrls' which automatically picks the right root--- path----relativizeUrlsCompiler :: Compiler (Page String) (Page String)-relativizeUrlsCompiler = getRoute &&& id >>^ uncurry relativize-  where-    relativize Nothing = id-    relativize (Just r) = fmap (relativizeUrls $ toSiteRoot r)---- | Relativize URL's in HTML----relativizeUrls :: String  -- ^ Path to the site root-               -> String  -- ^ HTML to relativize-               -> String  -- ^ Resulting HTML-relativizeUrls root = renderTags . map relativizeUrls' . parseTags-  where-    relativizeUrls' (TagOpen s a) = TagOpen s $ map (relativizeUrlsAttrs root) a-    relativizeUrls' x = x---- | Relativize URL's in attributes----relativizeUrlsAttrs :: String            -- ^ Path to the site root-                    -> Attribute String  -- ^ Attribute to relativize-                    -> Attribute String  -- ^ Resulting attribute-relativizeUrlsAttrs root (key, value)-    | key `S.member` urls && "/" `isPrefixOf` value = (key, root ++ value)-    | otherwise = (key, value)-  where-    urls = S.fromList ["src", "href"]
src/Hakyll/Web/Tags.hs view
@@ -55,7 +55,7 @@  import Hakyll.Web.Page import Hakyll.Web.Page.Metadata-import Hakyll.Web.Util.Url+import Hakyll.Web.Urls import Hakyll.Core.Writable import Hakyll.Core.Identifier import Hakyll.Core.Compiler
+ src/Hakyll/Web/Urls.hs view
@@ -0,0 +1,56 @@+-- | Provides utilities to manipulate URL's+--+module Hakyll.Web.Urls+    ( withUrls+    , toUrl+    , toSiteRoot+    , isExternal+    ) where++import Data.List (isPrefixOf)+import System.FilePath (splitPath, takeDirectory, joinPath)+import qualified Data.Set as S++import Text.HTML.TagSoup (Tag (..), renderTags, parseTags)++-- | Apply a function to each URL on a webpage+--+withUrls :: (String -> String) -> String -> String+withUrls f = renderTags . map tag . parseTags+  where+    tag (TagOpen s a) = TagOpen s $ map attr a+    tag x = x+    attr (k, v) = (k, if k `S.member` refs then f v else v)+    refs = S.fromList ["src", "href"]++-- | Convert a filepath to an URL starting from the site root+--+-- Example:+--+-- > toUrl "foo/bar.html"+--+-- Result:+--+-- > "/foo/bar.html"+--+toUrl :: FilePath -> String+toUrl ('/' : xs) = '/' : xs+toUrl url        = '/' : url++-- | Get the relative url to the site root, for a given (absolute) url+--+toSiteRoot :: String -> String+toSiteRoot = emptyException . joinPath . map parent+           . filter relevant . splitPath . takeDirectory+  where+    parent = const ".."+    emptyException [] = "."+    emptyException x  = x+    relevant "." = False+    relevant "/" = False+    relevant _   = True++-- | Check if an URL links to an external HTTP(S) source+--+isExternal :: String -> Bool+isExternal url = any (flip isPrefixOf url) ["http://", "https://"]
+ src/Hakyll/Web/Urls/Relativize.hs view
@@ -0,0 +1,47 @@+-- | This module exposes a function which can relativize URL's on a webpage.+--+-- This means that one can deploy the resulting site on+-- @http:\/\/example.com\/@, but also on @http:\/\/example.com\/some-folder\/@+-- without having to change anything (simply copy over the files).+--+-- To use it, you should use absolute URL's from the site root everywhere. For+-- example, use+--+-- > <img src="/images/lolcat.png" alt="Funny zomgroflcopter" />+--+-- in a blogpost. When running this through the relativize URL's module, this+-- will result in (suppose your blogpost is located at @\/posts\/foo.html@:+--+-- > <img src="../images/lolcat.png" alt="Funny zomgroflcopter" />+--+module Hakyll.Web.Urls.Relativize+    ( relativizeUrlsCompiler+    , relativizeUrls+    ) where++import Prelude hiding (id)+import Control.Category (id)+import Control.Arrow ((&&&), (>>^))+import Data.List (isPrefixOf)++import Hakyll.Core.Compiler+import Hakyll.Web.Page+import Hakyll.Web.Urls++-- | Compiler form of 'relativizeUrls' which automatically picks the right root+-- path+--+relativizeUrlsCompiler :: Compiler (Page String) (Page String)+relativizeUrlsCompiler = getRoute &&& id >>^ uncurry relativize+  where+    relativize Nothing = id+    relativize (Just r) = fmap (relativizeUrls $ toSiteRoot r)++-- | Relativize URL's in HTML+--+relativizeUrls :: String  -- ^ Path to the site root+               -> String  -- ^ HTML to relativize+               -> String  -- ^ Resulting HTML+relativizeUrls root = withUrls rel+  where+    rel x = if "/" `isPrefixOf` x then root ++ x else x
− src/Hakyll/Web/Util/Url.hs
@@ -1,35 +0,0 @@--- | Miscellaneous URL manipulation functions.----module Hakyll.Web.Util.Url-    ( toUrl-    , toSiteRoot-    ) where--import System.FilePath (splitPath, takeDirectory, joinPath)---- | Convert a filepath to an URL starting from the site root------ Example:------ > toUrl "foo/bar.html"------ Result:------ > "/foo/bar.html"----toUrl :: FilePath -> String-toUrl ('/' : xs) = '/' : xs-toUrl url        = '/' : url---- | Get the relative url to the site root, for a given (absolute) url----toSiteRoot :: String -> String-toSiteRoot = emptyException . joinPath . map parent-           . filter relevant . splitPath . takeDirectory-  where-    parent = const ".."-    emptyException [] = "."-    emptyException x  = x-    relevant "." = False-    relevant "/" = False-    relevant _   = True