mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-11 19:58:28 +01:00
Add sketch of 'stackage' executable download pages
This commit is contained in:
parent
1b4d149801
commit
80cb890dad
@ -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
28
Handler/Download.hs
Normal 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")
|
||||
38
Types.hs
38
Types.hs
@ -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
|
||||
|
||||
@ -57,3 +57,6 @@
|
||||
/upload2 UploadV2R PUT
|
||||
/build-version BuildVersionR GET
|
||||
/package-counts PackageCountsR GET
|
||||
|
||||
/download DownloadR GET
|
||||
/download/#SupportedArch/#StackageExecutable DownloadStackageExecutableR GET
|
||||
|
||||
@ -54,6 +54,7 @@ library
|
||||
Handler.PackageCounts
|
||||
Handler.Sitemap
|
||||
Handler.BuildPlan
|
||||
Handler.Download
|
||||
|
||||
if flag(dev) || flag(library-only)
|
||||
cpp-options: -DDEVELOPMENT
|
||||
|
||||
5
templates/download.hamlet
Normal file
5
templates/download.hamlet
Normal file
@ -0,0 +1,5 @@
|
||||
$forall (arch, exe) <- downloadCandidates
|
||||
<ul .downloads>
|
||||
<li>
|
||||
<a href=@{DownloadStackageExecutableR arch exe}>
|
||||
#{toPathPiece arch}: #{toPathPiece exe}
|
||||
3
templates/downloadExe.hamlet
Normal file
3
templates/downloadExe.hamlet
Normal file
@ -0,0 +1,3 @@
|
||||
TODO: replace this with the file download.
|
||||
|
||||
#{toPathPiece arch}: #{toPathPiece exe}
|
||||
Loading…
Reference in New Issue
Block a user