on master help sign in
Get runtime location working properly.
253e768evancz
elm-server/Server.hs+9−10
@@ -9,11 +9,13 @@ import Happstack.Server.Compression
9import System.Directory (makeRelativeToCurrentDirectory)
9import System.Directory (makeRelativeToCurrentDirectory)
10import System.Environment
10import System.Environment
11import qualified Language.Elm as Elm
11import qualified Language.Elm as Elm
12−import Paths_Elm
12+import Paths_elm_server
13+
14+runtime = "/elm-" ++ show version ++ ".js"
13
15
14serve :: String -> IO ()
16serve :: String -> IO ()
15serve libLoc = do
17serve libLoc = do
16− putStrLn "Elm Server 0.4.0.3: running at <http://localhost:8000>"
18+ putStrLn ("Elm Server "++show version++": running at <http://localhost:8000>")
17 simpleHTTP nullConf $ do
19 simpleHTTP nullConf $ do
18 _ <- compressedResponseFilter
20 _ <- compressedResponseFilter
19 msum [ uriRest serveElm
21 msum [ uriRest serveElm
@@ -29,10 +31,10 @@ serveElm fp = do
29 let ('/':filePath) = fp
31 let ('/':filePath) = fp
30 guard (".elm" `isSuffixOf` filePath)
32 guard (".elm" `isSuffixOf` filePath)
31 content <- liftIO (readFile filePath)
33 content <- liftIO (readFile filePath)
32− ok . toResponse $ Elm.toHtml "elm-runtime.js" (pageTitle filePath) content
34+ ok . toResponse $ Elm.toHtml runtime (pageTitle filePath) content
33
35
34serveLib libLoc fp = do
36serveLib libLoc fp = do
35− guard (fp == "/elm-runtime.js")
37+ guard (fp == runtime)
36 serveFile (asContentType "application/javascript") libLoc
38 serveFile (asContentType "application/javascript") libLoc
37
39
38main :: IO ()
40main :: IO ()
@@ -40,11 +42,8 @@ main = getArgs >>= parse
40
42
41parse :: [String] -> IO ()
43parse :: [String] -> IO ()
42parse ("--help":_) = putStrLn usage
44parse ("--help":_) = putStrLn usage
43−parse ("--version":_) = putStrLn "The Elm Server 0.4.0.3"
45+parse ("--version":_) = putStrLn ("The Elm Server " ++ show version)
44−parse [] = do
46+parse [] = serve =<< Elm.runtimeLocation
45− absolutePath <- getDataFileName "elm-runtime-0.4.0.3.js"
46− runtime <- makeRelativeToCurrentDirectory absolutePath
47− serve runtime
48parse [arg]
47parse [arg]
49 | "--runtime-location=" `isPrefixOf` arg =
48 | "--runtime-location=" `isPrefixOf` arg =
50 serve . tail $ dropWhile (/='=') arg
49 serve . tail $ dropWhile (/='=') arg
@@ -63,7 +62,7 @@ usage =
63 \Example: elm-server\n\
62 \Example: elm-server\n\
64 \\n\
63 \\n\
65 \Resource Locations:\n\
64 \Resource Locations:\n\
66− \ --runtime-location set the location of the Elm runtime (elm-mini.js)\n\
65+ \ --runtime-location set the location of the Elm runtime\n\
67 \\n\
66 \\n\
68 \Compiler Information:\n\
67 \Compiler Information:\n\
69 \ --version print the version information and exit\n\
68 \ --version print the version information and exit\n\
elm-server/elm-server.cabal+1−1
@@ -35,4 +35,4 @@ Executable elm-server
35 happstack-server == 7.0.2,
35 happstack-server == 7.0.2,
36 deepseq,
36 deepseq,
37 directory,
37 directory,
38− Elm == 0.4.*
38+ Elm >= 0.4.0.3
elm/Elm.cabal+4−3
@@ -32,7 +32,6 @@ source-repository head
32Library
32Library
33 exposed-modules: Language.Elm,
33 exposed-modules: Language.Elm,
34 Language.Elm.Quasi
34 Language.Elm.Quasi
35− Paths_Elm
36 Hs-Source-Dirs: src, src/Parse, src/Types, src/Gen
35 Hs-Source-Dirs: src, src/Parse, src/Types, src/Gen
37 other-modules: Ast,
36 other-modules: Ast,
38 CompileToJS,
37 CompileToJS,
@@ -56,7 +55,8 @@ Library
56 Types.Constrain,
55 Types.Constrain,
57 Types.Hints,
56 Types.Hints,
58 Types.Substitutions,
57 Types.Substitutions,
59− Types.Unify
58+ Types.Unify,
59+ Paths_Elm
60
60
61 Build-depends: base >=4.2 && <5,
61 Build-depends: base >=4.2 && <5,
62 containers >= 0.3,
62 containers >= 0.3,
@@ -98,7 +98,8 @@ Executable elm
98 Types.Constrain,
98 Types.Constrain,
99 Types.Hints,
99 Types.Hints,
100 Types.Substitutions,
100 Types.Substitutions,
101− Types.Unify
101+ Types.Unify,
102+ Paths_Elm
102
103
103 Build-depends: base >=4.2 && <5,
104 Build-depends: base >=4.2 && <5,
104 containers >= 0.3,
105 containers >= 0.3,
elm/src/Compiler.hs+2−2
@@ -40,11 +40,11 @@ elm = ELM { make = False &= help "automatically compile dependencies."
40 , minify = False &= help "Minify generated JavaScript"
40 , minify = False &= help "Minify generated JavaScript"
41 } &=
41 } &=
42 help "Compile Elm programs to HTML, CSS, and JavaScript." &=
42 help "Compile Elm programs to HTML, CSS, and JavaScript." &=
43− summary "The Elm Compiler v0.4.0.3, (c) Evan Czaplicki"
43+ summary ("The Elm Compiler " ++ show version ++ ", (c) Evan Czaplicki")
44
44
45main = do
45main = do
46 args <- cmdArgs elm
46 args <- cmdArgs elm
47− mini <- getDataFileName "elm-runtime-0.4.0.3.js"
47+ mini <- getDataFileName ("elm-runtime-" ++ show version ++ ".js")
48 compileArgs mini args
48 compileArgs mini args
49
49
50compileArgs mini (ELM _ [] _ _ _ _ _ _) =
50compileArgs mini (ELM _ [] _ _ _ _ _ _) =
elm/src/Language/Elm.hs+5−1
@@ -12,7 +12,8 @@
12 Example implementations using Yesod and Happstack are available at <https://github.com/tazjin/Elm/tree/master/Examples>
12 Example implementations using Yesod and Happstack are available at <https://github.com/tazjin/Elm/tree/master/Examples>
13-}
13-}
14module Language.Elm (
14module Language.Elm (
15− ElmSource (..)
15+ ElmSource (..),
16+ runtimeLocation
16 ) where
17 ) where
17
18
18import CompileToJS
19import CompileToJS
@@ -21,10 +22,13 @@ import GenerateHtml
21import Initialize
22import Initialize
22import Text.Blaze.Html (Html)
23import Text.Blaze.Html (Html)
23import Language.Elm.Quasi
24import Language.Elm.Quasi
25+import Paths_Elm
24
26
25import qualified Data.Text as TS
27import qualified Data.Text as TS
26import qualified Data.Text.Lazy as TL
28import qualified Data.Text.Lazy as TL
27
29
30+runtimeLocation = getDataFileName ("elm-runtime-" ++ show version ++ ".js")
31+
28class ElmSource a where
32class ElmSource a where
29 -- |This function compiles Elm code to three separate parts: HTML, CSS,
33 -- |This function compiles Elm code to three separate parts: HTML, CSS,
30 -- and JavaScript. The HTML is only the contents of the body, so the three
34 -- and JavaScript. The HTML is only the contents of the body, so the three