@@ -5,8 +5,8 @@ import Happstack.Server
5import Language.Elm
5import Language.Elm
6import Language.Elm.Quasi
6import Language.Elm.Quasi
8−elmLoc :: String
8+elmRuntime="elm-runtime.js"
9−elmLoc = "https://raw.github.com/evancz/Elm/master/elm/elm-runtime-0.7.1.1.js"
9+elmRTPath='/':elmRuntime
11-- elmResponse is a "nice to have" helper function for compiling
11-- elmResponse is a "nice to have" helper function for compiling
12-- Elm code when using Elm with Happstack. At some point this might
12-- Elm code when using Elm with Happstack. At some point this might
@@ -15,7 +15,7 @@ elmResponse :: ElmSource a
15 => String -- ^ Page title
15 => String -- ^ Page title
16 -> a -- ^ elm source
16 -> a -- ^ elm source
17 -> Response
17 -> Response
18−elmResponse title = toResponse . toHtml elmLoc title
18+elmResponse title = toResponse . toHtml elmRTPath title
20-- embedding variables (in this case URLs)
20-- embedding variables (in this case URLs)
21rootHandler :: ServerPart Response
21rootHandler :: ServerPart Response
@@ -52,11 +52,13 @@ shapesHandler :: ServerPart Response
52shapesHandler = ok $ elmResponse "Simple shapes" $ shapesPage
52shapesHandler = ok $ elmResponse "Simple shapes" $ shapesPage
55−elmExample :: ServerPart Response
55+elmExample :: String -> ServerPart Response
56−elmExample =
56+elmExample elmLoc = do
57− msum [ nullDir >> rootHandler
57+ msum [ nullDir >> rootHandler
58+ , dir elmRuntime $ nullDir >>
59+ serveFile (guessContentTypeM mimeTypes) elmLoc
58 , dir "mouse" $ nullDir >>
60 , dir "mouse" $ nullDir >>
59− mouseHandler
61+ mouseHandler
60 , dir "clock" $ nullDir >>
62 , dir "clock" $ nullDir >>
61 clockHandler
63 clockHandler
62 , dir "shapes" $ nullDir >>
64 , dir "shapes" $ nullDir >>
@@ -64,4 +66,6 @@ elmExample =
66main :: IO ()
68main :: IO ()
70+ elmLoc <- Language.Elm.runtimeLocation
67−main = simpleHTTP nullConf {port = 3000} elmExample
71+ simpleHTTP nullConf {port = 3000} $ elmExample elmLoc