diff --git a/__pycache__/enrich_html.cpython-312.pyc b/__pycache__/enrich_html.cpython-312.pyc index 214d0e00..7111203c 100644 Binary files a/__pycache__/enrich_html.cpython-312.pyc and b/__pycache__/enrich_html.cpython-312.pyc differ diff --git a/build_indexes.py b/build_indexes.py index b1dff0e6..3bc024ae 100755 --- a/build_indexes.py +++ b/build_indexes.py @@ -161,32 +161,7 @@ def generer_index(dossier_source, fichier_index): contenu_index_html = f"{config_title}\n{'- ' * len(config_title)}\n\n" contenu_index_gmi += "\n# Navigation\n-------------------------\n" - contenu_index_html += "

Navigation

" - for fichier in files_static: - # print(" -------- fichier ", fichier) - link_html = fichier.replace('.gmi', '.html') - link_org = fichier.replace('.gmi', '.org') - file_path_org = os.path.join(dossier_parent, "sources", website_name, link_org) - article_name = trouver_nom_article(file_path_org, 'org') - if article_name: - contenu_index_gmi += f"=> {fichier} {article_name}\n" - else: - contenu_index_gmi += f"=> {fichier}\n" - - if fichier != "index.gmi": - # print(' -------- rechercher le nom de l article dans le fichier ') - if use_article_file_for_name: - article_name = link_html - else: - article_name = trouver_nom_article(file_path_org, 'org') - - if not article_name: - article_name = link_html - else: - article_name = 'Index' - article_name = article_name.replace('_', ' ') - contenu_index_html += f"
{article_name}" # ne préciser la langue français que si on a des articles en Anglais if len(files_en): @@ -222,6 +197,33 @@ def generer_index(dossier_source, fichier_index): else: contenu_index_html += f"
{link_html}" + contenu_index_html += "
" + contenu_index_html += "

Navigation

" + for fichier in files_static: + # print(" -------- fichier ", fichier) + link_html = fichier.replace('.gmi', '.html') + link_org = fichier.replace('.gmi', '.org') + file_path_org = os.path.join(dossier_parent, "sources", website_name, link_org) + article_name = trouver_nom_article(file_path_org, 'org') + + if article_name: + contenu_index_gmi += f"=> {fichier} {article_name}\n" + else: + contenu_index_gmi += f"=> {fichier}\n" + + if fichier != "index.gmi": + # print(' -------- rechercher le nom de l article dans le fichier ') + if use_article_file_for_name: + article_name = link_html + else: + article_name = trouver_nom_article(file_path_org, 'org') + + if not article_name: + article_name = link_html + else: + article_name = 'Index' + article_name = article_name.replace('_', ' ') + contenu_index_html += f"
{article_name}" # ---------------- pareil en anglais TODO # contenu_index_gmi += "\n# Articles in English\n-------------------------\n" # contenu_index_html += "

Articles in English

" diff --git a/enrich_html.py b/enrich_html.py index c204f103..cc4b1942 100755 --- a/enrich_html.py +++ b/enrich_html.py @@ -1,8 +1,7 @@ #!/bin/python3 import argparse import os -import re - +from utils import * from website_config import configs_sites parser = argparse.ArgumentParser(description="Générer un site Web à partir de fichiers HTML.") @@ -15,47 +14,22 @@ args = parser.parse_args() style_file = args.style blog_name = args.blog_name.replace('html-websites/', '') +html_pages = 'html-websites/'+blog_name source_blog = f"sources/{blog_name}" header_content_path = f"{source_blog}/templates/converted/header_page.html" footer_content_path = f"{source_blog}/templates/converted/footer_page.html" static_page_path = f"{source_blog}/templates/html/static.html" -print('---------- blog name ', blog_name) +enable_header=True + +# print('---------- blog name ', blog_name) template_content = configs_sites[blog_name] after_article = '' inline_the_css = False - - # inline_the_css=True -def extract_body_content(html_content): - pattern = r']*?>(.*?)' - match = re.search(pattern, html_content, re.DOTALL) - if match: - return match.group(1) - else: - return None - - -def remove_properties_section(text): - pattern = r"

Article

.+?" - replacement = "" - return re.sub(pattern, replacement, text, flags=re.DOTALL) - - -def remove_article_head_properties_orgmode(text): - pattern = r":PROPERTIES:.+?:END:" - replacement = "" - return re.sub(pattern, replacement, text, flags=re.DOTALL) - - -def remove_hint_html(text): - pattern = r"

ceciestduhtml

" - replacement = "" - return re.sub(pattern, replacement, text, flags=re.DOTALL) - def enrich_one_file(html_content, partials={"header_page": "", "footer_content": ""}): # remove some parts @@ -70,7 +44,8 @@ def enrich_one_file(html_content, partials={"header_page": "", "footer_content": with open(os.path.join(root_path, file), "r") as f: css_content = f.read() css_content = "" - + template_content["CSS_INLINE_CONTENT"] = css_content + template_content["PAGE_SLUG"] = "la_page" # remplir le template html_content = f""" @@ -101,7 +76,7 @@ def enrich_one_file(html_content, partials={"header_page": "", "footer_content": -
+