summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-28 22:33:28 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-28 22:33:28 +0100
commit49989eab5767b24cb3e917b95137ae05566e34a8 (patch)
tree30a7cde43237c89660511129106ac0b5c87504ac /src
parentc355b047db5dfb479c83c13474f02cb83fe83e96 (diff)
downloadhakyll-49989eab5767b24cb3e917b95137ae05566e34a8.tar.gz
Web.Util.String → {Web.Util.Url, Core.Util.String}
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll.hs6
-rw-r--r--src/Hakyll/Core/Util/String.hs (renamed from src/Hakyll/Web/Util/String.hs)27
-rw-r--r--src/Hakyll/Web/CompressCss.hs2
-rw-r--r--src/Hakyll/Web/Feed.hs2
-rw-r--r--src/Hakyll/Web/Page.hs2
-rw-r--r--src/Hakyll/Web/Page/Metadata.hs2
-rw-r--r--src/Hakyll/Web/Page/Read.hs2
-rw-r--r--src/Hakyll/Web/Preview/Server.hs2
-rw-r--r--src/Hakyll/Web/RelativizeUrls.hs2
-rw-r--r--src/Hakyll/Web/Tags.hs3
-rw-r--r--src/Hakyll/Web/Util/Url.hs30
11 files changed, 44 insertions, 36 deletions
diff --git a/src/Hakyll.hs b/src/Hakyll.hs
index 9a17479..0261044 100644
--- a/src/Hakyll.hs
+++ b/src/Hakyll.hs
@@ -12,6 +12,7 @@ module Hakyll
, module Hakyll.Core.UnixFilter
, module Hakyll.Core.Util.Arrow
, module Hakyll.Core.Util.File
+ , module Hakyll.Core.Util.String
, module Hakyll.Core.Writable
, module Hakyll.Main
, module Hakyll.Web.CompressCss
@@ -24,7 +25,7 @@ module Hakyll
, module Hakyll.Web.RelativizeUrls
, module Hakyll.Web.Tags
, module Hakyll.Web.Template
- , module Hakyll.Web.Util.String
+ , module Hakyll.Web.Util.Url
) where
import Hakyll.Core.Compiler
@@ -38,6 +39,7 @@ import Hakyll.Core.Rules
import Hakyll.Core.UnixFilter
import Hakyll.Core.Util.Arrow
import Hakyll.Core.Util.File
+import Hakyll.Core.Util.String
import Hakyll.Core.Writable
import Hakyll.Main
import Hakyll.Web.CompressCss
@@ -50,4 +52,4 @@ import Hakyll.Web.Pandoc
import Hakyll.Web.RelativizeUrls
import Hakyll.Web.Tags
import Hakyll.Web.Template
-import Hakyll.Web.Util.String
+import Hakyll.Web.Util.Url
diff --git a/src/Hakyll/Web/Util/String.hs b/src/Hakyll/Core/Util/String.hs
index 0dde74a..7f75a36 100644
--- a/src/Hakyll/Web/Util/String.hs
+++ b/src/Hakyll/Core/Util/String.hs
@@ -1,17 +1,14 @@
-- | Miscellaneous string manipulation functions.
--
-module Hakyll.Web.Util.String
+module Hakyll.Core.Util.String
( trim
, replaceAll
, splitAll
- , toUrl
- , toSiteRoot
) where
import Data.Char (isSpace)
import Data.Maybe (listToMaybe)
-import System.FilePath (splitPath, takeDirectory, joinPath)
import Text.Regex.PCRE ((=~~))
-- | Trim a string (drop spaces, tabs and newlines at both sides).
@@ -49,25 +46,3 @@ splitAll pattern = filter (not . null) . splitAll'
Just (o, l) ->
let (before, tmp) = splitAt o src
in before : splitAll' (drop l tmp)
-
--- | Convert a filepath to an URL starting from the site root
---
--- Example:
---
--- > toUrl "foo/bar.html"
---
--- Result:
---
--- > "/foo/bar.html"
---
-toUrl :: FilePath -> String
-toUrl = ('/' :)
-
--- | Get the relative url to the site root, for a given (absolute) url
---
-toSiteRoot :: String -> String
-toSiteRoot = emptyException . joinPath . map parent . splitPath . takeDirectory
- where
- parent = const ".."
- emptyException [] = "."
- emptyException x = x
diff --git a/src/Hakyll/Web/CompressCss.hs b/src/Hakyll/Web/CompressCss.hs
index 94ba9a9..2df08fd 100644
--- a/src/Hakyll/Web/CompressCss.hs
+++ b/src/Hakyll/Web/CompressCss.hs
@@ -12,7 +12,7 @@ import Control.Arrow ((>>^))
import Hakyll.Core.Compiler
import Hakyll.Core.ResourceProvider
-import Hakyll.Web.Util.String
+import Hakyll.Core.Util.String
-- | Compiler form of 'compressCss'
--
diff --git a/src/Hakyll/Web/Feed.hs b/src/Hakyll/Web/Feed.hs
index d91a60f..85674c6 100644
--- a/src/Hakyll/Web/Feed.hs
+++ b/src/Hakyll/Web/Feed.hs
@@ -33,7 +33,7 @@ import Hakyll.Web.Page
import Hakyll.Web.Page.Metadata
import Hakyll.Web.Template
import Hakyll.Web.Template.Read.Hakyll (readTemplate)
-import Hakyll.Web.Util.String
+import Hakyll.Web.Util.Url
import Paths_hakyll
diff --git a/src/Hakyll/Web/Page.hs b/src/Hakyll/Web/Page.hs
index 8a16ef8..955e1a8 100644
--- a/src/Hakyll/Web/Page.hs
+++ b/src/Hakyll/Web/Page.hs
@@ -73,7 +73,7 @@ import Hakyll.Web.Page.Read
import Hakyll.Web.Page.Metadata
import Hakyll.Web.Pandoc
import Hakyll.Web.Template
-import Hakyll.Web.Util.String
+import Hakyll.Web.Util.Url
-- | Create a page from a body, without metadata
--
diff --git a/src/Hakyll/Web/Page/Metadata.hs b/src/Hakyll/Web/Page/Metadata.hs
index 23d98a4..72742e6 100644
--- a/src/Hakyll/Web/Page/Metadata.hs
+++ b/src/Hakyll/Web/Page/Metadata.hs
@@ -24,7 +24,7 @@ import System.FilePath (takeFileName)
import System.Locale (TimeLocale, defaultTimeLocale)
import Hakyll.Web.Page.Internal
-import Hakyll.Web.Util.String
+import Hakyll.Core.Util.String
-- | Get a metadata field. If the field does not exist, the empty string is
-- returned.
diff --git a/src/Hakyll/Web/Page/Read.hs b/src/Hakyll/Web/Page/Read.hs
index d72f32a..cf39ddd 100644
--- a/src/Hakyll/Web/Page/Read.hs
+++ b/src/Hakyll/Web/Page/Read.hs
@@ -12,7 +12,7 @@ import Data.Map (Map)
import qualified Data.Map as M
import Hakyll.Web.Page.Internal
-import Hakyll.Web.Util.String
+import Hakyll.Core.Util.String
-- | We're using a simple state monad as parser
--
diff --git a/src/Hakyll/Web/Preview/Server.hs b/src/Hakyll/Web/Preview/Server.hs
index 77b3cb0..c550b69 100644
--- a/src/Hakyll/Web/Preview/Server.hs
+++ b/src/Hakyll/Web/Preview/Server.hs
@@ -18,7 +18,7 @@ import Snap.Http.Server ( httpServe, setAccessLog, setErrorLog, addListen
, ConfigListen (..), emptyConfig
)
-import Hakyll.Web.Util.String (replaceAll)
+import Hakyll.Core.Util.String (replaceAll)
-- | The first file in the list that actually exists is returned
--
diff --git a/src/Hakyll/Web/RelativizeUrls.hs b/src/Hakyll/Web/RelativizeUrls.hs
index 1df4fea..2de4a0e 100644
--- a/src/Hakyll/Web/RelativizeUrls.hs
+++ b/src/Hakyll/Web/RelativizeUrls.hs
@@ -29,7 +29,7 @@ import Text.HTML.TagSoup
import Hakyll.Core.Compiler
import Hakyll.Web.Page
-import Hakyll.Web.Util.String
+import Hakyll.Web.Util.Url
-- | Compiler form of 'compressCss' which automatically picks the right root
-- path
diff --git a/src/Hakyll/Web/Tags.hs b/src/Hakyll/Web/Tags.hs
index 77dc440..211a06b 100644
--- a/src/Hakyll/Web/Tags.hs
+++ b/src/Hakyll/Web/Tags.hs
@@ -55,10 +55,11 @@ import qualified Text.Blaze.Html5.Attributes as A
import Hakyll.Web.Page
import Hakyll.Web.Page.Metadata
-import Hakyll.Web.Util.String
+import Hakyll.Web.Util.Url
import Hakyll.Core.Writable
import Hakyll.Core.Identifier
import Hakyll.Core.Compiler
+import Hakyll.Core.Util.String
-- | Data about tags
--
diff --git a/src/Hakyll/Web/Util/Url.hs b/src/Hakyll/Web/Util/Url.hs
new file mode 100644
index 0000000..54a361e
--- /dev/null
+++ b/src/Hakyll/Web/Util/Url.hs
@@ -0,0 +1,30 @@
+-- | 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 = ('/' :)
+
+-- | Get the relative url to the site root, for a given (absolute) url
+--
+toSiteRoot :: String -> String
+toSiteRoot = emptyException . joinPath . map parent . splitPath . takeDirectory
+ where
+ parent = const ".."
+ emptyException [] = "."
+ emptyException x = x