summaryrefslogtreecommitdiff
path: root/standalone/android/haskell-patches/yesod-core_expand_TH.patch
blob: 1687ff0e4a8de82ca916f8c1012f106f9e70b5a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
From 7583457fb410d07f480a2aa7d6c2f174324b3592 Mon Sep 17 00:00:00 2001
From: dummy <dummy@example.com>
Date: Sat, 19 Oct 2013 02:03:18 +0000
Subject: [PATCH] hackity

---
 Yesod/Core.hs              |    2 -
 Yesod/Core/Class/Yesod.hs  |  247 ++++++++++++++++++++++++++++++--------------
 Yesod/Core/Dispatch.hs     |    7 --
 Yesod/Core/Handler.hs      |   24 ++---
 Yesod/Core/Internal/Run.hs |    2 -
 5 files changed, 179 insertions(+), 103 deletions(-)

diff --git a/Yesod/Core.hs b/Yesod/Core.hs
index 12e59d5..f1ff21c 100644
--- a/Yesod/Core.hs
+++ b/Yesod/Core.hs
@@ -94,8 +94,6 @@ module Yesod.Core
     , JavascriptUrl
     , renderJavascriptUrl
       -- ** Cassius/Lucius
-    , cassius
-    , lucius
     , CssUrl
     , renderCssUrl
     ) where
diff --git a/Yesod/Core/Class/Yesod.hs b/Yesod/Core/Class/Yesod.hs
index cf02a1a..3f1e88e 100644
--- a/Yesod/Core/Class/Yesod.hs
+++ b/Yesod/Core/Class/Yesod.hs
@@ -9,6 +9,10 @@ import           Yesod.Core.Content
 import           Yesod.Core.Handler
 
 import           Yesod.Routes.Class
+import qualified Text.Blaze.Internal
+import qualified Control.Monad.Logger
+import qualified Text.Hamlet
+import qualified Data.Foldable
 
 import           Blaze.ByteString.Builder           (Builder)
 import           Blaze.ByteString.Builder.Char.Utf8 (fromText)
@@ -87,18 +91,27 @@ class RenderRoute site => Yesod site where
     defaultLayout w = do
         p <- widgetToPageContent w
         mmsg <- getMessage
-        giveUrlRenderer [hamlet|
-            $newline never
-            $doctype 5
-            <html>
-                <head>
-                    <title>#{pageTitle p}
-                    ^{pageHead p}
-                <body>
-                    $maybe msg <- mmsg
-                        <p .message>#{msg}
-                    ^{pageBody p}
-            |]
+        giveUrlRenderer  $         \ _render_aHra
+          -> do { id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<!DOCTYPE html>\n<html><head><title>");
+                  id (TBH.toHtml (pageTitle p));
+                  id ((Text.Blaze.Internal.preEscapedText . T.pack) "</title>");
+                  Text.Hamlet.asHtmlUrl (pageHead p) _render_aHra;
+                  id ((Text.Blaze.Internal.preEscapedText . T.pack) "</head><body>");
+                  Text.Hamlet.maybeH
+                    mmsg
+                    (\ msg_aHrb
+                       -> do { id
+                                 ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                    "<p class=\"message\">");
+                               id (TBH.toHtml msg_aHrb);
+                               id ((Text.Blaze.Internal.preEscapedText . T.pack) "</p>") })
+                    Nothing;
+                  Text.Hamlet.asHtmlUrl (pageBody p) _render_aHra;
+                  id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack) "</body></html>") }
+
 
     -- | Override the rendering function for a particular URL. One use case for
     -- this is to offload static hosting to a different domain name to avoid
@@ -356,45 +369,103 @@ widgetToPageContent w = do
     -- modernizr should be at the end of the <head> http://www.modernizr.com/docs/#installing
     -- the asynchronous loader means your page doesn't have to wait for all the js to load
     let (mcomplete, asyncScripts) = asyncHelper render scripts jscript jsLoc
