mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-22 08:51:55 +01:00
Initial older releases code
This commit is contained in:
parent
f56119fc18
commit
46c1b6e97f
@ -10,17 +10,22 @@ data WebsiteContent = WebsiteContent
|
|||||||
{ wcHomepage :: !Html
|
{ wcHomepage :: !Html
|
||||||
, wcAuthors :: !Html
|
, wcAuthors :: !Html
|
||||||
, wcInstall :: !Html
|
, wcInstall :: !Html
|
||||||
|
, wcOlderReleases :: !Html
|
||||||
}
|
}
|
||||||
|
|
||||||
loadWebsiteContent :: FilePath -> IO WebsiteContent
|
loadWebsiteContent :: FilePath -> IO WebsiteContent
|
||||||
loadWebsiteContent dir = do
|
loadWebsiteContent dir = do
|
||||||
wcHomepage <- fmap (preEscapedToMarkup :: Text -> Html)
|
wcHomepage <- readHtml "homepage.html"
|
||||||
$ readFile $ dir </> "homepage.html"
|
wcAuthors <- readHtml "authors.html"
|
||||||
wcAuthors <- fmap (preEscapedToMarkup :: Text -> Html)
|
wcInstall <- readMarkdown "install.md"
|
||||||
$ readFile $ dir </> "authors.html"
|
wcOlderReleases <- readHtml "older-releases.html" `catchIO`
|
||||||
wcInstall <- fmap (markdown def
|
\_ -> readMarkdown "older-releases.md"
|
||||||
|
return WebsiteContent {..}
|
||||||
|
where
|
||||||
|
readHtml fp = fmap (preEscapedToMarkup :: Text -> Html)
|
||||||
|
$ readFile $ dir </> fp
|
||||||
|
readMarkdown fp = fmap (markdown def
|
||||||
{ msXssProtect = False
|
{ msXssProtect = False
|
||||||
, msAddHeadingId = True
|
, msAddHeadingId = True
|
||||||
})
|
})
|
||||||
$ readFile $ dir </> "install.md"
|
$ readFile $ dir </> fp
|
||||||
return WebsiteContent {..}
|
|
||||||
|
|||||||
@ -22,6 +22,9 @@ getAuthorsR = contentHelper "Library Authors" wcAuthors
|
|||||||
getInstallR :: Handler Html
|
getInstallR :: Handler Html
|
||||||
getInstallR = contentHelper "Haskell Installation Instructions" wcInstall
|
getInstallR = contentHelper "Haskell Installation Instructions" wcInstall
|
||||||
|
|
||||||
|
getOlderReleasesR :: Handler Html
|
||||||
|
getOlderReleasesR = contentHelper "Older Releases" wcOlderReleases
|
||||||
|
|
||||||
contentHelper :: Html -> (WebsiteContent -> Html) -> Handler Html
|
contentHelper :: Html -> (WebsiteContent -> Html) -> Handler Html
|
||||||
contentHelper title accessor = do
|
contentHelper title accessor = do
|
||||||
homepage <- getYesod >>= fmap accessor . liftIO . grContent . websiteContent
|
homepage <- getYesod >>= fmap accessor . liftIO . grContent . websiteContent
|
||||||
|
|||||||
@ -49,3 +49,4 @@
|
|||||||
|
|
||||||
/authors AuthorsR GET
|
/authors AuthorsR GET
|
||||||
/install InstallR GET
|
/install InstallR GET
|
||||||
|
/older-releases OlderReleasesR GET
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user