create link form
This commit is contained in:
parent
54b9e32353
commit
55fcdf4d58
|
@ -25,15 +25,33 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
module Handler.Home where
|
module Handler.Home where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
import Helpers
|
||||||
|
|
||||||
|
title :: Text
|
||||||
|
title = "DiscussMormonism.com Link Fixer"
|
||||||
|
|
||||||
|
linkForm :: Form Text
|
||||||
|
linkForm = renderDivs $
|
||||||
|
areq urlField "Old URL" Nothing
|
||||||
|
|
||||||
getHomeR :: Handler Html
|
getHomeR :: Handler Html
|
||||||
getHomeR = defaultLayout $ do
|
getHomeR = do
|
||||||
setTitle "Welcome To Yesod!"
|
(widget, enctype) <- generateFormPost linkForm
|
||||||
$(widgetFile "homepage")
|
defaultLayout $ do
|
||||||
|
setTitle $ toHtml title
|
||||||
|
$(widgetFile "homepage")
|
||||||
|
|
||||||
postHomeR :: Handler Html
|
postHomeR :: Handler Html
|
||||||
postHomeR = defaultLayout $ do
|
postHomeR = do
|
||||||
setTitle "Welcome To Yesod!"
|
((result, _), _) <- runFormPost linkForm
|
||||||
$(widgetFile "homepage")
|
case result of
|
||||||
|
FormSuccess l -> case updateLink l of
|
||||||
|
Just l' -> redirect l'
|
||||||
|
Nothing -> do
|
||||||
|
setMessage "Invalid link"
|
||||||
|
redirect HomeR
|
||||||
|
_ -> do
|
||||||
|
setMessage "Something went wrong"
|
||||||
|
redirect HomeR
|
||||||
|
|
||||||
--jl
|
--jl
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
<div .masthead>
|
<div .container>
|
||||||
<div .container>
|
<div .row>
|
||||||
<div .row>
|
<h1 .header>
|
||||||
<h1 .header>
|
#{title}
|
||||||
DiscussMormonism.com Link Fixer
|
<p>
|
||||||
|
This site is not affiliated with
|
||||||
|
<a href="https://discussmormonism.com">DiscussMormonism.com
|
||||||
|
and is provided as a convenience. It takes links from the old MormonDiscussions.com site and redirects them to the current message board.
|
||||||
|
<form method=post enctype=#{enctype}>
|
||||||
|
^{widget}
|
||||||
|
<button>Go!
|
Loading…
Reference in New Issue
Block a user