@@ -440,8 +440,7 @@ htmlFeature env@ServerEnv{..}
440
440
441
441
{- ------------------------------------------------------------------------------
442
442
Core
443
- -----------------------------------------------------------------------------
444
- -}
443
+ -------------------------------------------------------------------------------}
445
444
446
445
data HtmlCore = HtmlCore {
447
446
htmlCoreResources :: [Resource ]
@@ -519,10 +518,10 @@ mkHtmlCore ServerEnv{serverBaseURI}
519
518
, (resourceAt " /packages/names" ) {
520
519
resourceGet = [(" html" , const $ readAsyncCache cacheNamesPage)]
521
520
}
522
- , (resourceAt " /packages/names/experiment " ) {
521
+ , (resourceAt " /packages/names/tags " ) {
523
522
resourceDesc = [(GET , " Show detailed package dependency information" )]
524
523
, resourceGet = [(" html" ,
525
- serveMaintainPage' )]
524
+ serveTagIndex )]
526
525
}
527
526
, (extendResource $ corePackagesPage cores) {
528
527
resourceDesc = [(GET , " Show package index" )]
@@ -619,13 +618,13 @@ mkHtmlCore ServerEnv{serverBaseURI}
619
618
, " versions" $= map packageId pkgs
620
619
]
621
620
622
- serveMaintainPage' :: DynamicPath -> ServerPartE Response
623
- serveMaintainPage' _ = do
621
+ serveTagIndex :: DynamicPath -> ServerPartE Response
622
+ serveTagIndex _ = do
624
623
pkgIndex <- queryGetPackageIndex
625
624
let packageNames = Pages. toPackageNames pkgIndex
626
625
pkgDetails <- liftIO $ makeItemList packageNames
627
626
let rowList = map (makeRow) pkgDetails
628
- tabledata = " " +++ rowList +++ " "
627
+ tabledata = " " +++ rowList +++ " "
629
628
template <- getTemplate templates " tag-interface.html"
630
629
return $ toResponse $ template
631
630
[ " tabledata" $= tabledata ]
@@ -679,8 +678,7 @@ mkHtmlCore ServerEnv{serverBaseURI}
679
678
680
679
{- ------------------------------------------------------------------------------
681
680
Users
682
- -----------------------------------------------------------------------------
683
- -}
681
+ -------------------------------------------------------------------------------}
684
682
685
683
data HtmlUsers = HtmlUsers {
686
684
htmlUsersResources :: [Resource ]
@@ -791,8 +789,7 @@ mkHtmlUsers UserFeature{..} UserDetailsFeature{..} = HtmlUsers{..}
791
789
792
790
{- ------------------------------------------------------------------------------
793
791
Uploads
794
- -----------------------------------------------------------------------------
795
- -}
792
+ -------------------------------------------------------------------------------}
796
793
797
794
data HtmlUploads = HtmlUploads {
798
795
htmlUploadsResources :: [Resource ]
@@ -840,8 +837,7 @@ mkHtmlUploads HtmlUtilities{..} UploadFeature{..} = HtmlUploads{..}
840
837
841
838
{- ------------------------------------------------------------------------------
842
839
Documentation uploads
843
- -----------------------------------------------------------------------------
844
- -}
840
+ -------------------------------------------------------------------------------}
845
841
846
842
data HtmlDocUploads = HtmlDocUploads {
847
843
htmlDocUploadsResources :: [Resource ]
@@ -888,8 +884,7 @@ mkHtmlDocUploads HtmlUtilities{..} CoreFeature{coreResource} DocumentationFeatur
888
884
889
885
{- ------------------------------------------------------------------------------
890
886
Build reports
891
- -----------------------------------------------------------------------------
892
- -}
887
+ -------------------------------------------------------------------------------}
893
888
894
889
data HtmlReports = HtmlReports {
895
890
htmlReportsResources :: [Resource ]
@@ -933,8 +928,7 @@ mkHtmlReports HtmlUtilities{..} CoreFeature{..} ReportsFeature{..} templates = H
933
928
934
929
{- ------------------------------------------------------------------------------
935
930
Candidates
936
- -----------------------------------------------------------------------------
937
- -}
931
+ -------------------------------------------------------------------------------}
938
932
939
933
data HtmlCandidates = HtmlCandidates {
940
934
htmlCandidatesResources :: [Resource ]
@@ -1191,8 +1185,7 @@ dependenciesPage isCandidate render =
1191
1185
1192
1186
{- ------------------------------------------------------------------------------
1193
1187
Preferred versions
1194
- -----------------------------------------------------------------------------
1195
- -}
1188
+ -------------------------------------------------------------------------------}
1196
1189
1197
1190
data HtmlPreferred = HtmlPreferred {
1198
1191
htmlPreferredResources :: [Resource ]
@@ -1410,8 +1403,7 @@ mkHtmlPreferred HtmlUtilities{..}
1410
1403
1411
1404
{- ------------------------------------------------------------------------------
1412
1405
Downloads
1413
- -----------------------------------------------------------------------------
1414
- -}
1406
+ -------------------------------------------------------------------------------}
1415
1407
1416
1408
data HtmlDownloads = HtmlDownloads {
1417
1409
htmlDownloadsResources :: [Resource ]
@@ -1449,8 +1441,7 @@ mkHtmlDownloads HtmlUtilities{..} DownloadFeature{..} = HtmlDownloads{..}
1449
1441
1450
1442
{- ------------------------------------------------------------------------------
1451
1443
Tags
1452
- -----------------------------------------------------------------------------
1453
- -}
1444
+ -------------------------------------------------------------------------------}
1454
1445
1455
1446
data HtmlTags = HtmlTags {
1456
1447
htmlTagsResources :: [Resource ]
@@ -1471,7 +1462,7 @@ mkHtmlTags HtmlUtilities{..}
1471
1462
, lookupPackageName
1472
1463
}
1473
1464
}
1474
- UploadFeature {guardAuthorisedAsUploaderOrMaintainerOrTrustee, guardAuthorisedAsTrustee}
1465
+ UploadFeature {authorisedAsAnyUser, authorisedAsMaintainerOrTrustee, guardAuthorisedAsTrustee}
1475
1466
ListFeature {makeItemList}
1476
1467
TagsFeature {.. }
1477
1468
templates
@@ -1524,21 +1515,24 @@ mkHtmlTags HtmlUtilities{..}
1524
1515
putAliasEdit dpath = do
1525
1516
let tagname = snd (dpath !! 0 )
1526
1517
mergeTags (Tag tagname)
1527
- return $ toResponse $ Resource. XHtml $ hackagePage (" Merged Tag " ++ tagname) $
1528
- [ paragraph << [" Return to" ]
1529
- , anchor ! [href " /packages/tags" ] << tagname
1518
+ return $ toResponse $ Resource. XHtml $ hackagePage " Merged Tag" $
1519
+ [ h2 << " Merged tag"
1520
+ , toHtml " Return to "
1521
+ , anchor ! [href $ " /packages/tags" ] << " tag listings"
1530
1522
]
1531
1523
1532
1524
serveAliasForm :: DynamicPath -> ServerPartE Response
1533
1525
serveAliasForm dpath = do
1534
1526
tagname <- tagInPath dpath
1535
1527
guardAuthorisedAsTrustee
1536
- let aliasForm = [ h2 << (" Merge Tag " ++ tagname)
1537
- , form ! [theclass " box" , XHtml. method " post" , action (" /packages/tag/" ++ tagname ++ " /alias" )] <<
1538
- [ hidden " _method" " PUT"
1539
- , input ! [value " " , name " tags" , identifier " tags" ]
1540
- , toHtml " Tag(s) to merge with"
1541
- , input ! [thetype " submit" , value " Merge" ]
1528
+ let aliasForm = [ thediv ! [theclass " box" ] <<
1529
+ [h2 << (" Merge Tag " ++ tagname)
1530
+ , form ! [XHtml. method " post" , action (" /packages/tag/" ++ tagname ++ " /alias" )] <<
1531
+ [ hidden " _method" " PUT"
1532
+ , input ! [value " " , name " tags" , identifier " tags" ]
1533
+ , toHtml " (Tag to merge with) " , br
1534
+ , input ! [thetype " submit" , value " Merge" ]
1535
+ ]
1542
1536
]
1543
1537
]
1544
1538
return $ toResponse $ Resource. XHtml $ hackagePage (" Merge Tag " ++ tagname) $ aliasForm
@@ -1579,40 +1573,16 @@ mkHtmlTags HtmlUtilities{..}
1579
1573
putTags pkgname
1580
1574
currTags <- queryTagsForPackage pkgname
1581
1575
revTags <- queryReviewTagsForPackage pkgname
1582
- let toStr = concat . intersperse " , " . map display . Set. toList
1583
- tagsStr = toStr currTags
1584
- addns = toStr $ fst $ fromMaybe (Set. empty, Set. empty) revTags
1585
- delns = toStr $ snd $ fromMaybe (Set. empty, Set. empty) revTags
1586
- disp = thediv ! [theclass " box" ] << [ paragraph << [bold $ toHtml " Current Tags: " , toHtml tagsStr, br],
1587
- paragraph << [bold $ toHtml " Additions to be reviewed: " , toHtml addns, br],
1588
- paragraph << [bold $ toHtml " Deletions to be reviewed: " , toHtml delns, br]
1589
- ]
1590
-
1591
- return $ toResponse $ Resource. XHtml $ hackagePage " Package Tags" [ big $ bold $ toHtml $ display pkgname
1592
- , disp
1593
- , anchor ! [href $ " tags/edit" ] << " Propose a tag?" , toHtml " or "
1594
- , toHtml " return to " , packageNameLink pkgname, br
1595
- ]
1576
+ let disp = renderReviewTags currTags revTags pkgname
1577
+ return $ toResponse $ Resource. XHtml $ hackagePage " Package Tags" disp
1596
1578
1597
1579
showPackageTags :: DynamicPath -> ServerPartE Response
1598
1580
showPackageTags dpath = do
1599
1581
pkgname <- packageInPath dpath
1600
1582
currTags <- queryTagsForPackage pkgname
1601
1583
revTags <- queryReviewTagsForPackage pkgname
1602
- let toStr = concat . intersperse " , " . map display . Set. toList
1603
- tagsStr = toStr currTags
1604
- addns = toStr $ fst $ fromMaybe (Set. empty, Set. empty) revTags
1605
- delns = toStr $ snd $ fromMaybe (Set. empty, Set. empty) revTags
1606
- disp = thediv ! [theclass " box" ] << [ paragraph << [bold $ toHtml " Current Tags: " , toHtml tagsStr, br],
1607
- paragraph << [bold $ toHtml " Additions to be reviewed: " , toHtml addns, br],
1608
- paragraph << [bold $ toHtml " Deletions to be reviewed: " , toHtml delns, br]
1609
- ]
1610
-
1611
- return $ toResponse $ Resource. XHtml $ hackagePage " Package Tags" [ big $ bold $ toHtml $ display pkgname
1612
- , disp
1613
- , anchor ! [href $ " tags/edit" ] << " Propose a tag?" , toHtml " or "
1614
- , toHtml " return to " , packageNameLink pkgname, br
1615
- ]
1584
+ let disp = renderReviewTags currTags revTags pkgname
1585
+ return $ toResponse $ Resource. XHtml $ hackagePage " Package Tags" disp
1616
1586
1617
1587
-- serve form for editing, to be received by putTags
1618
1588
serveTagsForm :: DynamicPath -> ServerPartE Response
@@ -1623,33 +1593,27 @@ mkHtmlTags HtmlUtilities{..}
1623
1593
template <- getTemplate templates " tag-edit.html"
1624
1594
let toStr = concat . intersperse " , " . map display . Set. toList
1625
1595
tagsStr = toStr currTags
1626
- addns = toStr $ fst $ fromMaybe (Set. empty,Set. empty) revTags
1627
- delns = toStr $ snd $ fromMaybe (Set. empty, Set. empty) revTags
1628
-
1629
-
1630
- user <- guardAuthorisedAsUploaderOrMaintainerOrTrustee pkgname
1631
- case user of
1632
- " Uploaders" -> return $ toResponse . template $
1633
- [ " pkgname" $= display pkgname
1634
- , " addns" $= addns
1635
- , " tags" $= (tagsStr)
1636
- , " delns" $= delns
1637
- , " isuser" $= " true"
1638
- ]
1639
- _ -> return $ toResponse . template $
1596
+ addns = toStr $ fst revTags
1597
+ delns = toStr $ snd revTags
1598
+ trustainer <- authorisedAsMaintainerOrTrustee pkgname
1599
+ user <- authorisedAsAnyUser
1600
+ if trustainer || user
1601
+ then return $ toResponse . template $
1640
1602
[ " pkgname" $= display pkgname
1641
1603
, " addns" $= addns
1642
- , " tags" $= ( tagsStr)
1604
+ , " tags" $= tagsStr
1643
1605
, " delns" $= delns
1644
- , " istrustee" $= " false"
1606
+ , " istrustee" $= trustainer
1607
+ , " isuser" $= if trustainer then False else True
1645
1608
]
1609
+ else return $ toResponse $ Resource. XHtml $ hackagePage " Error" $ [h2 << " Authorization Error"
1610
+ , paragraph << " You need to be logged in to propose tags" ]
1646
1611
1647
1612
1648
1613
1649
1614
{- ------------------------------------------------------------------------------
1650
1615
Search
1651
- -----------------------------------------------------------------------------
1652
- -}
1616
+ -------------------------------------------------------------------------------}
1653
1617
1654
1618
data HtmlSearch = HtmlSearch {
1655
1619
htmlSearchResources :: [Resource ]
@@ -1908,8 +1872,7 @@ mkHtmlSearch HtmlUtilities{..}
1908
1872
1909
1873
{- ------------------------------------------------------------------------------
1910
1874
Groups
1911
- -----------------------------------------------------------------------------
1912
- -}
1875
+ -------------------------------------------------------------------------------}
1913
1876
1914
1877
htmlGroupResource :: UserFeature -> GroupResource -> [Resource ]
1915
1878
htmlGroupResource UserFeature {.. } r@ (GroupResource groupR userR getGroup) =
0 commit comments