Add sketch of 'stackage' executable download pages

This commit is contained in:
Dan Burton 2015-04-15 16:35:19 -07:00
parent 1b4d149801
commit 80cb890dad
7 changed files with 79 additions and 0 deletions

View File

@ -74,6 +74,7 @@ import Handler.BuildVersion
import Handler.PackageCounts
import Handler.Sitemap
import Handler.BuildPlan
import Handler.Download
-- 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

28
Handler/Download.hs Normal file
View File

@ -0,0 +1,28 @@
module Handler.Download
( getDownloadR
, getDownloadStackageExecutableR
) where
import Import
executableFor :: SupportedArch -> StackageExecutable
executableFor Win32 = StackageWindowsExecutable
executableFor Win64 = StackageWindowsExecutable
executableFor _ = StackageUnixExecutable
downloadCandidates :: [(SupportedArch, StackageExecutable)]
downloadCandidates =
map (\arch -> (arch, executableFor arch))
[minBound .. maxBound]
getDownloadR :: Handler Html
getDownloadR = defaultLayout $ do
$(widgetFile "download")
getDownloadStackageExecutableR
:: SupportedArch -> StackageExecutable -> Handler Html
getDownloadStackageExecutableR arch exe = do
-- TODO: send exeutable file instead
when (executableFor arch /= exe) notFound
defaultLayout $ do
$(widgetFile "downloadExe")

View File

@ -102,3 +102,41 @@ instance HasHackageRoot HackageRoot where
data UnpackStatus = USReady
| USBusy
| USFailed !Text
data StackageExecutable
= StackageWindowsExecutable
| StackageUnixExecutable
deriving (Show, Read, Eq)
instance PathPiece StackageExecutable where
toPathPiece StackageWindowsExecutable = "stackage.exe"
toPathPiece StackageUnixExecutable = "stackage"
fromPathPiece "stackage" = Just StackageUnixExecutable
fromPathPiece "stackage.exe" = Just StackageWindowsExecutable
fromPathPiece _ = Nothing
data SupportedArch
= Win32
| Win64
| Linux32
| Linux64
| Mac32
| Mac64
deriving (Enum, Bounded, Show, Read, Eq)
instance PathPiece SupportedArch where
toPathPiece Win32 = "win32"
toPathPiece Win64 = "win64"
toPathPiece Linux32 = "linux32"
toPathPiece Linux64 = "linux64"
toPathPiece Mac32 = "mac32"
toPathPiece Mac64 = "mac64"
fromPathPiece "win32" = Just Win32
fromPathPiece "win64" = Just Win64
fromPathPiece "linux32" = Just Linux32
fromPathPiece "linux64" = Just Linux64
fromPathPiece "mac32" = Just Mac32
fromPathPiece "mac64" = Just Mac64
fromPathPiece _ = Nothing

View File

@ -57,3 +57,6 @@
/upload2 UploadV2R PUT
/build-version BuildVersionR GET
/package-counts PackageCountsR GET
/download DownloadR GET
/download/#SupportedArch/#StackageExecutable DownloadStackageExecutableR GET

View File

@ -54,6 +54,7 @@ library
Handler.PackageCounts
Handler.Sitemap
Handler.BuildPlan
Handler.Download
if flag(dev) || flag(library-only)
cpp-options: -DDEVELOPMENT

View File

@ -0,0 +1,5 @@
$forall (arch, exe) <- downloadCandidates
<ul .downloads>
<li>
<a href=@{DownloadStackageExecutableR arch exe}>
#{toPathPiece arch}: #{toPathPiece exe}

View File

@ -0,0 +1,3 @@
TODO: replace this with the file download.
#{toPathPiece arch}: #{toPathPiece exe}