on master help sign in
Merge remote-tracking branch 'upstream/master'
commit7a1989d288ac9f2e0d38e8f84509895c33780046 authorLorenzo <lortabac@gmx.com> dateFri 22 Jul 2016, 17:02 (10 years ago) parent3d713e9cb07202
4 files changed+24−42
hakyll.cabal+8−4 src/Hakyll/Commands.hs+1−3 src/Hakyll/Preview/Server.hs+14−34 src/Hakyll/Web/CompressCss.hs+1−1
hakyll.cabal+8−4
@@ -177,8 +177,10 @@ Library
177177
178178 If flag(previewServer)
179179 Build-depends:
180− snap-core >= 0.6 && < 0.10,
181− snap-server >= 0.6 && < 0.10,
180+ wai >= 3.2 && < 3.3,
181+ warp >= 3.2 && < 3.3,
182+ wai-app-static >= 3.1 && < 3.2,
183+ http-types >= 0.9 && < 0.10,
182184 fsnotify >= 0.2 && < 0.3,
183185 system-filepath >= 0.4.6 && <= 0.5
184186 Cpp-options:
@@ -268,8 +270,10 @@ Test-suite hakyll-tests
268270
269271 If flag(previewServer)
270272 Build-depends:
271− snap-core >= 0.6 && < 0.10,
272− snap-server >= 0.6 && < 0.10,
273+ wai >= 3.2 && < 3.3,
274+ warp >= 3.2 && < 3.3,
275+ wai-app-static >= 3.1 && < 3.2,
276+ http-types >= 0.9 && < 0.10,
273277 fsnotify >= 0.2 && < 0.3,
274278 system-filepath >= 0.4.6 && <= 0.5
275279 Cpp-options:
src/Hakyll/Commands.hs+1−3
@@ -121,9 +121,7 @@ server :: Configuration -> Logger -> String -> Int -> IO ()
121121#ifdef PREVIEW_SERVER
122122server conf logger host port = do
123123 let destination = destinationDirectory conf
124− staticServer logger destination preServeHook host port
125− where
126− preServeHook _ = return ()
124+ staticServer logger destination host port
127125#else
128126server _ _ _ _ = previewServerDisabled
129127#endif
src/Hakyll/Preview/Server.hs+14−34
@@ -7,48 +7,28 @@ module Hakyll.Preview.Server
77
88
99--------------------------------------------------------------------------------
10−import Control.Monad.Trans (liftIO)
11−import qualified Data.ByteString.Char8 as B
12−import qualified Snap.Core as Snap
13−import qualified Snap.Http.Server as Snap
14−import qualified Snap.Util.FileServe as Snap
15−
10+import Data.String
11+import qualified Network.Wai.Handler.Warp as Warp
12+import qualified Network.Wai.Application.Static as Static
13+import qualified Network.Wai as Wai
14+import Network.HTTP.Types.Status (Status)
1615
1716--------------------------------------------------------------------------------
1817import Hakyll.Core.Logger (Logger)
1918import qualified Hakyll.Core.Logger as Logger
2019
21−
22−--------------------------------------------------------------------------------
23−-- | Serve a given directory
24−static :: FilePath -- ^ Directory to serve
25− -> (FilePath -> IO ()) -- ^ Pre-serve hook
26− -> Snap.Snap ()
27−static directory preServe =
28− Snap.serveDirectoryWith directoryConfig directory
29− where
30− directoryConfig :: Snap.DirectoryConfig Snap.Snap
31− directoryConfig = Snap.fancyDirectoryConfig
32− { Snap.preServeHook = liftIO . preServe
33− }
34−
35−
36−--------------------------------------------------------------------------------
37−-- | Main method, runs a static server in the given directory
3820staticServer :: Logger -- ^ Logger
3921 -> FilePath -- ^ Directory to serve
40− -> (FilePath -> IO ()) -- ^ Pre-serve hook
4122 -> String -- ^ Host to bind on
4223 -> Int -- ^ Port to listen on
4324 -> IO () -- ^ Blocks forever
44−staticServer logger directory preServe host port = do
25+staticServer logger directory host port = do
4526 Logger.header logger $ "Listening on http://" ++ host ++ ":" ++ show port
46− Snap.httpServe config $ static directory preServe
47− where
48− -- Snap server config
49− config = Snap.setBind (B.pack host)
50− $ Snap.setPort port
51− $ Snap.setAccessLog Snap.ConfigNoLog
52− $ Snap.setErrorLog Snap.ConfigNoLog
53− $ Snap.setVerbose False
54− $ Snap.emptyConfig
27+ let settings = Warp.setLogger noLog
28+ $ Warp.setHost (fromString host)
29+ $ Warp.setPort port Warp.defaultSettings
30+ waiApp = Static.staticApp (Static.defaultWebAppSettings directory)
31+ Warp.runSettings settings waiApp
32+
33+noLog :: Wai.Request -> Status -> Maybe Integer -> IO ()
34+noLog _ _ _ = return ()
src/Hakyll/Web/CompressCss.hs+1−1
@@ -35,7 +35,7 @@ compressCss = compressSeparators . stripComments . compressWhitespace
3535compressSeparators :: String -> String
3636compressSeparators =
3737 replaceAll "; *}" (const "}") .
38− replaceAll " *([{};:]) *" (take 1 . dropWhile isSpace) .
38+ replaceAll " *([{};]) *" (take 1 . dropWhile isSpace) .
3939 replaceAll ";+" (const ";")
4040
4141