diff --git a/src/Stackage/Snapshot/Diff.hs b/src/Stackage/Snapshot/Diff.hs index 5900e05..f3335be 100644 --- a/src/Stackage/Snapshot/Diff.hs +++ b/src/Stackage/Snapshot/Diff.hs @@ -4,10 +4,12 @@ module Stackage.Snapshot.Diff , snapshotDiff , SnapshotDiff() , toDiffList + , toVersionedDiffList , VersionChange(..) , WithSnapshotNames(..) ) where +import qualified Data.Text as T(commonPrefixes) import Data.Align import Data.Aeson import qualified Data.HashMap.Strict as HashMap @@ -36,6 +38,20 @@ instance ToJSON (WithSnapshotNames SnapshotDiff) where toDiffList :: SnapshotDiff -> [(PackageName, VersionChange)] toDiffList = sortOn (toCaseFold . unPackageName . fst) . HashMap.toList . unSnapshotDiff +versionPrefix :: VersionChange -> Maybe (Text,Text,Text) +versionPrefix vc = case unVersionChange vc of + These (Version a) (Version b) -> T.commonPrefixes a b + _ -> Nothing + +versionedDiffList :: [(PackageName, VersionChange)] -> [(PackageName, VersionChange, Maybe (Text,Text,Text))] +versionedDiffList = map withPrefixedVersion + where + withPrefixedVersion (packageName, versionChange) = (packageName, versionChange, versionPrefix versionChange) + + +toVersionedDiffList :: SnapshotDiff -> [(PackageName, VersionChange, Maybe (Text, Text, Text))] +toVersionedDiffList = versionedDiffList . toDiffList + -- | Versions of a package as it occurs in the listings provided to `snapshotDiff`. -- -- Would be represented with `These v1 v2` if the package is present in both listings, diff --git a/templates/package-list.lucius b/templates/package-list.lucius index 54a842d..556bcb9 100644 --- a/templates/package-list.lucius +++ b/templates/package-list.lucius @@ -2,4 +2,13 @@ .table th, .table td { padding-left: 0; } + + .table span.version-removed { + background-color: red; + text-decoration: line-through; + } + + .table span.version-added { + background-color: green; + } } diff --git a/templates/stackage-diff.hamlet b/templates/stackage-diff.hamlet index 4b414d3..4cae29d 100644 --- a/templates/stackage-diff.hamlet +++ b/templates/stackage-diff.hamlet @@ -33,7 +33,7 @@ $else