2013-09-22 05:27:15 +00:00
|
|
|
From 05d0b6e6d2f84cd8ff53b8ee3e42021fa02fe8e4 Mon Sep 17 00:00:00 2001
|
|
|
|
From: foo <foo@bar>
|
|
|
|
Date: Sat, 21 Sep 2013 23:21:52 +0000
|
2013-03-01 03:43:26 +00:00
|
|
|
Subject: [PATCH] remove TH
|
|
|
|
|
|
|
|
---
|
2013-09-22 05:27:15 +00:00
|
|
|
Text/Cassius.hs | 23 -----------------------
|
|
|
|
Text/CssCommon.hs | 4 ----
|
|
|
|
Text/Lucius.hs | 30 +-----------------------------
|
|
|
|
3 files changed, 1 insertion(+), 56 deletions(-)
|
2013-03-01 03:43:26 +00:00
|
|
|
|
|
|
|
diff --git a/Text/Cassius.hs b/Text/Cassius.hs
|
|
|
|
index ce05374..ae56b0a 100644
|
|
|
|
--- a/Text/Cassius.hs
|
|
|
|
+++ b/Text/Cassius.hs
|
|
|
|
@@ -13,10 +13,6 @@ module Text.Cassius
|
|
|
|
, renderCss
|
|
|
|
, renderCssUrl
|
|
|
|
-- * Parsing
|
|
|
|
- , cassius
|
|
|
|
- , cassiusFile
|
|
|
|
- , cassiusFileDebug
|
|
|
|
- , cassiusFileReload
|
|
|
|
-- * ToCss instances
|
|
|
|
-- ** Color
|
|
|
|
, Color (..)
|
|
|
|
@@ -27,11 +23,8 @@ module Text.Cassius
|
|
|
|
, AbsoluteUnit (..)
|
|
|
|
, AbsoluteSize (..)
|
|
|
|
, absoluteSize
|
|
|
|
- , EmSize (..)
|
|
|
|
- , ExSize (..)
|
|
|
|
, PercentageSize (..)
|
|
|
|
, percentageSize
|
|
|
|
- , PixelSize (..)
|
|
|
|
-- * Internal
|
|
|
|
, cassiusUsedIdentifiers
|
|
|
|
) where
|
|
|
|
@@ -42,25 +35,9 @@ import Language.Haskell.TH.Quote (QuasiQuoter (..))
|
|
|
|
import Language.Haskell.TH.Syntax
|
|
|
|
import qualified Data.Text.Lazy as TL
|
|
|
|
import Text.CssCommon
|
|
|
|
-import Text.Lucius (lucius)
|
|
|
|
import qualified Text.Lucius
|
|
|
|
import Text.IndentToBrace (i2b)
|
|
|
|
|
|
|
|
-cassius :: QuasiQuoter
|
|
|
|
-cassius = QuasiQuoter { quoteExp = quoteExp lucius . i2b }
|
|
|
|
-
|
|
|
|
-cassiusFile :: FilePath -> Q Exp
|
|
|
|
-cassiusFile fp = do
|
|
|
|
-#ifdef GHC_7_4
|
|
|
|
- qAddDependentFile fp
|
|
|
|
-#endif
|
|
|
|
- contents <- fmap TL.unpack $ qRunIO $ readUtf8File fp
|
|
|
|
- quoteExp cassius contents
|
|
|
|
-
|
|
|
|
-cassiusFileDebug, cassiusFileReload :: FilePath -> Q Exp
|
|
|
|
-cassiusFileDebug = cssFileDebug True [|Text.Lucius.parseTopLevels|] Text.Lucius.parseTopLevels
|
|
|
|
-cassiusFileReload = cassiusFileDebug
|
|
|
|
-
|
|
|
|
-- | Determine which identifiers are used by the given template, useful for
|
|
|
|
-- creating systems like yesod devel.
|
|
|
|
cassiusUsedIdentifiers :: String -> [(Deref, VarType)]
|
|
|
|
diff --git a/Text/CssCommon.hs b/Text/CssCommon.hs
|
|
|
|
index 719e0a8..8c40e8c 100644
|
|
|
|
--- a/Text/CssCommon.hs
|
|
|
|
+++ b/Text/CssCommon.hs
|
|
|
|
@@ -1,4 +1,3 @@
|
|
|
|
-{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
@@ -156,6 +155,3 @@ showSize :: Rational -> String -> String
|
|
|
|
showSize value' unit = printf "%f" value ++ unit
|
|
|
|
where value = fromRational value' :: Double
|
|
|
|
|
|
|
|
-mkSizeType "EmSize" "em"
|
|
|
|
-mkSizeType "ExSize" "ex"
|
|
|
|
-mkSizeType "PixelSize" "px"
|
|
|
|
diff --git a/Text/Lucius.hs b/Text/Lucius.hs
|
2013-09-22 05:27:15 +00:00
|
|
|
index 89328bd..0a1cf5e 100644
|
2013-03-01 03:43:26 +00:00
|
|
|
--- a/Text/Lucius.hs
|
|
|
|
+++ b/Text/Lucius.hs
|
2013-09-22 05:27:15 +00:00
|
|
|
@@ -8,12 +8,8 @@
|
2013-03-01 03:43:26 +00:00
|
|
|
{-# OPTIONS_GHC -fno-warn-missing-fields #-}
|
|
|
|
module Text.Lucius
|
|
|
|
( -- * Parsing
|
|
|
|
- lucius
|
|
|
|
- , luciusFile
|
|
|
|
- , luciusFileDebug
|
|
|
|
- , luciusFileReload
|
2013-09-22 05:27:15 +00:00
|
|
|
-- ** Mixins
|
|
|
|
- , luciusMixin
|
|
|
|
+ luciusMixin
|
|
|
|
, Mixin
|
2013-03-01 03:43:26 +00:00
|
|
|
-- ** Runtime
|
2013-09-22 05:27:15 +00:00
|
|
|
, luciusRT
|
|
|
|
@@ -40,11 +36,8 @@ module Text.Lucius
|
2013-03-01 03:43:26 +00:00
|
|
|
, AbsoluteUnit (..)
|
|
|
|
, AbsoluteSize (..)
|
|
|
|
, absoluteSize
|
|
|
|
- , EmSize (..)
|
|
|
|
- , ExSize (..)
|
|
|
|
, PercentageSize (..)
|
|
|
|
, percentageSize
|
|
|
|
- , PixelSize (..)
|
|
|
|
-- * Internal
|
|
|
|
, parseTopLevels
|
|
|
|
, luciusUsedIdentifiers
|
2013-09-22 05:27:15 +00:00
|
|
|
@@ -66,18 +59,6 @@ import Data.Monoid (mconcat)
|
2013-03-01 03:43:26 +00:00
|
|
|
import Data.List (isSuffixOf)
|
2013-09-22 05:27:15 +00:00
|
|
|
import Control.Arrow (second)
|
2013-03-01 03:43:26 +00:00
|
|
|
|
|
|
|
--- |
|
|
|
|
---
|
|
|
|
--- >>> renderCss ([lucius|foo{bar:baz}|] undefined)
|
|
|
|
--- "foo{bar:baz}"
|
|
|
|
-lucius :: QuasiQuoter
|
|
|
|
-lucius = QuasiQuoter { quoteExp = luciusFromString }
|
|
|
|
-
|
|
|
|
-luciusFromString :: String -> Q Exp
|
|
|
|
-luciusFromString s =
|
|
|
|
- topLevelsToCassius
|
|
|
|
- $ either (error . show) id $ parse parseTopLevels s s
|
|
|
|
-
|
|
|
|
whiteSpace :: Parser ()
|
|
|
|
whiteSpace = many whiteSpace1 >> return ()
|
|
|
|
|
2013-09-22 05:27:15 +00:00
|
|
|
@@ -217,15 +198,6 @@ parseComment = do
|
2013-03-01 03:43:26 +00:00
|
|
|
_ <- manyTill anyChar $ try $ string "*/"
|
|
|
|
return $ ContentRaw ""
|
|
|
|
|
|
|
|
-luciusFile :: FilePath -> Q Exp
|
|
|
|
-luciusFile fp = do
|
|
|
|
- contents <- fmap TL.unpack $ qRunIO $ readUtf8File fp
|
|
|
|
- luciusFromString contents
|
|
|
|
-
|
|
|
|
-luciusFileDebug, luciusFileReload :: FilePath -> Q Exp
|
|
|
|
-luciusFileDebug = cssFileDebug False [|parseTopLevels|] parseTopLevels
|
|
|
|
-luciusFileReload = luciusFileDebug
|
|
|
|
-
|
2013-09-22 05:27:15 +00:00
|
|
|
parseTopLevels :: Parser [TopLevel Unresolved]
|
2013-03-01 03:43:26 +00:00
|
|
|
parseTopLevels =
|
|
|
|
go id
|
|
|
|
--
|
|
|
|
1.7.10.4
|
|
|
|
|