diff --git a/scripts b/scripts index 2fc59a85..e791ced0 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 2fc59a850bdc49e01f7a5e062b813df321ce5c78 +Subproject commit e791ced0395245e30d37b5098a27bba5e818ecb7 diff --git a/yesod-core/Yesod/Internal/Core.hs b/yesod-core/Yesod/Internal/Core.hs index 4ba14405..da038c13 100644 --- a/yesod-core/Yesod/Internal/Core.hs +++ b/yesod-core/Yesod/Internal/Core.hs @@ -52,7 +52,7 @@ import Control.Monad.Trans.RWS import Text.Hamlet import Text.Cassius import Text.Julius -import Text.Blaze ((!), customAttribute, textTag, toValue) +import Text.Blaze ((!), customAttribute, textTag, toValue, unsafeLazyByteString) import qualified Text.Blaze.Html5 as TBH import Data.Text.Lazy.Builder (toLazyText) import Data.Text.Lazy.Encoding (encodeUtf8) @@ -75,6 +75,9 @@ import qualified Data.Text.Lazy.IO import qualified Data.Text.Lazy.Builder as TB import Language.Haskell.TH.Syntax (Loc (..), Lift (..)) import Text.Blaze (preEscapedLazyText) +import Data.Aeson (Value (Array, String)) +import Data.Aeson.Encode (encode) +import qualified Data.Vector as Vector #if GHC7 #define HAMLET hamlet @@ -264,6 +267,11 @@ class RenderRoute (Route a) => Yesod a where gzipCompressFiles :: a -> Bool gzipCompressFiles _ = False + -- | Location of yepnope.js, if any. If one is provided, then all + -- Javascript files will be loaded asynchronously. + yepnopeJs :: a -> Maybe (Either Text (Route a)) + yepnopeJs _ = Nothing + messageLoggerHandler :: (Yesod m, MonadIO mo) => Loc -> LogLevel -> Text -> GGHandler s m mo () messageLoggerHandler loc level msg = do @@ -472,18 +480,22 @@ maybeAuthorized r isWrite = do x <- isAuthorized r isWrite return $ if x == Authorized then Just r else Nothing +jsToHtml :: Javascript -> Html +jsToHtml (Javascript b) = preEscapedLazyText $ toLazyText b + +jelper :: JavascriptUrl url -> HtmlUrl url +jelper = fmap jsToHtml + -- | Convert a widget to a 'PageContent'. widgetToPageContent :: (Eq (Route master), Yesod master) => GWidget sub master () -> GHandler sub master (PageContent (Route master)) widgetToPageContent (GWidget w) = do + master <- getYesod ((), _, GWData (Body body) (Last mTitle) scripts' stylesheets' style jscript (Head head')) <- runRWST w () 0 let title = maybe mempty unTitle mTitle let scripts = runUniqueList scripts' let stylesheets = runUniqueList stylesheets' - let jsToHtml (Javascript b) = preEscapedLazyText $ toLazyText b - jelper :: JavascriptUrl url -> HtmlUrl url - jelper = fmap jsToHtml render <- getUrlRenderParams let renderLoc x = @@ -536,16 +548,54 @@ $forall s <- css