diff --git a/site/archives.html b/site/archives.html
index 34b8059..c4ce88a 100644
--- a/site/archives.html
+++ b/site/archives.html
@@ -3,9 +3,9 @@ title: Liste des publications
---
diff --git a/site/index.html b/site/index.html
index 02ae527..a378cb5 100644
--- a/site/index.html
+++ b/site/index.html
@@ -23,7 +23,7 @@ index: true
diff --git a/site/templates/authors.html b/site/templates/authors.html
index 75a41bc..d34df03 100644
--- a/site/templates/authors.html
+++ b/site/templates/authors.html
@@ -1,8 +1,8 @@
$authors$
diff --git a/site/templates/division.html b/site/templates/division.html
index 50d9326..f62f4e0 100644
--- a/site/templates/division.html
+++ b/site/templates/division.html
@@ -2,7 +2,12 @@ $body$
$if(posts)$
-Liste des articles rattachés à ce pôle :
+
+
+ Retour à la liste des pôles
+
+
+
$partial("templates/posts.html")$
$endif$
diff --git a/site/templates/pole.html b/site/templates/pole.html
deleted file mode 100644
index 90e6dfd..0000000
--- a/site/templates/pole.html
+++ /dev/null
@@ -1,2 +0,0 @@
-Vous pouvez trouver tout les poles ici.
-$partial("templates/posts.html")$
diff --git a/site/templates/poles.html b/site/templates/poles.html
new file mode 100644
index 0000000..d77607e
--- /dev/null
+++ b/site/templates/poles.html
@@ -0,0 +1,8 @@
+
+
+$poles$
diff --git a/site/templates/post.html b/site/templates/post.html
index 800a507..5b970c0 100644
--- a/site/templates/post.html
+++ b/site/templates/post.html
@@ -1,19 +1,23 @@
-
-
- $if(poles)$
- $poles$
- $endif$
-
-
-
-
+
+
+
+
+
+ Posté le $date$
+ $if(author)$
+ $author$
+ $endif$
+
+ $if(poles)$
+ Pôles associés :
+ $poles$
+ $endif$
+
+ Catégories :
+ $if(tags)$
+ $tags$
+ $endif$
+
+
diff --git a/site/templates/tags.html b/site/templates/tags.html
index f237045..629eb6e 100644
--- a/site/templates/tags.html
+++ b/site/templates/tags.html
@@ -1,7 +1,7 @@
diff --git a/ssg/ssg.cabal b/ssg/ssg.cabal
index 6619265..145a45c 100644
--- a/ssg/ssg.cabal
+++ b/ssg/ssg.cabal
@@ -14,6 +14,7 @@ executable ssg
build-depends: base ^>=4.16.4.0
, blaze-html
, blaze-markup
+ , containers
, hakyll
, pandoc
, pandoc-types
diff --git a/ssg/ssg.hs b/ssg/ssg.hs
index fe9a909..d679558 100644
--- a/ssg/ssg.hs
+++ b/ssg/ssg.hs
@@ -8,6 +8,7 @@
import Control.Applicative ((<|>))
import Control.Monad (void, (<=<))
import Data.List (intersperse)
+import Data.Map qualified as M
import Data.Monoid (First (..))
import Hakyll
import Text.Blaze.Html.Renderer.String (renderHtml)
@@ -26,6 +27,18 @@ import Text.Pandoc.Walk (query, walk)
nbPostsHome :: Int
nbPostsHome = 10
+poleName :: M.Map String String
+poleName =
+ M.fromList
+ [ ("administration-systeme", "Administration Système"),
+ ("communication", "Communication"),
+ ("formation", "Formation"),
+ ("geopolitique", "Géopolitique"),
+ ("juridique", "Juridique"),
+ ("logiciel", "Logiciel"),
+ ("recherche", "Recherche")
+ ]
+
patternFrom :: [String] -> [String] -> Pattern
patternFrom basenames extensions =
foldl1 (.||.) $ map aux basenames
@@ -154,6 +167,10 @@ main = hakyll $ do
>>= loadAndApplyTemplate "templates/default.html" context
>>= relativizeUrls
+ create ["poles.html"] $ do
+ route idRoute
+ compile (polePanelCompiler poles)
+
-- Authors
tagsRules authors $ \authorStr authorsPattern -> do
let title = "Articles écrits par « " ++ authorStr ++ " »"
@@ -229,6 +246,24 @@ authorPanelCompiler authors = do
>>= loadAndApplyTemplate "templates/default.html" ctx
>>= relativizeUrls
+makePolePanelLink :: String -> String -> Int -> Int -> Int -> String
+makePolePanelLink pole url count _ _ =
+ renderHtml $ H.a H.! A.href (H.toValue url) H.! A.class_ "panel-block" $ do
+ H.span H.! A.class_ "tag mr-3" $ H.toHtml (pluralize count "publication")
+ H.toHtml (poleName M.! pole)
+
+polePanelCompiler :: Tags -> Compiler (Item String)
+polePanelCompiler poles = do
+ let ctx =
+ field "poles" (\_ -> renderTags makePolePanelLink (mconcat . intersperse "\n") poles)
+ <> constField "title" "Liste des pôles"
+ <> context
+
+ makeItem ""
+ >>= loadAndApplyTemplate "templates/poles.html" ctx
+ >>= loadAndApplyTemplate "templates/default.html" ctx
+ >>= relativizeUrls
+
makeTagPanelLink :: String -> String -> Int -> Int -> Int -> String
makeTagPanelLink tag url count _ _ =
renderHtml $ H.a H.! A.href (H.toValue url) H.! A.class_ "panel-block" $ do
@@ -247,6 +282,29 @@ tagPanelCompiler tags = do
>>= loadAndApplyTemplate "templates/default.html" ctx
>>= relativizeUrls
+renderTagLink :: String -> Maybe FilePath -> Maybe H.Html
+renderTagLink _ Nothing = Nothing
+renderTagLink tag (Just filePath) =
+ Just
+ $ H.a
+ H.! A.title (H.stringValue $ "Pages relatives à « " ++ tag ++ " »")
+ H.! A.class_ "tag is-link"
+ H.! A.href (H.toValue $ toUrl filePath)
+ $ H.toHtml tag
+
+renderPoleLink :: String -> Maybe FilePath -> Maybe H.Html
+renderPoleLink _ Nothing = Nothing
+renderPoleLink pole (Just filePath) =
+ Just
+ $ H.a
+ H.! A.title (H.stringValue $ "Page du pôle « " ++ (poleName M.! pole) ++ " »")
+ H.! A.class_ "tag is-light has-text-dark"
+ H.! A.href (H.toValue $ toUrl filePath)
+ $ H.toHtml (poleName M.! pole)
+
+makeTags :: [H.Html] -> H.Html
+makeTags tags = H.div H.! A.class_ "tags mt-2" $ (mconcat . intersperse "\n") tags
+
-- Utility functions
pluralize :: Int -> String -> String
pluralize count str = case count of
@@ -304,10 +362,10 @@ postCtx =
postCtxWith :: Tags -> Tags -> Tags -> Context String
postCtxWith tags authors poles =
- tagsFieldWith (getTagsByField "poles") simpleRenderLink (mconcat . intersperse ", ") "poles" poles
+ tagsFieldWith (getTagsByField "poles") renderPoleLink makeTags "poles" poles
<> tagsFieldWith (getTagsByField "authors") simpleRenderLink (mconcat . (\l -> if null l then [] else H.toHtml ("par " :: String) : l) . intersperse ", ") "author" authors
<> tagsFieldWith (getTagsByField "authors") licenseRenderLink (mconcat . intersperse ", " . (\l -> if null l then [] else l ++ [H.toHtml ("and" :: String)])) "authorLicense" authors
- <> tagsField "tags" tags
+ <> tagsFieldWith getTags renderTagLink makeTags "tags" tags
<> postCtx
simpleRenderLink :: String -> Maybe FilePath -> Maybe H.Html