diff --git a/Handler/Home.hs b/Handler/Home.hs index 32724a5..eddfbbd 100644 --- a/Handler/Home.hs +++ b/Handler/Home.hs @@ -4,6 +4,8 @@ import Import import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3, withSmallInput) +import Handler.Shared + -- This is a handler function for the GET request method on the HomeR -- resource pattern. All of your resource patterns are defined in -- config/routes diff --git a/Handler/Shared.hs b/Handler/Shared.hs index 4e9af57..6a7c416 100644 --- a/Handler/Shared.hs +++ b/Handler/Shared.hs @@ -39,6 +39,14 @@ arena = do gitPath :: FilePath gitPath = "/usr/bin/git" +browsableGitSite :: Text +browsableGitSite = "http://gonito.net/gitlist/" + +browsableGitRepo :: Text -> Text +browsableGitRepo bareRepoName + | ".git" `isSuffixOf` bareRepoName = browsableGitSite ++ bareRepoName + | otherwise = browsableGitSite ++ bareRepoName ++ ".git" + runViewProgress :: (Channel -> Handler ()) -> Handler TypedContent runViewProgress action = do App {..} <- getYesod diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index f41ec8d..816dafb 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -47,6 +47,17 @@ getChallengeReadmeR name = do showChallengeWidget challenge repo leaderboard = $(widgetFile "show-challenge") where leaderboardWithRanks = zip [1..] leaderboard + maybeRepoLink = getRepoLink repo + + +getRepoLink :: Repo -> Maybe Text +getRepoLink repo + | sitePrefix `isPrefixOf` url = Just $ (browsableGitRepo bareRepoName) ++ "/" ++ (repoBranch repo) + | otherwise = Nothing + where sitePrefix = "git://gonito.net/" :: Text + sitePrefixLen = length sitePrefix + url = repoUrl repo + bareRepoName = drop sitePrefixLen url getChallengeHowToR :: Text -> Handler Html getChallengeHowToR name = do diff --git a/templates/homepage.hamlet b/templates/homepage.hamlet index b3052c3..d2cd5bd 100644 --- a/templates/homepage.hamlet +++ b/templates/homepage.hamlet @@ -1,12 +1,12 @@
Gonito (pronounced ɡɔ̃ˈɲitɔ) is a Kaggle-like platform for machine learning competitions (disclaimer: Gonito is neither affiliated with nor endorsed by Kaggle) +
Gonito (pronounced ɡɔ̃ˈɲitɔ) is a Kaggle*-like platform for machine learning competitions.
What's so special about Gonito:
Gonito uses Persona authentication system available in Mozilla Firefox. Other authentication systems are on the way, but for the time being you need to use Firefox.
So, just click log in, then "Sign in with Persona" button and Firefox will guide you! + +
*Disclaimer: Gonito is neither affiliated with nor endorsed by Kaggle. \ No newline at end of file diff --git a/templates/show-challenge.hamlet b/templates/show-challenge.hamlet index a97bccf..8d410c4 100644 --- a/templates/show-challenge.hamlet +++ b/templates/show-challenge.hamlet @@ -1,7 +1,7 @@ -
Repo: - #{repoUrl repo} - \ Branch: - #{repoBranch repo} +$maybe repoLink <- maybeRepoLink +
Repo: #{repoUrl repo} Branch: #{repoBranch repo} +$nothing +
Repo: #{repoUrl repo} Branch: #{repoBranch repo}