Add default footer; further cleanup
This commit is contained in:
parent
c6bfc90897
commit
fa54723934
@ -1,27 +1,52 @@
|
|||||||
html{font-family:Monospace;background-color:#f1f6f0;color:#222323}
|
html{background-color:#f1f6f0;color:#222323}
|
||||||
a{text-decoration:none}
|
a{text-decoration:none}
|
||||||
h2{text-transform:uppercase}
|
|
||||||
h3{margin:0.25em 0 0.25em 0}
|
|
||||||
p{margin:0.4em 0 0.4em 0}
|
p{margin:0.4em 0 0.4em 0}
|
||||||
a{color:#6D92AD}
|
a{color:#6D92AD}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 1% 2%;
|
margin: 0 auto;
|
||||||
|
font-family: Monospace;
|
||||||
font-size: 1.25em;
|
font-size: 1.25em;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
text-align: left
|
text-align: left
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body strong {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
body li {
|
body li {
|
||||||
list-style-type: "~> ";
|
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 {
|
.main {
|
||||||
margin: 1em auto;
|
margin: 1em auto;
|
||||||
max-width: 60%;
|
max-width: 60%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navContainer {
|
.navContainer {
|
||||||
|
margin: 1.5em 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
@ -59,3 +84,10 @@ body li {
|
|||||||
.postList {
|
.postList {
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width : 768px) {
|
||||||
|
.main {
|
||||||
|
margin: 1em auto;
|
||||||
|
max-width: 90%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1
data/posts/footer.md.example
Normal file
1
data/posts/footer.md.example
Normal file
@ -0,0 +1 @@
|
|||||||
|
Copyright [Your Name](youremail@address.local)
|
@ -38,12 +38,14 @@ postProcessors = []
|
|||||||
automatically build an index of posts available to view. -}
|
automatically build an index of posts available to view. -}
|
||||||
routes :: [FilePath] -> [Middleware]
|
routes :: [FilePath] -> [Middleware]
|
||||||
routes postNames =
|
routes postNames =
|
||||||
[ get "/" Handle.index
|
[ get "/" Handle.index
|
||||||
, get "/posts" $ Handle.postsIndex postNames
|
, get "/posts" $ Handle.postsIndex postNames
|
||||||
] ++ (buildMdRoutes postNames) ++
|
] ++ handleDynamicPosts ++
|
||||||
[ get "/contact" Handle.contact
|
[ get "/contact" Handle.contact
|
||||||
, get "/feed" $ Handle.feed postNames
|
, 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
|
-- Takes a post's name extracted from the filepath and returns a valid route
|
||||||
mdFileToRoute :: FilePath -> Middleware
|
mdFileToRoute :: FilePath -> Middleware
|
||||||
|
@ -20,24 +20,28 @@ import Web.Twain
|
|||||||
index :: ResponderM a
|
index :: ResponderM a
|
||||||
index = do
|
index = do
|
||||||
-- Query the system environment for the BLOGTITLE environment variable
|
-- 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
|
-- 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
|
-- 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
|
-- Responds with processed Commonmark -> HTML for posts existing at app init
|
||||||
posts :: FilePath -> ResponderM a
|
posts :: FilePath -> ResponderM a
|
||||||
posts postName = do
|
posts postName = do
|
||||||
title <- liftIO Conf.appTitle
|
title <- liftIO Conf.appTitle
|
||||||
postMd <- liftIO $ mdFileToLucid ("./data/posts/" ++ postName ++ ".md")
|
footerMd <- liftIO $ mdFileToLucid "./data/posts/footer.md"
|
||||||
sendLucidFragment $ basePage title (basePost postMd)
|
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
|
-- Builds an index of all posts on filesystem as of application init
|
||||||
postsIndex :: [FilePath] -> ResponderM a
|
postsIndex :: [FilePath] -> ResponderM a
|
||||||
postsIndex postNames = do
|
postsIndex postNames = do
|
||||||
title <- liftIO Conf.appTitle
|
title <- liftIO Conf.appTitle
|
||||||
sendLucidFragment $ basePage title (postIndex postNames)
|
footerMd <- liftIO $ mdFileToLucid "./data/posts/footer.md"
|
||||||
|
sendLucidFragment $ basePage title (postIndex postNames) footerMd
|
||||||
|
|
||||||
-- Generates the XML feed at /feed
|
-- Generates the XML feed at /feed
|
||||||
feed :: [FilePath] -> ResponderM a
|
feed :: [FilePath] -> ResponderM a
|
||||||
@ -75,7 +79,8 @@ contact :: ResponderM a
|
|||||||
contact = do
|
contact = do
|
||||||
title <- liftIO Conf.appTitle
|
title <- liftIO Conf.appTitle
|
||||||
contactMd <- liftIO $ mdFileToLucid "./data/posts/contact.md"
|
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
|
-- Helper function for responding in ResponderM from Html
|
||||||
|
@ -15,10 +15,9 @@ baseDoc title bodyContent = doctypehtml_ $ do
|
|||||||
link_ [rel_ "stylesheet", type_ "text/css", href_ "/style.css"]
|
link_ [rel_ "stylesheet", type_ "text/css", href_ "/style.css"]
|
||||||
body_ bodyContent
|
body_ bodyContent
|
||||||
|
|
||||||
baseFeed :: Html ()
|
baseFooter :: Html () -> Html ()
|
||||||
baseFeed = div_ [class_ "main"] $ do
|
baseFooter content = footer_ $ do
|
||||||
h2_ "Oops, I haven't been implemented yet."
|
p_ $ content
|
||||||
h3_ "Check back in a couple days!"
|
|
||||||
|
|
||||||
baseHome :: Html () -> Html ()
|
baseHome :: Html () -> Html ()
|
||||||
baseHome content = div_ [class_ "main"] content
|
baseHome content = div_ [class_ "main"] content
|
||||||
@ -31,8 +30,8 @@ baseNav = div_ [class_ "navContainer"] $ do
|
|||||||
li_ $ a_ [href_ "/contact"] "Contact"
|
li_ $ a_ [href_ "/contact"] "Contact"
|
||||||
li_ $ a_ [href_ "/feed"] "Feed"
|
li_ $ a_ [href_ "/feed"] "Feed"
|
||||||
|
|
||||||
basePage :: String -> Html () -> Html()
|
basePage :: String -> Html () -> Html () -> Html ()
|
||||||
basePage title body = baseDoc title $ baseNav <> body
|
basePage title body footer = baseDoc title $ baseNav <> body <> baseFooter footer
|
||||||
|
|
||||||
basePost :: Html () -> Html ()
|
basePost :: Html () -> Html ()
|
||||||
basePost content = div_ [class_ "main"] content
|
basePost content = div_ [class_ "main"] content
|
||||||
|
15
src/Main.hs
15
src/Main.hs
@ -21,8 +21,13 @@ main = do
|
|||||||
getMdFilePaths :: FilePath -> IO [FilePath]
|
getMdFilePaths :: FilePath -> IO [FilePath]
|
||||||
getMdFilePaths fp = find isVisible fileFilter fp
|
getMdFilePaths fp = find isVisible fileFilter fp
|
||||||
where
|
where
|
||||||
isMdFile = extension ==? ".md"
|
isMdFile = extension ==? ".md"
|
||||||
isVisible = fileName /~? ".?*"
|
isVisible = fileName /~? ".?*"
|
||||||
isHome = fileName /~? "home.md"
|
isHome = fileName /~? "home.md"
|
||||||
isContact = fileName /~? "contact.md"
|
isContact = fileName /~? "contact.md"
|
||||||
fileFilter = isMdFile &&? isVisible &&? isHome &&? isContact
|
isFooter = fileName /~? "footer.md"
|
||||||
|
fileFilter = isMdFile
|
||||||
|
&&? isVisible
|
||||||
|
&&? isHome
|
||||||
|
&&? isContact
|
||||||
|
&&? isFooter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user