Add people and person pages
This commit is contained in:
parent
7ede602d1d
commit
a6525d7549
10 changed files with 165 additions and 13 deletions
|
@ -12,10 +12,25 @@
|
||||||
-- with this software. If not, see
|
-- with this software. If not, see
|
||||||
-- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
-- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
/static StaticR Static appStatic
|
-- ----------------------------------------------------------------------------
|
||||||
/auth AuthR Auth getAuth
|
-- Yesod misc
|
||||||
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/static StaticR Static appStatic
|
||||||
/favicon.ico FaviconR GET
|
/favicon.ico FaviconR GET
|
||||||
/robots.txt RobotsR GET
|
/robots.txt RobotsR GET
|
||||||
|
|
||||||
|
-- ----------------------------------------------------------------------------
|
||||||
|
-- User signup and login
|
||||||
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/auth AuthR Auth getAuth
|
||||||
|
|
||||||
|
-- ----------------------------------------------------------------------------
|
||||||
|
-- Everything else...
|
||||||
|
-- ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/ HomeR GET
|
/ HomeR GET
|
||||||
|
|
||||||
|
/p PeopleR GET
|
||||||
|
/p/#Text PersonR GET
|
||||||
|
|
|
@ -51,6 +51,7 @@ import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet,
|
||||||
-- Don't forget to add new modules to your cabal file!
|
-- Don't forget to add new modules to your cabal file!
|
||||||
import Handler.Common
|
import Handler.Common
|
||||||
import Handler.Home
|
import Handler.Home
|
||||||
|
import Handler.Person
|
||||||
|
|
||||||
-- This line actually creates our YesodDispatch instance. It is the second half
|
-- 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
|
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
||||||
|
|
|
@ -88,6 +88,7 @@ instance Yesod App where
|
||||||
defaultLayout widget = do
|
defaultLayout widget = do
|
||||||
master <- getYesod
|
master <- getYesod
|
||||||
mmsg <- getMessage
|
mmsg <- getMessage
|
||||||
|
mperson <- maybeAuth
|
||||||
|
|
||||||
-- We break up the default layout into two components:
|
-- We break up the default layout into two components:
|
||||||
-- default-layout is the contents of the body tag, and
|
-- default-layout is the contents of the body tag, and
|
||||||
|
|
|
@ -52,7 +52,6 @@ getHomeR = do
|
||||||
dt <- lastChange path
|
dt <- lastChange path
|
||||||
ago <- timeAgo dt
|
ago <- timeAgo dt
|
||||||
return (sharer, project, repo, ago)
|
return (sharer, project, repo, ago)
|
||||||
mp <- maybeAuth
|
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "Welcome to Vervis!"
|
setTitle "Welcome to Vervis!"
|
||||||
$(widgetFile "homepage")
|
$(widgetFile "homepage")
|
||||||
|
|
52
src/Handler/Person.hs
Normal file
52
src/Handler/Person.hs
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
{- This file is part of Vervis.
|
||||||
|
-
|
||||||
|
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
-
|
||||||
|
- ♡ 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
|
||||||
|
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
-}
|
||||||
|
|
||||||
|
module Handler.Person
|
||||||
|
( getPeopleR
|
||||||
|
, getPersonR
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
import Import hiding ((==.))
|
||||||
|
--import Prelude
|
||||||
|
|
||||||
|
import Text.Blaze (text)
|
||||||
|
import Database.Esqueleto
|
||||||
|
--import Model
|
||||||
|
--import Yesod.Core (Handler)
|
||||||
|
|
||||||
|
getPeopleR :: Handler Html
|
||||||
|
getPeopleR = do
|
||||||
|
people <- runDB $ select $ from $ \ (sharer, person) -> do
|
||||||
|
where_ $ sharer ^. SharerId ==. person ^. PersonIdent
|
||||||
|
orderBy [asc $ sharer ^. SharerIdent]
|
||||||
|
return $ sharer ^. SharerIdent
|
||||||
|
defaultLayout $ do
|
||||||
|
setTitle "Vervis > People"
|
||||||
|
$(widgetFile "people")
|
||||||
|
|
||||||
|
getPersonR :: Text -> Handler Html
|
||||||
|
getPersonR ident = do
|
||||||
|
people <- runDB $ select $ from $ \ (sharer, person) -> do
|
||||||
|
where_ $
|
||||||
|
sharer ^. SharerIdent ==. val ident &&.
|
||||||
|
sharer ^. SharerId ==. person ^. PersonIdent
|
||||||
|
return person
|
||||||
|
case people of
|
||||||
|
[] -> notFound
|
||||||
|
p:ps -> defaultLayout $ do
|
||||||
|
let mperson = if null ps then Just p else Nothing
|
||||||
|
setTitle $ text $ "Vervis > People > " <> ident
|
||||||
|
$(widgetFile "person")
|
|
@ -1,3 +1,26 @@
|
||||||
|
$# This file is part of Vervis.
|
||||||
|
$#
|
||||||
|
$# Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
$#
|
||||||
|
$# ♡ 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
|
||||||
|
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
|
$maybe Entity _pid person <- mperson
|
||||||
|
<p>
|
||||||
|
You are logged in as #{personLogin person}.
|
||||||
|
<a href=@{AuthR LogoutR}>Log out.
|
||||||
|
$nothing
|
||||||
|
<p>
|
||||||
|
You are not logged in.
|
||||||
|
<a href=@{AuthR LoginR}>Log in.
|
||||||
|
|
||||||
$maybe msg <- mmsg
|
$maybe msg <- mmsg
|
||||||
<div #message>#{msg}
|
<div #message>#{msg}
|
||||||
^{widget}
|
^{widget}
|
||||||
|
|
|
@ -1,18 +1,25 @@
|
||||||
|
$# This file is part of Vervis.
|
||||||
|
$#
|
||||||
|
$# Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
$#
|
||||||
|
$# ♡ 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
|
||||||
|
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
<h1>Vervis
|
<h1>Vervis
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Vervis is hopefully going to be, eventually, a decentralized project hosting
|
Vervis is hopefully going to be, eventually, a decentralized project hosting
|
||||||
platform. At the time of writing (2016-02-14), it is a simple scaffolded
|
platform. It's still in early development, but hopefully making progress
|
||||||
Yesod web application which displays a table of Git repositories.
|
fast.
|
||||||
|
|
||||||
$maybe Entity _pid person <- mp
|
<h2>Repos
|
||||||
<p>
|
|
||||||
You are logged in as #{personLogin person}.
|
|
||||||
<a href=@{AuthR LogoutR}>Log out.
|
|
||||||
$nothing
|
|
||||||
<p>
|
|
||||||
You are not logged in.
|
|
||||||
<a href=@{AuthR LoginR}>Log in.
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
$forall (sharer, proj, repo, ago) <- rows
|
$forall (sharer, proj, repo, ago) <- rows
|
||||||
|
@ -21,3 +28,9 @@ $nothing
|
||||||
<td>#{proj}
|
<td>#{proj}
|
||||||
<td>#{repo}
|
<td>#{repo}
|
||||||
<td>#{ago}
|
<td>#{ago}
|
||||||
|
|
||||||
|
<h2>People
|
||||||
|
|
||||||
|
<p>
|
||||||
|
See
|
||||||
|
<a href=@{PeopleR}>people</a>.
|
||||||
|
|
23
templates/people.hamlet
Normal file
23
templates/people.hamlet
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
$# This file is part of Vervis.
|
||||||
|
$#
|
||||||
|
$# Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
$#
|
||||||
|
$# ♡ 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
|
||||||
|
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
|
<h1>Vervis > People
|
||||||
|
|
||||||
|
<p>
|
||||||
|
These are the people registered in this Vervis instance.
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
$forall Value ident <- people
|
||||||
|
<li>
|
||||||
|
<a href=@{PersonR ident}>#{ident}
|
23
templates/person.hamlet
Normal file
23
templates/person.hamlet
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
$# This file is part of Vervis.
|
||||||
|
$#
|
||||||
|
$# Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
|
||||||
|
$#
|
||||||
|
$# ♡ 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
|
||||||
|
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
|
<h1>Vervis > People > #{ident}
|
||||||
|
|
||||||
|
$maybe Entity _pid _person <- mperson
|
||||||
|
<p>
|
||||||
|
This is the user page for <b>#{ident}</b>. Nothing exciting here yet.
|
||||||
|
|
||||||
|
$nothing
|
||||||
|
<p>
|
||||||
|
No such registered user in this Vervis instance.
|
|
@ -44,6 +44,7 @@ library
|
||||||
Settings.StaticFiles
|
Settings.StaticFiles
|
||||||
Handler.Common
|
Handler.Common
|
||||||
Handler.Home
|
Handler.Home
|
||||||
|
Handler.Person
|
||||||
-- other-modules:
|
-- other-modules:
|
||||||
default-extensions: TemplateHaskell
|
default-extensions: TemplateHaskell
|
||||||
QuasiQuotes
|
QuasiQuotes
|
||||||
|
@ -72,6 +73,7 @@ library
|
||||||
-- , unordered-containers >=0.2.5
|
-- , unordered-containers >=0.2.5
|
||||||
build-depends: aeson >= 0.6 && < 0.11
|
build-depends: aeson >= 0.6 && < 0.11
|
||||||
, base >= 4 && < 5
|
, base >= 4 && < 5
|
||||||
|
, blaze-markup
|
||||||
, bytestring >= 0.9 && < 0.11
|
, bytestring >= 0.9 && < 0.11
|
||||||
, case-insensitive
|
, case-insensitive
|
||||||
, classy-prelude >= 0.10.2
|
, classy-prelude >= 0.10.2
|
||||||
|
|
Loading…
Reference in a new issue