on master help sign in
Get runtime location working properly.
commit253e768e629f5b3ec5a864da52c2f7230f3832ab authorevancz <info@elm-lang.org> dateWed 3 Oct 2012, 02:47 (14 years ago) parentf454331
5 files changed+21−17
elm-server/Server.hs+9−10 elm-server/elm-server.cabal+1−1 elm/Elm.cabal+4−3 elm/src/Compiler.hs+2−2 elm/src/Language/Elm.hs+5−1
elm-server/Server.hs+9−10
@@ -9,11 +9,13 @@ import Happstack.Server.Compression
99import System.Directory (makeRelativeToCurrentDirectory)
1010import System.Environment
1111import qualified Language.Elm as Elm
12−import Paths_Elm
12+import Paths_elm_server
13+
14+runtime = "/elm-" ++ show version ++ ".js"
1315
1416serve :: String -> IO ()
1517serve 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>")
1719 simpleHTTP nullConf $ do
1820 _ <- compressedResponseFilter
1921 msum [ uriRest serveElm
@@ -29,10 +31,10 @@ serveElm fp = do
2931 let ('/':filePath) = fp
3032 guard (".elm" `isSuffixOf` filePath)
3133 content <- liftIO (readFile filePath)
32− ok . toResponse $ Elm.toHtml "elm-runtime.js" (pageTitle filePath) content
34+ ok . toResponse $ Elm.toHtml runtime (pageTitle filePath) content
3335
3436serveLib libLoc fp = do
35− guard (fp == "/elm-runtime.js")
37+ guard (fp == runtime)
3638 serveFile (asContentType "application/javascript") libLoc
3739
3840main :: IO ()
@@ -40,11 +42,8 @@ main = getArgs >>= parse
4042
4143parse :: [String] -> IO ()
4244parse ("--help":_) = putStrLn usage
43−parse ("--version":_) = putStrLn "The Elm Server 0.4.0.3"
44−parse [] = do
45− absolutePath <- getDataFileName "elm-runtime-0.4.0.3.js"
46− runtime <- makeRelativeToCurrentDirectory absolutePath
47− serve runtime
45+parse ("--version":_) = putStrLn ("The Elm Server " ++ show version)
46+parse [] = serve =<< Elm.runtimeLocation
4847parse [arg]
4948 | "--runtime-location=" `isPrefixOf` arg =
5049 serve . tail $ dropWhile (/='=') arg
@@ -63,7 +62,7 @@ usage =
6362 \Example: elm-server\n\
6463 \\n\
6564 \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\
6766 \\n\
6867 \Compiler Information:\n\
6968 \ --version print the version information and exit\n\
elm-server/elm-server.cabal+1−1
@@ -35,4 +35,4 @@ Executable elm-server
3535 happstack-server == 7.0.2,
3636 deepseq,
3737 directory,
38− Elm == 0.4.*
38+ Elm >= 0.4.0.3
elm/Elm.cabal+4−3
@@ -32,7 +32,6 @@ source-repository head
3232Library
3333 exposed-modules: Language.Elm,
3434 Language.Elm.Quasi
35− Paths_Elm
3635 Hs-Source-Dirs: src, src/Parse, src/Types, src/Gen
3736 other-modules: Ast,
3837 CompileToJS,
@@ -56,7 +55,8 @@ Library
5655 Types.Constrain,
5756 Types.Hints,
5857 Types.Substitutions,
59− Types.Unify
58+ Types.Unify,
59+ Paths_Elm
6060
6161 Build-depends: base >=4.2 && <5,
6262 containers >= 0.3,
@@ -98,7 +98,8 @@ Executable elm
9898 Types.Constrain,
9999 Types.Hints,
100100 Types.Substitutions,
101− Types.Unify
101+ Types.Unify,
102+ Paths_Elm
102103
103104 Build-depends: base >=4.2 && <5,
104105 containers >= 0.3,
elm/src/Compiler.hs+2−2
@@ -40,11 +40,11 @@ elm = ELM { make = False &= help "automatically compile dependencies."
4040 , minify = False &= help "Minify generated JavaScript"
4141 } &=
4242 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")
4444
4545main = do
4646 args <- cmdArgs elm
47− mini <- getDataFileName "elm-runtime-0.4.0.3.js"
47+ mini <- getDataFileName ("elm-runtime-" ++ show version ++ ".js")
4848 compileArgs mini args
4949
5050compileArgs mini (ELM _ [] _ _ _ _ _ _) =
elm/src/Language/Elm.hs+5−1
@@ -12,7 +12,8 @@
1212 Example implementations using Yesod and Happstack are available at <https://github.com/tazjin/Elm/tree/master/Examples>
1313-}
1414module Language.Elm (
15− ElmSource (..)
15+ ElmSource (..),
16+ runtimeLocation
1617 ) where
1718
1819import CompileToJS
@@ -21,10 +22,13 @@ import GenerateHtml
2122import Initialize
2223import Text.Blaze.Html (Html)
2324import Language.Elm.Quasi
25+import Paths_Elm
2426
2527import qualified Data.Text as TS
2628import qualified Data.Text.Lazy as TL
2729
30+runtimeLocation = getDataFileName ("elm-runtime-" ++ show version ++ ".js")
31+
2832class ElmSource a where
2933 -- |This function compiles Elm code to three separate parts: HTML, CSS,
3034 -- and JavaScript. The HTML is only the contents of the body, so the three