Commits

Luke Plant committed 097a83d

Moved IsString instance to Web.GenUtils and sorted out imports

Comments (0)

Files changed (8)

src/Blog/Views.hs

 
 import Web.Request
 import Web.Response
-import Web.Utils
+import Web.Utils (addHtml)
+import Web.GenUtils (utf8)
 import Blog.Templates
 
 standardResponse html = buildResponse [

src/Blog/settingslocal.hs

 module Blog.Settings where
 
 sqlite_path = "/home/luke/httpd/lukeplant.me.uk/web/cgi-bin/data/test1.db"
-root_url = "/blog/"
+root_url = "/testblog/"
 
 -- Testing
 testdb_sqlite_path = "/home/luke/devel/haskell/haskellblog/testsuite/test.db"

src/Web/Framework.hs

 import Data.List (isPrefixOf)
 import Web.Response
 import Web.Request
-import Web.Utils
 import System.IO (stdout, hClose)
 import qualified Data.ByteString.Lazy.Char8 as BS
 

src/Web/GenUtils.hs

 
 where
 
+import Data.ByteString.Lazy.Char8 (ByteString)
+import qualified Data.ByteString.Lazy.UTF8 as UTF8
+
+import GHC.Exts( IsString(..) )
+instance IsString ByteString where
+    fromString = UTF8.fromString
+
+utf8 = UTF8.fromString
 
 -- | Apply a list of transformation functions to an object
 apply :: [a -> a] -- ^ List of functions
-module Web.Utils where
+module Web.Utils ( addHtml
+                 )
 
-import Data.ByteString.Lazy.Char8 (ByteString)
-import qualified Data.ByteString.Lazy.UTF8 as UTF8
+where
+
 import Text.XHtml (renderHtml)
 import Web.Response (addContent)
-
-
-import GHC.Exts( IsString(..) )
-instance IsString ByteString where
-    fromString = UTF8.fromString
-
-utf8 = UTF8.fromString
+import Web.GenUtils (utf8)
 
 -- Utility functions
 addHtml html resp = addContent (utf8 $ renderHtml html) resp

testsuite/tests/Tests/Web/Framework.hs

 import Web.Response
 import Data.Maybe (isNothing, isJust)
 import Control.Monad (liftM, (>=>))
-import Web.Utils
+import Web.GenUtils (utf8)
 
 req1 = mkGetReq "/posts/"
 resp1 = buildResponse [ addContent "resp1" ] utf8HtmlResponse

testsuite/tests/Tests/Web/Request.hs

 
 import Web.Request
 import Test.HUnit
-import Web.Utils
+import Web.GenUtils () -- for IsString instance
 
 testMethod = "GET" ~=? requestMethod (mkRequest [("REQUEST_METHOD","GET")] "" utf8Encoding)
 testPath = "foo/bar" ~=? pathInfo (mkRequest [("PATH_INFO", "/foo/bar")] "" utf8Encoding)

testsuite/tests/Tests/Web/Response.hs

 import Test.HUnit
 import Data.ByteString.Lazy.Char8 (ByteString)
 import qualified Data.ByteString.Lazy.Char8 as BS
-import Web.Utils
 
 testAddContent1 = "“Hello”" ~=? (content $ addContent "“Hello”" $ emptyResponse)