From 589169f20590de400f53307821a3569a6907aef4 Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Thu, 6 Jul 2017 13:12:58 +0530 Subject: [PATCH 1/2] Update execution instruction --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a9683a..b5bb6ad 100644 --- a/README.md +++ b/README.md @@ -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 From 984cc11c9210b563acc6535c99485a3307eb3daa Mon Sep 17 00:00:00 2001 From: Sibi Prabakaran Date: Thu, 6 Jul 2017 13:13:28 +0530 Subject: [PATCH 2/2] 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. --- Handler/Snapshots.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Handler/Snapshots.hs b/Handler/Snapshots.hs index 1601b8c..effdc92 100644 --- a/Handler/Snapshots.hs +++ b/Handler/Snapshots.hs @@ -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" @@ -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