avoid using Blaze directly

New 0.5 changes the api, rather gratuitously, so run away. I can juse use
Hamlet here.
This commit is contained in:
Joey Hess 2012-10-31 13:27:56 -04:00
parent 1780c67b41
commit a4c6b30e2c
6 changed files with 13 additions and 15 deletions

View file

@ -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 ["<i class=\"icon-", s, "\"></i>"]
bootStrapIcon :: Text -> GWidget sub master ()
bootStrapIcon name = [whamlet|<i .icon-#{name}></i>|]
{- When clicked, a button always redirects to a URL
- It may also run an IO action in the background, which is useful

2
debian/control vendored
View file

@ -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,

View file

@ -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]]

View file

@ -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)

View file

@ -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

View file

@ -5,15 +5,15 @@
$if block
<h4 .alert-heading>
$maybe i <- alertIcon alert
#{htmlIcon i} #
^{htmlIcon i} #
#{h}
$else
$maybe i <- alertIcon alert
#{htmlIcon i} #
^{htmlIcon i} #
<strong>#{h}</strong> #
$nothing
$maybe i <- alertIcon alert
#{htmlIcon i} #
^{htmlIcon i} #
#{renderAlertMessage alert}
$maybe button <- alertButton alert
<br>