From 6a5b339b08ced2045eb5e8bae8160612a376b113 Mon Sep 17 00:00:00 2001
From: Orestis Malaspinas <orestis.malaspinas@hesge.ch>
Date: Thu, 19 Nov 2020 21:29:08 +0100
Subject: [PATCH] started to revamp a bit the dir structure

---
 hakyll-bootstrap/Main.hs                      | 54 +++++++++++++------
 .../{pages => old.pages}/about.html           |  0
 .../{pages => old.pages}/contact.html         |  0
 .../{pages => old.pages}/privacy.html         |  0
 .../{pages => old.pages}/signup.html          |  0
 .../{pages => old.pages}/team.html            |  0
 .../{pages => old.pages}/tos.html             |  0
 hakyll-bootstrap/templates/archive.html       |  2 +
 hakyll-bootstrap/templates/nav.html           | 14 ++---
 hakyll-bootstrap/templates/posts.html         | 41 ++++++++++++++
 10 files changed, 87 insertions(+), 24 deletions(-)
 rename hakyll-bootstrap/{pages => old.pages}/about.html (100%)
 rename hakyll-bootstrap/{pages => old.pages}/contact.html (100%)
 rename hakyll-bootstrap/{pages => old.pages}/privacy.html (100%)
 rename hakyll-bootstrap/{pages => old.pages}/signup.html (100%)
 rename hakyll-bootstrap/{pages => old.pages}/team.html (100%)
 rename hakyll-bootstrap/{pages => old.pages}/tos.html (100%)
 create mode 100644 hakyll-bootstrap/templates/posts.html

diff --git a/hakyll-bootstrap/Main.hs b/hakyll-bootstrap/Main.hs
index 9ceefff..b0334f7 100644
--- a/hakyll-bootstrap/Main.hs
+++ b/hakyll-bootstrap/Main.hs
@@ -73,7 +73,7 @@ main = hakyllWith config $ do
             >>= relativizeUrls
 
     -- Phys app post list
-    create ["phys_app.html"] $ do
+    create ["cours/phys_app.html"] $ do
         route idRoute
         compile $ do
             posts <- recentFirst =<< loadAll ("cours/isc_physics/*.markdown" .&&. hasNoVersion)
@@ -99,7 +99,7 @@ main = hakyllWith config $ do
     --         >>= xelatex
 
     -- Math Tech Info post list
-    create ["math_tech_info.html"] $ do
+    create ["cours/math_tech_info.html"] $ do
         route idRoute
         compile $ do
             posts <- recentFirst =<< loadAll ("cours/math_tech_info/*.markdown" .&&. hasNoVersion)
@@ -115,7 +115,7 @@ main = hakyllWith config $ do
             >>= relativizeUrls
 
     -- Phys app post list
-    create ["prog_seq.html"] $ do
+    create ["cours/prog_seq.html"] $ do
         route idRoute
         compile $ do
             posts <- recentFirst =<< loadAll "cours/prog_seq/slides/*.markdown"
@@ -129,13 +129,43 @@ main = hakyllWith config $ do
         compile $ pandocCompiler
             >>= relativizeUrls
 
-    -- Phys app post list
-    create ["team.html"] $ do
+    -- Team members list
+    create ["pages/team.html"] $ do
         route idRoute
         compile $ do
             posts <- recentFirst =<< loadAll "team/*.md"
             makeItem ""
-                >>= loadAndApplyTemplate "templates/team.html" (courseRevealCtx posts "Research group")
+                >>= loadAndApplyTemplate "templates/team.html" (pagesCtx posts "Research group")
+                >>= relativizeUrls
+
+    -- Research description
+    match "posts/research/*.md" $ do
+        route $ setExtension "html"
+        compile $ pandocCompiler
+            >>= relativizeUrls
+
+    -- Research topics
+    create ["pages/research_projects.html"] $ do
+        route idRoute
+        compile $ do
+            posts <- recentFirst =<< loadAll "posts/research/*.md"
+            makeItem ""
+                >>= loadAndApplyTemplate "templates/archive.html" (pagesCtx posts "Research projects")
+                >>= relativizeUrls
+
+    -- Team description
+    match "posts/bachelor/*.md" $ do
+        route $ setExtension "html"
+        compile $ pandocCompiler
+            >>= relativizeUrls
+
+    -- Team members list
+    create ["pages/bachelor_projects.html"] $ do
+        route idRoute
+        compile $ do
+            posts <- recentFirst =<< loadAll "posts/bachelor/*.md"
+            makeItem ""
+                >>= loadAndApplyTemplate "templates/archive.html" (pagesCtx posts "Bachelor projects")
                 >>= relativizeUrls
 
     -- Index
@@ -255,21 +285,11 @@ courseCtx posts title pdfurl =
   `mappend` constField "pdfurl" pdfurl
   `mappend` defaultContext
 
-courseRevealCtx posts title =
+pagesCtx posts title =
   listField "posts" postCtx (return posts)
   `mappend` constField "title" title
   `mappend` defaultContext
             
-researchCtx posts =
-  listField "posts" postCtx (return posts)
-  `mappend` constField "title" "Research projects"
-  `mappend` defaultContext
-
-bachelorCtx posts =
-  listField "posts" postCtx (return posts)
-  `mappend` constField "title" "Bachelor projects"
-  `mappend` defaultContext
-
 indexCtx posts =
   listField "posts" postCtx (return posts)
   `mappend` constField "title" "Home"
