Restyle snapshots page

This commit is contained in:
Chris Done 2014-11-13 15:52:45 +01:00
parent 8f0e0e7aa3
commit a6bb737cc8
4 changed files with 57 additions and 20 deletions

View File

@ -2,8 +2,11 @@
module Handler.Snapshots where module Handler.Snapshots where
import Import import Data.Time.Clock
import qualified Database.Esqueleto as E import qualified Database.Esqueleto as E
import Formatting
import Formatting.Time
import Import
-- This is a handler function for the GET request method on the HomeR -- This is a handler function for the GET request method on the HomeR
-- resource pattern. All of your resource patterns are defined in -- resource pattern. All of your resource patterns are defined in
@ -14,16 +17,18 @@ import qualified Database.Esqueleto as E
-- inclined, or create a single monolithic file. -- inclined, or create a single monolithic file.
getAllSnapshotsR :: Handler Html getAllSnapshotsR :: Handler Html
getAllSnapshotsR = do getAllSnapshotsR = do
stackages <- runDB $ E.select $ E.from $ \(stackage `E.InnerJoin` user) -> do now <- liftIO getCurrentTime
E.on (stackage E.^. StackageUser E.==. user E.^. UserId) groups <- fmap (groupBy (on (==) (\(_,_,uploaded,_,_) -> uploaded)) . map (uncrapify now)) $
E.orderBy [E.desc $ stackage E.^. StackageUploaded] runDB $ E.select $ E.from $ \(stackage `E.InnerJoin` user) -> do
return E.on (stackage E.^. StackageUser E.==. user E.^. UserId)
( stackage E.^. StackageIdent E.orderBy [E.desc $ stackage E.^. StackageUploaded]
, stackage E.^. StackageTitle return
, stackage E.^. StackageUploaded ( stackage E.^. StackageIdent
, user E.^. UserDisplay , stackage E.^. StackageTitle
, user E.^. UserHandle , stackage E.^. StackageUploaded
) , user E.^. UserDisplay
, user E.^. UserHandle
)
defaultLayout $ do defaultLayout $ do
setTitle "Stackage Server" setTitle "Stackage Server"
$(combineStylesheets 'StaticR $(combineStylesheets 'StaticR
@ -31,3 +36,6 @@ getAllSnapshotsR = do
, css_bootstrap_responsive_css , css_bootstrap_responsive_css
]) ])
$(widgetFile "all-snapshots") $(widgetFile "all-snapshots")
where uncrapify now c =
let (E.Value ident, E.Value title, E.Value uploaded, E.Value display, E.Value handle) = c
in (ident,title,format (diff True) (diffUTCTime uploaded now),display,handle)

View File

@ -78,7 +78,7 @@ library
BangPatterns BangPatterns
build-depends: build-depends:
base >= 4 base >= 4
, aeson >= 0.6 , aeson >= 0.6
, aws , aws
, base16-bytestring , base16-bytestring
@ -128,6 +128,7 @@ library
, yesod-form >= 1.3.14 , yesod-form >= 1.3.14
, yesod-static >= 1.2 , yesod-static >= 1.2
, zlib , zlib
, unordered-containers
-- Avoid https://github.com/haskell/cabal/issues/1202 -- Avoid https://github.com/haskell/cabal/issues/1202
, Cabal >= 1.18 , Cabal >= 1.18
, lifted-base , lifted-base

View File

@ -1,8 +1,14 @@
<div .container> <div .container>
<h1>All Snapshots <h1>Snapshots
<ul .snapshots> $forall stackages <- groups
$forall (E.Value ident, E.Value title, E.Value uploaded, E.Value display, E.Value handle) <- stackages $forall (_, _, uploaded, _, _) <- take 1 stackages
<li> <h3>
<a href=@{StackageHomeR ident}> #{uploaded}
#{title} <ul .snapshots>
<i>by #{display} (#{handle}) on #{show uploaded} $forall (ident, title, uploaded, display, handle) <- stackages
<li>
<strong>
<a href=@{StackageHomeR ident}>
#{title}
<p>
#{display} (#{handle})

View File

@ -1 +1,23 @@
.snapshots > li { line-height: 1.5em; } .snapshots > li {
list-style-type: none;
margin: 0 0 1.5em 0;
}
.snapshots > li > p {
margin-top: 0.5em;
padding: 0;
}
.snapshots {
margin: 1em 0 0 0;
padding: 0;
}
h3 {
border-bottom: 1px solid #aaa;
padding-bottom: 0.25em;
}
h1 {
margin-bottom: 0.5em;
}