Add default footer; further cleanup
This commit is contained in:
@ -38,12 +38,14 @@ postProcessors = []
|
||||
automatically build an index of posts available to view. -}
|
||||
routes :: [FilePath] -> [Middleware]
|
||||
routes postNames =
|
||||
[ get "/" Handle.index
|
||||
, get "/posts" $ Handle.postsIndex postNames
|
||||
] ++ (buildMdRoutes postNames) ++
|
||||
[ get "/contact" Handle.contact
|
||||
, get "/feed" $ Handle.feed postNames
|
||||
]
|
||||
[ get "/" Handle.index
|
||||
, get "/posts" $ Handle.postsIndex postNames
|
||||
] ++ handleDynamicPosts ++
|
||||
[ get "/contact" Handle.contact
|
||||
, get "/feed" $ Handle.feed postNames
|
||||
, get "/atom.xml" $ Handle.feed postNames
|
||||
] where
|
||||
handleDynamicPosts = (buildMdRoutes postNames)
|
||||
|
||||
-- Takes a post's name extracted from the filepath and returns a valid route
|
||||
mdFileToRoute :: FilePath -> Middleware
|
||||
|
@ -20,24 +20,28 @@ import Web.Twain
|
||||
index :: ResponderM a
|
||||
index = do
|
||||
-- Query the system environment for the BLOGTITLE environment variable
|
||||
title <- liftIO Conf.appTitle
|
||||
title <- liftIO Conf.appTitle
|
||||
-- Read a Commonmark Markdown file and process it to HTML
|
||||
homeMd <- liftIO $ mdFileToLucid "./data/posts/home.md"
|
||||
homeMd <- liftIO $ mdFileToLucid "./data/posts/home.md"
|
||||
-- Get the Footer content from Markdown
|
||||
footerMd <- liftIO $ mdFileToLucid "./data/posts/footer.md"
|
||||
-- Respond to request with fragments compositionally to create a home page
|
||||
sendLucidFragment $ basePage title (baseHome homeMd)
|
||||
sendLucidFragment $ basePage title (baseHome homeMd) footerMd
|
||||
|
||||
-- Responds with processed Commonmark -> HTML for posts existing at app init
|
||||
posts :: FilePath -> ResponderM a
|
||||
posts postName = do
|
||||
title <- liftIO Conf.appTitle
|
||||
postMd <- liftIO $ mdFileToLucid ("./data/posts/" ++ postName ++ ".md")
|
||||
sendLucidFragment $ basePage title (basePost postMd)
|
||||
title <- liftIO Conf.appTitle
|
||||
footerMd <- liftIO $ mdFileToLucid "./data/posts/footer.md"
|
||||
postMd <- liftIO $ mdFileToLucid ("./data/posts/" ++ postName ++ ".md")
|
||||
sendLucidFragment $ basePage title (basePost postMd) footerMd
|
||||
|
||||
-- Builds an index of all posts on filesystem as of application init
|
||||
postsIndex :: [FilePath] -> ResponderM a
|
||||
postsIndex postNames = do
|
||||
title <- liftIO Conf.appTitle
|
||||
sendLucidFragment $ basePage title (postIndex postNames)
|
||||
title <- liftIO Conf.appTitle
|
||||
footerMd <- liftIO $ mdFileToLucid "./data/posts/footer.md"
|
||||
sendLucidFragment $ basePage title (postIndex postNames) footerMd
|
||||
|
||||
-- Generates the XML feed at /feed
|
||||
feed :: [FilePath] -> ResponderM a
|
||||
@ -75,7 +79,8 @@ contact :: ResponderM a
|
||||
contact = do
|
||||
title <- liftIO Conf.appTitle
|
||||
contactMd <- liftIO $ mdFileToLucid "./data/posts/contact.md"
|
||||
sendLucidFragment $ basePage title (baseContact contactMd)
|
||||
footerMd <- liftIO $ mdFileToLucid "./data/posts/footer.md"
|
||||
sendLucidFragment $ basePage title (baseContact contactMd) footerMd
|
||||
|
||||
|
||||
-- Helper function for responding in ResponderM from Html
|
||||
|
Reference in New Issue
Block a user