From a4c6b30e2c00505835f3406e99245171366ba996 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 31 Oct 2012 13:27:56 -0400 Subject: [PATCH] avoid using Blaze directly New 0.5 changes the api, rather gratuitously, so run away. I can juse use Hamlet here. --- Assistant/Alert.hs | 12 ++++++------ debian/control | 2 -- ...:_type_constructor_or_class___96__Html__39__.mdwn | 4 +++- doc/install/fromscratch.mdwn | 2 -- git-annex.cabal | 2 +- templates/sidebar/alert.hamlet | 6 +++--- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Assistant/Alert.hs b/Assistant/Alert.hs index b73a67b67b..c729e4de42 100644 --- a/Assistant/Alert.hs +++ b/Assistant/Alert.hs @@ -5,7 +5,7 @@ - Licensed under the GNU GPL version 3 or higher. -} -{-# LANGUAGE RankNTypes, OverloadedStrings #-} +{-# LANGUAGE TemplateHaskell, QuasiQuotes, OverloadedStrings #-} module Assistant.Alert where @@ -18,7 +18,7 @@ import qualified Data.Text as T import Data.Text (Text) import qualified Data.Map as M import Data.String -import Text.Blaze +import Yesod {- Different classes of alerts are displayed differently. -} data AlertClass = Success | Message | Activity | Warning | Error @@ -57,16 +57,16 @@ data Alert = Alert data AlertIcon = ActivityIcon | SuccessIcon | ErrorIcon | InfoIcon | TheCloud -htmlIcon :: AlertIcon -> Html +htmlIcon :: AlertIcon -> GWidget sub master () htmlIcon ActivityIcon = bootStrapIcon "refresh" htmlIcon InfoIcon = bootStrapIcon "info-sign" htmlIcon SuccessIcon = bootStrapIcon "ok" htmlIcon ErrorIcon = bootStrapIcon "exclamation-sign" -- utf-8 umbrella (utf-8 cloud looks too stormy) -htmlIcon TheCloud = preEscapedText "☂" +htmlIcon TheCloud = [whamlet|☂|] -bootStrapIcon :: Text -> Html -bootStrapIcon s = preEscapedText $ T.concat [""] +bootStrapIcon :: Text -> GWidget sub master () +bootStrapIcon name = [whamlet||] {- When clicked, a button always redirects to a URL - It may also run an IO action in the background, which is useful diff --git a/debian/control b/debian/control index 24b204ed73..42ea4cb30d 100644 --- a/debian/control +++ b/debian/control @@ -35,8 +35,6 @@ Build-Depends: libghc-wai-logger-dev, libghc-warp-dev, libghc-blaze-builder-dev, - libghc-blaze-html-dev, - libghc-blaze-markup-dev, libghc-crypto-api-dev, libghc-network-multicast-dev, libghc-network-info-dev, diff --git a/doc/bugs/Building_fails:___Not_in_scope:_type_constructor_or_class___96__Html__39__.mdwn b/doc/bugs/Building_fails:___Not_in_scope:_type_constructor_or_class___96__Html__39__.mdwn index 0b916d9b8b..6459e3f2ed 100644 --- a/doc/bugs/Building_fails:___Not_in_scope:_type_constructor_or_class___96__Html__39__.mdwn +++ b/doc/bugs/Building_fails:___Not_in_scope:_type_constructor_or_class___96__Html__39__.mdwn @@ -184,4 +184,6 @@ git-annex HEAD from git, Ubuntu 12.10. Please provide any additional information below. - +> Hmm, seems that Blaze's API is not stable, and I should avoid using it +> directly. Converted this code to using Hamlet instead for its html +> generation. [[done]] --[[Joey]] diff --git a/doc/install/fromscratch.mdwn b/doc/install/fromscratch.mdwn index d192f08059..000bc8451b 100644 --- a/doc/install/fromscratch.mdwn +++ b/doc/install/fromscratch.mdwn @@ -36,8 +36,6 @@ quite a lot. * [wai-logger](http://hackage.haskell.org/package/wai-logger) * [warp](http://hackage.haskell.org/package/warp) * [blaze-builder](http://hackage.haskell.org/package/blaze-builder) - * [blaze-html](http://hackage.haskell.org/package/blaze-html) - * [blaze-markup](http://hackage.haskell.org/package/blaze-markup) * [crypto-api](http://hackage.haskell.org/package/crypto-api) * [hamlet](http://hackage.haskell.org/package/hamlet) * [clientsession](http://hackage.haskell.org/package/clientsession) diff --git a/git-annex.cabal b/git-annex.cabal index 344ef3e598..7f0374a50b 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -89,7 +89,7 @@ Executable git-annex if flag(Webapp) && flag(Assistant) Build-Depends: yesod, yesod-static, case-insensitive, http-types, transformers, wai, wai-logger, warp, blaze-builder, - blaze-html, blaze-markup, crypto-api, hamlet, clientsession, + crypto-api, hamlet, clientsession, template-haskell, yesod-default (>= 1.1.0), data-default CPP-Options: -DWITH_WEBAPP diff --git a/templates/sidebar/alert.hamlet b/templates/sidebar/alert.hamlet index 72dc5a4b2d..b1f16cb39c 100644 --- a/templates/sidebar/alert.hamlet +++ b/templates/sidebar/alert.hamlet @@ -5,15 +5,15 @@ $if block

$maybe i <- alertIcon alert - #{htmlIcon i} # + ^{htmlIcon i} # #{h} $else $maybe i <- alertIcon alert - #{htmlIcon i} # + ^{htmlIcon i} # #{h} # $nothing $maybe i <- alertIcon alert - #{htmlIcon i} # + ^{htmlIcon i} # #{renderAlertMessage alert} $maybe button <- alertButton alert