-        regularScriptLoad = [hamlet|
-            $newline never
-            $forall s <- scripts
-                ^{mkScriptTag s}
-            $maybe j <- jscript
-                $maybe s <- jsLoc
-                    <script src="#{s}">
-                $nothing
-                    <script>^{jelper j}
-        |]
-
-        headAll = [hamlet|
-            $newline never
-            \^{head'}
-            $forall s <- stylesheets
-                ^{mkLinkTag s}
-            $forall s <- css
-                $maybe t <- right $ snd s
-                    $maybe media <- fst s
-                        <link rel=stylesheet media=#{media} href=#{t}>
-                    $nothing
-                        <link rel=stylesheet href=#{t}>
-                $maybe content <- left $ snd s
-                    $maybe media <- fst s
-                        <style media=#{media}>#{content}
-                    $nothing
-                        <style>#{content}
-            $case jsLoader master
-              $of BottomOfBody
-              $of BottomOfHeadAsync asyncJsLoader
-                  ^{asyncJsLoader asyncScripts mcomplete}
-              $of BottomOfHeadBlocking
-                  ^{regularScriptLoad}
-        |]
-    let bodyScript = [hamlet|
-            $newline never
-            ^{body}
-            ^{regularScriptLoad}
-        |]
+        regularScriptLoad =         \ _render_aHsO
+          -> do { Data.Foldable.mapM_
+                    (\ s_aHsP
+                       -> Text.Hamlet.asHtmlUrl (mkScriptTag s_aHsP) _render_aHsO)
+                    scripts;
+                  Text.Hamlet.maybeH
+                    jscript
+                    (\ j_aHsQ
+                       -> Text.Hamlet.maybeH
+                            jsLoc
+                            (\ s_aHsR
+                               -> do { id
+                                         ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                            "<script src=\"");
+                                       id (TBH.toHtml s_aHsR);
+                                       id
+                                         ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                            "\"></script>") })
+                            (Just
+                               (do { id
+                                       ((Text.Blaze.Internal.preEscapedText . T.pack) "<script>");
+                                     Text.Hamlet.asHtmlUrl (jelper j_aHsQ) _render_aHsO;
+                                     id ((Text.Blaze.Internal.preEscapedText . T.pack) "</script>") })))
+                    Nothing }
+
+
+        headAll =         \ _render_aHsW
+          -> do { Text.Hamlet.asHtmlUrl head' _render_aHsW;
+                  Data.Foldable.mapM_
+                    (\ s_aHsX -> Text.Hamlet.asHtmlUrl (mkLinkTag s_aHsX) _render_aHsW)
+                    stylesheets;
+                  Data.Foldable.mapM_
+                    (\ s_aHsY
+                       -> do { Text.Hamlet.maybeH
+                                 (right (snd s_aHsY))
+                                 (\ t_aHsZ
+                                    -> Text.Hamlet.maybeH
+                                         (fst s_aHsY)
+                                         (\ media_aHt0
+                                            -> do { id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "<link rel=\"stylesheet\" media=\"");
+                                                    id (TBH.toHtml media_aHt0);
+                                                    id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "\" href=\"");
+                                                    id (TBH.toHtml t_aHsZ);
+                                                    id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "\">") })
+                                         (Just
+                                            (do { id
+                                                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                       "<link rel=\"stylesheet\" href=\"");
+                                                  id (TBH.toHtml t_aHsZ);
+                                                  id
+                                                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                       "\">") })))
+                                 Nothing;
+                               Text.Hamlet.maybeH
+                                 (left (snd s_aHsY))
+                                 (\ content_aHt1
+                                    -> Text.Hamlet.maybeH
+                                         (fst s_aHsY)
+                                         (\ media_aHt2
+                                            -> do { id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "<style media=\"");
+                                                    id (TBH.toHtml media_aHt2);
+                                                    id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "\">");
+                                                    id (TBH.toHtml content_aHt1);
+                                                    id
+                                                      ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                         "</style>") })
+                                         (Just
+                                            (do { id
+                                                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                       "<style>");
+                                                  id (TBH.toHtml content_aHt1);
+                                                  id
+                                                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                                                       "</style>") })))
+                                 Nothing })
+                    css;
+                  case jsLoader master of {
+                    BottomOfBody -> return ()
+                    ; BottomOfHeadAsync asyncJsLoader_aHt3
+                      -> Text.Hamlet.asHtmlUrl
+                           (asyncJsLoader_aHt3 asyncScripts mcomplete) _render_aHsW
+                    ; BottomOfHeadBlocking
+                      -> Text.Hamlet.asHtmlUrl regularScriptLoad _render_aHsW } }
+
+    let bodyScript =     \ _render_aHt8 -> do { Text.Hamlet.asHtmlUrl body _render_aHt8;
+              Text.Hamlet.asHtmlUrl regularScriptLoad _render_aHt8 }
+
 
     return $ PageContent title headAll $
         case jsLoader master of
