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
16serve :: String -> IO ()
18 putStrLn "Elm Server 0.1.0: running at <http://localhost:8000>"
19 simpleHTTP nullConf $ do
20 compressedResponseFilter
21 msum [ uriRest (serveElm libLoc)
22 , serveDirectory EnableBrowsing [] "."
25serveElm libLoc fp = do
27 guard (".elm" `isSuffixOf` path)
28 content <- liftIO (readFile path)
29 ok . toResponse $ compileToHtml libLoc path content
32main = getArgs >>= parse
34parse ("--help":_) = putStrLn usage
35parse ("--version":_) = putStrLn "The Elm Server 0.1.0"
36parse [] = serve "/elm-mini.js"
38 | "--runtime-location=" `isPrefixOf` arg =
39 serve . tail $ dropWhile (/='=') arg
40 | otherwise = putStrLn usageMini
41parse _ = putStrLn usageMini
44 "Usage: elm-server [OPTIONS]\n\
45 \Try `elm-server --help' for more information."
48 "Usage: elm-server [OPTIONS]\n\
49 \Compiles and serves .elm files from the current directory.\n\
50 \Example: elm-server\n\
52 \Resource Locations:\n\
53 \ --runtime-location set the location of the Elm runtime (elm-mini.js)\n\
55 \Compiler Information:\n\
56 \ --version print the version information and exit\n\
57 \ --help display this help and exit\n\
59 \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