Rename summary to contents

This commit is contained in:
Andrea Bedini 2022-10-26 17:18:36 +08:00
parent 4dcd18ac38
commit 37022542cc
3 changed files with 35 additions and 35 deletions

View File

@ -85,7 +85,7 @@ buildAction
packageVersions <- getPackageVersions inputDir
makeSummaryPage currentTime outputDir packageVersions
makeContentsPage currentTime outputDir packageVersions
makeTimelinePage currentTime outputDir packageVersions

View File

@ -4,10 +4,10 @@
{-# LANGUAGE TemplateHaskell #-}
module Foliage.Pages
( summaryPageTemplate,
( contentsPageTemplate,
timelinePageTemplate,
packageVersionPageTemplate,
makeSummaryPage,
makeContentsPage,
makePackageVersionPage,
makeTimelinePage,
)
@ -36,28 +36,28 @@ import Text.Mustache (Template)
import Text.Mustache.Compile.TH (compileMustacheDir)
import Text.Mustache.Render (renderMustache)
data SummaryPageEntry = SummaryPageEntry
{ summaryPageEntryPkgId :: PackageIdentifier,
summaryPageEntryTimestamp :: UTCTime,
summaryPageEntryTimestampPosix :: POSIXTime,
summaryPageEntrySource :: PackageVersionSource,
summaryPageEntryRevision :: Maybe RevisionSpec
data ContentsPageEntry = ContentsPageEntry
{ contentsPageEntryPkgId :: PackageIdentifier,
contentsPageEntryTimestamp :: UTCTime,
contentsPageEntryTimestampPosix :: POSIXTime,
contentsPageEntrySource :: PackageVersionSource,
contentsPageEntryRevision :: Maybe RevisionSpec
}
deriving stock (Generic)
deriving (ToJSON) via MyAesonEncoding SummaryPageEntry
deriving (ToJSON) via MyAesonEncoding ContentsPageEntry
makeSummaryPage :: UTCTime -> FilePath -> [PackageVersionMeta] -> Action ()
makeSummaryPage currentTime outputDir packageVersions = do
makeContentsPage :: UTCTime -> FilePath -> [PackageVersionMeta] -> Action ()
makeContentsPage currentTime outputDir packageVersions = do
let packages =
sortOn summaryPageEntryPkgId $
sortOn contentsPageEntryPkgId $
map
( ( \PackageVersionMeta {pkgId, pkgSpec = PackageVersionSpec {packageVersionTimestamp, packageVersionRevisions, packageVersionSource}} ->
SummaryPageEntry
{ summaryPageEntryPkgId = pkgId,
summaryPageEntryTimestamp = fromMaybe currentTime packageVersionTimestamp,
summaryPageEntryTimestampPosix = utcTimeToPOSIXSeconds (fromMaybe currentTime packageVersionTimestamp),
summaryPageEntrySource = packageVersionSource,
summaryPageEntryRevision = listToMaybe packageVersionRevisions
ContentsPageEntry
{ contentsPageEntryPkgId = pkgId,
contentsPageEntryTimestamp = fromMaybe currentTime packageVersionTimestamp,
contentsPageEntryTimestampPosix = utcTimeToPOSIXSeconds (fromMaybe currentTime packageVersionTimestamp),
contentsPageEntrySource = packageVersionSource,
contentsPageEntryRevision = listToMaybe packageVersionRevisions
}
)
. head
@ -66,9 +66,9 @@ makeSummaryPage currentTime outputDir packageVersions = do
$ groupBy ((==) `on` (pkgName . pkgId)) packageVersions
liftIO $ do
IO.createDirectoryIfMissing True outputDir
IO.createDirectoryIfMissing True (outputDir </> "summary")
TL.writeFile (outputDir </> "summary" </> "index.html") $
renderMustache summaryPageTemplate $
IO.createDirectoryIfMissing True (outputDir </> "contents")
TL.writeFile (outputDir </> "contents" </> "index.html") $
renderMustache contentsPageTemplate $
object ["packages" .= packages]
data TimelinePageEntry
@ -130,8 +130,8 @@ makePackageVersionPage inputDir outputDir pkgMeta@PackageVersionMeta {pkgId, pkg
"pkgDesc" .= jsonGenericPackageDescription pkgDesc
]
summaryPageTemplate :: Template
summaryPageTemplate = $(compileMustacheDir "summary" "templates")
contentsPageTemplate :: Template
contentsPageTemplate = $(compileMustacheDir "contents" "templates")
timelinePageTemplate :: Template
timelinePageTemplate = $(compileMustacheDir "timeline" "templates")

View File

@ -12,18 +12,18 @@
<link rel="stylesheet" href="https://cdn.datatables.net/v/bs5/dt-1.12.1/datatables.min.css" integrity="sha384-4+3RMUungd+Oh0juS2Jl3yQ7mPlVfsgr10NLSsqltLXIECi9ExY4d1cTtmf9aN8E" crossorigin="anonymous">
<script src="https://cdn.datatables.net/v/bs5/jq-3.6.0/dt-1.12.1/datatables.min.js" integrity="sha384-eU1uLDC5C4YCIouMauJZjbrnSmIiICWWAPdnZjRkNnuDxG+eJFN/EhW5GlKPAIVl" crossorigin="anonymous"></script>
<title>
Index summary
Index contents
</title>
</head>
<body>
<div class="container px-4 py-5">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item active" aria-current="page"><a href="/summary/">Summary</a></li>
<li class="breadcrumb-item active" aria-current="page"><a href="/contents/">Contents</a></li>
</ol>
</nav>
<h1 class="py-5">
Index summary
Index contents
</h1>
<p>
This page lists the latest version and revision of all packages in the index.
@ -40,22 +40,22 @@
<tbody>
{{#packages}}
<tr>
<td class="col-sm-2"><a href="/package/{{summaryPageEntryPkgId}}">{{summaryPageEntryPkgId}}</a></td>
<td class="col-sm-3" data-order="{{summaryPageEntryTimestampPosix}}">{{summaryPageEntryTimestamp}}</td>
<td class="col-sm-2"><a href="/package/{{contentsPageEntryPkgId}}">{{contentsPageEntryPkgId}}</a></td>
<td class="col-sm-3" data-order="{{contentsPageEntryTimestampPosix}}">{{contentsPageEntryTimestamp}}</td>
<td class="col-sm-6">
<dl class="row">
{{#summaryPageEntrySource}}
{{#contentsPageEntrySource}}
{{> packageVersionSource}}
{{/summaryPageEntrySource}}
{{/contentsPageEntrySource}}
</dl>
</td>
<td class="col-sm-3">
{{#summaryPageEntryRevision}}
{{#contentsPageEntryRevision}}
Last revision at {{revisionTimestamp}}
{{/summaryPageEntryRevision}}
{{^summaryPageEntryRevision}}
{{/contentsPageEntryRevision}}
{{^contentsPageEntryRevision}}
No revision
{{/summaryPageEntryRevision}}
{{/contentsPageEntryRevision}}
</td>
</tr>
{{/packages}}