@@ -424,10 +495,13 @@ defaultErrorHandler NotFound = selectRep $ do
         r <- waiRequest
         let path' = TE.decodeUtf8With TEE.lenientDecode $ W.rawPathInfo r
         setTitle "Not Found"
-        toWidget [hamlet|
-            <h1>Not Found
-            <p>#{path'}
-        |]
+        toWidget  $         \ _render_aHte
+          -> do { id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<h1>Not Found</h1>\n<p>");
+                  id (TBH.toHtml path');
+                  id ((Text.Blaze.Internal.preEscapedText . T.pack) "</p>") }
+
     provideRep $ return $ object ["message" .= ("Not Found" :: Text)]
 
 -- For API requests.
@@ -437,10 +511,11 @@ defaultErrorHandler NotFound = selectRep $ do
 defaultErrorHandler NotAuthenticated = selectRep $ do
     provideRep $ defaultLayout $ do
         setTitle "Not logged in"
-        toWidget [hamlet|
-            <h1>Not logged in
-            <p style="display:none;">Set the authRoute and the user will be redirected there.
-        |]
+        toWidget  $         \ _render_aHti
+          -> id
+               ((Text.Blaze.Internal.preEscapedText . T.pack)
+                  "<h1>Not logged in</h1>\n<p style=\"none;\">Set the authRoute and the user will be redirected there.</p>")
+
 
     provideRep $ do
         -- 401 *MUST* include a WWW-Authenticate header
@@ -462,10 +537,13 @@ defaultErrorHandler NotAuthenticated = selectRep $ do
 defaultErrorHandler (PermissionDenied msg) = selectRep $ do
     provideRep $ defaultLayout $ do
         setTitle "Permission Denied"
-        toWidget [hamlet|
-            <h1>Permission denied
-            <p>#{msg}
-        |]
+        toWidget  $         \ _render_aHtq
+          -> do { id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<h1>Permission denied</h1>\n<p>");
+                  id (TBH.toHtml msg);
+                  id ((Text.Blaze.Internal.preEscapedText . T.pack) "</p>") }
+
     provideRep $
         return $ object $ [
           "message" .= ("Permission Denied. " <> msg)
@@ -474,30 +552,43 @@ defaultErrorHandler (PermissionDenied msg) = selectRep $ do
 defaultErrorHandler (InvalidArgs ia) = selectRep $ do
     provideRep $ defaultLayout $ do
         setTitle "Invalid Arguments"
-        toWidget [hamlet|
-            <h1>Invalid Arguments
-            <ul>
-                $forall msg <- ia
-                    <li>#{msg}
-        |]
+        toWidget  $         \ _render_aHtv
+          -> do { id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<h1>Invalid Arguments</h1>\n<ul>");
+                  Data.Foldable.mapM_
+                    (\ msg_aHtw
+                       -> do { id ((Text.Blaze.Internal.preEscapedText . T.pack) "<li>");
+                               id (TBH.toHtml msg_aHtw);
+                               id ((Text.Blaze.Internal.preEscapedText . T.pack) "</li>") })
+                    ia;
+                  id ((Text.Blaze.Internal.preEscapedText . T.pack) "</ul>") }
+
     provideRep $ return $ object ["message" .= ("Invalid Arguments" :: Text), "errors" .= ia]
 defaultErrorHandler (InternalError e) = do
-    $logErrorS "yesod-core" e
     selectRep $ do
         provideRep $ defaultLayout $ do
             setTitle "Internal Server Error"
-            toWidget [hamlet|
-                <h1>Internal Server Error
-                <pre>#{e}
-            |]
+            toWidget  $             \ _render_aHtC
+              -> do { id
+                        ((Text.Blaze.Internal.preEscapedText . T.pack)
+                           "<h1>Internal Server Error</h1>\n<pre>");
+                      id (TBH.toHtml e);
+                      id ((Text.Blaze.Internal.preEscapedText . T.pack) "</pre>") }
+
         provideRep $ return $ object ["message" .= ("Internal Server Error" :: Text), "error" .= e]
 defaultErrorHandler (BadMethod m) = selectRep $ do
     provideRep $ defaultLayout $ do
         setTitle"Bad Method"
-        toWidget [hamlet|
-            <h1>Method Not Supported
-            <p>Method <code>#{S8.unpack m}</code> not supported
-        |]
+        toWidget  $         \ _render_aHtH
+          -> do { id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "<h1>Method Not Supported</h1>\n<p>Method <code>");
+                  id (TBH.toHtml (S8.unpack m));
+                  id
+                    ((Text.Blaze.Internal.preEscapedText . T.pack)
+                       "</code> not supported</p>") }
+
     provideRep $ return $ object ["message" .= ("Bad method" :: Text), "method" .= m]
 
 asyncHelper :: (url -> [x] -> Text)
diff --git a/Yesod/Core/Dispatch.hs b/Yesod/Core/Dispatch.hs
index 335a15c..4ca05da 100644
--- a/Yesod/Core/Dispatch.hs
+++ b/Yesod/Core/Dispatch.hs
@@ -123,13 +123,6 @@ toWaiApp site = do
                 , yreSite = site
                 , yreSessionBackend = sb
                 }
