Skip to content

List maintainers on package page #1098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions datafiles/templates/Html/candidate-page.html.st
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@
$downloadSection$

<h4>Maintainer's Corner</h4>
<p>Package maintainers</p>
<ul>
<li>
$maintainers$
</li>
</ul>
<p>For package maintainers and hackage trustees</p>
<ul>
<li>
Expand Down
8 changes: 7 additions & 1 deletion datafiles/templates/Html/package-page.html.st
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@

<div id="maintainer-corner">
<h4>Maintainer's Corner</h4>
<p>For $package.maintainerURL$ and hackage trustees</p>
<p><a href="$package.maintainerURL$">Package maintainers</a></p>
<ul>
<li>
$maintainers$
</li>
</ul>
<p>For package maintainers and hackage trustees</p>
<ul>
<li>
<a href="$baseurl$/package/$package.name$/maintain">
Expand Down
12 changes: 11 additions & 1 deletion src/Distribution/Server/Features/Html.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import qualified Text.XHtml.Strict as XHtml
import Text.XHtml.Table (simpleTable)
import Distribution.PackageDescription (hasLibs)
import Distribution.PackageDescription.Configuration (flattenPackageDescription)
import Distribution.Server.Pages.Group (listGroupCompact)


-- TODO: move more of the below to Distribution.Server.Pages.*, it's getting
Expand Down Expand Up @@ -590,6 +591,7 @@ mkHtmlCore ServerEnv{serverBaseURI, serverBlobStore}
docURL = packageDocsContentUri docs realpkg
execs = rendExecNames render
pkgdesc = flattenPackageDescription $ pkgDesc pkg
maintainers = maintainersGroup pkgname

prefInfo <- queryGetPreferredInfo pkgname
distributions <- queryPackageStatus pkgname
Expand All @@ -611,6 +613,8 @@ mkHtmlCore ServerEnv{serverBaseURI, serverBlobStore}
mdocIndex <- maybe (return Nothing)
(liftM Just . liftIO . cachedTarIndex) mdoctarblob
analyticsPixels <- getPackageAnalyticsPixels pkgname
userDb <- queryGetUserDb
maintainerlist <- liftIO $ queryUserGroup maintainers
let
idAndReport = fmap (\(rptId, rpt, _) -> (rptId, rpt)) rptStats
install = getInstall $ fmap (fst &&& BR.installOutcome . snd) idAndReport
Expand Down Expand Up @@ -660,6 +664,7 @@ mkHtmlCore ServerEnv{serverBaseURI, serverBlobStore}
, "candidates" $= case candidates of
[] -> [ toHtml "No Candidates"]
_ -> [ PagesNew.commaList $ flip map candidates $ \cand -> anchor ! [href $ corePackageIdUri candidatesCore "" $ packageId cand] << display (packageVersion cand) ]
, "maintainers" $= listGroupCompact (map (Users.userIdToName userDb) (Group.toList maintainerlist))
] ++
-- Items not related to IO (mostly pure functions)
PagesNew.packagePageTemplate render
Expand Down Expand Up @@ -1102,7 +1107,7 @@ mkHtmlCandidates utilities@HtmlUtilities{..}
DocumentationFeature{documentationResource, queryDocumentation,..}
TarIndexCacheFeature{cachedTarIndex}
PackageCandidatesFeature{..}
UserFeature{ guardAuthorised, guardAuthorised_ }
UserFeature{ guardAuthorised, guardAuthorised_, queryGetUserDb }
templates = HtmlCandidates{..}
where
candidates = candidatesResource
Expand Down Expand Up @@ -1261,10 +1266,15 @@ mkHtmlCandidates utilities@HtmlUtilities{..}
[] -> []
warn -> [thediv ! [theclass "candidate-warn"] << [paragraph << strong (toHtml "Warnings:"), unordList warn]]

let maintainers = maintainersGroup pkgname
userDb <- queryGetUserDb
maintainerlist <- liftIO $ queryUserGroup maintainers

return $ toResponse . template $
[ "versions" $= (PagesNew.renderVersion (packageId cand) (classifyVersions prefInfo $ insert version otherVersions) Nothing)
, "maintainHtml" $= [maintainHtml]
, "warningBox" $= warningBox
, "maintainers" $= listGroupCompact (map (Users.userIdToName userDb) (Group.toList maintainerlist))
] ++
PagesNew.packagePageTemplate render
mdocIndex Nothing mreadme
Expand Down
15 changes: 11 additions & 4 deletions src/Distribution/Server/Pages/Group.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
-- Body of the HTML page for a package
module Distribution.Server.Pages.Group (
groupPage,
renderGroupName
renderGroupName,
listGroupCompact
-- renderGroupNameWithCands
) where

Expand Down Expand Up @@ -69,7 +70,13 @@ removeUser uname uri =
]

listGroup :: [Users.UserName] -> Maybe String -> Html
listGroup [] _ = p << "No member exist presently"
listGroup users muri = unordList (map displayName users)
where displayName uname = (anchor ! [href $ "/user/" ++ display uname] << display uname) +++
listGroup [] _ = p << "No current members of group"
listGroup users muri = unordList (map (displayName muri) users)

listGroupCompact :: [Users.UserName] -> Html
listGroupCompact [] = toHtml "No current members of group"
listGroupCompact users = foldr1 (\a b -> a +++ ", " +++ b) (map (displayName Nothing) users)

displayName :: Maybe String -> Users.UserName -> Html
displayName muri uname = (anchor ! [href $ "/user/" ++ display uname] << display uname) +++
maybe [] (removeUser uname) muri
3 changes: 1 addition & 2 deletions src/Distribution/Server/Pages/PackageFromTemplate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ packagePageTemplate render
, templateVal "license" (Old.rendLicense render)
, templateVal "author" (toHtml $ author desc)
, templateVal "maintainer" (Old.maintainField $ rendMaintainer render)
, templateVal "maintainerURL" (toHtml $
anchor ! [href $ "/package" </> pkgName </> "maintainers" ] << "package maintainers")
, templateVal "maintainerURL" (toHtml $ "/package" </> pkgName </> "maintainers")
, templateVal "buildDepends" (snd (Old.renderDependencies render))
, templateVal "optional" optionalPackageInfoTemplate
, templateVal "candidateBanner" candidateBanner
Expand Down