Initial older releases code

This commit is contained in:
Michael Snoyman 2014-12-15 18:13:48 +02:00
parent f56119fc18
commit 46c1b6e97f
3 changed files with 16 additions and 7 deletions

View File

@ -10,17 +10,22 @@ data WebsiteContent = WebsiteContent
{ wcHomepage :: !Html
, wcAuthors :: !Html
, wcInstall :: !Html
, wcOlderReleases :: !Html
}
loadWebsiteContent :: FilePath -> IO WebsiteContent
loadWebsiteContent dir = do
wcHomepage <- fmap (preEscapedToMarkup :: Text -> Html)
$ readFile $ dir </> "homepage.html"
wcAuthors <- fmap (preEscapedToMarkup :: Text -> Html)
$ readFile $ dir </> "authors.html"
wcInstall <- fmap (markdown def
wcHomepage <- readHtml "homepage.html"
wcAuthors <- readHtml "authors.html"
wcInstall <- readMarkdown "install.md"
wcOlderReleases <- readHtml "older-releases.html" `catchIO`
\_ -> readMarkdown "older-releases.md"
return WebsiteContent {..}
where
readHtml fp = fmap (preEscapedToMarkup :: Text -> Html)
$ readFile $ dir </> fp
readMarkdown fp = fmap (markdown def
{ msXssProtect = False
, msAddHeadingId = True
})
$ readFile $ dir </> "install.md"
return WebsiteContent {..}
$ readFile $ dir </> fp

View File

@ -22,6 +22,9 @@ getAuthorsR = contentHelper "Library Authors" wcAuthors
getInstallR :: Handler Html
getInstallR = contentHelper "Haskell Installation Instructions" wcInstall
getOlderReleasesR :: Handler Html
getOlderReleasesR = contentHelper "Older Releases" wcOlderReleases
contentHelper :: Html -> (WebsiteContent -> Html) -> Handler Html
contentHelper title accessor = do
homepage <- getYesod >>= fmap accessor . liftIO . grContent . websiteContent

View File

@ -49,3 +49,4 @@
/authors AuthorsR GET
/install InstallR GET
/older-releases OlderReleasesR GET