list and show challenges
This commit is contained in:
parent
c05a3c55ef
commit
8b885c0dca
@ -37,6 +37,8 @@ import Handler.Common
|
||||
import Handler.Fay
|
||||
import Handler.Home
|
||||
import Handler.CreateChallenge
|
||||
import Handler.ListChallenges
|
||||
import Handler.ShowChallenge
|
||||
import Handler.Shared
|
||||
|
||||
-- This line actually creates our YesodDispatch instance. It is the second half
|
||||
|
13
Handler/ListChallenges.hs
Normal file
13
Handler/ListChallenges.hs
Normal file
@ -0,0 +1,13 @@
|
||||
module Handler.ListChallenges where
|
||||
|
||||
import Import
|
||||
|
||||
getListChallengesR :: Handler Html
|
||||
getListChallengesR = do
|
||||
challenges' <- runDB $ selectList [] [Desc ChallengeStamp]
|
||||
let challenges = map (\(Entity _ v) -> v) challenges'
|
||||
defaultLayout $ do
|
||||
setTitle "List challenges"
|
||||
$(widgetFile "list-challenges")
|
||||
|
||||
listChallengesCore challenges = $(widgetFile "list-challenges-core")
|
10
Handler/ShowChallenge.hs
Normal file
10
Handler/ShowChallenge.hs
Normal file
@ -0,0 +1,10 @@
|
||||
module Handler.ShowChallenge where
|
||||
|
||||
import Import
|
||||
|
||||
getShowChallengeR :: Text -> Handler Html
|
||||
getShowChallengeR name = do
|
||||
(Entity _ challenge) <- runDB $ getBy404 $ UniqueName name
|
||||
defaultLayout $ do
|
||||
setTitle "Show a challenge"
|
||||
$(widgetFile "show-challenge")
|
@ -9,3 +9,5 @@
|
||||
|
||||
/create-challenge CreateChallengeR GET POST
|
||||
/view-progress/#Int ViewProgressR GET
|
||||
/list-challenges ListChallengesR GET
|
||||
/challenge/#Text ShowChallengeR GET
|
||||
|
@ -26,7 +26,9 @@ library
|
||||
Handler.CreateChallenge
|
||||
Handler.Fay
|
||||
Handler.Home
|
||||
Handler.ListChallenges
|
||||
Handler.Shared
|
||||
Handler.ShowChallenge
|
||||
Handler.Extract
|
||||
|
||||
if flag(dev) || flag(library-only)
|
||||
|
@ -7,3 +7,4 @@ PublicUrl: public repo (URL)
|
||||
PrivateUrl: private repo (URL)
|
||||
Branch: branch
|
||||
Add: Add!
|
||||
ListChallenges: list challenges
|
||||
|
@ -2,6 +2,7 @@
|
||||
$maybe user <- maybeUser
|
||||
_{MsgLoggedAs} #{userIdent $ entityVal user}
|
||||
\ | <a href="@{CreateChallengeR}">_{MsgCreateChallenge}</a>
|
||||
\ | <a href="@{ListChallengesR}">_{MsgListChallenges}</a>
|
||||
\ | <a href="@{AuthR LogoutR}">_{MsgLogOut}</a>
|
||||
$nothing
|
||||
<a href="@{AuthR LoginR}">_{MsgLogIn}</a>
|
||||
|
4
templates/list-challenges-core.hamlet
Normal file
4
templates/list-challenges-core.hamlet
Normal file
@ -0,0 +1,4 @@
|
||||
$forall challenge <- challenges
|
||||
<div .challenge-item>
|
||||
<p .challenge-title><a .challenge-link href="@{ShowChallengeR (challengeName challenge)}">#{challengeTitle challenge}</a>
|
||||
<p .challenge-description>#{challengeDescription challenge}
|
1
templates/list-challenges.hamlet
Normal file
1
templates/list-challenges.hamlet
Normal file
@ -0,0 +1 @@
|
||||
^{listChallengesCore challenges}
|
2
templates/show-challenge.hamlet
Normal file
2
templates/show-challenge.hamlet
Normal file
@ -0,0 +1,2 @@
|
||||
<p .challenge-title>#{challengeTitle challenge}
|
||||
<p .challenge-description>#{challengeDescription challenge}
|
Loading…
Reference in New Issue
Block a user