on master help sign in
Merge remote-tracking branch 'upstream/master'
7a1989dLorenzo
hakyll.cabal+8−4
@@ -177,8 +177,10 @@ Library
177
177
178 If flag(previewServer)
178 If flag(previewServer)
179 Build-depends:
179 Build-depends:
180− snap-core >= 0.6 && < 0.10,
180+ wai >= 3.2 && < 3.3,
181− snap-server >= 0.6 && < 0.10,
181+ warp >= 3.2 && < 3.3,
182+ wai-app-static >= 3.1 && < 3.2,
183+ http-types >= 0.9 && < 0.10,
182 fsnotify >= 0.2 && < 0.3,
184 fsnotify >= 0.2 && < 0.3,
183 system-filepath >= 0.4.6 && <= 0.5
185 system-filepath >= 0.4.6 && <= 0.5
184 Cpp-options:
186 Cpp-options:
@@ -268,8 +270,10 @@ Test-suite hakyll-tests
268
270
269 If flag(previewServer)
271 If flag(previewServer)
270 Build-depends:
272 Build-depends:
271− snap-core >= 0.6 && < 0.10,
273+ wai >= 3.2 && < 3.3,
272− snap-server >= 0.6 && < 0.10,
274+ warp >= 3.2 && < 3.3,
275+ wai-app-static >= 3.1 && < 3.2,
276+ http-types >= 0.9 && < 0.10,
273 fsnotify >= 0.2 && < 0.3,
277 fsnotify >= 0.2 && < 0.3,
274 system-filepath >= 0.4.6 && <= 0.5
278 system-filepath >= 0.4.6 && <= 0.5
275 Cpp-options:
279 Cpp-options:
src/Hakyll/Commands.hs+1−3
@@ -121,9 +121,7 @@ server :: Configuration -> Logger -> String -> Int -> IO ()
121#ifdef PREVIEW_SERVER
121#ifdef PREVIEW_SERVER
122server conf logger host port = do
122server conf logger host port = do
123 let destination = destinationDirectory conf
123 let destination = destinationDirectory conf
124− staticServer logger destination preServeHook host port
124+ staticServer logger destination host port
125− where
126− preServeHook _ = return ()
127#else
125#else
128server _ _ _ _ = previewServerDisabled
126server _ _ _ _ = previewServerDisabled
129#endif
127#endif
src/Hakyll/Preview/Server.hs+14−34
@@ -7,48 +7,28 @@ module Hakyll.Preview.Server
7
7
8
8
9--------------------------------------------------------------------------------
9--------------------------------------------------------------------------------
10−import Control.Monad.Trans (liftIO)
10+import Data.String
11−import qualified Data.ByteString.Char8 as B
11+import qualified Network.Wai.Handler.Warp as Warp
12−import qualified Snap.Core as Snap
12+import qualified Network.Wai.Application.Static as Static
13−import qualified Snap.Http.Server as Snap
13+import qualified Network.Wai as Wai
14−import qualified Snap.Util.FileServe as Snap
14+import Network.HTTP.Types.Status (Status)
15−
16
15
17--------------------------------------------------------------------------------
16--------------------------------------------------------------------------------
18import Hakyll.Core.Logger (Logger)
17import Hakyll.Core.Logger (Logger)
19import qualified Hakyll.Core.Logger as Logger
18import qualified Hakyll.Core.Logger as Logger
20
19
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
38staticServer :: Logger -- ^ Logger
20staticServer :: Logger -- ^ Logger
39 -> FilePath -- ^ Directory to serve
21 -> FilePath -- ^ Directory to serve
40− -> (FilePath -> IO ()) -- ^ Pre-serve hook
41 -> String -- ^ Host to bind on
22 -> String -- ^ Host to bind on
42 -> Int -- ^ Port to listen on
23 -> Int -- ^ Port to listen on
43 -> IO () -- ^ Blocks forever
24 -> IO () -- ^ Blocks forever
44−staticServer logger directory preServe host port = do
25+staticServer logger directory host port = do
45 Logger.header logger $ "Listening on http://" ++ host ++ ":" ++ show port
26 Logger.header logger $ "Listening on http://" ++ host ++ ":" ++ show port
46− Snap.httpServe config $ static directory preServe
27+ let settings = Warp.setLogger noLog
47− where
28+ $ Warp.setHost (fromString host)
48− -- Snap server config
49− config = Snap.setBind (B.pack host)
50− $ Snap.setPort port
29+ $ Warp.setPort port Warp.defaultSettings
51− $ Snap.setAccessLog Snap.ConfigNoLog
30+ waiApp = Static.staticApp (Static.defaultWebAppSettings directory)
52− $ Snap.setErrorLog Snap.ConfigNoLog
31+ Warp.runSettings settings waiApp
53− $ Snap.setVerbose False
32+
54− $ Snap.emptyConfig
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
35compressSeparators :: String -> String
35compressSeparators :: String -> String
36compressSeparators =
36compressSeparators =
37 replaceAll "; *}" (const "}") .
37 replaceAll "; *}" (const "}") .
38− replaceAll " *([{};:]) *" (take 1 . dropWhile isSpace) .
38+ replaceAll " *([{};]) *" (take 1 . dropWhile isSpace) .
39 replaceAll ";+" (const ";")
39 replaceAll ";+" (const ";")
40
40
41
41