4import Control.Monad (msum,guard)
5import Control.Monad.Trans (MonadIO(liftIO))
6import Data.List (isPrefixOf, isSuffixOf)
8import Happstack.Server.Compression
9import System.Environment
12serve :: String -> IO ()
14 putStrLn "Elm Server 0.1.1.4: running at <http://localhost:8000>"
15 simpleHTTP nullConf $ do
16 compressedResponseFilter
17 msum [ uriRest (serveElm libLoc)
18 , serveDirectory EnableBrowsing [] "."
22 reverse . takeWhile (/='/') . drop 1 . dropWhile (/='.') $ reverse fp
24serveElm libLoc fp = do
26 guard (".elm" `isSuffixOf` path)
27 content <- liftIO (readFile path)
28 ok . toResponse $ compileToHtml libLoc (pageTitle path) content
31main = getArgs >>= parse
33parse ("--help":_) = putStrLn usage
34parse ("--version":_) = putStrLn "The Elm Server 0.1.1.4"
35parse [] = serve "/elm-mini.js"
37 | "--runtime-location=" `isPrefixOf` arg =
38 serve . tail $ dropWhile (/='=') arg
39 | otherwise = putStrLn usageMini
40parse _ = putStrLn usageMini
43 "Usage: elm-server [OPTIONS]\n\
44 \Try `elm-server --help' for more information."
47 "Usage: elm-server [OPTIONS]\n\
48 \Compiles and serves .elm files from the current directory.\n\
49 \Example: elm-server\n\
51 \Resource Locations:\n\
52 \ --runtime-location set the location of the Elm runtime (elm-mini.js)\n\
54 \Compiler Information:\n\
55 \ --version print the version information and exit\n\
56 \ --help display this help and exit\n\
58 \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