diff --git a/hptool/src/ReleaseFiles.hs b/hptool/src/ReleaseFiles.hs new file mode 100644 index 0000000..a03586b --- /dev/null +++ b/hptool/src/ReleaseFiles.hs @@ -0,0 +1,103 @@ +module ReleaseFiles + ( + Version, Date, OSType, Arch, Url, Hash, FileInfo, ReleaseFiles + , releaseFiles + ) + where + +type Version = String + +type Date = (Int,Int) +jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec :: Int -> Date +[ jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec ] = map (,) [1..12] + +type OSType = String +type Arch = String +type Url = String +type Hash = String +type FileInfo = (OSType, Maybe Arch, Url, Maybe Hash) +type ReleaseFiles = (Version, Date, [FileInfo]) + +i386, x86_64 :: Arch +i386 = "32bit" +x86_64 = "64bit" + +mac, win :: Arch -> Url -> Maybe Hash -> FileInfo +mac a u mh = ("Mac OS X", Just a, u, mh) +win a u mh = ("Windows", Just a, u, mh) + +src :: Url -> Maybe Hash -> FileInfo +src u mh = ("Source", Nothing, u, mh) + +nohash :: Maybe Hash +nohash = Nothing + +hash :: String -> Maybe Hash +hash = Just + + +releaseFiles :: [ReleaseFiles] +releaseFiles = + [ ("2012.4.0.0", nov 2012, + [ mac i386 "download/2012.4.0.0/Haskell%20Platform%202012.4.0.0%2032bit.pkg" nohash + , mac x86_64 "download/2012.4.0.0/Haskell%20Platform%202012.4.0.0%2064bit.pkg" nohash + , win i386 "download/2012.4.0.0/HaskellPlatform-2012.4.0.0-setup.exe" nohash + , src "download/2012.4.0.0/haskell-platform-2012.4.0.0.tar.gz" nohash + ]) + + , ("2012.2.0.0", jun 2012, + [ mac i386 "download/2012.2.0.0/Haskell%20Platform%202012.2.0.0%2032bit.pkg" nohash + , mac x86_64 "download/2012.2.0.0/Haskell%20Platform%202012.2.0.0%2064bit.pkg" nohash + , win i386 "download/2012.2.0.0/HaskellPlatform-2012.2.0.0-setup.exe" nohash + , src "download/2012.2.0.0/haskell-platform-2012.2.0.0.tar.gz" nohash + ]) + + , ("2011.4.0.0", apr 2011, + [ mac i386 "download/2011.4.0.0/Haskell%20Platform%202011.4.0.0%2032bit.pkg" nohash + , mac x86_64 "download/2011.4.0.0/Haskell%20Platform%202011.4.0.0%2064bit.pkg" nohash + , win i386 "download/2011.4.0.0/HaskellPlatform-2011.4.0.0-setup.exe" nohash + , src "download/2011.4.0.0/haskell-platform-2011.4.0.0.tar.gz" nohash + ]) + + , ("2011.2.0.1", apr 2011, + [ mac i386 "download/2011.2.0.1/Haskell%20Platform%202011.2.0.1-i386.pkg" nohash + , mac x86_64 "download/2011.2.0.1/Haskell%20Platform%202011.2.0.1-x86_64.pkg" nohash + , win i386 "download/2011.2.0.1/HaskellPlatform-2011.2.0.1-setup.exe" nohash + , src "download/2011.2.0.1/haskell-platform-2011.2.0.1.tar.gz" nohash + ]) + + , ("2011.2.0.0", mar 2011, + [ mac i386 "download/2011.2.0.0/Haskell%20Platform%202011.2.0.0-i386.pkg" nohash + , mac x86_64 "download/2011.2.0.0/Haskell%20Platform%202011.2.0.0-x86_64.pkg" nohash + , win i386 "download/2011.2.0.0/HaskellPlatform-2011.2.0.0-setup.exe" nohash + , src "download/2011.2.0.0/haskell-platform-2011.2.0.0.tar.gz" nohash + ]) + + , ("2010.2.0.0", jul 2010, + [ mac i386 "download/2010.2.0.0/haskell-platform-2010.2.0.0.i386.dmg" nohash + , win i386 "download/2010.2.0.0/HaskellPlatform-2010.2.0.0-setup.exe" nohash + , src "download/2010.2.0.0/haskell-platform-2010.2.0.0.tar.gz" nohash + ]) + + , ("2010.1.0.0", mar 2010, + [ mac i386 "http://hackage.haskell.org/platform/2010.1.0.0/haskell-platform-2010.1.0.1-i386.dmg" nohash + , win i386 "http://hackage.haskell.org/platform/2010.1.0.0/HaskellPlatform-2010.1.0.0-setup.exe" nohash + , src "http://hackage.haskell.org/platform/2010.1.0.0/haskell-platform-2010.1.0.0.tar.gz" nohash + ]) + + , ("2009.2.0.2", jul 2009, + [ mac i386 "http://hackage.haskell.org/platform/2009.2.0.2/haskell-platform-2009.2.0.2-i386.dmg" nohash + , win i386 "http://hackage.haskell.org/platform/2009.2.0.2/HaskellPlatform-2009.2.0.2-setup.exe" nohash + , src "http://hackage.haskell.org/platform/2009.2.0.2/haskell-platform-2009.2.0.2.tar.gz" nohash + ]) + + , ("2009.2.0.1", jun 2009, + [ win i386 "http://hackage.haskell.org/platform/2009.2.0.1/HaskellPlatform-2009.2.0.1-setup.exe" nohash + , src "http://hackage.haskell.org/platform/2009.2.0.1/haskell-platform-2009.2.0.1.tar.gz" nohash + ]) + + , ("2009.2.0", may 2009, + [ win i386 "http://hackage.haskell.org/platform/2009.2.0/HaskellPlatform-2009.2.0-setup.exe" nohash + , src "http://hackage.haskell.org/platform/2009.2.0/haskell-platform-2009.2.0.tar.gz" nohash + ]) + ] diff --git a/hptool/src/Website.hs b/hptool/src/Website.hs index 89dcb43..1a4d98d 100644 --- a/hptool/src/Website.hs +++ b/hptool/src/Website.hs @@ -2,15 +2,65 @@ module Website where +import Data.Function (on) +import Data.List (groupBy) import Development.Shake +import Text.Hastache +import Text.Hastache.Context import Dirs import Paths +import ReleaseFiles import Templates websiteRules :: FilePath -> Rules () websiteRules templateSite = do websiteDir */> \dst -> do bcCtx <- buildConfigContext - let ctx = bcCtx `ctxAppend` errorCtx + let rlsCtx = releasesCtx releaseFiles + ctx = ctxConcat [rlsCtx, bcCtx, errorCtx] copyExpandedDir ctx templateSite dst + + +fileCtx :: (Monad m) => FileInfo -> MuContext m +fileCtx (os, mArch, url, mHash) = mkStrContext ctx + where + ctx "osName" = MuVariable os + ctx "osNameAndArch" = MuVariable $ os ++ maybe "" (\a -> ", " ++ a) mArch + ctx "url" = MuVariable url + ctx "mHash" = maybe (MuBool False) MuVariable mHash + ctx _ = MuNothing + +releaseCtx :: (Monad m) => ReleaseFiles -> MuContext m +releaseCtx (ver, (month, year), files) = mkStrContext ctx + where + ctx "version" = MuVariable ver + ctx "year" = MuVariable $ show year + ctx "month" = MuVariable $ monthName month + ctx "files" = MuList $ map fileCtx files + ctx _ = MuNothing + +releasesCtx :: (Monad m) => [ReleaseFiles] -> MuContext m +releasesCtx allRs = mkStrContext ctx + where + ctx "years" = MuList $ map (mkStrContext . yearCtx) years + ctx _ = MuNothing + + yearCtx [] _ = MuBool False + yearCtx (r0:_) "year" = MuVariable $ show $ releaseYear r0 + yearCtx rs "releases" = MuList $ map releaseCtx rs + yearCtx _ _ = MuNothing + + years = groupBy ((==) `on` releaseYear) allRs + +releaseYear :: ReleaseFiles -> Int +releaseYear (_ver, (_month, year), _files) = year + +monthName :: Int -> String +monthName i = maybe (show i) id $ lookup i monthNames + where + monthNames = zip [1..] $ + words "January Feburary March April May June \ + \July August September October November December" + + diff --git a/website/prior.html.mu b/website/prior.html.mu index fea1a6b..2b5fe25 100644 --- a/website/prior.html.mu +++ b/website/prior.html.mu @@ -14,21 +14,19 @@ +

