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
import Import
import Data.Time.Clock
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
-- 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.
getAllSnapshotsR :: Handler Html
getAllSnapshotsR = do
stackages <- runDB $ E.select $ E.from $ \(stackage `E.InnerJoin` user) -> do
E.on (stackage E.^. StackageUser E.==. user E.^. UserId)
E.orderBy [E.desc $ stackage E.^. StackageUploaded]
return
( stackage E.^. StackageIdent
, stackage E.^. StackageTitle
, stackage E.^. StackageUploaded
, user E.^. UserDisplay
, user E.^. UserHandle
)
now <- liftIO getCurrentTime
groups <- fmap (groupBy (on (==) (\(_,_,uploaded,_,_) -> uploaded)) . map (uncrapify now)) $
runDB $ E.select $ E.from $ \(stackage `E.InnerJoin` user) -> do
E.on (stackage E.^. StackageUser E.==. user E.^. UserId)
E.orderBy [E.desc $ stackage E.^. StackageUploaded]
return
( stackage E.^. StackageIdent
, stackage E.^. StackageTitle
, stackage E.^. StackageUploaded
, user E.^. UserDisplay
, user E.^. UserHandle
)
defaultLayout $ do
setTitle "Stackage Server"
$(combineStylesheets 'StaticR
@ -31,3 +36,6 @@ getAllSnapshotsR = do
, css_bootstrap_responsive_css
])
$(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
build-depends:
base >= 4
base >= 4
, aeson >= 0.6
, aws
, base16-bytestring
@ -128,6 +128,7 @@ library
, yesod-form >= 1.3.14
, yesod-static >= 1.2
, zlib
, unordered-containers
-- Avoid https://github.com/haskell/cabal/issues/1202
, Cabal >= 1.18
, lifted-base

View File

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