From 7afabf5c098efc2f0df482ab66d9091d7aa3bd23 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 31 Jan 2010 11:19:57 +0100 Subject: Better naming scheme. --- src/Text/Hakyll/Internal/CompressCSS.hs | 36 --------------------------------- src/Text/Hakyll/Internal/CompressCss.hs | 36 +++++++++++++++++++++++++++++++++ src/Text/Hakyll/Internal/Render.hs | 2 +- 3 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 src/Text/Hakyll/Internal/CompressCSS.hs create mode 100644 src/Text/Hakyll/Internal/CompressCss.hs (limited to 'src/Text/Hakyll/Internal') diff --git a/src/Text/Hakyll/Internal/CompressCSS.hs b/src/Text/Hakyll/Internal/CompressCSS.hs deleted file mode 100644 index 7d52bef..0000000 --- a/src/Text/Hakyll/Internal/CompressCSS.hs +++ /dev/null @@ -1,36 +0,0 @@ --- | Module used for CSS compression. The compression is currently in a simple --- state, but would typically reduce the number of bytes by about 25%. -module Text.Hakyll.Internal.CompressCSS - ( compressCSS - ) where - -import Data.List (isPrefixOf) - -import Text.Hakyll.Regex (substituteRegex) - --- | Compress CSS to speed up your site. -compressCSS :: String -> String -compressCSS = compressSeparators - . stripComments - . compressWhitespace - --- | Compresses certain forms of separators. -compressSeparators :: String -> String -compressSeparators = substituteRegex "; *}" "}" - . substituteRegex " *([{};:]) *" "\\1" - . substituteRegex ";;*" ";" - --- | Compresses all whitespace. -compressWhitespace :: String -> String -compressWhitespace = substituteRegex "[ \t\n][ \t\n]*" " " - --- | Function that strips CSS comments away. -stripComments :: String -> String -stripComments [] = [] -stripComments str - | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str - | otherwise = head str : stripComments (tail str) - where - eatComments str' | null str' = [] - | isPrefixOf "*/" str' = drop 2 str' - | otherwise = eatComments $ tail str' diff --git a/src/Text/Hakyll/Internal/CompressCss.hs b/src/Text/Hakyll/Internal/CompressCss.hs new file mode 100644 index 0000000..4b19984 --- /dev/null +++ b/src/Text/Hakyll/Internal/CompressCss.hs @@ -0,0 +1,36 @@ +-- | Module used for CSS compression. The compression is currently in a simple +-- state, but would typically reduce the number of bytes by about 25%. +module Text.Hakyll.Internal.CompressCss + ( compressCss + ) where + +import Data.List (isPrefixOf) + +import Text.Hakyll.Regex (substituteRegex) + +-- | Compress CSS to speed up your site. +compressCss :: String -> String +compressCss = compressSeparators + . stripComments + . compressWhitespace + +-- | Compresses certain forms of separators. +compressSeparators :: String -> String +compressSeparators = substituteRegex "; *}" "}" + . substituteRegex " *([{};:]) *" "\\1" + . substituteRegex ";;*" ";" + +-- | Compresses all whitespace. +compressWhitespace :: String -> String +compressWhitespace = substituteRegex "[ \t\n][ \t\n]*" " " + +-- | Function that strips CSS comments away. +stripComments :: String -> String +stripComments [] = [] +stripComments str + | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str + | otherwise = head str : stripComments (tail str) + where + eatComments str' | null str' = [] + | isPrefixOf "*/" str' = drop 2 str' + | otherwise = eatComments $ tail str' diff --git a/src/Text/Hakyll/Internal/Render.hs b/src/Text/Hakyll/Internal/Render.hs index a3d2d9b..167c58a 100644 --- a/src/Text/Hakyll/Internal/Render.hs +++ b/src/Text/Hakyll/Internal/Render.hs @@ -65,4 +65,4 @@ writePage page = do liftIO $ writeFile destination $ finalSubstitute (fromString $ getBody page) context where - url = getURL page + url = getUrl page -- cgit v1.2.3