Separate page for all snapshots of a package

This commit is contained in:
Chris Done 2014-12-15 11:49:01 +01:00
parent af2552041c
commit b498d0a041
3 changed files with 51 additions and 0 deletions

View File

@ -245,3 +245,32 @@ postPackageUntagR packageName =
,TagTag ==. slug
,TagVoter ==. uid]))
Nothing -> error "Need a slug"
getPackageSnapshotsR :: PackageName -> Handler Html
getPackageSnapshotsR pn =
do let haddocksLink ident version =
HaddockR ident [concat [toPathPiece pn, "-", toPathPiece version]]
muid <- maybeAuthId
snapshots <- (runDB .
fmap (map reformat) .
E.select . E.from)
(\(p,s) ->
do E.where_ $
(p ^. PackageStackage E.==. s ^. StackageId) &&.
(p ^. PackageName' E.==. E.val pn)
E.orderBy [E.desc $ s ^. StackageUploaded]
return
(p ^. PackageVersion
,s ^. StackageTitle
,s ^. StackageSlug
,s ^. StackageHasHaddocks))
defaultLayout
(do setTitle ("Packages for " >> toHtml pn)
$(combineStylesheets 'StaticR
[css_font_awesome_min_css])
$(widgetFile "package-snapshots"))
where reformat (Value version,Value title,Value ident,Value hasHaddocks) =
(version
,fromMaybe title (stripPrefix "Stackage build for " title)
,ident
,hasHaddocks)

View File

@ -33,6 +33,7 @@
/system SystemR GET
/haddock/#SnapSlug/*Texts HaddockR GET
/package/#PackageName PackageR GET
/package/#PackageName/snapshots PackageSnapshotsR GET
/package PackageListR GET
/compressor-status CompressorStatusR GET
/package/#PackageName/like PackageLikeR POST

View File

@ -0,0 +1,21 @@
$newline never
<div .container #snapshot-home .content>
<div .row>
<div .span12>
<h1>Snapshots containing #{toHtml pn}
<table .table .snapshots>
<thead>
<th colspan=2>
Package
<th>
Snapshot
$forall (version, title, slug, hasHaddocks) <- snapshots
<tr>
<td>
$if hasHaddocks
<a href=@{haddocksLink slug version}>
Docs
<td>
#{version}
<td>
<a href=@{SnapshotR slug StackageHomeR}>#{fromMaybe title $ stripSuffix ", exclusive" title}