-    messageLoggerSource
-        site
-        logger
-        $(qLocation >>= liftLoc)
-        "yesod-core"
-        LevelInfo
-        (toLogStr ("Application launched" :: S.ByteString))
     middleware <- mkDefaultMiddlewares logger
     return $ middleware $ toWaiAppYre yre
 
diff --git a/Yesod/Core/Handler.hs b/Yesod/Core/Handler.hs
index f3b1799..d819b04 100644
--- a/Yesod/Core/Handler.hs
+++ b/Yesod/Core/Handler.hs
@@ -152,7 +152,7 @@ import qualified Control.Monad.Trans.Writer    as Writer
 
 import           Control.Monad.IO.Class        (MonadIO, liftIO)
 import           Control.Monad.Trans.Resource  (MonadResource, liftResourceT)
-
+import qualified Text.Blaze.Internal
 import qualified Network.HTTP.Types            as H
 import qualified Network.Wai                   as W
 import Control.Monad.Trans.Class (lift)
@@ -710,19 +710,15 @@ redirectToPost :: (MonadHandler m, RedirectUrl (HandlerSite m) url)
                -> m a
 redirectToPost url = do
     urlText <- toTextUrl url
-    giveUrlRenderer [hamlet|
-$newline never
-$doctype 5
-
-<html>
-    <head>
-        <title>Redirecting...
-    <body onload="document.getElementById('form').submit()">
-        <form id="form" method="post" action=#{urlText}>
-            <noscript>
-                <p>Javascript has been disabled; please click on the button below to be redirected.
-            <input type="submit" value="Continue">
-|] >>= sendResponse
+    giveUrlRenderer  $     \ _render_awps
+      -> do { id
+                ((Text.Blaze.Internal.preEscapedText . T.pack)
+                   "<!DOCTYPE html>\n<html><head><title>Redirecting...</title></head><body onload=\"document.getElementById('form').submit()\"><form id=\"form\" method=\"post\" action=\"");
+              id (toHtml urlText);
+              id
+                ((Text.Blaze.Internal.preEscapedText . T.pack)
+                   "\"><noscript><p>Javascript has been disabled; please click on the button below to be redirected.</p></noscript><input type=\"submit\" value=\"Continue\"></form></body></html>") }
+ >>= sendResponse
 
 -- | Wraps the 'Content' generated by 'hamletToContent' in a 'RepHtml'.
 hamletToRepHtml :: MonadHandler m => HtmlUrl (Route (HandlerSite m)) -> m Html
diff --git a/Yesod/Core/Internal/Run.hs b/Yesod/Core/Internal/Run.hs
index 35f1d3f..8b92e99 100644
--- a/Yesod/Core/Internal/Run.hs
+++ b/Yesod/Core/Internal/Run.hs
@@ -122,8 +122,6 @@ safeEh :: (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
        -> ErrorResponse
        -> YesodApp
 safeEh log' er req = do
-    liftIO $ log' $(qLocation >>= liftLoc) "yesod-core" LevelError
-           $ toLogStr $ "Error handler errored out: " ++ show er
     return $ YRPlain
         H.status500
         []
-- 
1.7.10.4