Beginning of old widget function deprecation, not complete
This commit is contained in:
parent
0b9ced7f6c
commit
4cc468ca3b
@ -149,7 +149,7 @@ setCreds doRedirects creds = do
|
|||||||
Nothing ->
|
Nothing ->
|
||||||
when doRedirects $ do
|
when doRedirects $ do
|
||||||
case authRoute y of
|
case authRoute y of
|
||||||
Nothing -> do rh <- defaultLayout $ addHtml [shamlet| <h1>Invalid login |]
|
Nothing -> do rh <- defaultLayout $ toWidget [shamlet| <h1>Invalid login |]
|
||||||
sendResponse rh
|
sendResponse rh
|
||||||
Just ar -> do setMessageI Msg.InvalidLogin
|
Just ar -> do setMessageI Msg.InvalidLogin
|
||||||
redirect ar
|
redirect ar
|
||||||
@ -164,7 +164,7 @@ getCheckR = do
|
|||||||
creds <- maybeAuthId
|
creds <- maybeAuthId
|
||||||
defaultLayoutJson (do
|
defaultLayoutJson (do
|
||||||
setTitle "Authentication Status"
|
setTitle "Authentication Status"
|
||||||
addHtml $ html' creds) (jsonCreds creds)
|
toWidget $ html' creds) (jsonCreds creds)
|
||||||
where
|
where
|
||||||
html' creds =
|
html' creds =
|
||||||
[shamlet|
|
[shamlet|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ helper maudience = AuthPlugin
|
|||||||
_ -> notFound
|
_ -> notFound
|
||||||
, apLogin = \toMaster -> do
|
, apLogin = \toMaster -> do
|
||||||
addScriptRemote browserIdJs
|
addScriptRemote browserIdJs
|
||||||
addHamlet [hamlet|
|
toWidget [hamlet|
|
||||||
<p>
|
<p>
|
||||||
<a href="javascript:navigator.id.getVerifiedEmail(function(a){if(a)document.location='@{toMaster complete}/'+a});">
|
<a href="javascript:navigator.id.getVerifiedEmail(function(a){if(a)document.location='@{toMaster complete}/'+a});">
|
||||||
<img src="https://browserid.org/i/sign_in_green.png">
|
<img src="https://browserid.org/i/sign_in_green.png">
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import Yesod.Auth
|
|||||||
import Yesod.Form (runInputPost, textField, ireq)
|
import Yesod.Form (runInputPost, textField, ireq)
|
||||||
import Yesod.Handler (notFound)
|
import Yesod.Handler (notFound)
|
||||||
import Text.Hamlet (hamlet)
|
import Text.Hamlet (hamlet)
|
||||||
import Yesod.Widget (addHamlet)
|
import Yesod.Widget (toWidget)
|
||||||
|
|
||||||
authDummy :: YesodAuth m => AuthPlugin m
|
authDummy :: YesodAuth m => AuthPlugin m
|
||||||
authDummy =
|
authDummy =
|
||||||
@ -24,7 +24,7 @@ authDummy =
|
|||||||
dispatch _ _ = notFound
|
dispatch _ _ = notFound
|
||||||
url = PluginR "dummy" []
|
url = PluginR "dummy" []
|
||||||
login authToMaster =
|
login authToMaster =
|
||||||
addHamlet [hamlet|
|
toWidget [hamlet|
|
||||||
<form method="post" action="@{authToMaster url}">
|
<form method="post" action="@{authToMaster url}">
|
||||||
Your new identifier is: #
|
Your new identifier is: #
|
||||||
<input type="text" name="ident">
|
<input type="text" name="ident">
|
||||||
|
|||||||
@ -158,6 +158,10 @@ setTitleI msg = do
|
|||||||
mr <- lift getMessageRender
|
mr <- lift getMessageRender
|
||||||
setTitle $ toHtml $ mr msg
|
setTitle $ toHtml $ mr msg
|
||||||
|
|
||||||
|
{-# DEPRECATED addHamletHead, addHtmlHead "Use toWidgetHead instead" #-}
|
||||||
|
{-# DEPRECATED addHamlet, addHtml, addCassius, addLucius, addJulius "Use toWidget instead" #-}
|
||||||
|
{-# DEPRECATED addJuliusBody "Use toWidgetBody instead" #-}
|
||||||
|
|
||||||
-- | Add a 'Hamlet' to the head tag.
|
-- | Add a 'Hamlet' to the head tag.
|
||||||
addHamletHead :: HtmlUrl (Route master) -> GWidget sub master ()
|
addHamletHead :: HtmlUrl (Route master) -> GWidget sub master ()
|
||||||
addHamletHead = tell . GWData mempty mempty mempty mempty mempty mempty . Head
|
addHamletHead = tell . GWData mempty mempty mempty mempty mempty mempty . Head
|
||||||
|
|||||||
@ -48,7 +48,7 @@ module Yesod.Form.Fields
|
|||||||
import Yesod.Form.Types
|
import Yesod.Form.Types
|
||||||
import Yesod.Form.I18n.English
|
import Yesod.Form.I18n.English
|
||||||
import Yesod.Handler (getMessageRender)
|
import Yesod.Handler (getMessageRender)
|
||||||
import Yesod.Widget
|
import Yesod.Widget (toWidget, whamlet, GWidget)
|
||||||
import Yesod.Message (RenderMessage (renderMessage), SomeMessage (..))
|
import Yesod.Message (RenderMessage (renderMessage), SomeMessage (..))
|
||||||
import Text.Hamlet
|
import Text.Hamlet
|
||||||
import Text.Blaze (ToHtml (..), preEscapedText, unsafeByteString)
|
import Text.Blaze (ToHtml (..), preEscapedText, unsafeByteString)
|
||||||
@ -100,8 +100,7 @@ intField = Field
|
|||||||
Right (a, "") -> Right a
|
Right (a, "") -> Right a
|
||||||
_ -> Left $ MsgInvalidInteger s
|
_ -> Left $ MsgInvalidInteger s
|
||||||
|
|
||||||
, fieldView = \theId name theClass val isReq -> addHamlet
|
, fieldView = \theId name theClass val isReq -> toWidget [hamlet|
|
||||||
[hamlet|
|
|
||||||
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="number" :isReq:required="" value="#{showVal val}">
|
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="number" :isReq:required="" value="#{showVal val}">
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -116,8 +115,7 @@ doubleField = Field
|
|||||||
Right (a, "") -> Right a
|
Right (a, "") -> Right a
|
||||||
_ -> Left $ MsgInvalidNumber s
|
_ -> Left $ MsgInvalidNumber s
|
||||||
|
|
||||||
, fieldView = \theId name theClass val isReq -> addHamlet
|
, fieldView = \theId name theClass val isReq -> toWidget [hamlet|
|
||||||
[hamlet|
|
|
||||||
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="text" :isReq:required="" value="#{showVal val}">
|
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="text" :isReq:required="" value="#{showVal val}">
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -126,8 +124,7 @@ doubleField = Field
|
|||||||
dayField :: RenderMessage master FormMessage => Field sub master Day
|
dayField :: RenderMessage master FormMessage => Field sub master Day
|
||||||
dayField = Field
|
dayField = Field
|
||||||
{ fieldParse = blank $ parseDate . unpack
|
{ fieldParse = blank $ parseDate . unpack
|
||||||
, fieldView = \theId name theClass val isReq -> addHamlet
|
, fieldView = \theId name theClass val isReq -> toWidget [hamlet|
|
||||||
[hamlet|
|
|
||||||
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="date" :isReq:required="" value="#{showVal val}">
|
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="date" :isReq:required="" value="#{showVal val}">
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -136,8 +133,7 @@ dayField = Field
|
|||||||
timeField :: RenderMessage master FormMessage => Field sub master TimeOfDay
|
timeField :: RenderMessage master FormMessage => Field sub master TimeOfDay
|
||||||
timeField = Field
|
timeField = Field
|
||||||
{ fieldParse = blank $ parseTime . unpack
|
{ fieldParse = blank $ parseTime . unpack
|
||||||
, fieldView = \theId name theClass val isReq -> addHamlet
|
, fieldView = \theId name theClass val isReq -> toWidget [hamlet|
|
||||||
[hamlet|
|
|
||||||
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate "" theClass}" :isReq:required="" value="#{showVal val}">
|
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate "" theClass}" :isReq:required="" value="#{showVal val}">
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -151,9 +147,8 @@ timeField = Field
|
|||||||
htmlField :: RenderMessage master FormMessage => Field sub master Html
|
htmlField :: RenderMessage master FormMessage => Field sub master Html
|
||||||
htmlField = Field
|
htmlField = Field
|
||||||
{ fieldParse = blank $ Right . preEscapedText . sanitizeBalance
|
{ fieldParse = blank $ Right . preEscapedText . sanitizeBalance
|
||||||
, fieldView = \theId name theClass val _isReq -> addHamlet
|
, fieldView = \theId name theClass val _isReq -> toWidget [hamlet|
|
||||||
-- FIXME: There was a class="html" attribute, for what purpose?
|
-- FIXME: There was a class="html" attribute, for what purpose?
|
||||||
[hamlet|\
|
|
||||||
<textarea id="#{theId}" name="#{name}" :not (null theClass):class=#{T.intercalate " " theClass}>#{showVal val}
|
<textarea id="#{theId}" name="#{name}" :not (null theClass):class=#{T.intercalate " " theClass}>#{showVal val}
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -180,8 +175,7 @@ instance ToHtml Textarea where
|
|||||||
textareaField :: RenderMessage master FormMessage => Field sub master Textarea
|
textareaField :: RenderMessage master FormMessage => Field sub master Textarea
|
||||||
textareaField = Field
|
textareaField = Field
|
||||||
{ fieldParse = blank $ Right . Textarea
|
{ fieldParse = blank $ Right . Textarea
|
||||||
, fieldView = \theId name theClass val _isReq -> addHamlet
|
, fieldView = \theId name theClass val _isReq -> toWidget [hamlet|
|
||||||
[hamlet|\
|
|
||||||
<textarea id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}">#{either id unTextarea val}
|
<textarea id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}">#{either id unTextarea val}
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -189,8 +183,7 @@ textareaField = Field
|
|||||||
hiddenField :: RenderMessage master FormMessage => Field sub master Text
|
hiddenField :: RenderMessage master FormMessage => Field sub master Text
|
||||||
hiddenField = Field
|
hiddenField = Field
|
||||||
{ fieldParse = blank $ Right
|
{ fieldParse = blank $ Right
|
||||||
, fieldView = \theId name theClass val _isReq -> addHamlet
|
, fieldView = \theId name theClass val _isReq -> toWidget [hamlet|
|
||||||
[hamlet|\
|
|
||||||
<input type="hidden" id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" value="#{either id id val}">
|
<input type="hidden" id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" value="#{either id id val}">
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -207,8 +200,7 @@ textField = Field
|
|||||||
passwordField :: RenderMessage master FormMessage => Field sub master Text
|
passwordField :: RenderMessage master FormMessage => Field sub master Text
|
||||||
passwordField = Field
|
passwordField = Field
|
||||||
{ fieldParse = blank $ Right
|
{ fieldParse = blank $ Right
|
||||||
, fieldView = \theId name theClass val isReq -> addHamlet
|
, fieldView = \theId name theClass val isReq -> toWidget [hamlet|
|
||||||
[hamlet|\
|
|
||||||
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="password" :isReq:required="" value="#{either id id val}">
|
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="password" :isReq:required="" value="#{either id id val}">
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -257,8 +249,7 @@ emailField = Field
|
|||||||
\s -> if Email.isValid (unpack s)
|
\s -> if Email.isValid (unpack s)
|
||||||
then Right s
|
then Right s
|
||||||
else Left $ MsgInvalidEmail s
|
else Left $ MsgInvalidEmail s
|
||||||
, fieldView = \theId name theClass val isReq -> addHamlet
|
, fieldView = \theId name theClass val isReq -> toWidget [hamlet|
|
||||||
[hamlet|\
|
|
||||||
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="email" :isReq:required="" value="#{either id id val}">
|
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="email" :isReq:required="" value="#{either id id val}">
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -274,7 +265,7 @@ searchField autoFocus = Field
|
|||||||
when autoFocus $ do
|
when autoFocus $ do
|
||||||
-- we want this javascript to be placed immediately after the field
|
-- we want this javascript to be placed immediately after the field
|
||||||
[whamlet|<script>if (!('autofocus' in document.createElement('input'))) {document.getElementById('#{theId}').focus();}|]
|
[whamlet|<script>if (!('autofocus' in document.createElement('input'))) {document.getElementById('#{theId}').focus();}|]
|
||||||
addCassius [cassius|
|
toWidget [cassius|
|
||||||
#{theId}
|
#{theId}
|
||||||
-webkit-appearance: textfield
|
-webkit-appearance: textfield
|
||||||
|]
|
|]
|
||||||
|
|||||||
@ -65,13 +65,13 @@ jqueryDayField jds = Field
|
|||||||
. readMay
|
. readMay
|
||||||
. unpack
|
. unpack
|
||||||
, fieldView = \theId name theClass val isReq -> do
|
, fieldView = \theId name theClass val isReq -> do
|
||||||
addHtml [shamlet|\
|
toWidget [shamlet|
|
||||||
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="date" :isReq:required="" value="#{showVal val}">
|
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="date" :isReq:required="" value="#{showVal val}">
|
||||||
|]
|
|]
|
||||||
addScript' urlJqueryJs
|
addScript' urlJqueryJs
|
||||||
addScript' urlJqueryUiJs
|
addScript' urlJqueryUiJs
|
||||||
addStylesheet' urlJqueryUiCss
|
addStylesheet' urlJqueryUiCss
|
||||||
addJulius [julius|
|
toWidget [julius|
|
||||||
$(function(){
|
$(function(){
|
||||||
var i = $("##{theId}");
|
var i = $("##{theId}");
|
||||||
if (i.attr("type") != "date") {
|
if (i.attr("type") != "date") {
|
||||||
@ -104,13 +104,13 @@ jqueryAutocompleteField :: (RenderMessage master FormMessage, YesodJquery master
|
|||||||
jqueryAutocompleteField src = Field
|
jqueryAutocompleteField src = Field
|
||||||
{ fieldParse = blank $ Right
|
{ fieldParse = blank $ Right
|
||||||
, fieldView = \theId name theClass val isReq -> do
|
, fieldView = \theId name theClass val isReq -> do
|
||||||
addHtml [shamlet|\
|
toWidget [shamlet|
|
||||||
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="text" :isReq:required="" value="#{either id id val}" .autocomplete>
|
<input id="#{theId}" name="#{name}" :not (null theClass):class="#{T.intercalate " " theClass}" type="text" :isReq:required="" value="#{either id id val}" .autocomplete>
|
||||||
|]
|
|]
|
||||||
addScript' urlJqueryJs
|
addScript' urlJqueryJs
|
||||||
addScript' urlJqueryUiJs
|
addScript' urlJqueryUiJs
|
||||||
addStylesheet' urlJqueryUiCss
|
addStylesheet' urlJqueryUiCss
|
||||||
addJulius [julius|
|
toWidget [julius|
|
||||||
$(function(){$("##{theId}").autocomplete({source:"@{src}",minLength:2})});
|
$(function(){$("##{theId}").autocomplete({source:"@{src}",minLength:2})});
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,12 +32,12 @@ nicHtmlField :: YesodNic master => Field sub master Html
|
|||||||
nicHtmlField = Field
|
nicHtmlField = Field
|
||||||
{ fieldParse = return . Right . fmap (preEscapedText . sanitizeBalance) . listToMaybe
|
{ fieldParse = return . Right . fmap (preEscapedText . sanitizeBalance) . listToMaybe
|
||||||
, fieldView = \theId name theClass val _isReq -> do
|
, fieldView = \theId name theClass val _isReq -> do
|
||||||
addHtml [shamlet|
|
toWidget [shamlet|
|
||||||
<textarea id="#{theId}" :not (null theClass):class="#{T.intercalate " " theClass}" name="#{name}" .html>#{showVal val}
|
<textarea id="#{theId}" :not (null theClass):class="#{T.intercalate " " theClass}" name="#{name}" .html>#{showVal val}
|
||||||
|]
|
|]
|
||||||
addScript' urlNicEdit
|
addScript' urlNicEdit
|
||||||
master <- lift getYesod
|
master <- lift getYesod
|
||||||
addJulius $
|
toWidget $
|
||||||
case jsLoader master of
|
case jsLoader master of
|
||||||
BottomOfHeadBlocking -> [julius|
|
BottomOfHeadBlocking -> [julius|
|
||||||
bkLib.onDomLoaded(function(){new nicEditor({fullPanel:true}).panelInstance("#{theId}")});
|
bkLib.onDomLoaded(function(){new nicEditor({fullPanel:true}).panelInstance("#{theId}")});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user