From ab786eb67cafd0061936eb2c161f96a94cd8a34d Mon Sep 17 00:00:00 2001 From: Pere Lev Date: Wed, 13 Dec 2023 00:09:28 +0200 Subject: [PATCH] UI, Vocab: Link from project/team to children & parents pages --- src/Vervis/Handler/Group.hs | 4 +-- src/Vervis/Handler/Project.hs | 4 +-- src/Web/ActivityPub.hs | 52 +++++++---------------------- templates/group/nav.hamlet | 6 ++++ templates/project/widget/nav.hamlet | 6 ++++ 5 files changed, 28 insertions(+), 44 deletions(-) diff --git a/src/Vervis/Handler/Group.hs b/src/Vervis/Handler/Group.hs index e7f58ed..69feb78 100644 --- a/src/Vervis/Handler/Group.hs +++ b/src/Vervis/Handler/Group.hs @@ -196,8 +196,8 @@ getGroupR groupHash = do } groupAP = AP.Team { AP.teamActor = actorAP - , AP.teamChildren = [] - , AP.teamParents = [] + , AP.teamChildren = encodeRouteLocal $ GroupChildrenR groupHash + , AP.teamParents = encodeRouteLocal $ GroupParentsR groupHash , AP.teamMembers = encodeRouteLocal $ GroupMembersR groupHash } diff --git a/src/Vervis/Handler/Project.hs b/src/Vervis/Handler/Project.hs index d833d73..5f089b3 100644 --- a/src/Vervis/Handler/Project.hs +++ b/src/Vervis/Handler/Project.hs @@ -159,8 +159,8 @@ getProjectR projectHash = do } } , AP.projectTracker = Nothing - , AP.projectChildren = [] - , AP.projectParents = [] + , AP.projectChildren = encodeRouteLocal $ ProjectChildrenR projectHash + , AP.projectParents = encodeRouteLocal $ ProjectParentsR projectHash , AP.projectComponents = encodeRouteLocal $ ProjectComponentsR projectHash , AP.projectCollaborators = diff --git a/src/Web/ActivityPub.hs b/src/Web/ActivityPub.hs index 7e3f5fe..104bcd8 100644 --- a/src/Web/ActivityPub.hs +++ b/src/Web/ActivityPub.hs @@ -880,8 +880,8 @@ instance ActivityPub ResourceWithCollections where data Project u = Project { projectActor :: Actor u , projectTracker :: Maybe (ObjURI u) - , projectChildren :: [ObjURI u] - , projectParents :: [ObjURI u] + , projectChildren :: LocalURI + , projectParents :: LocalURI , projectComponents :: LocalURI , projectCollaborators :: LocalURI } @@ -895,36 +895,22 @@ instance ActivityPub Project where fmap (h,) $ Project a <$> o .:? "ticketsTrackedBy" - <*> (do c <- o .: "subprojects" - typ <- c .: "type" - unless (typ == ("Collection" :: Text)) $ - fail "subprojects.type isn't Collection" - items <- c .: "items" - mtotal <- c .:? "totalItems" - for_ mtotal $ \ total -> - unless (length items == total) $ - fail "Incorrect totalItems" - return items - ) - <*> o .:? "context" .!= [] + <*> withAuthorityO h (o .: "subprojects") + <*> withAuthorityO h (o .: "context") <*> withAuthorityO h (o .: "components") <*> withAuthorityO h (o .: "collaborators") toSeries h (Project actor tracker children parents components collabs) = toSeries h actor <> "ticketsTrackedBy" .=? tracker - <> "subprojects" `pair` pairs - ( "type" .= ("Collection" :: Text) - <> "items" .= children - <> "totalItems" .= length children - ) - <> "context" .= parents + <> "subprojects" .= ObjURI h children + <> "context" .= ObjURI h parents <> "components" .= ObjURI h components <> "collaborators" .= ObjURI h collabs data Team u = Team { teamActor :: Actor u - , teamChildren :: [ObjURI u] - , teamParents :: [ObjURI u] + , teamChildren :: LocalURI + , teamParents :: LocalURI , teamMembers :: LocalURI } @@ -936,27 +922,13 @@ instance ActivityPub Team where fail "Actor type isn't Team" fmap (h,) $ Team a - <$> (do c <- o .: "subteams" - typ <- c .: "type" - unless (typ == ("Collection" :: Text)) $ - fail "subteams.type isn't Collection" - items <- c .: "items" - mtotal <- c .:? "totalItems" - for_ mtotal $ \ total -> - unless (length items == total) $ - fail "Incorrect totalItems" - return items - ) - <*> o .:? "context" .!= [] + <$> withAuthorityO h (o .: "subteams") + <*> withAuthorityO h (o .: "context") <*> withAuthorityO h (o .: "members") toSeries h (Team actor children parents members) = toSeries h actor - <> "subteams" `pair` pairs - ( "type" .= ("Collection" :: Text) - <> "items" .= children - <> "totalItems" .= length children - ) - <> "context" .= parents + <> "subteams" .= ObjURI h children + <> "context" .= ObjURI h parents <> "members" .= ObjURI h members data Audience u = Audience diff --git a/templates/group/nav.hamlet b/templates/group/nav.hamlet index 7855295..7866ddf 100644 --- a/templates/group/nav.hamlet +++ b/templates/group/nav.hamlet @@ -30,5 +30,11 @@ $# . [🤝 Members] + + + [🐛 Children] + + + [🦋 Parents] [✏ Edit] diff --git a/templates/project/widget/nav.hamlet b/templates/project/widget/nav.hamlet index bd8ec5f..8be0178 100644 --- a/templates/project/widget/nav.hamlet +++ b/templates/project/widget/nav.hamlet @@ -33,6 +33,12 @@ $# . [🧩 Components] + + + [🐛 Children] + + + [🦋 Parents] [No wiki]