diff --git a/config/routes b/config/routes index d085c3f..c1ead1e 100644 --- a/config/routes +++ b/config/routes @@ -16,21 +16,23 @@ -- Yesod misc -- ---------------------------------------------------------------------------- -/static StaticR Static appStatic -/favicon.ico FaviconR GET -/robots.txt RobotsR GET +/static StaticR Static appStatic +/favicon.ico FaviconR GET +/robots.txt RobotsR GET -- ---------------------------------------------------------------------------- -- User signup and login -- ---------------------------------------------------------------------------- -/auth AuthR Auth getAuth +/auth AuthR Auth getAuth -- ---------------------------------------------------------------------------- -- Everything else... -- ---------------------------------------------------------------------------- -/ HomeR GET +/ HomeR GET -/p PeopleR GET -/p/#Text PersonR GET +/u PeopleR GET +/u/#Text PersonR GET +/u/#Text/p ProjectsR GET +/u/#Text/p/#Text ProjectR GET diff --git a/src/Application.hs b/src/Application.hs index 7477d2b..c22e211 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -52,6 +52,7 @@ import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet, import Handler.Common import Handler.Home import Handler.Person +import Handler.Project -- 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/src/Handler/Home.hs b/src/Handler/Home.hs index 1182d05..80850f4 100644 --- a/src/Handler/Home.hs +++ b/src/Handler/Home.hs @@ -52,6 +52,7 @@ getHomeR = do dt <- lastChange path ago <- timeAgo dt return (sharer, project, repo, ago) + mp <- maybeAuth defaultLayout $ do setTitle "Welcome to Vervis!" $(widgetFile "homepage") diff --git a/src/Handler/Project.hs b/src/Handler/Project.hs new file mode 100644 index 0000000..0da4923 --- /dev/null +++ b/src/Handler/Project.hs @@ -0,0 +1,60 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ Copying is an act of love. Please copy, reuse and share. + - + - The author(s) have dedicated all copyright and related and neighboring + - rights to this software to the public domain worldwide. This software is + - distributed without any warranty. + - + - You should have received a copy of the CC0 Public Domain Dedication along + - with this software. If not, see + - . + -} + +module Handler.Project + ( getProjectsR + , getProjectR + ) +where + +import Import hiding ((==.)) +--import Prelude + +import Text.Blaze (text) +import Database.Esqueleto +--import Model +--import Yesod.Core (Handler) + +getProjectsR :: Text -> Handler Html +getProjectsR ident = do + projects <- runDB $ select $ from $ \ (sharer, project) -> do + where_ $ + sharer ^. SharerIdent ==. val ident &&. + sharer ^. SharerId ==. project ^. ProjectSharer + orderBy [asc $ project ^. ProjectIdent] + return $ project ^. ProjectIdent + defaultLayout $ do + setTitle $ text $ "Vervis > People > " <> ident <> " > Projects" + $(widgetFile "projects") + +getProjectR :: Text -> Text -> Handler Html +getProjectR user proj = do + projects <- runDB $ select $ from $ \ (sharer, project) -> do + where_ $ + sharer ^. SharerIdent ==. val user &&. + project ^. ProjectIdent ==. val proj &&. + sharer ^. SharerId ==. project ^. ProjectSharer + return project + case projects of + [] -> notFound + p:ps -> defaultLayout $ do + let mproject = if null ps then Just p else Nothing + setTitle $ text $ mconcat + [ "Vervis > People > " + , user + , " > Project > " + , proj + ] + $(widgetFile "project") diff --git a/templates/homepage.hamlet b/templates/homepage.hamlet index 7c7f9ff..d4f1a10 100644 --- a/templates/homepage.hamlet +++ b/templates/homepage.hamlet @@ -19,6 +19,18 @@ $# . platform. It's still in early development, but hopefully making progress fast. +

Intended Content + +

+ This page, the homepage, is currently planned to be an intro or global + overview page when not logged in, and be a user-specific overview page when + browsing to it while logged in. + +$maybe _ <- mp +

You're logged in, i.e. you should see a personal overview. +$nothing +

You aren't logged in, i.e. you should see a global overview/intro. +

Repos diff --git a/templates/person.hamlet b/templates/person.hamlet index 3756beb..1e74c27 100644 --- a/templates/person.hamlet +++ b/templates/person.hamlet @@ -15,9 +15,14 @@ $# .

Vervis > People > #{ident} $maybe Entity _pid _person <- mperson +

About

- This is the user page for #{ident}. Nothing exciting here yet. + This is the user page for #{ident} + +

Projects +

+ See + projects. $nothing -

- No such registered user in this Vervis instance. +

Internal error: More than one user with the same identifier! diff --git a/templates/project.hamlet b/templates/project.hamlet new file mode 100644 index 0000000..1f17e6b --- /dev/null +++ b/templates/project.hamlet @@ -0,0 +1,39 @@ +$# This file is part of Vervis. +$# +$# Written in 2016 by fr33domlover . +$# +$# ♡ Copying is an act of love. Please copy, reuse and share. +$# +$# The author(s) have dedicated all copyright and related and neighboring +$# rights to this software to the public domain worldwide. This software is +$# distributed without any warranty. +$# +$# You should have received a copy of the CC0 Public Domain Dedication along +$# with this software. If not, see +$# . + +

Vervis > People > #{user} > Projects > #{proj} + +$maybe Entity _pid project <- mproject +

About +

This is the project page for #{proj}, shared by #{user}. + +

Details +

+ + +
Human-friendly name + + $maybe name <- projectName project + #{name} + $nothing + (none) +
Description + + $maybe desc <- projectDesc project + #{desc} + $nothing + (none) + +$nothing +

Internal error: More than one project per user/proj name pair! diff --git a/templates/projects.hamlet b/templates/projects.hamlet new file mode 100644 index 0000000..9b059c7 --- /dev/null +++ b/templates/projects.hamlet @@ -0,0 +1,22 @@ +$# This file is part of Vervis. +$# +$# Written in 2016 by fr33domlover . +$# +$# ♡ Copying is an act of love. Please copy, reuse and share. +$# +$# The author(s) have dedicated all copyright and related and neighboring +$# rights to this software to the public domain worldwide. This software is +$# distributed without any warranty. +$# +$# You should have received a copy of the CC0 Public Domain Dedication along +$# with this software. If not, see +$# . + +

Vervis > People > #{ident} > Projects + +

These are projects shared by #{ident}. + +