1{-# LANGUAGE OverloadedStrings #-}
4import Prelude hiding (head,span,id)
5import Control.Monad (msum,guard)
6import Control.Monad.Trans (MonadIO(liftIO))
7import Data.List (isPrefixOf, isSuffixOf)
8import Happstack.Server hiding (body)
9import Happstack.Server.Compression
10import System.Environment
11import Text.Blaze.Html5 hiding (map)
12import Text.Blaze.Html5.Attributes hiding (title,span,dir,style)
13import Text.Blaze.Internal
16serverConf = Conf { port = 80
17 , validator = validator nullConf
19 , logAccess = logAccess nullConf
20 , timeout = timeout nullConf }
22serve :: String -> IO ()
24 putStrLn "Elm Server 0.1: running at <http://localhost:8000>"
25 simpleHTTP nullConf $ do
26 compressedResponseFilter
27 msum [ uriRest (serveElm libLoc)
28 , serveDirectory EnableBrowsing [] "."
31serveElm libLoc fp = do
33 guard (".elm" `isSuffixOf` path)
34 content <- liftIO (readFile path)
35 ok . toResponse $ compileToHtml libLoc path content
38main = getArgs >>= parse
40parse ("--help":_) = putStrLn usage
41parse ("--version":_) = putStrLn "The Elm Server 0.1"
42parse [] = serve "/elm-mini.js"
44 | "--runtime-location=" `isPrefixOf` arg =
45 serve . tail $ dropWhile (/='=') arg
46 | otherwise = putStrLn usageMini
47parse _ = putStrLn usageMini
50 "Usage: elm-server [OPTIONS]\n\
51 \Try `elm-server --help' for more information."
54 "Usage: elm-server [OPTIONS]\n\
55 \Compiles and serves .elm files from the current directory.\n\
56 \Example: elm-server\n\
58 \Resource Locations:\n\
59 \ --runtime-location set the location of the Elm runtime (elm-mini.js)\n\
61 \Compiler Information:\n\
62 \ --version print the version information and exit\n\
63 \ --help display this help and exit\n\
65 \Elm home page: <http://elm-lang.org>"
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