Provide a link to snapshot's changes

This commit is contained in:
Konstantin Zudov 2015-10-10 10:58:15 +03:00
parent 160f2b02f9
commit 1ab01273bc
3 changed files with 10 additions and 2 deletions

View File

@ -11,13 +11,13 @@ import qualified Data.HashMap.Strict as HashMap
import Data.These import Data.These
import Data.Time (FormatTime) import Data.Time (FormatTime)
import Stackage.Database import Stackage.Database
import Stackage.Database.Types (sortNicely) import Stackage.Database.Types (sortNicely, previousSnapName)
import Stackage.Snapshot.Diff import Stackage.Snapshot.Diff
getStackageHomeR :: SnapName -> Handler Html getStackageHomeR :: SnapName -> Handler Html
getStackageHomeR name = do getStackageHomeR name = do
Entity sid snapshot <- lookupSnapshot name >>= maybe notFound return Entity sid snapshot <- lookupSnapshot name >>= maybe notFound return
snapNames <- map snapshotName . snd <$> getSnapshots 0 0
let hoogleForm = let hoogleForm =
let queryText = "" :: Text let queryText = "" :: Text
exact = False exact = False

View File

@ -1,6 +1,7 @@
module Stackage.Database.Types module Stackage.Database.Types
( SnapName (..) ( SnapName (..)
, sortNicely , sortNicely
, previousSnapName
) where ) where
import ClassyPrelude.Conduit import ClassyPrelude.Conduit
@ -26,6 +27,10 @@ sortNicely :: [SnapName] -> [SnapName]
sortNicely ns = reverse (sort lts) ++ reverse (sort nightly) sortNicely ns = reverse (sort lts) ++ reverse (sort nightly)
where (lts, nightly) = partition isLTS ns where (lts, nightly) = partition isLTS ns
previousSnapName :: [SnapName] -> SnapName -> SnapName
previousSnapName ns n =
fromMaybe n $ maximumMay $ filter (< n) $ filter ((isLTS n ==) . isLTS) ns
instance PersistField SnapName where instance PersistField SnapName where
toPersistValue = toPersistValue . toPathPiece toPersistValue = toPersistValue . toPathPiece
fromPersistValue v = do fromPersistValue v = do

View File

@ -5,6 +5,9 @@ $newline never
<p> <p>
Published on #{yearMonthDay (snapshotCreated snapshot)} Published on #{yearMonthDay (snapshotCreated snapshot)}
<span .separator> <span .separator>
<span>
<a href=@{StackageDiffR (previousSnapName snapNames name) name}>View changes
<span .separator>
<span> <span>
stack # stack #
<code>resolver: #{toPathPiece name} <code>resolver: #{toPathPiece name}