Update homepage to show Snapshots

This commit is contained in:
Chris Done 2016-10-27 13:35:21 +01:00
parent 89f8650151
commit bc45faa645
3 changed files with 102 additions and 2 deletions

View File

@ -1,4 +1,5 @@
{-# LANGUAGE TupleSections, OverloadedStrings #-}
module Handler.Home
( getHomeR
, getAuthorsR
@ -6,7 +7,11 @@ module Handler.Home
, getOlderReleasesR
) where
import Import hiding ((=.),on,(||.),(==.))
import Data.Time.Clock
import Formatting
import Formatting.Time
import Import
import Stackage.Database
import Yesod.GitRepo (grContent)
-- This is a handler function for the G request method on the HomeR
@ -17,7 +22,31 @@ import Yesod.GitRepo (grContent)
-- functions. You can spread them across multiple files if you are so
-- inclined, or create a single monolithic file.
getHomeR :: Handler Html
getHomeR = contentHelper "Stackage Server" wcHomepage
getHomeR = track "Handler.Snapshots.getAllSnapshotsR" $ do
now' <- liftIO getCurrentTime
currentPageMay <- lookupGetParam "page"
let currentPage :: Int
currentPage = fromMaybe 1 (currentPageMay >>= readMay)
(map entityVal -> snapshots) <-
getSnapshots Nothing snapshotsPerPage
((fromIntegral currentPage - 1) * snapshotsPerPage)
let groups = groupUp now' snapshots
defaultLayout $ do
setTitle "Stackage Server"
$(widgetFile "home")
where uncrapify now' snapshot =
( snapshotName snapshot
, snapshotTitle snapshot
, format (diff True)
$ diffUTCTime
(UTCTime (snapshotCreated snapshot) 0)
now'
)
groupUp now' = groupBy (on (==) (\(_,_,uploaded) -> uploaded))
. map (uncrapify now')
snapshotsPerPage :: Int
snapshotsPerPage = 8
getAuthorsR :: Handler Html
getAuthorsR = contentHelper "Library Authors" wcAuthors

61
templates/home.hamlet Normal file
View File

@ -0,0 +1,61 @@
<div .container>
<div .row .header>
<div .span6>
<img src=@{StaticR img_logo_png} .logo>
<div .span6>
<form class="hoogle" action="/lts/hoogle">
<div class="input-append hoogle-q">
<input class="search span3" type="search" autofocus="" name="q" value="" placeholder="E.g. map, a -> a, etc.">
<button class="btn" type="submit">
Search
<span class="brws-pkgs">
or
<a href="/lts">
browse packages
<label class="checkbox exact-lookup" for="exact" title="Only find identifiers matching your search term precisely">
<input type="checkbox" name="exact" id="exact">
Exact lookup
<div .row>
<div .span12>
<p>
Stackage is a stable source of Haskell packages. We guarantee that packages build consistently and pass tests before generating nightly and Long Term Support (LTS) releases.
<div .row>
<div .span6>
<h3>
Latest releases
<p>
You browse the latest long term support (what are Long
Term Support releases?) release, or the latest
bleeding-edge nightly release.
<p>
<a href="https://www.stackage.org/lts">
LTS Haskell
<p>
<a href="https://www.stackage.org/nightly">
Stackage Nightly
<h3>
Commercial Haskell
<p>
Stackage is part of an initiative by the commercial Haskell group. More information on the architecture of Stackage can be found here.
<p>
FP Complete offer custom installations for businesses who want to build their development platform upon Stackage. If you're considering this for your business and want to find out more, please email us at: sales@fpcomplete.com
<div .span6>
<h3>Snapshots
$forall stackages <- groups
$forall (_, _, uploaded) <- take 1 stackages
<h5>
#{uploaded}
<ul .snapshots>
$forall (ident, title, _uploaded) <- stackages
<li>
<strong>
<a href=@{SnapshotR ident StackageHomeR}>
#{title}
<p>
<a href=@{AllSnapshotsR}>
Snapshots archive

10
templates/home.lucius Normal file
View File

@ -0,0 +1,10 @@
.navbar {
display: none;
}
.logo {
width: 300px;
}
.header {
margin-bottom: 1em;
margin-top: 2em;
}