site: Update posts and tags
This commit is contained in:
parent
56dc9177c4
commit
b840e902b9
10 changed files with 107 additions and 33 deletions
|
@ -3,9 +3,9 @@ title: Liste des publications
|
||||||
---
|
---
|
||||||
|
|
||||||
<div class="panel-tabs">
|
<div class="panel-tabs">
|
||||||
<a class="is-active" href="#">Récentes</a>
|
<a class="is-active">Toutes les publications</a>
|
||||||
<a href="/tags.html">Catégories</a>
|
<a href="/tags.html">Catégories</a>
|
||||||
<a href="/about.html#poles">Pôles</a>
|
<a href="/poles.html">Pôles</a>
|
||||||
<a href="/authors.html">Auteur·e·s</a>
|
<a href="/authors.html">Auteur·e·s</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ index: true
|
||||||
<div class="panel-tabs">
|
<div class="panel-tabs">
|
||||||
<a class="is-active" href="#">Récents</a>
|
<a class="is-active" href="#">Récents</a>
|
||||||
<a href="/tags.html">Catégories</a>
|
<a href="/tags.html">Catégories</a>
|
||||||
<a href="/about.html#poles">Pôles</a>
|
<a href="/poles.html">Pôles</a>
|
||||||
<a href="/authors.html">Auteur·e·s</a>
|
<a href="/authors.html">Auteur·e·s</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<div class="panel-tabs">
|
<div class="panel-tabs">
|
||||||
<a href="/archives.html">Récentes</a>
|
<a href="/archives.html">Toutes les publications</a>
|
||||||
<a href="/tags.html">Catégories</a>
|
<a href="/tags.html">Catégories</a>
|
||||||
<a href="/about.html#poles">Pôles</a>
|
<a href="/poles.html">Pôles</a>
|
||||||
<a class="is-active" href="#">Auteur·e·s</a>
|
<a class="is-active">Auteur·e·s</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
$authors$
|
$authors$
|
||||||
|
|
|
@ -2,7 +2,12 @@ $body$
|
||||||
|
|
||||||
$if(posts)$
|
$if(posts)$
|
||||||
<hr>
|
<hr>
|
||||||
<div class="subtitle is-6">Liste des articles rattachés à ce pôle :</div>
|
<a class="panel-block" href="/poles.html">
|
||||||
|
<span class="control is-fullwidth has-text-centered">
|
||||||
|
Retour à la liste des pôles
|
||||||
|
<span class="icon"><i class="fa-solid fa-rotate-left"></i></span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
$partial("templates/posts.html")$
|
$partial("templates/posts.html")$
|
||||||
$endif$
|
$endif$
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
Vous pouvez trouver tout les poles <a href="/about.html#pôles">ici</a>.
|
|
||||||
$partial("templates/posts.html")$
|
|
8
site/templates/poles.html
Normal file
8
site/templates/poles.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<div class="panel-tabs">
|
||||||
|
<a href="/archives.html">Toutes les publications</a>
|
||||||
|
<a href="/tags.html">Catégories</a>
|
||||||
|
<a class="is-active">Pôles</a>
|
||||||
|
<a href="/authors.html">Auteur·e·s</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
$poles$
|
|
@ -1,19 +1,23 @@
|
||||||
<article>
|
<section class="content">
|
||||||
<section class="header">
|
$body$
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<section class="mt-5 notification is-dark">
|
||||||
Posté le $date$
|
Posté le $date$
|
||||||
$if(author)$
|
$if(author)$
|
||||||
$author$
|
$author$
|
||||||
$endif$
|
$endif$
|
||||||
</section>
|
<div class="mt-2">
|
||||||
<ul class="poles">$if(poles)$
|
$if(poles)$
|
||||||
|
<span>Pôles associés :</span>
|
||||||
$poles$
|
$poles$
|
||||||
$endif$
|
$endif$
|
||||||
</ul>
|
|
||||||
<ul class="tags">$if(tags)$
|
<span>Catégories :</span>
|
||||||
|
$if(tags)$
|
||||||
$tags$
|
$tags$
|
||||||
$endif$
|
$endif$
|
||||||
</ul>
|
</div>
|
||||||
<section class="content">
|
|
||||||
$body$
|
|
||||||
</section>
|
</section>
|
||||||
</article>
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="panel-tabs">
|
<div class="panel-tabs">
|
||||||
<a href="/archives.html">Récentes</a>
|
<a href="/archives.html">Toutes les publications</a>
|
||||||
<a class="is-active" href="#">Catégories</a>
|
<a class="is-active">Catégories</a>
|
||||||
<a href="/about.html#poles">Pôles</a>
|
<a href="/poles.html">Pôles</a>
|
||||||
<a href="/authors.html">Auteur·e·s</a>
|
<a href="/authors.html">Auteur·e·s</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ executable ssg
|
||||||
build-depends: base ^>=4.16.4.0
|
build-depends: base ^>=4.16.4.0
|
||||||
, blaze-html
|
, blaze-html
|
||||||
, blaze-markup
|
, blaze-markup
|
||||||
|
, containers
|
||||||
, hakyll
|
, hakyll
|
||||||
, pandoc
|
, pandoc
|
||||||
, pandoc-types
|
, pandoc-types
|
||||||
|
|
62
ssg/ssg.hs
62
ssg/ssg.hs
|
@ -8,6 +8,7 @@
|
||||||
import Control.Applicative ((<|>))
|
import Control.Applicative ((<|>))
|
||||||
import Control.Monad (void, (<=<))
|
import Control.Monad (void, (<=<))
|
||||||
import Data.List (intersperse)
|
import Data.List (intersperse)
|
||||||
|
import Data.Map qualified as M
|
||||||
import Data.Monoid (First (..))
|
import Data.Monoid (First (..))
|
||||||
import Hakyll
|
import Hakyll
|
||||||
import Text.Blaze.Html.Renderer.String (renderHtml)
|
import Text.Blaze.Html.Renderer.String (renderHtml)
|
||||||
|
@ -26,6 +27,18 @@ import Text.Pandoc.Walk (query, walk)
|
||||||
nbPostsHome :: Int
|
nbPostsHome :: Int
|
||||||
nbPostsHome = 10
|
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 :: [String] -> [String] -> Pattern
|
||||||
patternFrom basenames extensions =
|
patternFrom basenames extensions =
|
||||||
foldl1 (.||.) $ map aux basenames
|
foldl1 (.||.) $ map aux basenames
|
||||||
|
@ -154,6 +167,10 @@ main = hakyll $ do
|
||||||
>>= loadAndApplyTemplate "templates/default.html" context
|
>>= loadAndApplyTemplate "templates/default.html" context
|
||||||
>>= relativizeUrls
|
>>= relativizeUrls
|
||||||
|
|
||||||
|
create ["poles.html"] $ do
|
||||||
|
route idRoute
|
||||||
|
compile (polePanelCompiler poles)
|
||||||
|
|
||||||
-- Authors
|
-- Authors
|
||||||
tagsRules authors $ \authorStr authorsPattern -> do
|
tagsRules authors $ \authorStr authorsPattern -> do
|
||||||
let title = "Articles écrits par « " ++ authorStr ++ " »"
|
let title = "Articles écrits par « " ++ authorStr ++ " »"
|
||||||
|
@ -229,6 +246,24 @@ authorPanelCompiler authors = do
|
||||||
>>= loadAndApplyTemplate "templates/default.html" ctx
|
>>= loadAndApplyTemplate "templates/default.html" ctx
|
||||||
>>= relativizeUrls
|
>>= 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 :: String -> String -> Int -> Int -> Int -> String
|
||||||
makeTagPanelLink tag url count _ _ =
|
makeTagPanelLink tag url count _ _ =
|
||||||
renderHtml $ H.a H.! A.href (H.toValue url) H.! A.class_ "panel-block" $ do
|
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
|
>>= loadAndApplyTemplate "templates/default.html" ctx
|
||||||
>>= relativizeUrls
|
>>= 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
|
-- Utility functions
|
||||||
pluralize :: Int -> String -> String
|
pluralize :: Int -> String -> String
|
||||||
pluralize count str = case count of
|
pluralize count str = case count of
|
||||||
|
@ -304,10 +362,10 @@ postCtx =
|
||||||
|
|
||||||
postCtxWith :: Tags -> Tags -> Tags -> Context String
|
postCtxWith :: Tags -> Tags -> Tags -> Context String
|
||||||
postCtxWith tags authors poles =
|
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") 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
|
<> 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
|
<> postCtx
|
||||||
|
|
||||||
simpleRenderLink :: String -> Maybe FilePath -> Maybe H.Html
|
simpleRenderLink :: String -> Maybe FilePath -> Maybe H.Html
|
||||||
|
|
Loading…
Reference in a new issue