mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-11 19:58:28 +01:00
commit
da9c47b945
@ -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
|
||||
|
||||
63
templates/home.hamlet
Normal file
63
templates/home.hamlet
Normal file
@ -0,0 +1,63 @@
|
||||
<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>
|
||||
Related initiatives
|
||||
<p>
|
||||
Get started with using Stackage with our tool called Stack at our
|
||||
<a href="https://haskell-lang.org/get-started">
|
||||
Getting Started
|
||||
on
|
||||
<a href="https://haskell-lang.org/">
|
||||
haskell-lang.org
|
||||
<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
10
templates/home.lucius
Normal file
@ -0,0 +1,10 @@
|
||||
.navbar {
|
||||
display: none;
|
||||
}
|
||||
.logo {
|
||||
width: 300px;
|
||||
}
|
||||
.header {
|
||||
margin-bottom: 1em;
|
||||
margin-top: 2em;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user