mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-06-20 09:04:42 +02:00
fix template include for article
This commit is contained in:
parent
a473479b83
commit
9ab4b98c1d
30 changed files with 115 additions and 87 deletions
|
@ -23,13 +23,13 @@ start_time = time.time()
|
|||
# Configurer argparse pour prendre le blog en argument
|
||||
parser = argparse.ArgumentParser(description='Générer une liste des derniers articles de blog.')
|
||||
parser.add_argument('blog', type=str, help='Nom du dossier du blog à traiter', default='cipherbliss_blog')
|
||||
parser.add_argument('--run_gemini', type=str, help='Activer ou non la génération des billets gemini', default=True)
|
||||
parser.add_argument('--run_pandoc', type=str, help='Activer ou non la génération des fichiers html', default=True)
|
||||
parser.add_argument('--enable_roam_id_rewrite', type=str, help='Activer ou non la réécriture des liens roam', default=False)
|
||||
parser.add_argument('--generate_html_pages', type=str, help='Activer ou non la génération des pages html', default=True)
|
||||
parser.add_argument('--generate_linkings_json', type=str, help='Activer ou non la génération du json des liens entre articles', default=True)
|
||||
parser.add_argument('--force_html_regen', action='store_true', help='Forcer la régénération des fichiers HTML même s\'ils existent déjà', default=False)
|
||||
parser.add_argument('--rebuild_articles_info_json', type=str, help='Reconstruire le fichier de données JSON des articles', default=False)
|
||||
parser.add_argument('--run_gemini', type=bool, help='Activer ou non la génération des billets gemini', default=True)
|
||||
parser.add_argument('--run_pandoc', type=bool, help='Activer ou non la génération des fichiers html', default=True)
|
||||
parser.add_argument('--enable_roam_id_rewrite', type=bool, help='Activer ou non la réécriture des liens roam', default=False)
|
||||
parser.add_argument('--generate_html_pages', type=bool, help='Activer ou non la génération des pages html', default=True)
|
||||
parser.add_argument('--generate_linkings_json', type=bool, help='Activer ou non la génération du json des liens entre articles', default=True)
|
||||
parser.add_argument('--force_html_regen', type=bool, help='Forcer la régénération des fichiers HTML même s\'ils existent déjà', default=False)
|
||||
parser.add_argument('--rebuild_articles_info_json', type=bool, help='Reconstruire le fichier de données JSON des articles', default=False)
|
||||
|
||||
args = parser.parse_args()
|
||||
run_gemini = args.run_gemini
|
||||
|
@ -191,6 +191,8 @@ if generate_linkings_json :
|
|||
# Vérifier si l'article doit être reconstruit
|
||||
file_modified_time = os.path.getmtime(file_path)
|
||||
rebuild_this_article_gemini = file_modified_time > last_gemini_build_time
|
||||
if rebuild_this_article_gemini:
|
||||
print("le dernier build gemini est plus ancien que la dernière modification de la source, on le rebuild")
|
||||
except Exception as e:
|
||||
print(f"Erreur lors de la vérification des dates pour {gemini_path}: {e}")
|
||||
rebuild_this_article_gemini = True
|
||||
|
@ -210,7 +212,7 @@ if generate_linkings_json :
|
|||
if rebuild_this_article_html:
|
||||
print(f"\033[91m--------- article modifié après le build de son rendu html: {file_path}, {rebuild_this_article_html}\033[0m")
|
||||
# else:
|
||||
# print(f"\033[91m--------- article non modifié après le build de son rendu html: {file_path}, {rebuild_this_article_html}, on ne recrée pas\033[0m")
|
||||
# print(f"\033[91m--------- article non modifié après le build de son rendu html: {file_path}, {rebuild_this_article_html}, on ne recrée pas\033[0m")
|
||||
|
||||
else:
|
||||
# si il n'y a pas de fichier html, on le construit pour la première fois
|
||||
|
@ -238,7 +240,7 @@ if generate_linkings_json :
|
|||
if len(files_dict[slug_with_year]['html_content_without_h1']) > 0 :
|
||||
html_content_without_h1 = files_dict[slug_with_year]['html_content_without_h1']
|
||||
else:
|
||||
print('========= pas de contenu html existant: ', title)
|
||||
print('========= pas de contenu html existant: ', title , '|on le génère|',slug_with_year)
|
||||
print(f"\033[91m {time.strftime('%H:%M:%S')} BRRRRRRRRRRRRR pandoc html_content : {title} en html\033[0m")
|
||||
pandoc_runs_counter += 1
|
||||
html_content = pypandoc.convert_text(content_without_h1, 'html', format='org')
|
||||
|
@ -247,13 +249,13 @@ if generate_linkings_json :
|
|||
|
||||
|
||||
if run_pandoc and rebuild_this_article_html or force_html_regen:
|
||||
print(f"run_pandoc: {run_pandoc}")
|
||||
print(f"rebuild_this_article_html: {rebuild_this_article_html}")
|
||||
print(f"force_html_regen: {force_html_regen}")
|
||||
# print(f"run_pandoc: {run_pandoc}")
|
||||
# print(f"rebuild_this_article_html: {rebuild_this_article_html}")
|
||||
# print(f"force_html_regen: {force_html_regen}")
|
||||
# convertir le contenu d'article org vers html
|
||||
print(f"\033[91m {time.strftime('%H:%M:%S')} BRRRRRRRRRRRRR pandoc : {title} en html\033[0m")
|
||||
# print(f"\033[91m.\033[0m", end='', flush=True)
|
||||
if not html_content:
|
||||
print(f"\033[91m {time.strftime('%H:%M:%S')} BRRRRRRRRRRRRR pandoc : {title} en html\033[0m")
|
||||
html_content = pypandoc.convert_text(content_without_h1, 'html', format='org')
|
||||
html_content_without_h1 = re.sub(r'<h1>.*?</h1>', '', html_content)
|
||||
pandoc_runs_counter += 1
|
||||
|
@ -435,8 +437,11 @@ Dernière mise à jour: {dt.datetime.now().strftime('%Y-%m-%d, %H:%M:%S')}
|
|||
=> tags.gmi Tags
|
||||
|
||||
-----------------------------------------------
|
||||
|
||||
{template_content['SOUTIEN']}
|
||||
|
||||
-----------------------------------------------
|
||||
|
||||
{template_content['WEBSITE_GENERATOR_DESCRIPTION']}
|
||||
{template_content['WEBSITE_GENERATOR']}
|
||||
"""
|
||||
|
@ -535,7 +540,7 @@ def generate_article_pages(json_file, template_file, output_dir):
|
|||
print(f"\033[94m Nombre d'articles gemini générés : {counter_gemini}\033[0m")
|
||||
return
|
||||
except IOError as e:
|
||||
print(f"Erreur lors de la lecture du fichier {json_file}: {e}")
|
||||
print(f"linking articles prev next: Erreur lors de la lecture du fichier {json_file}: {e}")
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"Erreur inattendue lors de la lecture du fichier {json_file}: {e}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue