1--------------------------------------------------------------------------------
2-- | Implements a basic static file server for previewing options
3{-# LANGUAGE OverloadedStrings #-}
4module Hakyll.Preview.Server
9--------------------------------------------------------------------------------
10import Control.Monad.Trans (liftIO)
11import qualified Snap.Core as Snap
12import qualified Snap.Http.Server as Snap
13import qualified Snap.Util.FileServe as Snap
16--------------------------------------------------------------------------------
17-- | Serve a given directory
18static :: FilePath -- ^ Directory to serve
19 -> (FilePath -> IO ()) -- ^ Pre-serve hook
21static directory preServe =
22 Snap.serveDirectoryWith directoryConfig directory
24 directoryConfig :: Snap.DirectoryConfig Snap.Snap
25 directoryConfig = Snap.fancyDirectoryConfig
26 { Snap.preServeHook = liftIO . preServe
30--------------------------------------------------------------------------------
31-- | Main method, runs a static server in the given directory
32staticServer :: FilePath -- ^ Directory to serve
33 -> (FilePath -> IO ()) -- ^ Pre-serve hook
34 -> Int -- ^ Port to listen on
35 -> IO () -- ^ Blocks forever
36staticServer directory preServe port =
37 Snap.httpServe config $ static directory preServe
40 config = Snap.setPort port
41 $ Snap.setAccessLog Snap.ConfigNoLog
42 $ 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