Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
cdupont committed Aug 1, 2021
1 parent 071ed48 commit 3a9f738
Show file tree
Hide file tree
Showing 15 changed files with 202 additions and 261 deletions.
63 changes: 0 additions & 63 deletions blog/templates/mainperso.html

This file was deleted.

2 changes: 0 additions & 2 deletions blog/templates/posts.html

This file was deleted.

6 changes: 4 additions & 2 deletions css/footer.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
background-color: @footBG;
color: @footTextColor;
font-size: @footFontSize;
position: relative;
overflow: auto;
padding-right: @hMargin;
padding-left: @hMargin;
}

.foot-block {
Expand Down Expand Up @@ -46,8 +50,6 @@
}

.foot-madeby {
position: absolute;
bottom: 0;
text-align: right;
right: @hMargin;
padding-top: @footPad;
Expand Down
23 changes: 16 additions & 7 deletions css/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,19 @@ html, body {
}

#content {
margin-top: 0px;
margin-right: 200px;
margin-bottom: 0px;
margin-left: 200px;
text-align:justify;
padding:0px 36px 0px 36px;
padding-bottom: @footHeight + @vMargin;
}

#header {
margin-bottom: @vMargin;
}

#footer {
// height: @footHeight;
width: 100%;
position: absolute;
bottom: 0;
}

.break {
clear: both;
}
Expand Down Expand Up @@ -97,3 +96,13 @@ pre, code {
pre {
margin-left: 2em;
}

div#navigation {
background: #FFFFFF repeat-x left bottom;
text-align: center;
width:14%;
margin: 0px 0px 0px 0px;
position:absolute;
top:100px;
left:0px;
}
2 changes: 2 additions & 0 deletions css/navbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#header {
background-color: @navBG;
padding-right: @hMargin;
padding-left: @hMargin;
}

