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