@@ -1,33 +1,42 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−module GenerateHtml (generateHtml) where
3−
4−import Text.Blaze (preEscapedToMarkup)
5−import qualified Text.Blaze.Html5 as H
6−import Text.Blaze.Html5 ((!))
7−import qualified Text.Blaze.Html5.Attributes as A
8−
9−css = preEscapedToMarkup $
10− ("* { padding:0; margin:0; \
11− \hyphens: auto; -moz-hyphens: auto;\
12− \ -webkit-hyphens: auto; -ms-hyphens: auto; }\
13− \body { font-family: Arial; }\
14− \a:link {text-decoration: none}\
15− \a:visited {text-decoration: none}\
16− \a:active {text-decoration: none}\
17− \a:hover {text-decoration: underline; color: #ff8f12;}" :: String)
18−
19−makeScript :: String -> H.Html
20−makeScript s = H.script ! A.type_ "text/javascript" ! A.src (H.toValue s) $ ""
21−
22−generateHtml libLoc title source =
23− H.docTypeHtml $ do
24− H.head $ do
25− H.meta ! A.charset "UTF-8"
26− H.title . H.toHtml $ title
27− makeScript libLoc
28− (H.script ! A.type_ "text/javascript") . preEscapedToMarkup $ source
29− H.style ! A.type_ "text/css" $ css
30− H.body $ do
31− H.div ! A.id "widthChecker" ! A.style "width:100%; height:1px; position:absolute; top:-1px;" $ ""
32− H.span ! A.id "content" $ ""
33− H.script ! A.type_ "text/javascript" $ "Dispatcher.initialize()"
1+{-# LANGUAGE OverloadedStrings #-}
2+module GenerateHtml (generateHtml) where
3+
4+import Text.Blaze (preEscapedToMarkup)
5+import qualified Text.Blaze.Html5 as H
6+import Text.Blaze.Html5 ((!))
7+import qualified Text.Blaze.Html5.Attributes as A
8+
9+import Initialize
10+import CompileToJS
11+import ExtractNoscript
12+
13+css = preEscapedToMarkup $
14+ ("* { padding:0; margin:0; \
15+ \hyphens: auto; -moz-hyphens: auto;\
16+ \ -webkit-hyphens: auto; -ms-hyphens: auto; }\
17+ \body { font-family: Arial; }\
18+ \a:link {text-decoration: none}\
19+ \a:visited {text-decoration: none}\
20+ \a:active {text-decoration: none}\
21+ \a:hover {text-decoration: underline; color: #ff8f12;}" :: String)
22+
23+makeScript :: String -> H.Html
24+makeScript s = H.script ! A.type_ "text/javascript" ! A.src (H.toValue s) $ ""
25+
26+generateHtml libLoc title source =
27+ let expr = initialize source
28+ js = compileToJS expr
29+ noscript = either id extract expr
30+ in
31+ H.docTypeHtml $ do
32+ H.head $ do
33+ H.meta ! A.charset "UTF-8"
34+ H.title . H.toHtml $ title
35+ makeScript libLoc
36+ H.script ! A.type_ "text/javascript" $ preEscapedToMarkup js
37+ H.style ! A.type_ "text/css" $ css
38+ H.body $ do
39+ H.div ! A.id "widthChecker" ! A.style "width:100%; height:1px; position:absolute; top:-1px;" $ ""
40+ H.span ! A.id "content" $ ""
41+ H.script ! A.type_ "text/javascript" $ "Dispatcher.initialize()"
42+ H.noscript $ preEscapedToMarkup noscript