diff --git a/Data/WebsiteContent.hs b/Data/WebsiteContent.hs index 2f38958..8777e50 100644 --- a/Data/WebsiteContent.hs +++ b/Data/WebsiteContent.hs @@ -5,13 +5,20 @@ module Data.WebsiteContent import ClassyPrelude.Yesod import Text.Blaze.Html (preEscapedToMarkup) +import Text.Markdown (markdown, msXssProtect) data WebsiteContent = WebsiteContent { wcHomepage :: !Html + , wcAuthors :: !Html + , wcInstall :: !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 { msXssProtect = False }) + $ readFile $ dir "install.md" return WebsiteContent {..} diff --git a/Handler/Home.hs b/Handler/Home.hs index 35344e6..2d18637 100644 --- a/Handler/Home.hs +++ b/Handler/Home.hs @@ -14,10 +14,19 @@ import Yesod.GitRepo (grContent) -- functions. You can spread them across multiple files if you are so -- inclined, or create a single monolithic file. 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" restLatest <- linkFor "unstable-ghc78-inclusive" - homepage <- getYesod >>= fmap wcHomepage . liftIO . grContent . websiteContent + homepage <- getYesod >>= fmap accessor . liftIO . grContent . websiteContent defaultLayout $ do setTitle "Stackage Server" $(combineStylesheets 'StaticR diff --git a/config/routes b/config/routes index 180c88c..fa9507b 100644 --- a/config/routes +++ b/config/routes @@ -44,3 +44,6 @@ /lts/*Texts LtsR GET /nightly/*Texts NightlyR GET + +/authors AuthorsR GET +/install InstallR GET