1-- | Implements a basic static file server for previewing options
3{-# LANGUAGE OverloadedStrings #-}
4module Hakyll.Web.Preview.Server
8import Control.Monad.Trans (liftIO)
10import qualified Snap.Core as Snap
11import qualified Snap.Http.Server as Snap
12import qualified Snap.Util.FileServe as Snap
14-- | Serve a given directory
16static :: FilePath -- ^ Directory to serve
17 -> (FilePath -> IO ()) -- ^ Pre-serve hook
19static directory preServe =
20 Snap.serveDirectoryWith directoryConfig directory
22 directoryConfig :: Snap.DirectoryConfig Snap.Snap
23 directoryConfig = Snap.fancyDirectoryConfig
24 { Snap.preServeHook = liftIO . preServe
27-- | Main method, runs a static server in the given directory
29staticServer :: FilePath -- ^ Directory to serve
30 -> (FilePath -> IO ()) -- ^ Pre-serve hook
31 -> Int -- ^ Port to listen on
32 -> IO () -- ^ Blocks forever
33staticServer directory preServe port =
34 Snap.httpServe config $ static directory preServe
37 config = Snap.setPort port
38 $ Snap.setAccessLog Snap.ConfigNoLog
39 $ Snap.setErrorLog Snap.ConfigNoLog
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list