diff --git a/Application.hs b/Application.hs index 054e53b..38f4af7 100644 --- a/Application.hs +++ b/Application.hs @@ -34,6 +34,7 @@ import Yesod.Fay (getFaySite) import Handler.Common import Handler.Fay import Handler.Home +import Handler.CreateChallenge -- This line actually creates our YesodDispatch instance. It is the second half -- of the call to mkYesodData which occurs in Foundation.hs. Please see the diff --git a/Handler/CreateChallenge.hs b/Handler/CreateChallenge.hs new file mode 100644 index 0000000..6690ae1 --- /dev/null +++ b/Handler/CreateChallenge.hs @@ -0,0 +1,36 @@ +module Handler.CreateChallenge where + +import Import +import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3, + withSmallInput) + +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") + +postCreateChallengeR :: Handler Html +postCreateChallengeR = do + ((result, formWidget), formEnctype) <- runFormPost sampleForm + let handlerName = "postCreateChallengeR" :: Text + challengeData = case result of + FormSuccess res -> Just res + _ -> Nothing + + defaultLayout $ do + aDomId <- newIdent + setTitle "Welcome To Yesod!" + $(widgetFile "creating-challenge") + +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 diff --git a/config/routes b/config/routes index 6e44434..7f5616e 100644 --- a/config/routes +++ b/config/routes @@ -6,3 +6,5 @@ /robots.txt RobotsR GET / HomeR GET POST + +/create-challenge CreateChallengeR GET POST diff --git a/gonito.cabal b/gonito.cabal index 36e3c8a..4b0d1d3 100644 --- a/gonito.cabal +++ b/gonito.cabal @@ -23,6 +23,7 @@ library Settings.StaticFiles SharedTypes Handler.Common + Handler.CreateChallenge Handler.Fay Handler.Home diff --git a/messages/en.msg b/messages/en.msg index 434f70f..b6e450f 100644 --- a/messages/en.msg +++ b/messages/en.msg @@ -1,3 +1,9 @@ LogIn: log in LogOut: log out LoggedAs: logged as +CreateChallenge: add a challenge +Name: name +PublicUrl: public repo (URL) +PrivateUrl: private repo (URL) +Branch: branch +Add: Add! diff --git a/templates/create-challenge.hamlet b/templates/create-challenge.hamlet new file mode 100644 index 0000000..1d20fd6 --- /dev/null +++ b/templates/create-challenge.hamlet @@ -0,0 +1,7 @@ +
+