Skip to content

GSoC20 candidates workflow #895

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 30 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cd7c51a
added candidate template
sitaochen Jun 11, 2020
d962c7f
upload keys
sitaochen Jun 11, 2020
2c67e7a
added candidatePage template
sitaochen Jun 16, 2020
85ee001
add candidate template
sitaochen Jun 16, 2020
a0e4207
Resolve conflict
sitaochen Jun 16, 2020
4d289df
add template for candidatesPage
sitaochen Jun 17, 2020
3de69f8
update templates
sitaochen Jun 23, 2020
52b2436
fix warning
sitaochen Jun 25, 2020
9e7ec2f
Merge branch 'master' into candidate_template
sitaochen Jun 25, 2020
1f80335
Merge pull request #1 from sitaochen/candidate_template
sitaochen Jun 25, 2020
ac59bf7
Delete servers.cfg
sitaochen Jun 25, 2020
157def0
Add example keys for testing purposes
sitaochen Jun 25, 2020
d7a26b7
Change to example keys for testing purposes
sitaochen Jun 25, 2020
bddfcac
update comments
sitaochen Jun 25, 2020
0b3b852
fix comments
sitaochen Jun 25, 2020
85ff195
remove .DS_Store
sitaochen Jun 25, 2020
ecb1d92
Merge branch 'master' of https://github.com/haskell/hackage-server
sitaochen Jul 14, 2020
f655009
fixed maintain link
sitaochen Jul 15, 2020
c2ebf16
Merge branch 'master' of https://github.com/sitaochen/hackage-server
sitaochen Jul 15, 2020
b640fd5
remove comments
sitaochen Jul 15, 2020
a590485
updated candidate-page template
sitaochen Jul 15, 2020
33f91f1
updated candidates workflow
sitaochen Jul 22, 2020
3f2c30c
add candidate link on user page
sitaochen Jul 31, 2020
6c32799
add "delete all candidates for this package" on candidates page
sitaochen Aug 7, 2020
83357c5
add comments for lifecycle
sitaochen Aug 17, 2020
388755a
expose doc upload in candidates
sitaochen Aug 18, 2020
483aaf6
update candidate docs upload UI
sitaochen Aug 20, 2020
da176f1
fix candidate link on doc upload form
sitaochen Aug 25, 2020
0416997
add config
sitaochen Aug 26, 2020
d383e38
moved candidate section
sitaochen Sep 26, 2020
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
1 change: 1 addition & 0 deletions Distribution/Server/Features/Documentation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ data DocumentationFeature = DocumentationFeature {
uploadDocumentation :: DynamicPath -> ServerPartE Response,
deleteDocumentation :: DynamicPath -> ServerPartE Response,


documentationResource :: DocumentationResource,

-- | Notification of documentation changes
Expand Down
141 changes: 94 additions & 47 deletions Distribution/Server/Features/Html.hs

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion Distribution/Server/Features/Html/HtmlUtilities.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Text.XHtml.Strict
import qualified Data.Set as Set
import Distribution.Server.Features.Tags
import Distribution.Server.Features.Core
import Distribution.Server.Features.PackageCandidates
import Distribution.Text (display)
import Data.List (intersperse, intercalate)
import Data.Set (Set)
Expand All @@ -20,20 +21,25 @@ import Distribution.Server.Features.Users

data HtmlUtilities = HtmlUtilities {
packageLink :: PackageId -> Html
, candidateLink :: PackageId -> Html
, packageNameLink :: PackageName -> Html
, renderItem :: PackageItem -> Html
, makeRow :: PackageItem -> Html
, renderTags :: Set Tag -> [Html]
, renderReviewTags :: Set Tag -> (Set Tag, Set Tag) -> PackageName -> [Html]
}

htmlUtilities :: CoreFeature -> TagsFeature -> UserFeature -> HtmlUtilities
htmlUtilities :: CoreFeature -> PackageCandidatesFeature -> TagsFeature -> UserFeature -> HtmlUtilities
htmlUtilities CoreFeature{coreResource}
PackageCandidatesFeature{candidatesCoreResource}
TagsFeature{tagsResource} UserFeature{userResource} = HtmlUtilities{..}
where
packageLink :: PackageId -> Html
packageLink pkgid = anchor ! [href $ corePackageIdUri cores "" pkgid] << display pkgid

candidateLink :: PackageId -> Html
candidateLink pkgid = anchor ! [href $ corePackageIdUri candidatesCoreResource "" pkgid] << display pkgid

packageNameLink :: PackageName -> Html
packageNameLink pkgname = anchor ! [href $ corePackageNameUri cores "" pkgname] << display pkgname

Expand Down
13 changes: 13 additions & 0 deletions Distribution/Server/Features/PackageCandidates.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ data PackageCandidatesFeature = PackageCandidatesFeature {
postPackageCandidate :: DynamicPath -> ServerPartE Response,
putPackageCandidate :: DynamicPath -> ServerPartE Response,
doDeleteCandidate :: DynamicPath -> ServerPartE Response,
doDeleteCandidates :: DynamicPath -> ServerPartE Response,
uploadCandidate :: (PackageId -> Bool) -> ServerPartE CandPkgInfo,
publishCandidate :: DynamicPath -> Bool -> ServerPartE UploadResult,
checkPublish :: forall m. MonadIO m => Users.UserId -> PackageIndex PkgInfo -> CandPkgInfo -> m (Maybe ErrorResponse),
Expand Down Expand Up @@ -110,9 +111,11 @@ data PackageCandidatesResource = PackageCandidatesResource {
packageCandidatesPage :: Resource,
publishPage :: Resource,
deletePage :: Resource,
deleteCandidatesPage :: Resource,
packageCandidatesUri :: String -> PackageName -> String,
publishUri :: String -> PackageId -> String,
deleteUri :: String -> PackageId -> String,
deleteCandidatesUri :: String -> PackageName -> String,

-- TODO: Why don't the following entries have a corresponding entry
-- in CoreResource?
Expand Down Expand Up @@ -248,6 +251,7 @@ candidatesFeature ServerEnv{serverBlobStore = store}
}
, publishPage = resourceAt "/package/:package/candidate/publish.:format"
, deletePage = resourceAt "/package/:package/candidate/delete.:format"
, deleteCandidatesPage = resourceAt "/package/:package/candidates/delete.:format"
, candidateContents = (resourceAt "/package/:package/candidate/src/..") {
resourceGet = [("", serveContents)]
}
Expand All @@ -261,6 +265,8 @@ candidatesFeature ServerEnv{serverBlobStore = store}
renderResource (publishPage r) [display pkgid, format]
, deleteUri = \format pkgid ->
renderResource (deletePage r) [display pkgid, format]
, deleteCandidatesUri = \format pkgname ->
renderResource (deleteCandidatesPage r) [display pkgname, format]
, candidateChangeLogUri = \pkgid ->
renderResource (candidateChangeLog candidatesResource) [display pkgid, display (packageName pkgid)]
}
Expand Down Expand Up @@ -341,6 +347,13 @@ candidatesFeature ServerEnv{serverBlobStore = store}
void $ updateState candidatesState $ DeleteCandidate (packageId candidate)
seeOther (packageCandidatesUri candidatesResource "" $ packageName candidate) $ toResponse ()

doDeleteCandidates :: DynamicPath -> ServerPartE Response
doDeleteCandidates dpath = do
pkgname <- packageInPath dpath
guardAuthorisedAsMaintainer pkgname
void $ updateState candidatesState $ DeleteCandidates pkgname
seeOther (packageCandidatesUri candidatesResource "" $ pkgname) $ toResponse ()

serveCandidateTarball :: DynamicPath -> ServerPartE Response
serveCandidateTarball dpath = do
pkgid <- packageTarballInPath dpath
Expand Down
1 change: 1 addition & 0 deletions Distribution/Server/Features/Upload.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ data UploadFeature = UploadFeature {
uploadResource :: UploadResource,
-- | The main upload routine. This uses extractPackage on a multipart
-- request to get contextual information.
-- For new pacakges lifecycle, this should be removed
uploadPackage :: ServerPartE UploadResult,

--TODO: consider moving the trustee and/or per-package maintainer groups
Expand Down
6 changes: 5 additions & 1 deletion Distribution/Server/Pages/Group.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module Distribution.Server.Pages.Group (
groupPage,
renderGroupName
-- renderGroupNameWithCands
) where

import Text.XHtml.Strict
Expand All @@ -17,8 +18,11 @@ renderGroupName :: GroupDescription -> Maybe String -> Html
renderGroupName desc murl =
maybeUrl (groupTitle desc) murl
+++
maybe noHtml (\(for, mfor) -> " for " +++ maybeUrl for mfor) (groupEntity desc)
maybe noHtml (\(for, mfor) -> " for " +++ maybeUrl for mfor ) (groupEntity desc)
+++
maybe noHtml (\(_, mfor) -> " : " +++ candUrl "No Candidates" mfor ) (groupEntity desc)
where maybeUrl text = maybe (toHtml text) (\url -> anchor ! [href url] << text)
candUrl text = maybe (toHtml text) (\url -> anchor ! [href $ url ++ "/candidates"] << "candidates")

-- Primitive access control: the URI to post a new user request to, or the the URI/user/<username> to DELETE
-- if neither adding or removing is enabled, a link to a URI/edit page is provided
Expand Down
163 changes: 119 additions & 44 deletions Distribution/Server/Pages/PackageFromTemplate.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
{-# LANGUAGE PatternGuards, RecordWildCards #-}
module Distribution.Server.Pages.PackageFromTemplate
( packagePageTemplate
, candidatesPageTemplate
, renderVersion
, latestVersion
, commaList
) where

import Distribution.Server.Framework.Templating
import Distribution.Server.Features.PreferredVersions
import Distribution.Server.Features.Core

import Distribution.Server.Util.DocMeta
import Distribution.Server.Packages.Render
import qualified Distribution.Server.Packages.PackageIndex as PackageIndex
import Distribution.Server.Packages.PackageIndex (PackageIndex)
import Distribution.Server.Packages.Types
import Distribution.Server.Features.PackageCandidates
import Distribution.Server.Users.Types (userStatus, userName, isActiveAccount)
import Data.TarIndex (TarIndex)
import Distribution.Server.Features.Distro.Types
Expand Down Expand Up @@ -75,54 +82,81 @@ packagePageTemplate :: PackageRender
-> URL -> [(DistroName, DistroPackageInfo)]
-> Maybe [PackageName]
-> HtmlUtilities
-> Bool
-> [TemplateAttr]
packagePageTemplate render
mdocIndex mdocMeta mreadme
docURL distributions
deprs utilities =
-- The main two namespaces
[ "package" $= packageFieldsTemplate
, "hackage" $= hackageFieldsTemplate
, "doc" $= docFieldsTemplate
] ++

-- Miscellaneous things that could still stand to be refactored a bit.
[ "moduleList" $= Old.moduleSection render mdocIndex docURL hasQuickNav
, "executables" $= (commaList . map toHtml $ rendExecNames render)
, "downloadSection" $= Old.downloadSection render
, "stability" $= renderStability desc
, "isDeprecated" $= (if deprs == Nothing then False else True)
, "deprecatedMsg" $= (deprHtml deprs)
]
deprs utilities isCandidate =
if isCandidate
then
-- The main two namespaces
[ "package" $= packageFieldsTemplate
, "hackage" $= hackageFieldsTemplate
, "doc" $= docFieldsTemplate
] ++
-- Miscellaneous things that could still stand to be refactored a bit.
[ "moduleList" $= Old.moduleSection render mdocIndex docURL False
, "downloadSection" $= Old.downloadSection render
]
else
-- The main two namespaces
[ "package" $= packageFieldsTemplate
, "hackage" $= hackageFieldsTemplate
, "doc" $= docFieldsTemplate
] ++
-- Miscellaneous things that could still stand to be refactored a bit.
[ "moduleList" $= Old.moduleSection render mdocIndex docURL hasQuickNav
, "executables" $= (commaList . map toHtml $ rendExecNames render)
, "downloadSection" $= Old.downloadSection render
, "stability" $= renderStability desc
, "isDeprecated" $= (if deprs == Nothing then False else True)
, "deprecatedMsg" $= (deprHtml deprs)
]
where
-- Access via "$hackage.varName$"
hackageFieldsTemplate = templateDict $
[ templateVal "uploadTime"
(uncurry renderUploadInfo $ rendUploadInfo render)
] ++

[ templateVal "hasUpdateTime"
(case rendUpdateInfo render of Nothing -> False; _ -> True)
, templateVal "updateTime" [ renderUpdateInfo revisionNo utime uinfo
| (revisionNo, utime, uinfo) <- maybeToList (rendUpdateInfo render) ]
] ++

[ templateVal "hasDistributions"
True
{-(if distributions == [] then False else True)-}
, templateVal "distributions"
(concatHtml . intersperse (toHtml ", ") $ map showDist distributions)
] ++

[ templateVal "hasFlags"
(if rendFlags render == [] then False else True)
, templateVal "flagsSection"
(Old.renderPackageFlags render docURL)
]
where
showDist (dname, info) = toHtml (display dname ++ ":") +++
hackageFieldsTemplate =
if isCandidate
then templateDict $
[ templateVal "uploadTime"
(uncurry renderUploadInfo $ rendUploadInfo render)
] ++
[ templateVal "hasUpdateTime"
(case rendUpdateInfo render of Nothing -> False; _ -> True)
, templateVal "updateTime" [ renderUpdateInfo revisionNo utime uinfo
| (revisionNo, utime, uinfo) <- maybeToList (rendUpdateInfo render) ]
] ++
[ templateVal "hasFlags"
(if rendFlags render == [] then False else True)
, templateVal "flagsSection"
(Old.renderPackageFlags render docURL)
]
else templateDict $
[ templateVal "uploadTime"
(uncurry renderUploadInfo $ rendUploadInfo render)
] ++

[ templateVal "hasUpdateTime"
(case rendUpdateInfo render of Nothing -> False; _ -> True)
, templateVal "updateTime" [ renderUpdateInfo revisionNo utime uinfo
| (revisionNo, utime, uinfo) <- maybeToList (rendUpdateInfo render) ]
] ++
[ templateVal "hasDistributions"
True
{-(if distributions == [] then False else True)-}
, templateVal "distributions"
(concatHtml . intersperse (toHtml ", ") $ map showDist distributions)
] ++
[ templateVal "hasFlags"
(if rendFlags render == [] then False else True)
, templateVal "flagsSection"
(Old.renderPackageFlags render docURL)
]
where
showDist (dname, info) = toHtml (display dname ++ ":") +++
anchor ! [href $ distroUrl info] << toHtml (display $ distroVersion info)


-- Fields from the .cabal file.
-- Access via "$package.varName$"
packageFieldsTemplate = templateDict $
Expand All @@ -133,12 +167,15 @@ packagePageTemplate render
, templateVal "maintainer" (Old.maintainField $ rendMaintainer render)
, templateVal "buildDepends" (snd (Old.renderDependencies render))
, templateVal "optional" optionalPackageInfoTemplate
, templateVal "candidateBanner" candidateBanner
]

docFieldsTemplate = templateDict $
[ templateVal "hasQuickNavV1" hasQuickNavV1
, templateVal "baseUrl" docURL
]
docFieldsTemplate =
if isCandidate
then templateDict $ [ templateVal "baseUrl" docURL ]
else templateDict $ [ templateVal "hasQuickNavV1" hasQuickNavV1
, templateVal "baseUrl" docURL
]

-- Fields that may be empty, along with booleans to see if they're present.
-- Access via "$package.optional.varname$"
Expand Down Expand Up @@ -205,6 +242,17 @@ packagePageTemplate render

desc = rendOther render

candidateBanner
| isCandidate = [ thediv ! [theclass "candidate-info"]
<< [ paragraph << [ strong (toHtml "This is a package candidate release!")
, toHtml " Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below)."
, toHtml " Please note that once a package has been published to the main package index it cannot be undone!"
, toHtml " Please consult the "
, anchor ! [href "/upload"] << "package uploading documentation"
, toHtml " for more information."
] ] ]
| otherwise = []

renderCopyright :: Html
renderCopyright = toHtml $ case text of
"" -> "None provided"
Expand Down Expand Up @@ -264,6 +312,33 @@ packagePageTemplate render
hasQuickNav :: Bool
hasQuickNav = hasQuickNavV1

candidatesPageTemplate :: (PackageIndex CandPkgInfo) -> PackageCandidatesResource -> CoreResource -> [TemplateAttr]
candidatesPageTemplate cands candidates candidatesCore=
["heading" $= "Package candidates"
,"content" $= (paragraph <<
[ toHtml "Here follow all the candidate package versions on Hackage. "
, thespan ! [thestyle "color: gray"] <<
[ toHtml "["
, anchor ! [href "/packages/candidates/upload"] << "upload"
, toHtml "]" ]
])
,"list" $= (unordList $ map showCands $ PackageIndex.allPackagesByName cands)
]
where showCands pkgs =
-- TODO: Duncan changed this to packageSynopsis but without an
-- accomponaying definition of packageSynposis. Changed back for now.
let desc = packageDescription . pkgDesc . candPkgInfo $ last pkgs
pkgname = packageName desc
-- candidates = candidatesResource
-- candidatesCore = candidatesCoreResource
in [ anchor ! [href $ packageCandidatesUri candidates "" pkgname ] << display pkgname
, toHtml ": "
, toHtml $ intersperse (toHtml ", ") $ flip map pkgs $ \pkg ->
anchor ! [href $ corePackageIdUri candidatesCore "" (packageId pkg)] << display (packageVersion pkg)
, toHtml $ ". " ++ synopsis desc
]


-- #ToDo: Pick out several interesting versions to display, with a link to
-- display all versions.
renderVersion :: PackageId -> [(Version, VersionStatus)] -> Maybe String -> Html
Expand Down
Loading