diff --git a/hakyll-bootstrap/pages/about.html b/hakyll-bootstrap/old.pages/about.html
similarity index 100%
rename from hakyll-bootstrap/pages/about.html
rename to hakyll-bootstrap/old.pages/about.html
diff --git a/hakyll-bootstrap/pages/contact.html b/hakyll-bootstrap/old.pages/contact.html
similarity index 100%
rename from hakyll-bootstrap/pages/contact.html
rename to hakyll-bootstrap/old.pages/contact.html
diff --git a/hakyll-bootstrap/pages/privacy.html b/hakyll-bootstrap/old.pages/privacy.html
similarity index 100%
rename from hakyll-bootstrap/pages/privacy.html
rename to hakyll-bootstrap/old.pages/privacy.html
diff --git a/hakyll-bootstrap/pages/signup.html b/hakyll-bootstrap/old.pages/signup.html
similarity index 100%
rename from hakyll-bootstrap/pages/signup.html
rename to hakyll-bootstrap/old.pages/signup.html
diff --git a/hakyll-bootstrap/pages/team.html b/hakyll-bootstrap/old.pages/team.html
similarity index 100%
rename from hakyll-bootstrap/pages/team.html
rename to hakyll-bootstrap/old.pages/team.html
diff --git a/hakyll-bootstrap/pages/tos.html b/hakyll-bootstrap/old.pages/tos.html
similarity index 100%
rename from hakyll-bootstrap/pages/tos.html
rename to hakyll-bootstrap/old.pages/tos.html
diff --git a/hakyll-bootstrap/templates/archive.html b/hakyll-bootstrap/templates/archive.html
index ccc167d..c681d70 100644
--- a/hakyll-bootstrap/templates/archive.html
+++ b/hakyll-bootstrap/templates/archive.html
@@ -23,7 +23,9 @@
 
     <div class="container">
       <h1>$title$</h1>
+      $if(pdfurl)$
       <h3><a href="$pdfurl$">Le polycopié en entier [pdf]</a></h3>
+      $endif$
       <h2>Les chapitres</h2>
       <ul>
         $for(posts)$
diff --git a/hakyll-bootstrap/templates/nav.html b/hakyll-bootstrap/templates/nav.html
index 7e8137c..40836cf 100644
--- a/hakyll-bootstrap/templates/nav.html
+++ b/hakyll-bootstrap/templates/nav.html
@@ -17,18 +17,18 @@
             <li class="dropdown">
               <a href="#" class="dropdown-toggle" data-toggle="dropdown"> Classes <b class="caret"></b></a>
               <ul class="dropdown-menu">
-                <li><a href="/phys_app.html">Physique appliquée</a></li>
-                <li><a href="/math_tech_info.html">Mathématiques en technologie de l'information</a></li>
-                <li><a href="/prog_seq.html">Programmation séquentielle en C</a></li>
+                <li><a href="/cours/phys_app.html">Physique appliquée</a></li>
+                <li><a href="/cours/math_tech_info.html">Mathématiques en technologie de l'information</a></li>
+                <li><a href="/cours/prog_seq.html">Programmation séquentielle en C</a></li>
                 <li class="divider"></li>
                 <li class="dropdown-header">Archived</li>
                 <li><a href="#">Sciences orientation logicielle</a></li>
                 <li><a href="#">Programmation séquentielle en Rust</a></li>
-                <li><a href="/prog_conc.html">Programmation concurrente</a></li>
+                <li><a href="/cours/prog_conc.html">Programmation concurrente</a></li>
               </ul>
-              <li><a href="/research_projects.html">Research projects</a></li>
-              <li><a href="/bachelor_projects.html">Bachelor projects</a></li>
-              <li><a href="/team.html">Team</a></li>
+              <li><a href="/pages/research_projects.html">Research projects</a></li>
+              <li><a href="/pages/bachelor_projects.html">Bachelor projects</a></li>
+              <li><a href="/pages/team.html">Team</a></li>
               <li><a href="/pages/contact.html">Contact </a></li>
             </li>
           </ul>
diff --git a/hakyll-bootstrap/templates/posts.html b/hakyll-bootstrap/templates/posts.html
new file mode 100644
index 0000000..0ec1e09
--- /dev/null
+++ b/hakyll-bootstrap/templates/posts.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta name="description" content="">
+    <meta name="author" content="">
+    <title>$title$</title>
+    <link href="/css/bootstrap.css" rel="stylesheet">
+    <link href="/css/syntax.css" rel="stylesheet">
+    <link href="/css/carousel.css" rel="stylesheet">
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
+    <style>
+        body { 
+            font-family: 'Open Sans', sans-serif;
+        }
+        body { margin-top: 80px; }
+        footer { margin-top: 80px; }
+    </style>
+  </head>
+  <body>
+    $partial("templates/nav.html")$
+
+    <div class="container">
+      <h1>$title$</h1>
+      <ul>
+        $for(posts)$
+        <li>
+          <a href="$url$">$title$</a> - $date$
+        </li>
+        $endfor$
+      </ul>
+      $partial("templates/footer.html")$
+    </div>
+
+    </div><!-- /.container -->
+    <script src="/js/jquery.js"></script>
+    <script src="/js/bootstrap.js"></script>
+    <script src="/js/holder.js"></script>
+  </body>
+</html>
-- 
GitLab