@@ -33,6 +33,7 @@ import Control.Monad (when, forM_)
33
33
import Control.Monad.Trans
34
34
import qualified Data.Map as M
35
35
import Text.Blaze.Html
36
+ import Text.Blaze.Internal
36
37
import Text.Blaze.Html.Renderer.Text
37
38
import qualified Text.Blaze.Html5 as H
38
39
import qualified Text.Blaze.Html5.Attributes as A
@@ -76,9 +77,6 @@ str = id
76
77
mono :: H. Html -> H. Html
77
78
mono h = h ! A. class_ " mono"
78
79
79
- examplesJs :: String
80
- examplesJs = BU. toString $ (embedFile " assets/examples.js" )
81
-
82
80
css :: String
83
81
css = BU. toString $ (embedFile " assets/style.css" )
84
82
@@ -114,7 +112,7 @@ page ex input res = html $ renderHtml $ do
114
112
H. head $ do
115
113
H. title $ H. toHtml $ str " Try PureScript!"
116
114
H. meta ! A. name " viewport" ! A. content " width=device-width, initial-scale=1.0"
117
- H. link ! A. rel " stylesheet" ! A. type_ " text/css" ! A. href " http://fonts.googleapis.com/css?family=Lato:300, 400,700"
115
+ H. link ! A. rel " stylesheet" ! A. type_ " text/css" ! A. href " http://fonts.googleapis.com/css?family=PT+Serif: 400,700"
118
116
H. link ! A. rel " stylesheet" ! A. type_ " text/css" ! A. href " http://fonts.googleapis.com/css?family=Ubuntu+Mono"
119
117
H. style $ H. toHtml $ str css
120
118
H. script ! A. type_ " text/javascript" $ preEscapedToHtml gaq
@@ -123,40 +121,33 @@ page ex input res = html $ renderHtml $ do
123
121
H. script ! A. type_ " text/javascript" ! A. src " //cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/mode-haskell.js" $ mempty
124
122
H. script ! A. type_ " text/javascript" ! A. src " //cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/theme-dawn.js" $ mempty
125
123
H. body $ do
126
- H. div ! A. class_ " header" $ do
127
- H. div ! A. class_ " center" $ do
124
+ H. a ! A. href " https://github.com/purescript" $
125
+ H. img ! A. style " position: absolute; top: 0; right: 0; border: 0;"
126
+ ! A. src " https://github-camo.global.ssl.fastly.net/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67"
127
+ ! A. alt " Fork me on GitHub"
128
+ ! customAttribute " data-canonical-src" " https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"
129
+ H. div ! A. class_ " wrapper" $ do
130
+ H. div ! A. class_ " header" $ do
128
131
H. h1 $ H. toHtml $ str " Try PureScript!"
129
- H. p $ H. toHtml $ str " Type PureScript code below and press 'Compile' to view the compiled Javascript."
130
- H. p $ mconcat [ H. a ! A. href " http://functorial.com/purescript" $ H. toHtml $ str " Documentation"
131
- , H. toHtml $ str " , "
132
- , H. a ! A. href " http://github.com/paf31/purescript" $ H. toHtml $ str " Compiler Source"
133
- , H. toHtml $ str " , "
134
- , H. a ! A. href " http://github.com/paf31/trypurescript" $ H. toHtml $ str " Try PureScript Source" ]
135
- H. div ! A. class_ " splitter" $ mempty
136
- H. div ! A. class_ " main" $ do
137
- H. div ! A. class_ " center" $ do
132
+ H. div ! A. class_ " body" $ do
133
+ H. p $ H. toHtml $ str " Type PureScript code below and press 'Compile', or select one of the examples below:"
134
+
135
+ H. h2 $ H. toHtml $ str " Examples"
136
+ H. ul $ do
137
+ forM_ examples $ \ (name, (title, _)) ->
138
+ H. li $ H. a ! A. href (fromString $ " /example/" ++ name) $ H. toHtml title
139
+
138
140
let (success, text) = responseToJs res
139
- H. div $ do
140
- H. select ! A. style " float: right;" ! A. id " examples" $ do
141
- H. option ! A. value " " $ " Examples"
142
- H. option ! A. value " " $ " "
143
- forM_ examples $ \ (name, (title, _)) -> case () of
144
- _ | ex == Just name -> H. option ! A. value (fromString name) ! A. selected " selected" $ H. toHtml title
145
- _ -> H. option ! A. value (fromString name) $ H. toHtml title
146
- H. script ! A. type_ " text/javascript" $ preEscapedToHtml examplesJs
147
- H. div ! A. style " clear: right;" $ mempty
148
- H. div ! A. style " position: relative; " $ do
149
- H. div ! A. style " position: absolute; width: 50%;" $ do
150
- H. h2 $ H. toHtml $ str " PureScript Code"
151
- H. form ! A. action " /compile" ! A. method " POST" $ do
152
- H. div ! A. id " code" $ mempty
153
- H. textarea ! A. name " code" ! A. id " textarea" ! A. style " display: none;" $ maybe mempty (H. toHtml . str) input
154
- H. div $ H. button ! A. type_ " submit" $ H. toHtml $ str " Compile"
155
- H. div ! A. style " position: absolute; width: 50%; left: 50%;" $ do
156
- H. h2 $ H. toHtml $ str " Generated Javascript"
157
- H. div ! A. id " js" $ H. toHtml . str $ text
158
- H. script ! A. type_ " text/javascript" $ preEscapedToHtml $ str $ " var compiledSuccessfully = " ++ if success then " true;" else " false;"
141
+
142
+ H. h2 $ H. toHtml $ str " PureScript Code"
143
+ H. form ! A. action " /compile" ! A. method " POST" $ do
144
+ H. div ! A. id " code" $ mempty
145
+ H. textarea ! A. name " code" ! A. id " textarea" ! A. style " display: none;" $ maybe mempty (H. toHtml . str) input
146
+ H. div $ H. button ! A. type_ " submit" $ H. toHtml $ str " Compile"
159
147
H. script ! A. type_ " text/javascript" $ preEscapedToHtml ace
148
+
149
+ H. h2 $ H. toHtml $ str " Generated Javascript"
150
+ H. pre $ H. code $ H. toHtml . str $ text
160
151
161
152
responseToJs :: Maybe Response -> (Bool , String )
162
153
responseToJs Nothing = (False , " " )
0 commit comments