elm-server 0.1.2 → 0.2.0
raw patch · 2 files changed
+100/−101 lines, 2 filesdep ~Elm
Dependency ranges changed: Elm
Files
- Server.hs +63/−63
- elm-server.cabal +37/−38
Server.hs view
@@ -1,63 +1,63 @@- -module Main where - -import Control.Monad (msum,guard) -import Control.Monad.Trans (MonadIO(liftIO)) -import Data.List (isPrefixOf, isSuffixOf) -import Happstack.Server -import Happstack.Server.Compression -import System.Environment -import qualified Language.Elm as Elm - -serve :: String -> IO () -serve libLoc = do - putStrLn "Elm Server 0.1.2: running at <http://localhost:8000>" - simpleHTTP nullConf $ do - _ <- compressedResponseFilter - msum [ uriRest (serveElm libLoc) - , serveDirectory EnableBrowsing [] "." - ] - -pageTitle :: String -> String -pageTitle fp = - reverse . takeWhile (/='/') . drop 1 . dropWhile (/='.') $ reverse fp - -serveElm libLoc fp = do - let ('/':filePath) = fp - guard (".elm" `isSuffixOf` filePath) - content <- liftIO (readFile filePath) - ok . toResponse $ Elm.toHtml libLoc (pageTitle filePath) content - - -main :: IO () -main = getArgs >>= parse - -parse :: [String] -> IO () -parse ("--help":_) = putStrLn usage -parse ("--version":_) = putStrLn "The Elm Server 0.1.2" -parse [] = serve "/elm-mini.js" -parse [arg] - | "--runtime-location=" `isPrefixOf` arg = - serve . tail $ dropWhile (/='=') arg - | otherwise = putStrLn usageMini -parse _ = putStrLn usageMini - -usageMini :: String -usageMini = - "Usage: elm-server [OPTIONS]\n\ - \Try `elm-server --help' for more information." - -usage :: String -usage = - "Usage: elm-server [OPTIONS]\n\ - \Compiles and serves .elm files from the current directory.\n\ - \Example: elm-server\n\ - \\n\ - \Resource Locations:\n\ - \ --runtime-location set the location of the Elm runtime (elm-mini.js)\n\ - \\n\ - \Compiler Information:\n\ - \ --version print the version information and exit\n\ - \ --help display this help and exit\n\ - \\n\ - \Elm home page: <http://elm-lang.org>" ++module Main where++import Control.Monad (msum,guard)+import Control.Monad.Trans (MonadIO(liftIO))+import Data.List (isPrefixOf, isSuffixOf)+import Happstack.Server+import Happstack.Server.Compression+import System.Environment+import qualified Language.Elm as Elm++serve :: String -> IO ()+serve libLoc = do+ putStrLn "Elm Server 0.2.0: running at <http://localhost:8000>"+ simpleHTTP nullConf $ do+ _ <- compressedResponseFilter+ msum [ uriRest (serveElm libLoc)+ , serveDirectory EnableBrowsing [] "."+ ]++pageTitle :: String -> String+pageTitle fp =+ reverse . takeWhile (/='/') . drop 1 . dropWhile (/='.') $ reverse fp++serveElm libLoc fp = do+ let ('/':filePath) = fp+ guard (".elm" `isSuffixOf` filePath)+ content <- liftIO (readFile filePath)+ ok . toResponse $ Elm.toHtml libLoc (pageTitle filePath) content+++main :: IO ()+main = getArgs >>= parse++parse :: [String] -> IO ()+parse ("--help":_) = putStrLn usage+parse ("--version":_) = putStrLn "The Elm Server 0.2.0"+parse [] = serve "/elm-mini.js"+parse [arg]+ | "--runtime-location=" `isPrefixOf` arg =+ serve . tail $ dropWhile (/='=') arg+ | otherwise = putStrLn usageMini+parse _ = putStrLn usageMini++usageMini :: String+usageMini =+ "Usage: elm-server [OPTIONS]\n\+ \Try `elm-server --help' for more information."++usage :: String+usage =+ "Usage: elm-server [OPTIONS]\n\+ \Compiles and serves .elm files from the current directory.\n\+ \Example: elm-server\n\+ \\n\+ \Resource Locations:\n\+ \ --runtime-location set the location of the Elm runtime (elm-mini.js)\n\+ \\n\+ \Compiler Information:\n\+ \ --version print the version information and exit\n\+ \ --help display this help and exit\n\+ \\n\+ \Elm home page: <http://elm-lang.org>"
elm-server.cabal view
@@ -1,38 +1,37 @@-Name: elm-server -Version: 0.1.2 -Synopsis: The Elm language server. -Description: This package provides a standalone, Happstack-based Elm server. - -Homepage: http://elm-lang.org - -License: BSD3 -License-file: LICENSE - -Author: Evan Czaplicki -Maintainer: info@elm-lang.org -Copyright: Copyright: (c) 2011-2012 Evan Czaplicki - -Category: Compiler, Language - -Build-type: Simple - ---Extra-source-files: README.md -Cabal-version: >=1.6 - -source-repository head - type: git - location: git://github.com/evancz/Elm.git - -Executable elm-server - Main-is: Server.hs --- ghc-options: -O2 -Wall - Build-depends: base >=4.2 && <5, - containers >= 0.3, - transformers >= 0.2, - mtl >= 2, - parsec >= 3.1.1, - blaze-html == 0.5.0.*, - HTTP >= 4000, - happstack-server == 7.0.2, - deepseq, - Elm == 0.1.2.*+Name: elm-server+Version: 0.2.0+Synopsis: The Elm language server.+Description: This package provides a standalone, Happstack-based Elm server.++Homepage: http://elm-lang.org++License: BSD3+License-file: LICENSE++Author: Evan Czaplicki+Maintainer: info@elm-lang.org+Copyright: Copyright: (c) 2011-2012 Evan Czaplicki++Category: Compiler, Language++Build-type: Simple++--Extra-source-files: README.md+Cabal-version: >=1.6++source-repository head+ type: git+ location: git://github.com/evancz/Elm.git++Executable elm-server+ Main-is: Server.hs+ Build-depends: base >=4.2 && <5,+ containers >= 0.3,+ transformers >= 0.2,+ mtl >= 2,+ parsec >= 3.1.1,+ blaze-html == 0.5.0.*,+ HTTP >= 4000,+ happstack-server == 7.0.2,+ deepseq,+ Elm >= 0.2.0