Skip to content
Snippets Groups Projects
Unverified Commit 6ad2fd13 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

will need to make headers better.

parent 519a7ec4
No related branches found
No related tags found
No related merge requests found
Pipeline #12539 passed
dist
cabal-dev
*.o
*.hi
......
......@@ -12,16 +12,195 @@
module Main where
{-# LANGUAGE OverloadedStrings #-}
import Data.Monoid (mappend)
import Hakyll
import Text.Pandoc
import qualified Data.Map as M
import Text.Pandoc as Pandoc
import qualified Data.Text as T
import qualified System.Process as Process
import System.FilePath (replaceExtension, takeDirectory)
import Data.Maybe (isJust)
import Text.Pandoc.Highlighting
import Hakyll.Images ( loadImage
, scaleImageCompiler
)
--------------------------------------------------------------------------------
-- | Entry point
main :: IO ()
main = hakyllWith cfg $ do
-- Resize images
match "img/thumbnails/**.png" $ do
route idRoute
compile $ loadImage
>>= scaleImageCompiler 140 140
match "img/heads/**.png" $ do
route idRoute
compile $ loadImage
>>= scaleImageCompiler 256 256
match "img/large/**.png" $ do
route idRoute
compile $ loadImage
>>= scaleImageCompiler 900 262
-- copying stuff
match ("fonts/*"
.||. "img/*"
.||. "img/*/**.png"
.||. "css/*"
.||. "js/*"
.||. "reveal.js/dist/**"
.||. "reveal.js/plugin/**"
.||. "cours/math_tech_info/figs/*"
.||. "cours/math_tech_info/cours.pdf"
.||. "cours/isc_physics/cours.pdf"
.||. "cours/isc_physics/figs/*") $ do
route idRoute
compile $ copyFileCompiler
-- Phys app posts
match "cours/isc_physics/*.markdown" $ do
route $ setExtension "html"
compile $ pandocCrossrefNumberingCompiler
>>= loadAndApplyTemplate "templates/class.html" postCtx
>>= relativizeUrls
-- Phys app post list
create ["phys_app.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll ("cours/isc_physics/*.markdown" .&&. hasNoVersion)
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" (courseCtx posts "Physique appliquée" "cours/isc_physics/cours.pdf")
>>= relativizeUrls
-- Math Tech Info posts
match "cours/math_tech_info/*.markdown" $ do
route $ setExtension "html"
compile $ pandocCrossrefNumberingCompiler
>>= loadAndApplyTemplate "templates/class.html" postCtx
>>= relativizeUrls
-- Math Tech Info posts in PDF. Producing the .pdf
-- PDF produced but putting it into a list not...
-- match "cours/math_tech_info/1_Rappel.markdown" $ version "pdf" $ do
-- route $ setExtension "pdf"
-- compile $ do getResourceBody
-- >>= readPandoc
-- >>= writeXeTex
-- >>= loadAndApplyTemplate "templates/default.latex" defaultContext
-- >>= xelatex
-- Math Tech Info post list
create ["math_tech_info.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll ("cours/math_tech_info/*.markdown" .&&. hasNoVersion)
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" (courseCtx posts "Mathématiques en technologie de l'information" "cours/math_tech_info/cours.pdf")
>>= relativizeUrls
-- Phys app posts
match "cours/prog_seq/base_1.md" $ do
route $ setExtension "html"
compile $ pandocRevealCompiler
>>= loadAndApplyTemplate "templates/reveal.html" postCtx
>>= relativizeUrls
-- Phys app post list
create ["prog_seq.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll ("cours/prog_seq/base_1.md" .&&. hasNoVersion)
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" (courseCtx posts "Programmation séquentielle" "cours/isc_physics/cours.pdf")
>>= relativizeUrls
-- Index
match "index.html" $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/*"
getResourceBody
>>= applyAsTemplate (indexCtx posts)
>>= relativizeUrls
-- Read templates
match "templates/*" $ compile templateCompiler
-- Used to compile to PDF
-- where
-- writeXeTex :: Item Pandoc.Pandoc -> Compiler (Item String)
-- writeXeTex = traverse $ \pandoc ->
-- case Pandoc.runPure (Pandoc.writeLaTeX Pandoc.def pandoc) of
-- Left err -> fail $ show err
-- Right x -> return (T.unpack x)
-- pages :: Rules ()
-- pages = do
-- match "pages/*" $ do
-- route $ setExtension "html"
-- compile $ getResourceBody
-- >>= loadAndApplyTemplate "templates/page.html" postCtx
-- >>= relativizeUrls
-- research :: Rules ()
-- research = do
-- create ["research_projects.html"] $ do
-- route idRoute
-- compile $ do
-- posts <- recentFirst =<< loadAll "posts/research/*"
-- makeItem ""
-- >>= loadAndApplyTemplate "templates/archive.html" (researchCtx posts)
-- >>= relativizeUrls
-- bachelor :: Rules ()
-- bachelor = do
-- create ["bachelor_projects.html"] $ do
-- route idRoute
-- compile $ do
-- posts <- recentFirst =<< loadAll "posts/bachelor/*"
-- makeItem ""
-- >>= loadAndApplyTemplate "templates/archive.html" (bachelorCtx posts)
-- >>= relativizeUrls
-- cours_conc :: Rules ()
-- cours_conc = do
-- match "cours/*" $ do
-- route $ setExtension "html"
-- -- compile $ myPandocCompiler
-- compile $ pandocCrossrefNumberingCompiler
-- >>= loadAndApplyTemplate "templates/post.html" postCtx
-- >>= relativizeUrls
-- conc :: Rules ()
-- conc = do
-- create ["prog_conc.html"] $ do
-- route idRoute
-- compile $ do
-- posts <- recentFirst =<< loadAll "cours/*"
-- makeItem ""
-- >>= loadAndApplyTemplate "templates/archive.html" (courseCtx posts "Programmation concurrente")
-- >>= relativizeUrls
-- index :: Rules ()
-- index = do
-- match "index.html" $ do
-- route idRoute
-- compile $ do
-- posts <- recentFirst =<< loadAll "posts/*"
-- getResourceBody
-- >>= applyAsTemplate (indexCtx posts)
-- >>= relativizeUrls
-- templates :: Rules ()
-- templates = match "templates/*" $ compile templateCompiler
--------------------------------------------------------------------
-- Contexts
--------------------------------------------------------------------
......@@ -40,9 +219,10 @@ mathCtx = field "mathjax" $ \item -> do
then "<script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML\"></script>"
else ""
courseCtx posts title =
courseCtx posts title pdfurl =
listField "posts" postCtx (return posts)
`mappend` constField "title" title
`mappend` constField "pdfurl" pdfurl
`mappend` defaultContext
researchCtx posts =
......@@ -60,150 +240,6 @@ indexCtx posts =
`mappend` constField "title" "Home"
`mappend` defaultContext
--------------------------------------------------------------------
-- Rules
--------------------------------------------------------------------
static :: Rules ()
static = do
match ("fonts/*"
.||. "img/*"
.||. "img/*/**.png"
.||. "css/*"
.||. "js/*"
.||. "cours/math_tech_info/figs/*"
.||. "cours/isc_physics/figs/*") $ do
route idRoute
compile $ copyFileCompiler
resizeThumbnails :: Rules ()
resizeThumbnails = do
match "img/thumbnails/**.png" $ do
route idRoute
compile $ loadImage
>>= scaleImageCompiler 140 140
resizeHeads :: Rules ()
resizeHeads = do
match "img/heads/**.png" $ do
route idRoute
compile $ loadImage
>>= scaleImageCompiler 256 256
resizeLarge :: Rules ()
resizeLarge = do
match "img/large/**.png" $ do
route idRoute
compile $ loadImage
>>= scaleImageCompiler 900 500
pages :: Rules ()
pages = do
match "pages/*" $ do
route $ setExtension "html"
compile $ getResourceBody
>>= loadAndApplyTemplate "templates/page.html" postCtx
>>= relativizeUrls
posts :: Rules ()
posts = do
match "posts/*" $ do
route $ setExtension "html"
-- compile $ myPandocCompiler
compile $ bibtexCompiler
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= relativizeUrls
research :: Rules ()
research = do
create ["research_projects.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/research/*"
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" (researchCtx posts)
>>= relativizeUrls
bachelor :: Rules ()
bachelor = do
create ["bachelor_projects.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/bachelor/*"
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" (bachelorCtx posts)
>>= relativizeUrls
cours_conc :: Rules ()
cours_conc = do
match "cours/*" $ do
route $ setExtension "html"
-- compile $ myPandocCompiler
compile $ bibtexCompiler
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= relativizeUrls
conc :: Rules ()
conc = do
create ["prog_conc.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "cours/*"
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" (courseCtx posts "Programmation concurrente")
>>= relativizeUrls
cours_mti :: Rules ()
cours_mti = do
match "cours/math_tech_info/*.markdown" $ do
route $ setExtension "html"
-- compile $ myPandocCompiler
compile $ bibtexCompiler
>>= loadAndApplyTemplate "templates/class.html" postCtx
>>= relativizeUrls
mti :: Rules ()
mti = do
create ["math_tech_info.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "cours/math_tech_info/*"
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" (courseCtx posts "Mathématiques en technologie de l'information")
>>= relativizeUrls
cours_phys_app :: Rules ()
cours_phys_app = do
match "cours/isc_physics/*.markdown" $ do
route $ setExtension "html"
-- compile $ myPandocCompiler
compile $ bibtexCompiler
>>= loadAndApplyTemplate "templates/class.html" postCtx
>>= relativizeUrls
phys_app :: Rules ()
phys_app = do
create ["phys_app.html"] $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "cours/isc_physics/*"
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" (courseCtx posts "Physique appliquée")
>>= relativizeUrls
index :: Rules ()
index = do
match "index.html" $ do
route idRoute
compile $ do
posts <- recentFirst =<< loadAll "posts/*"
getResourceBody
>>= applyAsTemplate (indexCtx posts)
>>= relativizeUrls
templates :: Rules ()
templates = match "templates/*" $ compile templateCompiler
--------------------------------------------------------------------
-- Configuration
--------------------------------------------------------------------
......@@ -246,8 +282,8 @@ defaultPandocExtensions =
in foldr enableExtension defaultExtensions extensions
bibtexCompiler :: Compiler (Item String)
bibtexCompiler = do
pandocCrossrefNumberingCompiler :: Compiler (Item String)
pandocCrossrefNumberingCompiler = do
getResourceBody
>>= withItemBody (unixFilter "pandoc" ["-F"
, "pandoc-numbering"
......@@ -260,25 +296,60 @@ bibtexCompiler = do
>>= return . writePandocWith pandocOptions
pandocRevealCompiler :: Compiler (Item String)
pandocRevealCompiler = do
getResourceBody
>>= withItemBody (unixFilter "pandoc" ["-F"
, "pandoc-numbering"
, "-F"
, "pandoc-crossref"
, "-t"
, "revealjs"
, "-V"
, "revealjs-url=./reveal.js"
, "-V"
, "theme=white"
])
>>= readPandocWith defaultHakyllReaderOptions
>>= return . writePandocWith pandocOptions
--------------------------------------------------------------------------------
-- | Hacky.
-- xelatex :: Item String -> Compiler (Item TmpFile)
-- xelatex item = do
-- TmpFile texPath <- newTmpFile "xelatex.tex"
-- let tmpDir = takeDirectory texPath
-- pdfPath = replaceExtension texPath "pdf"
-- unsafeCompiler $ do
-- writeFile texPath $ itemBody item
-- _ <- Process.system $ unwords ["xelatex", "-halt-on-error",
-- "-output-directory", tmpDir, texPath, ">/dev/null", "2>&1"]
-- return ()
-- makeItem $ TmpFile pdfPath
cfg :: Configuration
cfg = defaultConfiguration
main :: IO ()
main = hakyllWith cfg $ do
pages
posts
cours_conc
conc
cours_mti
mti
cours_phys_app
phys_app
research
bachelor
index
templates
resizeThumbnails
resizeLarge
resizeHeads
static
-- main :: IO ()
-- main = hakyllWith cfg $ do
-- pages
-- posts
-- cours_conc
-- conc
-- cours_mti
-- mti
-- cours_phys_app
-- phys_app
-- research
-- bachelor
-- index
-- templates
-- resizeThumbnails
-- resizeLarge
-- resizeHeads
-- static
watch: Main.hs cours/math_tech_info/*.md cours/isc_physics/*.md
make hakyll_gen -C cours/math_tech_info
make hakyll_gen -C cours/isc_physics
stack build && stack exec blog -- rebuild && stack exec blog -- watch
make -C cours/math_tech_info
make -C cours/isc_physics
stack build && stack exec blog -- build && stack exec blog -- watch
build_revealjs:
cd reveal.js && npm install && npm run build && cd ..
clean:
rm -rf _cache _site
......
hakyll-bootstrap/img/large/q_0_5.0000.png

233 KiB | W: | H:

hakyll-bootstrap/img/large/q_0_5.0000.png

389 KiB | W: | H:

hakyll-bootstrap/img/large/q_0_5.0000.png
hakyll-bootstrap/img/large/q_0_5.0000.png
hakyll-bootstrap/img/large/q_0_5.0000.png
hakyll-bootstrap/img/large/q_0_5.0000.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -23,6 +23,8 @@
<div class="container">
<h1>$title$</h1>
<h3><a href="$pdfurl$">Le polycopié en entier [pdf]</a></h3>
<h2>Les chapitres</h2>
<ul>
$for(posts)$
<li>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment