Add default footer; further cleanup

This commit is contained in:
James Eversole 2024-02-24 17:53:59 -06:00
parent c6bfc90897
commit fa54723934
6 changed files with 74 additions and 30 deletions

View File

@ -1,27 +1,52 @@
html{font-family:Monospace;background-color:#f1f6f0;color:#222323}
html{background-color:#f1f6f0;color:#222323}
a{text-decoration:none}
h2{text-transform:uppercase}
h3{margin:0.25em 0 0.25em 0}
p{margin:0.4em 0 0.4em 0}
a{color:#6D92AD}
body {
margin: 1% 2%;
margin: 0 auto;
font-family: Monospace;
font-size: 1.25em;
font-weight: 300;
text-align: left
}
body strong {
font-weight: 600;
}
body li {
list-style-type: "~> ";
}
footer {
position: absolute;
margin: 0;
bottom: 0;
width: 100%;
background-color: rgba(109, 146, 173, 0.3);
text-align: center;
padding: 1em 0 0.9em 0;
box-sizing: border-box;
}
footer p {
font-size: 0.75em;
margin: 0 2em;
color: #f1f6f0;
}
footer p a {
color: #f1f6f0;
}
.main {
margin: 1em auto;
max-width: 60%;
}
.navContainer {
margin: 1.5em 0;
width: 100%;
text-align: center;
}
@ -59,3 +84,10 @@ body li {
.postList {
font-size: 1.5em;
}
@media only screen and (max-width : 768px) {
.main {
margin: 1em auto;
max-width: 90%;
}
}

View File

@ -0,0 +1 @@
Copyright [Your Name](youremail@address.local)

View File

@ -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

View File

@ -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

View File

@ -15,10 +15,9 @@ baseDoc title bodyContent = doctypehtml_ $ do
link_ [rel_ "stylesheet", type_ "text/css", href_ "/style.css"]
body_ bodyContent
baseFeed :: Html ()
baseFeed = div_ [class_ "main"] $ do
h2_ "Oops, I haven't been implemented yet."
h3_ "Check back in a couple days!"
baseFooter :: Html () -> Html ()
baseFooter content = footer_ $ do
p_ $ content
baseHome :: Html () -> Html ()
baseHome content = div_ [class_ "main"] content
@ -31,8 +30,8 @@ baseNav = div_ [class_ "navContainer"] $ do
li_ $ a_ [href_ "/contact"] "Contact"
li_ $ a_ [href_ "/feed"] "Feed"
basePage :: String -> Html () -> Html()
basePage title body = baseDoc title $ baseNav <> body
basePage :: String -> Html () -> Html () -> Html ()
basePage title body footer = baseDoc title $ baseNav <> body <> baseFooter footer
basePost :: Html () -> Html ()
basePost content = div_ [class_ "main"] content

View File

@ -21,8 +21,13 @@ main = do
getMdFilePaths :: FilePath -> IO [FilePath]
getMdFilePaths fp = find isVisible fileFilter fp
where
isMdFile = extension ==? ".md"
isVisible = fileName /~? ".?*"
isHome = fileName /~? "home.md"
isContact = fileName /~? "contact.md"
fileFilter = isMdFile &&? isVisible &&? isHome &&? isContact
isMdFile = extension ==? ".md"
isVisible = fileName /~? ".?*"
isHome = fileName /~? "home.md"
isContact = fileName /~? "contact.md"
isFooter = fileName /~? "footer.md"
fileFilter = isMdFile
&&? isVisible
&&? isHome
&&? isContact
&&? isFooter