mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-11 19:58:28 +01:00
Download links for latest Stack (fixes commercialhaskell/stack#532)
This commit is contained in:
parent
1bf967903f
commit
bef289a8c3
@ -25,6 +25,7 @@ import Yesod.Default.Main
|
|||||||
import Yesod.GitRepo
|
import Yesod.GitRepo
|
||||||
import System.Process (rawSystem)
|
import System.Process (rawSystem)
|
||||||
import Stackage.Database.Cron (loadFromS3)
|
import Stackage.Database.Cron (loadFromS3)
|
||||||
|
import Control.AutoUpdate
|
||||||
|
|
||||||
import qualified Echo
|
import qualified Echo
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ import Handler.BuildPlan
|
|||||||
import Handler.Download
|
import Handler.Download
|
||||||
import Handler.OldLinks
|
import Handler.OldLinks
|
||||||
import Handler.Feed
|
import Handler.Feed
|
||||||
|
import Handler.DownloadStack
|
||||||
|
|
||||||
-- This line actually creates our YesodDispatch instance. It is the second half
|
-- This line actually creates our YesodDispatch instance. It is the second half
|
||||||
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
||||||
@ -128,6 +130,12 @@ makeFoundation useEcho conf = do
|
|||||||
handleAny print refreshDB
|
handleAny print refreshDB
|
||||||
handleAny print $ grRefresh websiteContent'
|
handleAny print $ grRefresh websiteContent'
|
||||||
|
|
||||||
|
latestStackMatcher' <- mkAutoUpdate defaultUpdateSettings
|
||||||
|
{ updateFreq = 1000 * 1000 * 60 * 30
|
||||||
|
-- ^ update every thirty minutes
|
||||||
|
, updateAction = getLatestMatcher manager
|
||||||
|
}
|
||||||
|
|
||||||
let logger = Yesod.Core.Types.Logger loggerSet' getter
|
let logger = Yesod.Core.Types.Logger loggerSet' getter
|
||||||
foundation = App
|
foundation = App
|
||||||
{ settings = conf
|
{ settings = conf
|
||||||
@ -137,6 +145,7 @@ makeFoundation useEcho conf = do
|
|||||||
, genIO = gen
|
, genIO = gen
|
||||||
, websiteContent = websiteContent'
|
, websiteContent = websiteContent'
|
||||||
, stackageDatabase = stackageDatabase'
|
, stackageDatabase = stackageDatabase'
|
||||||
|
, latestStackMatcher = latestStackMatcher'
|
||||||
}
|
}
|
||||||
|
|
||||||
return foundation
|
return foundation
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
module Data.WebsiteContent
|
module Data.WebsiteContent
|
||||||
( WebsiteContent (..)
|
( WebsiteContent (..)
|
||||||
|
, StackRelease (..)
|
||||||
, loadWebsiteContent
|
, loadWebsiteContent
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import ClassyPrelude.Yesod
|
import ClassyPrelude.Yesod
|
||||||
import Text.Markdown (markdown, msXssProtect, msAddHeadingId)
|
import Text.Markdown (markdown, msXssProtect, msAddHeadingId)
|
||||||
import Data.GhcLinks
|
import Data.GhcLinks
|
||||||
|
import Data.Aeson (withObject)
|
||||||
|
import Data.Yaml
|
||||||
|
|
||||||
data WebsiteContent = WebsiteContent
|
data WebsiteContent = WebsiteContent
|
||||||
{ wcHomepage :: !Html
|
{ wcHomepage :: !Html
|
||||||
@ -13,6 +16,7 @@ data WebsiteContent = WebsiteContent
|
|||||||
, wcInstall :: !Html
|
, wcInstall :: !Html
|
||||||
, wcOlderReleases :: !Html
|
, wcOlderReleases :: !Html
|
||||||
, wcGhcLinks :: !GhcLinks
|
, wcGhcLinks :: !GhcLinks
|
||||||
|
, wcStackReleases :: ![StackRelease]
|
||||||
}
|
}
|
||||||
|
|
||||||
loadWebsiteContent :: FilePath -> IO WebsiteContent
|
loadWebsiteContent :: FilePath -> IO WebsiteContent
|
||||||
@ -23,6 +27,8 @@ loadWebsiteContent dir = do
|
|||||||
wcOlderReleases <- readHtml "older-releases.html" `catchIO`
|
wcOlderReleases <- readHtml "older-releases.html" `catchIO`
|
||||||
\_ -> readMarkdown "older-releases.md"
|
\_ -> readMarkdown "older-releases.md"
|
||||||
wcGhcLinks <- readGhcLinks $ dir </> "stackage-cli"
|
wcGhcLinks <- readGhcLinks $ dir </> "stackage-cli"
|
||||||
|
wcStackReleases <- decodeFileEither (dir </> "stack" </> "releases.yaml")
|
||||||
|
>>= either throwIO return
|
||||||
return WebsiteContent {..}
|
return WebsiteContent {..}
|
||||||
where
|
where
|
||||||
readHtml fp = fmap (preEscapedToMarkup . decodeUtf8 :: ByteString -> Html)
|
readHtml fp = fmap (preEscapedToMarkup . decodeUtf8 :: ByteString -> Html)
|
||||||
@ -32,3 +38,12 @@ loadWebsiteContent dir = do
|
|||||||
, msAddHeadingId = True
|
, msAddHeadingId = True
|
||||||
})
|
})
|
||||||
$ readFile $ dir </> fp
|
$ readFile $ dir </> fp
|
||||||
|
|
||||||
|
data StackRelease = StackRelease
|
||||||
|
{ srName :: !Text
|
||||||
|
, srPattern :: !Text
|
||||||
|
}
|
||||||
|
instance FromJSON StackRelease where
|
||||||
|
parseJSON = withObject "StackRelease" $ \o -> StackRelease
|
||||||
|
<$> o .: "name"
|
||||||
|
<*> o .: "pattern"
|
||||||
|
|||||||
@ -28,6 +28,8 @@ data App = App
|
|||||||
, genIO :: MWC.GenIO
|
, genIO :: MWC.GenIO
|
||||||
, websiteContent :: GitRepo WebsiteContent
|
, websiteContent :: GitRepo WebsiteContent
|
||||||
, stackageDatabase :: IO StackageDatabase
|
, stackageDatabase :: IO StackageDatabase
|
||||||
|
, latestStackMatcher :: IO (Text -> Maybe Text)
|
||||||
|
-- ^ Give a pattern, get a URL
|
||||||
}
|
}
|
||||||
|
|
||||||
instance HasGenIO App where
|
instance HasGenIO App where
|
||||||
|
|||||||
@ -50,3 +50,6 @@
|
|||||||
!/feed/#LtsMajor LtsMajorFeedR GET
|
!/feed/#LtsMajor LtsMajorFeedR GET
|
||||||
/feed/lts LtsFeedR GET
|
/feed/lts LtsFeedR GET
|
||||||
/feed/nightly NightlyFeedR GET
|
/feed/nightly NightlyFeedR GET
|
||||||
|
|
||||||
|
/stack DownloadStackListR GET
|
||||||
|
/stack/#Text DownloadStackR GET
|
||||||
|
|||||||
@ -49,6 +49,7 @@ library
|
|||||||
Handler.Download
|
Handler.Download
|
||||||
Handler.OldLinks
|
Handler.OldLinks
|
||||||
Handler.Feed
|
Handler.Feed
|
||||||
|
Handler.DownloadStack
|
||||||
|
|
||||||
if flag(dev) || flag(library-only)
|
if flag(dev) || flag(library-only)
|
||||||
cpp-options: -DDEVELOPMENT
|
cpp-options: -DDEVELOPMENT
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user