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 <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 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 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>. <p>#{personAbout person} -<div> - <span> - <a href=@{SharerInboxR shr}> - [📥 Inbox] - <span> - <a href=@{SharerOutboxR shr}> - [📤 Outbox] - <span> - <a href=@{SharerFollowersR shr}> - [🐤 Followers] - <span> - <a href=@{SharerFollowingR shr}> - [🐔 Following] - <span> - <a href=@{ProjectsR shr}> - [🏗 Projects] - <span> - <a href=@{ReposR shr}> - [🗃 Repositories] - <span> - <a href=@{WorkflowsR shr}> - [🔁 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 <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/>. + +<div> + <span> + [[ 🧙 + <a href=@{SharerR shr}> + #{shr2text shr} + ]] :: + <span> + <a href=@{SharerInboxR shr}> + [📥 Inbox] + <span> + <a href=@{SharerOutboxR shr}> + [📤 Outbox] + <span> + <a href=@{SharerFollowersR shr}> + [🐤 Followers] + <span> + <a href=@{SharerFollowingR shr}> + [🐔 Following] + <span> + <a href=@{ProjectsR shr}> + [🏗 Projects] + <span> + <a href=@{ReposR shr}> + [🗃 Repositories] + <span> + <a href=@{WorkflowsR shr}> + [🔁 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 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>. - <span>#{desc} -<div> - <span> - <a href=@{ProjectInboxR shar proj}> - [📥 Inbox] - <span> - <a href=@{ProjectOutboxR shar proj}> - [📤 Outbox] - <span> - <a href=@{ProjectFollowersR shar proj}> - [🐤 Followers] - <span> - <a href=@{ProjectDevsR shar proj}> - [🤝 Collaborators] - <span> - <a href=@{TicketsR shar proj}> - [🐛 Tickets] - <span> - <a href=@{ClaimRequestsProjectR shar proj}> - [✋ Ticket claim requests] - <span> - [🔁 Ticket workflow: - ^{workflowLinkW wsharer workflow}] - <span> - $maybe _wiki <- projectWiki project - <a href=@{WikiPageR shar proj []}> - [📖 Wiki] - $nothing - [No wiki] - <span> - <a href=@{ProjectEditR shar proj}> - [✏ 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 <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/>. + +<div> + <span> + [[ 🏗 + <a href=@{ProjectR shar proj}> + #{prj2text proj} + ]] :: + <span> + <a href=@{ProjectInboxR shar proj}> + [📥 Inbox] + <span> + <a href=@{ProjectOutboxR shar proj}> + [📤 Outbox] + <span> + <a href=@{ProjectFollowersR shar proj}> + [🐤 Followers] + <span> + <a href=@{ProjectDevsR shar proj}> + [🤝 Collaborators] + <span> + <a href=@{TicketsR shar proj}> + [🐛 Tickets] + <span> + <a href=@{ClaimRequestsProjectR shar proj}> + [✋ Ticket claim requests] + <span> + [🔁 Ticket workflow: + ^{workflowLinkW wsharer workflow}] + <span> + $maybe _wiki <- projectWiki project + <a href=@{WikiPageR shar proj []}> + [📖 Wiki] + $nothing + [No wiki] + <span> + <a href=@{ProjectEditR shar proj}> + [✏ 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 $# <http://creativecommons.org/publicdomain/zero/1.0/>. -$maybe (s, j) <- mproject +$maybe (s, j, w, sw) <- mproject <p> Belongs to project <a href=@{ProjectR (sharerIdent s) (projectIdent j)}> @@ -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 <p>#{desc} +^{personNavW user} + <div> + <span> + [[ 🗃 + <a href=@{RepoR user repo}> + #{rp2text repo} + ]] :: <span> <a href=@{RepoInboxR user 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 $# <http://creativecommons.org/publicdomain/zero/1.0/>. -$maybe (s, j) <- mproject +$maybe (s, j, w, sw) <- mproject <p> Belongs to project <a href=@{ProjectR (sharerIdent s) (projectIdent j)}> @@ -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 <p>#{desc} +^{personNavW user} + <div> + <span> + [[ 🗃 + <a href=@{RepoR user repo}> + #{rp2text repo} + ]] :: <span> <a href=@{RepoInboxR user repo}> [📥 Inbox] diff --git a/vervis.cabal b/vervis.cabal index ef48160..41c0f73 100644 --- a/vervis.cabal +++ b/vervis.cabal @@ -207,6 +207,7 @@ library Vervis.Time Vervis.Widget Vervis.Widget.Discussion + Vervis.Widget.Project Vervis.Widget.Repo Vervis.Widget.Role Vervis.Widget.Sharer