2015-08-29 14:58:47 +02:00
|
|
|
module Handler.CreateChallenge where
|
|
|
|
|
|
|
|
import Import
|
|
|
|
import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
|
|
|
|
withSmallInput)
|
|
|
|
|
2015-08-29 18:24:01 +02:00
|
|
|
import Handler.Shared
|
|
|
|
|
2015-08-29 14:58:47 +02:00
|
|
|
getCreateChallengeR :: Handler Html
|
|
|
|
getCreateChallengeR = do
|
|
|
|
(formWidget, formEnctype) <- generateFormPost sampleForm
|
|
|
|
let submission = Nothing :: Maybe (FileInfo, Text)
|
|
|
|
handlerName = "getCreateChallengeR" :: Text
|
|
|
|
defaultLayout $ do
|
|
|
|
aDomId <- newIdent
|
|
|
|
setTitle "Welcome To Yesod!"
|
|
|
|
$(widgetFile "create-challenge")
|
|
|
|
|
2015-08-29 18:24:01 +02:00
|
|
|
postCreateChallengeR :: Handler TypedContent
|
2015-08-29 14:58:47 +02:00
|
|
|
postCreateChallengeR = do
|
|
|
|
((result, formWidget), formEnctype) <- runFormPost sampleForm
|
|
|
|
let handlerName = "postCreateChallengeR" :: Text
|
|
|
|
challengeData = case result of
|
|
|
|
FormSuccess res -> Just res
|
|
|
|
_ -> Nothing
|
2015-08-29 22:19:44 +02:00
|
|
|
Just (name, publicUrl, publicBranch, privateUrl, privateBranch) = challengeData
|
2015-08-29 14:58:47 +02:00
|
|
|
|
2015-08-29 22:19:44 +02:00
|
|
|
runViewProgress $ doRepoCloning publicUrl publicBranch
|
2015-08-29 14:58:47 +02:00
|
|
|
|
|
|
|
sampleForm :: Form (Text, Text, Text, Text, Text)
|
|
|
|
sampleForm = renderBootstrap3 BootstrapBasicForm $ (,,,,)
|
|
|
|
<$> areq textField (fieldSettingsLabel MsgName) Nothing
|
|
|
|
<*> areq textField (fieldSettingsLabel MsgPublicUrl) Nothing
|
|
|
|
<*> areq textField (fieldSettingsLabel MsgBranch) Nothing
|
|
|
|
<*> areq textField (fieldSettingsLabel MsgPrivateUrl) Nothing
|
|
|
|
<*> areq textField (fieldSettingsLabel MsgBranch) Nothing
|