mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-12 04:08:29 +01:00
Initial older releases code
This commit is contained in:
parent
f56119fc18
commit
46c1b6e97f
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -49,3 +49,4 @@
|
||||
|
||||
/authors AuthorsR GET
|
||||
/install InstallR GET
|
||||
/older-releases OlderReleasesR GET
|
||||
|
||||
Loading…
Reference in New Issue
Block a user