yepnope loads in the <head>. closes #257
previous commit just put modernizr/yepnope in the head
This commit is contained in:
parent
91d6a121d6
commit
b7924975b0
@ -527,8 +527,8 @@ widgetToPageContent w = do
|
|||||||
master <- getYesod
|
master <- getYesod
|
||||||
((), GWData (Body body) (Last mTitle) scripts' stylesheets' style jscript (Head head')) <- unGWidget w
|
((), GWData (Body body) (Last mTitle) scripts' stylesheets' style jscript (Head head')) <- unGWidget w
|
||||||
let title = maybe mempty unTitle mTitle
|
let title = maybe mempty unTitle mTitle
|
||||||
let scripts = runUniqueList scripts'
|
scripts = runUniqueList scripts'
|
||||||
let stylesheets = runUniqueList stylesheets'
|
stylesheets = runUniqueList stylesheets'
|
||||||
|
|
||||||
render <- getUrlRenderParams
|
render <- getUrlRenderParams
|
||||||
let renderLoc x =
|
let renderLoc x =
|
||||||
@ -552,22 +552,11 @@ widgetToPageContent w = do
|
|||||||
$ encodeUtf8 $ renderJavascriptUrl render s
|
$ encodeUtf8 $ renderJavascriptUrl render s
|
||||||
return $ renderLoc x
|
return $ renderLoc x
|
||||||
|
|
||||||
let addAttr x (y, z) = x ! customAttribute (textTag y) (toValue z)
|
-- modernizr should be at the end of the <head> http://www.modernizr.com/docs/#installing
|
||||||
let renderLoc' render' (Local url) = render' url []
|
-- the asynchronous loader means your page doesn't have to wait for all the js to load
|
||||||
renderLoc' _ (Remote s) = s
|
let (mcomplete, ynscripts) = ynHelper render scripts jscript jsLoc
|
||||||
let mkScriptTag (Script loc attrs) render' =
|
headAll = [HAMLET|
|
||||||
foldl' addAttr TBH.script (("src", renderLoc' render' loc) : attrs) $ return ()
|
\^{head'}
|
||||||
let mkLinkTag (Stylesheet loc attrs) render' =
|
|
||||||
foldl' addAttr TBH.link
|
|
||||||
( ("rel", "stylesheet")
|
|
||||||
: ("href", renderLoc' render' loc)
|
|
||||||
: attrs
|
|
||||||
)
|
|
||||||
let left (Left x) = Just x
|
|
||||||
left _ = Nothing
|
|
||||||
right (Right x) = Just x
|
|
||||||
right _ = Nothing
|
|
||||||
let head'' = [HAMLET|
|
|
||||||
$forall s <- stylesheets
|
$forall s <- stylesheets
|
||||||
^{mkLinkTag s}
|
^{mkLinkTag s}
|
||||||
$forall s <- css
|
$forall s <- css
|
||||||
@ -581,20 +570,6 @@ $forall s <- css
|
|||||||
<style media=#{media}>#{content}
|
<style media=#{media}>#{content}
|
||||||
$nothing
|
$nothing
|
||||||
<style>#{content}
|
<style>#{content}
|
||||||
$maybe _ <- yepnopeJs master
|
|
||||||
$nothing
|
|
||||||
$forall s <- scripts
|
|
||||||
^{mkScriptTag s}
|
|
||||||
$maybe j <- jscript
|
|
||||||
$maybe s <- jsLoc
|
|
||||||
<script src="#{s}">
|
|
||||||
$nothing
|
|
||||||
<script>^{jelper j}
|
|
||||||
\^{head'}
|
|
||||||
|]
|
|
||||||
let (mcomplete, ynscripts) = ynHelper render scripts jscript jsLoc
|
|
||||||
let bodyYN = [HAMLET|
|
|
||||||
^{body}
|
|
||||||
$maybe eyn <- yepnopeJs master
|
$maybe eyn <- yepnopeJs master
|
||||||
$maybe yn <- left eyn
|
$maybe yn <- left eyn
|
||||||
<script src=#{yn}>
|
<script src=#{yn}>
|
||||||
@ -604,8 +579,34 @@ $maybe eyn <- yepnopeJs master
|
|||||||
<script>yepnope({load:#{ynscripts},complete:function(){^{complete}}})
|
<script>yepnope({load:#{ynscripts},complete:function(){^{complete}}})
|
||||||
$nothing
|
$nothing
|
||||||
<script>yepnope({load:#{ynscripts}})
|
<script>yepnope({load:#{ynscripts}})
|
||||||
|
$nothing
|
||||||
|
$forall s <- scripts
|
||||||
|
^{mkScriptTag s}
|
||||||
|
$maybe j <- jscript
|
||||||
|
$maybe s <- jsLoc
|
||||||
|
<script src="#{s}">
|
||||||
|
$nothing
|
||||||
|
<script>^{jelper j}
|
||||||
|]
|
|]
|
||||||
return $ PageContent title head'' bodyYN
|
return $ PageContent title headAll body
|
||||||
|
where
|
||||||
|
left (Left x) = Just x
|
||||||
|
left _ = Nothing
|
||||||
|
right (Right x) = Just x
|
||||||
|
right _ = Nothing
|
||||||
|
|
||||||
|
renderLoc' render' (Local url) = render' url []
|
||||||
|
renderLoc' _ (Remote s) = s
|
||||||
|
|
||||||
|
addAttr x (y, z) = x ! customAttribute (textTag y) (toValue z)
|
||||||
|
mkScriptTag (Script loc attrs) render' =
|
||||||
|
foldl' addAttr TBH.script (("src", renderLoc' render' loc) : attrs) $ return ()
|
||||||
|
mkLinkTag (Stylesheet loc attrs) render' =
|
||||||
|
foldl' addAttr TBH.link
|
||||||
|
( ("rel", "stylesheet")
|
||||||
|
: ("href", renderLoc' render' loc)
|
||||||
|
: attrs
|
||||||
|
)
|
||||||
|
|
||||||
ynHelper :: (url -> [x] -> Text)
|
ynHelper :: (url -> [x] -> Text)
|
||||||
-> [Script (url)]
|
-> [Script (url)]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user