Prior releases of Haskell Platform:

-

2012

-

2012.4.0.0, November 2012 ⟹ Mac OS X, 32bit - Mac OS X, 64bit - Windows - Source

-

2012.2.0.0, June 2012 ⟹ Mac OS X, 32bit - Mac OS X, 64bit - Windows - Source

-

2011

-

2011.4.0.0, April 2011 ⟹ Mac OS X, 32bit - Mac OS X, 64bit - Windows - Source

-

2011.2.0.1, April 2011 ⟹ Mac OS X, 32bit - Mac OS X, 64bit - Windows - Source

-

2011.2.0.0 - March 2011 ⟹ Mac OS X, 32bit - Mac OS X, 64bit - Windows - Source

-

2010

-

2010.2.0.0 - July 2010 ⟹ Mac OS X, 32bit - Windows - Source

-

2010.1.0.0 - March 2010 ⟹ Mac OS X, 32bit - Windows - Source

-

2009

-

2009.2.0.2 - July 2009 ⟹ Mac OS X, 32bit - Windows - Source

-

2009.2.0.1 - June 2009 ⟹ Windows - Source

-

2009.2.0 - May 2009 ⟹ Windows - Source

+{{#years}} +

{{year}}

+ {{#releases}} +

{{version}}, {{month}} {{year}} ⟹ + {{#files}} + {{osNameAndArch}} - + {{/files}} +

+ {{/releases}} +{{/years}} + {{> footer}}