From 1846e10016db37fb541ef7f61b17237dceffa641 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Wed, 11 Nov 2015 13:25:09 +0100 Subject: [PATCH] make it more user-friendly --- Foundation.hs | 1 + Handler/Home.hs | 29 ++++------------- config/routes | 2 +- messages/en.msg | 1 + templates/default-layout.hamlet | 3 +- templates/homepage.hamlet | 56 ++++++++++----------------------- templates/homepage.lucius | 7 ----- templates/your-account.hamlet | 7 +++++ 8 files changed, 34 insertions(+), 72 deletions(-) diff --git a/Foundation.hs b/Foundation.hs index ecc1c42..bcbe1bf 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -104,6 +104,7 @@ instance Yesod App where isAuthorized (AuthR _) _ = return Authorized isAuthorized FaviconR _ = return Authorized isAuthorized RobotsR _ = return Authorized + isAuthorized HomeR _ = return Authorized -- Default to Authorized for now. isAuthorized _ _ = isTrustedAuthorized diff --git a/Handler/Home.hs b/Handler/Home.hs index 78190e8..32724a5 100644 --- a/Handler/Home.hs +++ b/Handler/Home.hs @@ -13,29 +13,12 @@ import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3, -- inclined, or create a single monolithic file. getHomeR :: Handler Html getHomeR = do - (formWidget, formEnctype) <- generateFormPost sampleForm - let submission = Nothing :: Maybe (FileInfo, Text) - handlerName = "getHomeR" :: Text - defaultLayout $ do + maybeUser <- maybeAuth + let maybeLocalId = case maybeUser of + Just user -> userLocalId $ entityVal user + Nothing -> Nothing + defaultLayout $ do aDomId <- newIdent - setTitle "Welcome To Yesod!" + setTitle "Welcome To Gonito.net!" $(widgetFile "homepage") $(fayFile "Home") - -postHomeR :: Handler Html -postHomeR = do - ((result, formWidget), formEnctype) <- runFormPost sampleForm - let handlerName = "postHomeR" :: Text - submission = case result of - FormSuccess res -> Just res - _ -> Nothing - - defaultLayout $ do - aDomId <- newIdent - setTitle "Welcome To Yesod!" - $(widgetFile "homepage") - -sampleForm :: Form (FileInfo, Text) -sampleForm = renderBootstrap3 BootstrapBasicForm $ (,) - <$> fileAFormReq "Choose a file" - <*> areq textField (withSmallInput "What's on the file?") Nothing diff --git a/config/routes b/config/routes index 12153f6..2865b13 100644 --- a/config/routes +++ b/config/routes @@ -5,7 +5,7 @@ /favicon.ico FaviconR GET /robots.txt RobotsR GET -/ HomeR GET POST +/ HomeR GET /create-challenge CreateChallengeR GET POST /view-progress/#Int ViewProgressR GET diff --git a/messages/en.msg b/messages/en.msg index c29d31b..b241569 100644 --- a/messages/en.msg +++ b/messages/en.msg @@ -18,3 +18,4 @@ AboutMe: about me AccountName: name Id: ID SshPubKey: your SSH public key +Home: home diff --git a/templates/default-layout.hamlet b/templates/default-layout.hamlet index 5e9f5bf..5b24463 100644 --- a/templates/default-layout.hamlet +++ b/templates/default-layout.hamlet @@ -1,6 +1,7 @@
$maybe user <- maybeUser _{MsgLoggedAs} #{userIdent $ entityVal user} + \ | _{MsgHome} \ | _{MsgCreateChallenge} \ | _{MsgListChallenges} \ | _{MsgYourAccount} @@ -8,5 +9,5 @@ $nothing _{MsgLogIn} $maybe msg <- mmsg -
#{msg} +
× #{msg} ^{widget} diff --git a/templates/homepage.hamlet b/templates/homepage.hamlet index 98558ff..f4d7df7 100644 --- a/templates/homepage.hamlet +++ b/templates/homepage.hamlet @@ -1,46 +1,22 @@ -

Welcome to Yesod! +

Welcome to Gonito.net! -
    -
  1. Now that you have a working project you should use the # - \Yesod book to learn more. # - You can also use this scaffolded site to explore some basic concepts. +

    Gonito (pronounced ɡɔ̃ˈɲitɔ) is a Kaggle-like platform for machine learning competitions. -

  2. This page was generated by the #{handlerName} handler in # - \Handler/Home.hs. +

    What's so special about Gonito: -

  3. The #{handlerName} handler is set to generate your site's home screen in Routes file # - config/routes +
      +
    • free & open-source (AGPL), you can use it your own, in your company, at your university, etc. (git repo: git://gonito.net/gonito) +
    • git-based (challenges and solutions are submitted only with git) -
    • The HTML you are seeing now is actually composed by a number of widgets, # - most of them are brought together by the defaultLayout function which # - is defined in the Foundation.hs module, and used by #{handlerName}. # - All the files for templates and wigdets are in templates. +$maybe _ <- maybeUser + $maybe _ <- maybeLocalId +

      Go to the challenge list and choose a challenge for you! + $nothing +

      How to setup your account? +

      Click your account to setup your name, ID and SSH public key. +$nothing +

      How to log in? -
    • - A Widget's Html, Css and Javascript are separated in three files with the # - \.hamlet, .lucius and .julius extensions. +

      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. -

    • If you had javascript enabled then you wouldn't be seeing this. - -
      -
    • - This is an example trivial Form. Read the # - \Forms chapter # - on the yesod book to learn more about them. - $maybe (info,con) <- submission -
      - Your file's type was #{fileContentType info}. You say it has: #{con} -
      - ^{formWidget} -