mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-02-05 15:50:26 +01:00
Provide JSON API interface for snapshot
The motivation for this patch is to implement a option like `ls-remote` in stack (which is quite similar to the one present in nvm). The ability to see the latest snapshots via the commandline tool itself would be a nice addition IMO.
This commit is contained in:
parent
589169f205
commit
984cc11c92
@ -16,7 +16,7 @@ snapshotsPerPage = 50
|
|||||||
-- The majority of the code you will write in Yesod lives in these handler
|
-- 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
|
-- functions. You can spread them across multiple files if you are so
|
||||||
-- inclined, or create a single monolithic file.
|
-- inclined, or create a single monolithic file.
|
||||||
getAllSnapshotsR :: Handler Html
|
getAllSnapshotsR :: Handler TypedContent
|
||||||
getAllSnapshotsR = track "Handler.Snapshots.getAllSnapshotsR" $ do
|
getAllSnapshotsR = track "Handler.Snapshots.getAllSnapshotsR" $ do
|
||||||
now' <- liftIO getCurrentTime
|
now' <- liftIO getCurrentTime
|
||||||
currentPageMay <- lookupGetParam "page"
|
currentPageMay <- lookupGetParam "page"
|
||||||
@ -31,10 +31,14 @@ getAllSnapshotsR = track "Handler.Snapshots.getAllSnapshotsR" $ do
|
|||||||
let isFirstPage = currentPage == 1
|
let isFirstPage = currentPage == 1
|
||||||
isLastPage = currentPage * snapshotsPerPage >= totalCount
|
isLastPage = currentPage * snapshotsPerPage >= totalCount
|
||||||
|
|
||||||
defaultLayout $ do
|
selectRep $ do
|
||||||
|
provideRep $ defaultLayout $ do
|
||||||
setTitle "Stackage Server"
|
setTitle "Stackage Server"
|
||||||
let snapshotsNav = $(widgetFile "snapshots-nav")
|
let snapshotsNav = $(widgetFile "snapshots-nav")
|
||||||
$(widgetFile "all-snapshots")
|
$(widgetFile "all-snapshots")
|
||||||
|
|
||||||
|
provideRep $ return $ object ["snapshots" .= groups, "totalCount" .= totalCount]
|
||||||
|
|
||||||
where uncrapify now' snapshot =
|
where uncrapify now' snapshot =
|
||||||
( snapshotName snapshot
|
( snapshotName snapshot
|
||||||
, snapshotTitle snapshot
|
, snapshotTitle snapshot
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user