diff --git a/converters.sh b/converters.sh index 396addce..c344e5b7 100755 --- a/converters.sh +++ b/converters.sh @@ -196,7 +196,6 @@ convert_markdown_to_gmi() { } # regrouper les types de fichiers générés - bash sass_styles.sh # Boucle à travers la liste des sites Web @@ -222,7 +221,7 @@ for website_name in "${blogs_folders[@]}"; do python3 linking_articles_prev_next.py $website_name # déplacer les fichiers générés en html dans le dossier statique - mv sources/$website_name/converted/*.html html-websites/$website_name/ + # mv sources/$website_name/converted/*.html html-websites/$website_name/ # python3 enrich_html.py $website_name --style $style_file diff --git a/gather_tags_in_json.py b/gather_tags_in_json.py index 621e6475..f8379cb8 100644 --- a/gather_tags_in_json.py +++ b/gather_tags_in_json.py @@ -24,6 +24,12 @@ automatic_tagging_enabled = global_config['automatic_tagging_enabled'] count_not_tagged_files = 0 count_orgfiles = 0 +destination_json = f'sources/{args.blog}/build' +json_file = destination_json + '/articles_info.json' +# Charger les données JSON +with open(json_file, 'r', encoding='utf-8') as f: + articles_info = json.load(f) + def find_org_files(directory): @@ -50,8 +56,19 @@ def group_files_by_tags(org_files, excluded_tags): tag_to_files = defaultdict(set) for file_path in org_files: tags = extract_tags_from_file(file_path, excluded_tags) + # ajout de slug avec année pour retrouver dans le fichier d'infos json + # slug = find_slug_in_file_basename(file_path) + date_str, annee, slug = find_year_and_slug_on_filename(file_path) + + print(file_path) + boom = file_path.split('/') + dernière_partie = boom[-1] + boom = dernière_partie.split('__') + slug = boom[0][:4]+'/'+slug + + # print( slug ) for tag in tags: - tag_to_files[tag].add(file_path) + tag_to_files[tag].add(slug) return tag_to_files @@ -64,35 +81,34 @@ def generate_html_pages_for_all_tags(tag_to_files, html_output_folder): if not os.path.exists(html_output_folder): os.makedirs(html_output_folder) + + template_content = configs_sites[args.blog] + + # Charger le template Jinja2 + env = Environment(loader=FileSystemLoader('.')) + template = env.get_template('templates/html/tag.html.jinja') + sorted_tags = sorted(tag_to_files.items()) + + tags_count = {tag: len(files) for tag, files in sorted_tags} + + print(tags_count) + for tag, files in tag_to_files.items(): - html_content = f""" - - - - - - Articles comportant le tag "{tag}" - - -

Articles comportant le tag "{tag}"

- -

Retour à l'index des tags

- - - """ html_file_path = os.path.join(html_output_folder, f"{tag}.html") with open(html_file_path, 'w', encoding='utf-8') as html_file: diff --git a/templates/html/article.html.jinja b/templates/html/article.html.jinja index f27ae8db..c93a5148 100644 --- a/templates/html/article.html.jinja +++ b/templates/html/article.html.jinja @@ -15,7 +15,7 @@ - {{template_content['TITLE']}} + {{ article.title | safe }} -{{template_content['TITLE']}} @@ -35,7 +35,7 @@ -

{{ article.title | safe }} - {{template_content['BLOG_TITLE']}} +

{{template_content['BLOG_TITLE']}}

{{template_content['BLOG_SUBTITLE']}}

diff --git a/templates/html/tag.html.jinja b/templates/html/tag.html.jinja index 2bb674d9..3023b41b 100644 --- a/templates/html/tag.html.jinja +++ b/templates/html/tag.html.jinja @@ -15,7 +15,7 @@ - {{template_content['TITLE']}} + Index des tags - {{template_content['TITLE']}} @@ -35,7 +35,7 @@ -

Index des tags - {{template_content['BLOG_TITLE']}} +

{{template_content['BLOG_TITLE']}}

{{template_content['BLOG_SUBTITLE']}}

@@ -74,11 +74,45 @@

+ + {% if title %} + {{title}} {{tag}} + {% else %} Tags + {% endif %} +

- + {% if files %} + +
+ +
+ {% endif %} + {% if tags %} +
+ {% endif %}

+ Retour à l'index des tags
Retour à l'accueil