on master help sign in
Fix elm-happstack examples.
commit675a46be9f464b6231b1cf31bacf6ac7bce4a903 authorevancz <info@elm-lang.org> dateWed 27 Jun 2012, 01:52 (14 years ago) parent68840c6
4 files changed+26−19
Examples/elm-happstack/Main.hs+1−1 Examples/elm-happstack/elm_source/clock.elm+5−4 Examples/elm-happstack/elm_source/index.elm+9−9 Examples/elm-happstack/elm_source/mouse.elm+11−5
Examples/elm-happstack/Main.hs+1−1
@@ -6,7 +6,7 @@ import Language.Elm
66import Language.Elm.Quasi
77
88elmLoc :: String
9−elmLoc = "http://f.cl.ly/items/2e3Z3r3v29263U393c3x/elm-min.js"
9+elmLoc = "https://raw.github.com/evancz/Elm/master/elm/elm-runtime-0.3.0.js"
1010
1111-- elmResponse is a "nice to have" helper function for compiling
1212-- Elm code when using Elm with Happstack. At some point this might
Examples/elm-happstack/elm_source/clock.elm+5−4
@@ -1,12 +1,13 @@
1−clockColor = rgb (6/16) (11/16) (14/16)
1+
2+import Signal.Time (every)
23
34hand clr len time =
4− let t = Math.PI * time / 30 - Math.PI / 2 in
5+ let t = pi * time / 30 - pi / 2 in
56 solid clr $ line [(200,200), (200 + len * cos t, 200 + len * sin t)]
67
7−clock t = collage 400 400 [ filled clockColor $ ngon 12 110 (200, 200)
8+clock t = collage 400 400 [ filled (rgb 96 176 224) $ ngon 12 110 (200, 200)
89 , hand red 100 t
910 , hand black 100 (t/60)
1011 , hand black 60 (t/720) ]
1112
12−main = lift clock $ Time.every 1
13+main = lift clock (every 1)
Examples/elm-happstack/elm_source/index.elm+9−9
@@ -1,7 +1,7 @@
1−title w = size w 60 . box 4 . text . header . toText $ "Elm-Happstack"
1+title w = size w 60 . box 4 . text . header . toText $ "Elm-Yesod"
22
3−lightGrey = rgb (240/255) (241/255) (244/255)
4−mediumGrey = rgb (216/255) (221/255) (225/255)
3+lightGrey = rgb 240 241 244
4+mediumGrey = rgb 216 221 225
55heading outer inner =
66 color mediumGrey . size outer 61 . box 1 .
77 color lightGrey . size outer 60 . box 5 .
@@ -18,16 +18,16 @@ skeleton body outer =
1818section = text . bold . Text.height (5/4) . toText
1919
2020info w = List.map (\f -> f ()) . List.intersperse (\x -> plainText "&nbsp;") . List.map ((\e x -> e) . width w) $
21− [ section "Written in Elm, served with Happstack"
21+ [ section "Written in Elm, served with Yesod"
2222 , text $ toText "This page is written in " ++ link "http://elm-lang.org/" (toText "Elm") ++
2323 toText " and served using the " ++
24− link "http://happstack.com/" (toText "Happstack Web Framework") ++
24+ link "http://yesodweb.com/" (toText "Yesod Web Framework") ++
2525 toText ". Since you are looking at this page it is safe to assume that you already have the example code. "
26− , text $ toText "A second Happstack example using web-routes will be added later on."
26+ , text $ toText "Type-safe URLs are rendered using simple QuasiQuoter variable interpolation."
2727 , section "More examples:"
28− , text $ toText "- " ++ link "#{mouse}" (toText "A simple mouse input example")
29− , text $ toText "- " ++ link "#{clock}" (toText "An animated analog clock")
30− , text $ toText "- " ++ link "#{shapes}" (toText "Some simple rendered shapes")
28+ , text $ toText "- " ++ link "@{MouseR}" (toText "A simple mouse input example")
29+ , text $ toText "- " ++ link "@{ClockR}" (toText "An animated analog clock")
30+ , text $ toText "- " ++ link "@{ShapesR}" (toText "Some simple rendered shapes")
3131 ]
3232
3333body outer inner = width outer . box 2 . flow down . (:) (plainText "&nbsp;") $ info inner
Examples/elm-happstack/elm_source/mouse.elm+11−5
@@ -1,9 +1,15 @@
1−niceBlue = rgb 0 (1/3) (2/3)
2−clearGreen = rgba (1/9) (8/9) (3/9) (1/2)
1+
2+-- Move your mouse around above the canvas!
3+
4+import Signal.Mouse (position)
5+import Signal.Window (dimensions)
6+
7+myBlue = rgb 0 85 170
8+myGreen = rgba 28 267 85 (1/2)
39
410scene (x,y) (w,h) =
5− collage w h [ filled niceBlue . rotate ((x+y)/1000) $ ngon 4 100 (200,200)
6− , filled clearGreen $ ngon 5 30 (x,y)
11+ collage w h [ filled myBlue . rotate ((x+y)/1000) $ ngon 4 100 (200,200)
12+ , filled myGreen $ ngon 5 30 (x,y)
713 ]
814
9−main = lift2 scene Mouse.position Window.dimensions
15+main = lift2 scene position dimensions