authors and install pages

This commit is contained in:
Michael Snoyman 2014-12-11 12:21:30 +02:00
parent cab4e08fcc
commit 6b25df3e59
3 changed files with 21 additions and 2 deletions

View File

@ -5,13 +5,20 @@ module Data.WebsiteContent
import ClassyPrelude.Yesod import ClassyPrelude.Yesod
import Text.Blaze.Html (preEscapedToMarkup) import Text.Blaze.Html (preEscapedToMarkup)
import Text.Markdown (markdown, msXssProtect)
data WebsiteContent = WebsiteContent data WebsiteContent = WebsiteContent
{ wcHomepage :: !Html { wcHomepage :: !Html
, wcAuthors :: !Html
, wcInstall :: !Html
} }
loadWebsiteContent :: FilePath -> IO WebsiteContent loadWebsiteContent :: FilePath -> IO WebsiteContent
loadWebsiteContent dir = do loadWebsiteContent dir = do
wcHomepage <- fmap (preEscapedToMarkup :: Text -> Html) wcHomepage <- fmap (preEscapedToMarkup :: Text -> Html)
$ readFile $ dir </> "homepage.html" $ readFile $ dir </> "homepage.html"
wcAuthors <- fmap (preEscapedToMarkup :: Text -> Html)
$ readFile $ dir </> "authors.html"
wcInstall <- fmap (markdown def { msXssProtect = False })
$ readFile $ dir </> "install.md"
return WebsiteContent {..} return WebsiteContent {..}

View File

@ -14,10 +14,19 @@ import Yesod.GitRepo (grContent)
-- functions. You can spread them across multiple files if you are so -- functions. You can spread them across multiple files if you are so
-- inclined, or create a single monolithic file. -- inclined, or create a single monolithic file.
getHomeR :: Handler Html getHomeR :: Handler Html
getHomeR = do getHomeR = contentHelper wcHomepage
getAuthorsR :: Handler Html
getAuthorsR = contentHelper wcAuthors
getInstallR :: Handler Html
getInstallR = contentHelper wcInstall
contentHelper :: (WebsiteContent -> Html) -> Handler Html
contentHelper accessor = do
windowsLatest <- linkFor "unstable-ghc78hp-inclusive" windowsLatest <- linkFor "unstable-ghc78hp-inclusive"
restLatest <- linkFor "unstable-ghc78-inclusive" restLatest <- linkFor "unstable-ghc78-inclusive"
homepage <- getYesod >>= fmap wcHomepage . liftIO . grContent . websiteContent homepage <- getYesod >>= fmap accessor . liftIO . grContent . websiteContent
defaultLayout $ do defaultLayout $ do
setTitle "Stackage Server" setTitle "Stackage Server"
$(combineStylesheets 'StaticR $(combineStylesheets 'StaticR

View File

@ -44,3 +44,6 @@
/lts/*Texts LtsR GET /lts/*Texts LtsR GET
/nightly/*Texts NightlyR GET /nightly/*Texts NightlyR GET
/authors AuthorsR GET
/install InstallR GET