]> Git — Sourcephile - comptalang.git/blob - web/Handler/Home.hs
.gitignore
[comptalang.git] / web / Handler / Home.hs
1 {-# LANGUAGE TemplateHaskell #-}
2 module Handler.Home where
3
4 import Import
5 import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
6 withSmallInput)
7
8 -- This is a handler function for the GET request method on the HomeR
9 -- resource pattern. All of your resource patterns are defined in
10 -- config/routes
11 --
12 -- The majority of the code you will write in Yesod lives in these handler
13 -- functions. You can spread them across multiple files if you are so
14 -- inclined, or create a single monolithic file.
15 getHomeR :: Handler Html
16 getHomeR = do
17 (formWidget, formEnctype) <- generateFormPost sampleForm
18 let submission = Nothing :: Maybe (FileInfo, Text)
19 handlerName = "getHomeR" :: Text
20 defaultLayout $ do
21 aDomId <- newIdent
22 setTitle "Welcome To Yesod!"
23 $(widgetFile "homepage")
24
25 postHomeR :: Handler Html
26 postHomeR = do
27 ((result, formWidget), formEnctype) <- runFormPost sampleForm
28 let handlerName = "postHomeR" :: Text
29 submission = case result of
30 FormSuccess res -> Just res
31 _ -> Nothing
32
33 defaultLayout $ do
34 aDomId <- newIdent
35 setTitle "Welcome To Yesod!"
36 $(widgetFile "homepage")
37
38 sampleForm :: Form (FileInfo, Text)
39 sampleForm = renderBootstrap3 BootstrapBasicForm $ (,)
40 <$> fileAFormReq "Choose a file"
41 <*> areq textField (withSmallInput "What's on the file?") Nothing