From d8fabbdfc564778a8841c0f96afbae1316b7bc79 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Sat, 28 Dec 2019 16:34:44 +0000 Subject: [PATCH] Display project/repo sharer nav, and project nav in repo page --- src/Vervis/Handler/Project.hs | 1 + src/Vervis/Handler/Repo.hs | 6 ++-- src/Vervis/Handler/Repo/Darcs.hs | 3 +- src/Vervis/Handler/Repo/Git.hs | 3 +- src/Vervis/Widget/Project.hs | 29 +++++++++++++++++ src/Vervis/Widget/Sharer.hs | 5 +++ templates/person.hamlet | 23 +------------ templates/person/widget/nav.hamlet | 41 +++++++++++++++++++++++ templates/project/one.hamlet | 34 ++------------------ templates/project/widget/nav.hamlet | 50 +++++++++++++++++++++++++++++ templates/repo/source-darcs.hamlet | 13 +++++++- templates/repo/source-git.hamlet | 13 +++++++- vervis.cabal | 1 + 13 files changed, 163 insertions(+), 59 deletions(-) create mode 100644 src/Vervis/Widget/Project.hs create mode 100644 templates/person/widget/nav.hamlet create mode 100644 templates/project/widget/nav.hamlet diff --git a/src/Vervis/Handler/Project.hs b/src/Vervis/Handler/Project.hs index 5e3454f..d213176 100644 --- a/src/Vervis/Handler/Project.hs +++ b/src/Vervis/Handler/Project.hs @@ -65,6 +65,7 @@ import Vervis.Model import Vervis.Model.Ident import Vervis.Model.Repo import Vervis.Settings +import Vervis.Widget.Project import Vervis.Widget.Sharer import Vervis.Widget.Workflow diff --git a/src/Vervis/Handler/Repo.hs b/src/Vervis/Handler/Repo.hs index 42702d6..31a0793 100644 --- a/src/Vervis/Handler/Repo.hs +++ b/src/Vervis/Handler/Repo.hs @@ -208,14 +208,16 @@ getRepoNewR user = do ((_result, widget), enctype) <- runFormPost $ newRepoForm sid Nothing defaultLayout $(widgetFile "repo/new") -selectRepo :: ShrIdent -> RpIdent -> AppDB (Maybe (Sharer, Project), Repo) +selectRepo :: ShrIdent -> RpIdent -> AppDB (Maybe (Sharer, Project, Workflow, Sharer), Repo) selectRepo shar repo = do Entity sid _s <- getBy404 $ UniqueSharer shar Entity _rid r <- getBy404 $ UniqueRepo repo sid mj <- for (repoProject r) $ \ jid -> do j <- get404 jid s <- get404 $ projectSharer j - return (s, j) + w <- get404 $ projectWorkflow j + sw <- get404 $ workflowSharer w + return (s, j, w, sw) return (mj, r) getRepoR :: ShrIdent -> RpIdent -> Handler TypedContent diff --git a/src/Vervis/Handler/Repo/Darcs.hs b/src/Vervis/Handler/Repo/Darcs.hs index 5af84fd..e3ca775 100644 --- a/src/Vervis/Handler/Repo/Darcs.hs +++ b/src/Vervis/Handler/Repo/Darcs.hs @@ -74,12 +74,13 @@ import Vervis.SourceTree import Vervis.Style import Vervis.Time import Vervis.Widget (buttonW) +import Vervis.Widget.Project import Vervis.Widget.Repo import Vervis.Widget.Sharer import qualified Vervis.Darcs as D (readSourceView, readChangesView, readPatch) -getDarcsRepoSource :: (Maybe (Sharer, Project), Repo) -> ShrIdent -> RpIdent -> [Text] -> Handler Html +getDarcsRepoSource :: (Maybe (Sharer, Project, Workflow, Sharer), Repo) -> ShrIdent -> RpIdent -> [Text] -> Handler Html getDarcsRepoSource (mproject, repository) user repo dir = do path <- askRepoDir user repo msv <- liftIO $ D.readSourceView path dir diff --git a/src/Vervis/Handler/Repo/Git.hs b/src/Vervis/Handler/Repo/Git.hs index c582c95..cd7a926 100644 --- a/src/Vervis/Handler/Repo/Git.hs +++ b/src/Vervis/Handler/Repo/Git.hs @@ -88,13 +88,14 @@ import Vervis.SourceTree import Vervis.Style import Vervis.Time (showDate) import Vervis.Widget (buttonW) +import Vervis.Widget.Project import Vervis.Widget.Repo import Vervis.Widget.Sharer import qualified Data.ByteString.Lazy as BL (ByteString) import qualified Vervis.Git as G (readSourceView, readChangesView, listRefs, readPatch) -getGitRepoSource :: (Maybe (Sharer, Project), Repo) -> ShrIdent -> RpIdent -> Text -> [Text] -> Handler Html +getGitRepoSource :: (Maybe (Sharer, Project, Workflow, Sharer), Repo) -> ShrIdent -> RpIdent -> Text -> [Text] -> Handler Html getGitRepoSource (mproject, repository) user repo ref dir = do path <- askRepoDir user repo (branches, tags, msv) <- liftIO $ G.readSourceView path ref dir diff --git a/src/Vervis/Widget/Project.hs b/src/Vervis/Widget/Project.hs new file mode 100644 index 0000000..a6cb135 --- /dev/null +++ b/src/Vervis/Widget/Project.hs @@ -0,0 +1,29 @@ +{- This file is part of Vervis. + - + - Written in 2019 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 Vervis.Widget.Project + ( projectNavW + ) +where + +import Vervis.Foundation +import Vervis.Model +import Vervis.Model.Ident +import Vervis.Settings +import Vervis.Widget.Workflow + +projectNavW :: Project -> Workflow -> Sharer -> ShrIdent -> PrjIdent -> Widget +projectNavW project workflow wsharer shar proj = + $(widgetFile "project/widget/nav") diff --git a/src/Vervis/Widget/Sharer.hs b/src/Vervis/Widget/Sharer.hs index 008a78a..f1c3afb 100644 --- a/src/Vervis/Widget/Sharer.hs +++ b/src/Vervis/Widget/Sharer.hs @@ -17,6 +17,7 @@ module Vervis.Widget.Sharer ( sharerLinkW , sharerLinkFedW , followW + , personNavW ) where @@ -34,6 +35,7 @@ import Database.Persist.Local import Vervis.Foundation import Vervis.Model import Vervis.Model.Ident +import Vervis.Settings import Vervis.Widget sharerLinkW :: Sharer -> Widget @@ -69,3 +71,6 @@ followW followRoute unfollowRoute getFsid = do case mfollow of Nothing -> buttonW POST "Follow" followRoute Just _ -> buttonW POST "Unfollow" unfollowRoute + +personNavW :: ShrIdent -> Widget +personNavW shr = $(widgetFile "person/widget/nav") diff --git a/templates/person.hamlet b/templates/person.hamlet index 0651902..383eed3 100644 --- a/templates/person.hamlet +++ b/templates/person.hamlet @@ -18,25 +18,4 @@ $# .

#{personAbout person} -

- - - [📥 Inbox] - - - [📤 Outbox] - - - [🐤 Followers] - - - [🐔 Following] - - - [🏗 Projects] - - - [🗃 Repositories] - - - [🔁 Workflows] +^{personNavW shr} diff --git a/templates/person/widget/nav.hamlet b/templates/person/widget/nav.hamlet new file mode 100644 index 0000000..b6f8036 --- /dev/null +++ b/templates/person/widget/nav.hamlet @@ -0,0 +1,41 @@ +$# This file is part of Vervis. +$# +$# Written in 2019 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 +$# . + +
+ + [[ 🧙 + + #{shr2text shr} + ]] :: + + + [📥 Inbox] + + + [📤 Outbox] + + + [🐤 Followers] + + + [🐔 Following] + + + [🏗 Projects] + + + [🗃 Repositories] + + + [🔁 Workflows] diff --git a/templates/project/one.hamlet b/templates/project/one.hamlet index fdb7f87..17e72e4 100644 --- a/templates/project/one.hamlet +++ b/templates/project/one.hamlet @@ -22,37 +22,9 @@ $# . - #{desc} -
- - - [📥 Inbox] - - - [📤 Outbox] - - - [🐤 Followers] - - - [🤝 Collaborators] - - - [🐛 Tickets] - - - [✋ Ticket claim requests] - - [🔁 Ticket workflow: - ^{workflowLinkW wsharer workflow}] - - $maybe _wiki <- projectWiki project - - [📖 Wiki] - $nothing - [No wiki] - - - [✏ Edit] +^{personNavW shar} + +^{projectNavW project workflow wsharer shar proj} ^{followButton} diff --git a/templates/project/widget/nav.hamlet b/templates/project/widget/nav.hamlet new file mode 100644 index 0000000..300636b --- /dev/null +++ b/templates/project/widget/nav.hamlet @@ -0,0 +1,50 @@ +$# This file is part of Vervis. +$# +$# Written in 2019 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 +$# . + +
+ + [[ 🏗 + + #{prj2text proj} + ]] :: + + + [📥 Inbox] + + + [📤 Outbox] + + + [🐤 Followers] + + + [🤝 Collaborators] + + + [🐛 Tickets] + + + [✋ Ticket claim requests] + + [🔁 Ticket workflow: + ^{workflowLinkW wsharer workflow}] + + $maybe _wiki <- projectWiki project + + [📖 Wiki] + $nothing + [No wiki] + + + [✏ Edit] diff --git a/templates/repo/source-darcs.hamlet b/templates/repo/source-darcs.hamlet index e13f020..f63bbfd 100644 --- a/templates/repo/source-darcs.hamlet +++ b/templates/repo/source-darcs.hamlet @@ -12,7 +12,7 @@ $# You should have received a copy of the CC0 Public Domain Dedication along $# with this software. If not, see $# . -$maybe (s, j) <- mproject +$maybe (s, j, w, sw) <- mproject

Belongs to project @@ -21,10 +21,21 @@ $maybe (s, j) <- mproject $nothing #{prj2text $ projectIdent j} + ^{personNavW $ sharerIdent s} + + ^{projectNavW j w sw (sharerIdent s) (projectIdent j)} + $maybe desc <- repoDesc repository

#{desc} +^{personNavW user} +

+ + [[ 🗃 + + #{rp2text repo} + ]] :: [📥 Inbox] diff --git a/templates/repo/source-git.hamlet b/templates/repo/source-git.hamlet index f198242..1c7116e 100644 --- a/templates/repo/source-git.hamlet +++ b/templates/repo/source-git.hamlet @@ -12,7 +12,7 @@ $# You should have received a copy of the CC0 Public Domain Dedication along $# with this software. If not, see $# . -$maybe (s, j) <- mproject +$maybe (s, j, w, sw) <- mproject

Belongs to project @@ -21,10 +21,21 @@ $maybe (s, j) <- mproject $nothing #{prj2text $ projectIdent j} + ^{personNavW $ sharerIdent s} + + ^{projectNavW j w sw (sharerIdent s) (projectIdent j)} + $maybe desc <- repoDesc repository

#{desc} +^{personNavW user} +