Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
cdupont committed Jul 30, 2021
1 parent 55da091 commit 071ed48
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 61 deletions.
19 changes: 4 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
---
title: Home
position: Researcher
univ: University of Trento, Italy
univ-link: http://www.unitn.it
employer: Create-Net, Italy
employer-link: http://www.create-net.org/
---

<img class="img-me" src="/images/CDUPONT2.jpg" alt="Me">

<h1 class="big-name">Corentin Dupont</h1>

<div class="info-box">
<div>$position$</div>
<div>$employer$ (<a href="$employer-link$">link</a>)</div>
<div>$univ$ (<a href="$univ-link$">link</a>)</div>
<div>Email: corentin.dupont@create-net.org<span class="cdupont-email"></span></div>
<div>Researcher, Founder</div>
<div>Waziup (<a href="http://www.waziup.org">link</a>)</div>
<div>Email: corentin.dupont@waziup.org<span class="cdupont-email"></span></div>
</div>

<div class="break"></div>
Expand Down Expand Up @@ -53,7 +42,7 @@ <h2 id="software">Software</h2>
<li><a href="http://github.com/dc4cities/easc/">EASC</a>: An application controler allowing to use more renewable energies in data centres</li>
</ul>

<h2>News</h2>
<h2>Latest news</h2>

$partial("templates/news-list.html")$

Expand Down
5 changes: 0 additions & 5 deletions projects/nomyx.md

This file was deleted.

73 changes: 32 additions & 41 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,40 @@ main = hakyll $ do
-- Compile templates
match ("templates/*.html" .||. "blog/templates/*.html") $ compile templateCompiler
-- Compile partial markdown (will be inserted in HTML pages)
match ("blog/*.md" .||. "blurbs/*.md" .||. "news/*.md") $ compile pandocCompiler
-- Compile full pages markdown
match ("pages/*.md" .||. "projects/*.md") $ do
match ("news/*.md") $ compile pandocCompiler
-- Compile markdown pages
match ("pages/*.md") $ do
route $ setExtension ".html"
compile $ bibtexCompiler >>= mainTemplate
compile $ bibtexCompiler >>=
loadAndApplyTemplate "templates/main.html" (baseContext)
>>= relativizeUrls
compileCSS
-- compile HTML pages
match ("index.html" .||. "pages/news.html") $ do
-- compile index page
match ("index.html") $ do
route idRoute
compile $ getResourceBody >>= mainTemplate
compile $ do
posts <- fmap (take 3) . recentFirst =<< loadAll "news/*"
let indexContext =
listField "news" baseContext (return posts) <>
baseContext
getResourceBody
>>= applyAsTemplate indexContext
>>= loadAndApplyTemplate "templates/main.html" indexContext
>>= relativizeUrls

-- Post list
create ["pages/news.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "news/*"
let ctx = constField "title" "News" <>
listField "news" baseContext (return posts) <>
baseContext
makeItem ""
>>= loadAndApplyTemplate "templates/news.html" ctx
>>= loadAndApplyTemplate "templates/main.html" ctx
>>= relativizeUrls

-- Côpy over static files
match ("images/*" .||. "js/*" .||. "docs/*.pdf" .||. "bibliography/files/*" .||. "**/img/*") $ do
route idRoute
Expand All @@ -50,38 +74,6 @@ baseContext =
<> constField "jquery" "//ajax.googleapis.com/ajax/libs/jquery/2.0.3"
<> defaultContext


-- * Utility functions

-- | Lookup an item based on its file path.
lookupItem :: FilePath -> [Item a] -> Maybe (Item a)
lookupItem path = find ((fromFilePath path ==) . itemIdentifier)

-- | The complete context.
getContext :: Compiler (Context String)
getContext = do
fileContext <- getBlurbContext
let newsContext = listField "news" baseContext (loadAll "news/*" >>= recentFirst)
return (fileContext <> newsContext <> baseContext)

-- | Makes the contents of the blurbs directory available as template fields.
getBlurbContext :: Compiler (Context String)
getBlurbContext = do
items <- loadAll ("blurbs/*" .||. "blog/*.md")
let fields = map getField items
return $ foldr (<>) baseContext fields
where getField (Item id body) = constField (takeBaseName (toFilePath id)) body

-- | Apply the main template to a page of a given name.
mainTemplate :: Item String -> Compiler (Item String)
mainTemplate item = do
path <- fmap toFilePath getUnderlying
context <- fmap (onPage path <>) getContext
applyAsTemplate context item
>>= loadAndApplyTemplate "templates/main.html" context
>>= relativizeUrls
where onPage path = constField ("on-" ++ (takeBaseName path)) ""

bibtexCompiler :: Compiler (Item String)
bibtexCompiler = do
bib <- load "bibliography/central-bibliography.bib"
Expand Down Expand Up @@ -134,12 +126,11 @@ buildPerso = do
route idRoute
compile $ do
posts <- fmap (take 10) . recentFirst =<< loadAll posts
context <- getContext
let indexContext =
listField "posts" (postCtx tags cats) (return posts) <>
field "tags" (\_ -> renderTagList tags) <>
field "cats" (\_ -> renderCatsList cats) <>
context <>
baseContext <>
defaultContext
getResourceBody
>>= applyAsTemplate indexContext
Expand Down

0 comments on commit 071ed48

Please sign in to comment.