Skip to content

Commit

Permalink
Merge pull request #230 from psibi/snapshot-api
Browse files Browse the repository at this point in the history
Expose JSON Snapshot Api
  • Loading branch information
snoyberg committed Jul 6, 2017
2 parents 13663c2 + 984cc11 commit 185a263
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Handler/Snapshots.hs
Expand Up @@ -16,7 +16,7 @@ snapshotsPerPage = 50
-- The majority of the code you will write in Yesod lives in these handler
-- functions. You can spread them across multiple files if you are so
-- inclined, or create a single monolithic file.
getAllSnapshotsR :: Handler Html
getAllSnapshotsR :: Handler TypedContent
getAllSnapshotsR = track "Handler.Snapshots.getAllSnapshotsR" $ do
now' <- liftIO getCurrentTime
currentPageMay <- lookupGetParam "page"
Expand All @@ -31,10 +31,14 @@ getAllSnapshotsR = track "Handler.Snapshots.getAllSnapshotsR" $ do
let isFirstPage = currentPage == 1
isLastPage = currentPage * snapshotsPerPage >= totalCount

defaultLayout $ do
selectRep $ do
provideRep $ defaultLayout $ do
setTitle "Stackage Server"
let snapshotsNav = $(widgetFile "snapshots-nav")
$(widgetFile "all-snapshots")

provideRep $ return $ object ["snapshots" .= groups, "totalCount" .= totalCount]

where uncrapify now' snapshot =
( snapshotName snapshot
, snapshotTitle snapshot
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -15,4 +15,4 @@ generated by the `stackage-server-cron` executable in this repository.
You can run this site with `yesod devel`, e.g.:

stack --install-ghc install yesod-bin
yesod devel
stack exec -- yesod devel

0 comments on commit 185a263

Please sign in to comment.