ul.nav-list {
Expand Down
120 changes: 50 additions & 70 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import System.FilePath

main = hakyll $ do
-- Compile bibliography
match "bibliography/*.bib" $ compile biblioCompiler
match "pages/*.csl" $ compile cslCompiler
match "bibliography/*.bib" $ compile biblioCompiler
match "pages/*.csl" $ compile cslCompiler
-- Compile templates
match ("templates/*.html" .||. "blog/templates/*.html") $ compile templateCompiler
match "templates/*.html" $ compile templateCompiler
-- Compile partial markdown (will be inserted in HTML pages)
match ("news/*.md") $ compile pandocCompiler
-- Compile markdown pages
Expand Down Expand Up @@ -62,11 +62,55 @@ main = hakyll $ do
>>= loadAndApplyTemplate "templates/main.html" ctx
>>= relativizeUrls

let posts = ("blog/posts/*/*.md" .||. "blog/posts/*/*.lhs" .||. "blog/posts/*/*.Rmd")
let drafts = "blog/drafts/*"
-- Build tags
tags <- buildTags posts (fromCapture "tags/*.html")
cats <- buildCategories posts (fromCapture "tags/*.html")

-- build post lists
--tagsRules tags $ postList tags cats
--tagsRules cats $ postList tags cats
create ["blog/posts.html"] $ postList tags cats "All posts" posts

-- Render each post
match (posts .||. drafts) $ do
route $ setExtension ".html"
compile $ do
myPandocCompiler
>>= saveSnapshot "content"
>>= return . fmap demoteHeaders
>>= loadAndApplyTemplate "templates/post.html" (postCtx tags cats)
>>= loadAndApplyTemplate "templates/mainperso.html" (postCtx tags cats)
>>= relativizeUrls

-- build index page
match "blog/index.html" $ do
route idRoute
compile $ do
posts <- fmap (take 10) . recentFirst =<< loadAll posts
let indexContext =
listField "posts" (postCtx tags cats) (return posts) <>
field "tags" (\_ -> renderTagList tags) <>
field "cats" (\_ -> renderCatsList cats) <>
baseContext <>
defaultContext
getResourceBody
>>= applyAsTemplate indexContext
>>= loadAndApplyTemplate "templates/mainperso.html" indexContext
>>= relativizeUrls

-- Render some static pages
match "blog/pages/*.md" $ do
route $ setExtension ".html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/mainperso.html" (postCtx tags cats)
>>= relativizeUrls

-- Côpy over static files
match ("images/*" .||. "js/*" .||. "docs/*.pdf" .||. "bibliography/files/*" .||. "**/img/*") $ do
route idRoute
compile copyFileCompiler
buildPerso

baseContext :: Context String
baseContext =
Expand Down Expand Up @@ -97,54 +141,6 @@ compileCSS = do
route idRoute
compile compressCssCompiler

buildPerso :: Rules ()
buildPerso = do
let posts = ("blog/posts/*/*.md" .||. "blog/posts/*/*.lhs" .||. "blog/posts/*/*.Rmd")
let drafts = "blog/drafts/*"
-- Build tags
tags <- buildTags posts (fromCapture "tags/*.html")
cats <- buildCategories posts (fromCapture "tags/*.html")

-- build post lists
tagsRules tags $ postList tags cats
tagsRules cats $ postList tags cats
create ["blog/posts.html"] $ postList tags cats "All posts" posts

-- Render each and every post
match (posts .||. drafts) $ do
route $ setExtension ".html"
compile $ do
myPandocCompiler
>>= saveSnapshot "content"
>>= return . fmap demoteHeaders
>>= loadAndApplyTemplate "blog/templates/post.html" (postCtx tags cats)
>>= loadAndApplyTemplate "blog/templates/mainperso.html" (postCtx tags cats)
>>= relativizeUrls

-- build index page
match "blog/index.html" $ do
route idRoute
compile $ do
posts <- fmap (take 10) . recentFirst =<< loadAll posts
let indexContext =
listField "posts" (postCtx tags cats) (return posts) <>
field "tags" (\_ -> renderTagList tags) <>
field "cats" (\_ -> renderCatsList cats) <>
baseContext <>
defaultContext
getResourceBody
>>= applyAsTemplate indexContext
>>= loadAndApplyTemplate "blog/templates/mainperso.html" indexContext
>>= relativizeUrls

-- Render some static pages
match "blog/pages/*.md" $ do
route $ setExtension ".html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "blog/templates/mainperso.html" (postCtx tags cats)
>>= relativizeUrls


postList :: Tags -> Tags -> String -> Pattern -> Rules ()
postList tags cats title pattern = do
route idRoute
Expand All @@ -154,8 +150,8 @@ postList tags cats title pattern = do
listField "posts" (postCtx tags cats) (return posts) <>
postCtx tags cats
makeItem ""
>>= loadAndApplyTemplate "blog/templates/posts.html" ctx
>>= loadAndApplyTemplate "blog/templates/mainperso.html" ctx
>>= loadAndApplyTemplate "templates/posts.html" ctx
>>= loadAndApplyTemplate "templates/mainperso.html" ctx
>>= relativizeUrls


Expand All @@ -178,22 +174,6 @@ postCtx tags cats = mconcat
, defaultContext
]

--------------------------------------------------------------------------------
feedCtx :: Context String
feedCtx = mconcat
[ bodyField "description"
, defaultContext
]

--------------------------------------------------------------------------------
feedConfiguration :: String -> FeedConfiguration
feedConfiguration title = FeedConfiguration
{ feedTitle = "Corentin Dupont - " ++ title
, feedDescription = "Personal blog of Corentin Dupont"
, feedAuthorName = "Corentin Dupont"
, feedAuthorEmail = "corentin.dupont@gmail.com"
, feedRoot = "http://corentindupont.info"
}

myPandocCompiler :: Compiler (Item String)
myPandocCompiler = pandocCompilerWithTransformM readerOptions writerOptions $ diagramsTransformer >=> rTransformer
Expand Down
Loading

0 comments on commit 3a9f738

Please sign in to comment.