Skip to content

Commit

Permalink
Amélioration : gère les caractères HTML dans les titres, descriptions…
Browse files Browse the repository at this point in the history
… et mots-clés des articles pour la liste dans les page auteur/ices (#1125)
  • Loading branch information
Guts authored May 15, 2024
2 parents 7179a58 + 913e4a4 commit 6110455
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ categories:
- article
comments: true
date: 2015-01-11
description: "OpenStreetMap ce n'est pas (qu') une carte"
description: "Lorsque je discute d'OpenStreetMap, pour beaucoup c'est une carte, rien de plus. Alors qu'en réalité OSM est un projet collaboratif dont le coeur est la base de données géographiques. La carte résultante n’étant qu'un des nombreux dérivés de cette base."
icon: material/database-marker
tags:
- OpenStreetMap
---
Expand Down Expand Up @@ -51,6 +52,4 @@ Comme je vous le disais en introduction, OpenStreetMap c'est un système complet

J'espère avoir réussi à clarifier ce qu'est OpenStreetMap sans pour autant trop vous embrouiller. Mais c'est un projet complexe dont l'étendue ne cesse de s'agrandir. Ne voir que sa simple composante cartographique est très réducteur et cela serait oublier toutes les autres fonctionnalités !

----

<!-- geotribu:authors-block -->
30 changes: 19 additions & 11 deletions content/theme/main.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
{% extends "base.html" %}

{% block extrahead %}

{# Meta type #}
{% set page_type = "article" %}
{% if page.is_homepage or page.abs_url == "/" %}
{% set page_type = "website" %}
{% elif "rdp/" in page.url %}
{% set page_type = "geordp" %}
{% elif "team/" in page.url %}
{% set page_type = "author_profile" %}
{% else %}
{% set page_type = "article" %}
{% endif %}

{# SEO Robots #}
{% if page and page.meta and page.meta.robots %}
<meta property="robots" content="{{ page.meta.robots }}" />
Expand All @@ -23,18 +36,23 @@
{% if page and page.meta and page.meta.date %}
{% set page_date = page.meta.date %}
{% endif %}

{# Meta description #}
{% set description = config.site_description %}
{% if page and page.meta and page.meta.description %}
{% set description = page.meta.description | striptags %}
{% elif page and page_type == "author_profile" %}
{% set description = "Profil Geotribu de " + page.title | striptags %}
{% elif page and page.description and not page.is_homepage %}
{% set description = page.description | striptags %}
{% endif %}

{# Meta image #}
{% set image = 'https://cdn.geotribu.fr/img/internal/charte/geotribu_banner.jpg' %}
{% if page and page.meta and page.meta.image %}
{% set image = page.meta.image %}
{% endif %}

{# Meta author #}
{% set author = config.site_author %}
{% if page and page.meta and page.meta.authors and not page.is_homepage %}
Expand Down Expand Up @@ -64,17 +82,7 @@
<meta http-equiv="cache-control" content="public">
<meta http-equiv="expires" content="43200" />

{# Meta type #}
{% set page_type = "article" %}
{% if page.is_homepage or page.abs_url == "/" %}
{% set page_type = "website" %}
{% elif "rdp/" in page.url %}
{% set page_type = "geordp" %}
{% elif "team/" in page.url %}
{% set page_type = "author_profile" %}
{% else %}
{% set page_type = "article" %}
{% endif %}


{# JSON Feed #}
{% include "partials/json_feed.html.jinja2" %}
Expand Down
22 changes: 16 additions & 6 deletions hooks/mkdocs/G006_authors_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# standard library
import logging
import re
from html import escape
from pathlib import Path

# 3rd party
Expand Down Expand Up @@ -105,25 +106,34 @@ def on_page_markdown(
# icône
item_icon = ""
if page.meta.get("icon"):
item_icon = f":{page.meta.get('icon').replace('/', '-')}:"
item_icon = f" :{page.meta.get('icon').replace('/', '-')}:"

# hyperlink data
list_item_link_data = ""
if page.meta.get("description"):
list_item_link_data += page.meta.get("description")
if (
page.meta.get("description")
and page.meta.get("description") != page.title
):
list_item_link_data += escape(
page.meta.get("description"), quote=True
)
if page.meta.get("tags"):
if page.meta.get("description"):
if (
page.meta.get("description")
and page.meta.get("description") != page.title
):
list_item_link_data += "<br/><br/>"
list_item_link_data += (
f"<i>Mots-clés : {' , '.join(page.meta.get('tags'))}</i>"
"<i>Mots-clés : "
f"{escape(', ', quote=True).join(page.meta.get('tags'))}</i>"
)

with Path(f"content/team/{sluggy(author)}.md").open(
"a", encoding="UTF-8"
) as author_file:
author_file.write(articles_headers)
author_file.write(
f"\n- {item_icon} [{page.title}](../{page.file.src_uri} '{list_item_link_data}') - _publié le {item_date}_"
f"\n-{item_icon} [{escape(page.title, quote=True)}](../{page.file.src_uri} '{list_item_link_data}') - _publié le {item_date}_"
)

# on cherche et remplace la balise de bloc de signature en ignorant la casse
Expand Down
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,6 @@ markdown_extensions:
# Permalinks - https://squidfunk.github.io/mkdocs-material/extensions/permalinks/
- toc:
permalink: "#"

exclude_docs: |
toc_nav_ignored/*

0 comments on commit 6110455

Please sign in to comment.