Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Replace xhtml-combinators with blaze #21

Merged
merged 1 commit into from Sep 19, 2012
Jump to file or symbol
Failed to load files and symbols.
+12 −8
Split
View
@@ -29,13 +29,13 @@ Executable snap-website
process,
snap >= 0.9 && <0.10,
snap-core >= 0.9 && <0.10,
+ snap-blaze >= 0.2.1 && <0.3,
snap-server >= 0.9 && <0.10,
snap-static-pages >= 0.2 && <0.3,
text,
time,
transformers,
utf8-string,
- xhtml-combinators >= 0.2.2 && < 0.3,
xmlhtml >= 0.1 && < 0.3
ghc-prof-options: -prof -auto-all
View
@@ -20,13 +20,15 @@ import Foreign.C.Types
import Prelude hiding (catch)
import Snap.Http.Server
import Snap.StaticPages
+import Snap.Blaze (blaze)
import Snap.Core
import Snap.Snaplet
import Snap.Snaplet.Heist
import Snap.Util.FileServe
import Snap.Util.GZip
+import Text.Blaze.Html5 (toHtml)
+import qualified Text.Blaze.Html5 as H
import Text.Templating.Heist
-import qualified Text.XHtmlCombinators.Escape as XH
data App = App
{ _heist :: Snaplet (Heist App)
@@ -81,12 +83,14 @@ catch500 :: MonadSnap m => m a -> m ()
catch500 m = (m >> return ()) `catch` \(e::SomeException) -> do
let t = T.pack $ show e
putResponse r
- writeBS "<html><head><title>Internal Server Error</title></head>"
- writeBS "<body><h1>Internal Server Error</h1>"
- writeBS "<p>A web handler threw an exception. Details:</p>"
- writeBS "<pre>\n"
- writeText $ XH.escape t
- writeBS "\n</pre></body></html>"
+ blaze $ do
+ H.docType
+ H.html $ do
+ H.head $ H.title "Internal Server Error"
+ H.body $ do
+ H.h1 "Internal Server Error"
+ H.p "A web handler threw an exception. Details:"
+ H.pre $ "\n" >> (toHtml t) >> "\n"
logError $ B.concat [ "caught exception: ", B.pack $ show e ]
where