2014-05-21 16:42:22 +00:00
|
|
|
From 606c5f4f4b2d476d274907eb2bb8c12b60fc451f Mon Sep 17 00:00:00 2001
|
2014-03-07 06:23:03 +00:00
|
|
|
From: dummy <dummy@example.com>
|
2014-05-21 16:42:22 +00:00
|
|
|
Date: Wed, 21 May 2014 04:43:30 +0000
|
|
|
|
Subject: [PATCH] remove TH
|
2013-12-27 04:32:29 +00:00
|
|
|
|
|
|
|
---
|
2014-03-07 06:23:03 +00:00
|
|
|
Yesod/EmbeddedStatic/Generators.hs | 3 +--
|
|
|
|
Yesod/Static.hs | 29 ++++++++++++++++++-----------
|
2014-05-21 16:42:22 +00:00
|
|
|
yesod-static.cabal | 9 ---------
|
|
|
|
3 files changed, 19 insertions(+), 22 deletions(-)
|
2013-12-27 04:32:29 +00:00
|
|
|
|
|
|
|
diff --git a/Yesod/EmbeddedStatic/Generators.hs b/Yesod/EmbeddedStatic/Generators.hs
|
2014-05-21 16:42:22 +00:00
|
|
|
index 08febb9..e3a6d51 100644
|
2013-12-27 04:32:29 +00:00
|
|
|
--- a/Yesod/EmbeddedStatic/Generators.hs
|
|
|
|
+++ b/Yesod/EmbeddedStatic/Generators.hs
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -42,7 +42,6 @@ import Language.Haskell.TH
|
2013-12-27 04:32:29 +00:00
|
|
|
import Network.Mime (defaultMimeLookup)
|
|
|
|
import System.Directory (doesDirectoryExist, getDirectoryContents, findExecutable)
|
|
|
|
import System.FilePath ((</>))
|
|
|
|
-import Text.Jasmine (minifym)
|
|
|
|
import qualified Data.ByteString.Lazy as BL
|
|
|
|
import qualified Data.Conduit.List as C
|
2014-05-21 16:42:22 +00:00
|
|
|
import Data.Conduit.Binary (sourceHandle)
|
|
|
|
@@ -162,7 +161,7 @@ concatFilesWith loc process files = do
|
2013-12-27 04:32:29 +00:00
|
|
|
|
|
|
|
-- | Convienient rexport of 'minifym' with a type signature to work with 'concatFilesWith'.
|
|
|
|
jasmine :: BL.ByteString -> IO BL.ByteString
|
|
|
|
-jasmine ct = return $ either (const ct) id $ minifym ct
|
|
|
|
+jasmine ct = return ct
|
|
|
|
|
|
|
|
-- | Use <https://github.com/mishoo/UglifyJS2 UglifyJS2> to compress javascript.
|
|
|
|
-- Assumes @uglifyjs@ is located in the path and uses options @[\"-m\", \"-c\"]@
|
2014-03-07 06:23:03 +00:00
|
|
|
diff --git a/Yesod/Static.hs b/Yesod/Static.hs
|
2014-05-21 16:42:22 +00:00
|
|
|
index 725ebf4..33eaffd 100644
|
2014-03-07 06:23:03 +00:00
|
|
|
--- a/Yesod/Static.hs
|
|
|
|
+++ b/Yesod/Static.hs
|
|
|
|
@@ -37,8 +37,8 @@ module Yesod.Static
|
|
|
|
, staticDevel
|
|
|
|
-- * Combining CSS/JS
|
|
|
|
-- $combining
|
|
|
|
- , combineStylesheets'
|
|
|
|
- , combineScripts'
|
|
|
|
+ --, combineStylesheets'
|
|
|
|
+ --, combineScripts'
|
|
|
|
-- ** Settings
|
|
|
|
, CombineSettings
|
|
|
|
, csStaticDir
|
|
|
|
@@ -48,13 +48,13 @@ module Yesod.Static
|
|
|
|
, csJsPreProcess
|
|
|
|
, csCombinedFolder
|
|
|
|
-- * Template Haskell helpers
|
|
|
|
- , staticFiles
|
|
|
|
- , staticFilesList
|
|
|
|
- , publicFiles
|
|
|
|
+ --, staticFiles
|
|
|
|
+ --, staticFilesList
|
|
|
|
+ --, publicFiles
|
|
|
|
-- * Hashing
|
|
|
|
, base64md5
|
|
|
|
-- * Embed
|
|
|
|
- , embed
|
|
|
|
+ --, embed
|
|
|
|
#ifdef TEST_EXPORT
|
|
|
|
, getFileListPieces
|
|
|
|
#endif
|
|
|
|
@@ -64,7 +64,7 @@ import Prelude hiding (FilePath)
|
|
|
|
import qualified Prelude
|
|
|
|
import System.Directory
|
|
|
|
import Control.Monad
|
|
|
|
-import Data.FileEmbed (embedDir)
|
|
|
|
+import Data.FileEmbed
|
|
|
|
|
2014-05-21 16:42:22 +00:00
|
|
|
import Control.Monad.Trans.Resource (runResourceT)
|
2014-03-07 06:23:03 +00:00
|
|
|
import Yesod.Core
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -136,6 +136,7 @@ staticDevel dir = do
|
2014-03-07 06:23:03 +00:00
|
|
|
hashLookup <- cachedETagLookupDevel dir
|
|
|
|
return $ Static $ webAppSettingsWithLookup (F.decodeString dir) hashLookup
|
|
|
|
|
|
|
|
+{-
|
|
|
|
-- | Produce a 'Static' based on embedding all of the static files' contents in the
|
|
|
|
-- executable at compile time.
|
|
|
|
--
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -150,6 +151,7 @@ staticDevel dir = do
|
2014-03-07 06:23:03 +00:00
|
|
|
-- This will cause yesod to embed those assets into the generated HTML file itself.
|
|
|
|
embed :: Prelude.FilePath -> Q Exp
|
|
|
|
embed fp = [|Static (embeddedSettings $(embedDir fp))|]
|
|
|
|
+-}
|
|
|
|
|
|
|
|
instance RenderRoute Static where
|
|
|
|
-- | A route on the static subsite (see also 'staticFiles').
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -215,6 +217,7 @@ getFileListPieces = flip evalStateT M.empty . flip go id
|
2014-03-07 06:23:03 +00:00
|
|
|
put $ M.insert s s m
|
|
|
|
return s
|
|
|
|
|
|
|
|
+{-
|
|
|
|
-- | Template Haskell function that automatically creates routes
|
|
|
|
-- for all of your static files.
|
|
|
|
--
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -267,7 +270,7 @@ staticFilesList dir fs =
|
2014-03-07 06:23:03 +00:00
|
|
|
-- see if their copy is up-to-date.
|
|
|
|
publicFiles :: Prelude.FilePath -> Q [Dec]
|
|
|
|
publicFiles dir = mkStaticFiles' dir "StaticRoute" False
|
|
|
|
-
|
|
|
|
+-}
|
|
|
|
|
|
|
|
mkHashMap :: Prelude.FilePath -> IO (M.Map F.FilePath S8.ByteString)
|
|
|
|
mkHashMap dir = do
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -310,6 +313,7 @@ cachedETagLookup dir = do
|
2014-03-07 06:23:03 +00:00
|
|
|
etags <- mkHashMap dir
|
|
|
|
return $ (\f -> return $ M.lookup f etags)
|
|
|
|
|
|
|
|
+{-
|
|
|
|
mkStaticFiles :: Prelude.FilePath -> Q [Dec]
|
|
|
|
mkStaticFiles fp = mkStaticFiles' fp "StaticRoute" True
|
|
|
|
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -357,6 +361,7 @@ mkStaticFilesList fp fs routeConName makeHash = do
|
2014-03-07 06:23:03 +00:00
|
|
|
[ Clause [] (NormalB $ (ConE route) `AppE` f' `AppE` qs) []
|
|
|
|
]
|
|
|
|
]
|
|
|
|
+-}
|
|
|
|
|
|
|
|
base64md5File :: Prelude.FilePath -> IO String
|
|
|
|
base64md5File = fmap (base64 . encode) . hashFile
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -395,7 +400,7 @@ base64 = map tr
|
2014-03-07 06:23:03 +00:00
|
|
|
-- single static file at compile time.
|
|
|
|
|
|
|
|
data CombineType = JS | CSS
|
|
|
|
-
|
|
|
|
+{-
|
|
|
|
combineStatics' :: CombineType
|
|
|
|
-> CombineSettings
|
|
|
|
-> [Route Static] -- ^ files to combine
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -429,7 +434,7 @@ combineStatics' combineType CombineSettings {..} routes = do
|
2014-03-07 06:23:03 +00:00
|
|
|
case combineType of
|
|
|
|
JS -> "js"
|
|
|
|
CSS -> "css"
|
|
|
|
-
|
|
|
|
+-}
|
|
|
|
-- | Data type for holding all settings for combining files.
|
|
|
|
--
|
|
|
|
-- This data type is a settings type. For more information, see:
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -505,6 +510,7 @@ instance Default CombineSettings where
|
2014-03-07 06:23:03 +00:00
|
|
|
errorIntro :: [FilePath] -> [Char] -> [Char]
|
|
|
|
errorIntro fps s = "Error minifying " ++ show fps ++ ": " ++ s
|
|
|
|
|
|
|
|
+{-
|
|
|
|
liftRoutes :: [Route Static] -> Q Exp
|
|
|
|
liftRoutes =
|
|
|
|
fmap ListE . mapM go
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -551,4 +557,5 @@ combineScripts' :: Bool -- ^ development? if so, perform no combining
|
2014-03-07 06:23:03 +00:00
|
|
|
-> Q Exp
|
|
|
|
combineScripts' development cs con routes
|
|
|
|
| development = [| mapM_ (addScript . $(return $ ConE con)) $(liftRoutes routes) |]
|
|
|
|
- | otherwise = [| addScript $ $(return $ ConE con) $(combineStatics' JS cs routes) |]
|
|
|
|
+ | otherwise = [| addScript $ $(return $ ConE con) $(combineStatics' JS cs routes) |]a
|
|
|
|
+-}
|
2013-12-27 04:32:29 +00:00
|
|
|
diff --git a/yesod-static.cabal b/yesod-static.cabal
|
2014-05-21 16:42:22 +00:00
|
|
|
index 2582a95..5df03b3 100644
|
2013-12-27 04:32:29 +00:00
|
|
|
--- a/yesod-static.cabal
|
|
|
|
+++ b/yesod-static.cabal
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -49,7 +49,6 @@ library
|
2013-12-27 04:32:29 +00:00
|
|
|
, data-default
|
|
|
|
, shakespeare-css >= 1.0.3
|
|
|
|
, mime-types >= 0.1
|
|
|
|
- , hjsmin
|
|
|
|
, filepath >= 1.3
|
|
|
|
, resourcet >= 0.4
|
|
|
|
, unordered-containers >= 0.2
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -62,13 +61,6 @@ library
|
|
|
|
, hashable >= 1.1
|
2013-12-27 04:32:29 +00:00
|
|
|
|
|
|
|
exposed-modules: Yesod.Static
|
|
|
|
- Yesod.EmbeddedStatic
|
|
|
|
- Yesod.EmbeddedStatic.Generators
|
|
|
|
- Yesod.EmbeddedStatic.Types
|
2014-05-21 16:42:22 +00:00
|
|
|
- Yesod.EmbeddedStatic.Css.AbsoluteUrl
|
2013-12-27 04:32:29 +00:00
|
|
|
-
|
|
|
|
- other-modules: Yesod.EmbeddedStatic.Internal
|
2014-05-21 16:42:22 +00:00
|
|
|
- Yesod.EmbeddedStatic.Css.Util
|
2013-12-27 04:32:29 +00:00
|
|
|
|
|
|
|
ghc-options: -Wall
|
|
|
|
extensions: TemplateHaskell
|
2014-05-21 16:42:22 +00:00
|
|
|
@@ -108,7 +100,6 @@ test-suite tests
|
2013-12-27 04:32:29 +00:00
|
|
|
, data-default
|
|
|
|
, shakespeare-css
|
|
|
|
, mime-types
|
|
|
|
- , hjsmin
|
|
|
|
, filepath
|
|
|
|
, resourcet
|
2014-05-21 16:42:22 +00:00
|
|
|
, unordered-containers
|
2013-12-27 04:32:29 +00:00
|
|
|
--
|
2014-05-21 16:42:22 +00:00
|
|
|
2.0.0.rc2
|
2013-12-27 04:32:29 +00:00
|
|
|
|