less verbose logs
This commit is contained in:
parent
17e935a3ca
commit
9543704e15
@ -25,10 +25,18 @@ parser = argparse.ArgumentParser(description='Générer une liste des derniers a
|
|||||||
parser.add_argument('blog', type=str, help='Nom du dossier du blog à traiter', default='cipherbliss_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=False)
|
parser.add_argument('--run_gemini', type=str, help='Activer ou non la génération des billets gemini', default=False)
|
||||||
parser.add_argument('--run_pandoc', type=str, help='Activer ou non la génération des fichiers html', 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('--force_html_regen', action='store_true', help='Forcer la régénération des fichiers HTML même s\'ils existent déjà')
|
||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
run_gemini = args.run_gemini
|
run_gemini = args.run_gemini
|
||||||
run_pandoc = args.run_pandoc
|
run_pandoc = args.run_pandoc
|
||||||
|
force_html_regen = args.force_html_regen
|
||||||
|
|
||||||
|
# TODO check cette fonctionnalité
|
||||||
|
enable_roam_id_rewrite = args.enable_roam_id_rewrite
|
||||||
|
|
||||||
# Fonction pour extraire le basename d'un fichier
|
# Fonction pour extraire le basename d'un fichier
|
||||||
def get_basename(file_name):
|
def get_basename(file_name):
|
||||||
return os.path.splitext(file_name)[0]
|
return os.path.splitext(file_name)[0]
|
||||||
@ -106,7 +114,7 @@ if generate_linkings_json :
|
|||||||
for file_name in os.listdir(directory):
|
for file_name in os.listdir(directory):
|
||||||
if file_name.endswith('.org'):
|
if file_name.endswith('.org'):
|
||||||
counter+=1
|
counter+=1
|
||||||
if counter % 10 == 0:
|
if force_html_regen and counter % 10 == 0:
|
||||||
print(f"{time.strftime('%H:%M:%S')} : Articles traités : {counter}/{count_articles}")
|
print(f"{time.strftime('%H:%M:%S')} : Articles traités : {counter}/{count_articles}")
|
||||||
file_path = os.path.join(directory, file_name)
|
file_path = os.path.join(directory, file_name)
|
||||||
with open(file_path, "r", encoding="utf-8") as f:
|
with open(file_path, "r", encoding="utf-8") as f:
|
||||||
@ -136,7 +144,7 @@ if generate_linkings_json :
|
|||||||
# Obtenir la date de création du fichier HTML
|
# Obtenir la date de création du fichier HTML
|
||||||
last_html_build_time = os.path.getctime(html_path)
|
last_html_build_time = os.path.getctime(html_path)
|
||||||
|
|
||||||
print(f"last_html_build: {last_html_build_time} : {html_path}")
|
# print(f"last_html_build: {last_html_build_time} : {html_path}")
|
||||||
else:
|
else:
|
||||||
print(f"----------- last_html_build html_path: {html_path} n'existe pas")
|
print(f"----------- last_html_build html_path: {html_path} n'existe pas")
|
||||||
# Vérifier l'existence du fichier Gemini pour déterminer last_gemini_build
|
# Vérifier l'existence du fichier Gemini pour déterminer last_gemini_build
|
||||||
@ -158,7 +166,7 @@ if generate_linkings_json :
|
|||||||
rebuild_this_article_html = False
|
rebuild_this_article_html = False
|
||||||
if last_html_build_time:
|
if last_html_build_time:
|
||||||
file_modified_time = os.path.getmtime(file_path)
|
file_modified_time = os.path.getmtime(file_path)
|
||||||
print(f"--------- file_modified_time: {file_path} : {file_modified_time}")
|
# print(f"--------- file_modified_time: {file_path} : {file_modified_time}")
|
||||||
# Obtenir l'heure de dernière modification du fichier HTML
|
# Obtenir l'heure de dernière modification du fichier HTML
|
||||||
|
|
||||||
rebuild_this_article_html = file_modified_time > last_html_build_time
|
rebuild_this_article_html = file_modified_time > last_html_build_time
|
||||||
@ -172,7 +180,7 @@ if generate_linkings_json :
|
|||||||
if rebuild_this_article_html:
|
if rebuild_this_article_html:
|
||||||
rebuild_counter += 1
|
rebuild_counter += 1
|
||||||
|
|
||||||
if run_pandoc and rebuild_this_article_html:
|
if run_pandoc and rebuild_this_article_html or force_html_regen:
|
||||||
# convertir le contenu d'article org vers html
|
# convertir le contenu d'article org vers html
|
||||||
print(f"BRRRRRRRRRRRR pandoc time {time.strftime('%H:%M:%S')} : Conversion de {file_name} en html")
|
print(f"BRRRRRRRRRRRR pandoc time {time.strftime('%H:%M:%S')} : Conversion de {file_name} en html")
|
||||||
html_content = pypandoc.convert_text(content_without_h1, 'html', format='org')
|
html_content = pypandoc.convert_text(content_without_h1, 'html', format='org')
|
||||||
@ -221,15 +229,16 @@ template_content = get_blog_template_conf(args.blog)
|
|||||||
articles_roam_id_to_slugs = {info['roam_id']: slug for slug, info in files_dict.items()}
|
articles_roam_id_to_slugs = {info['roam_id']: slug for slug, info in files_dict.items()}
|
||||||
|
|
||||||
# Parcourir les articles de files_dict et ajouter une clé rewritten_roam_links_html là où un lien vers un identifiant roam est trouvé dans le html_content
|
# Parcourir les articles de files_dict et ajouter une clé rewritten_roam_links_html là où un lien vers un identifiant roam est trouvé dans le html_content
|
||||||
for slug, info in files_dict.items():
|
if enable_roam_id_rewrite:
|
||||||
html_content = info['html_content']
|
for slug, info in files_dict.items():
|
||||||
rewritten_html_content = html_content
|
html_content = info['html_content']
|
||||||
for roam_id, slug in articles_roam_id_to_slugs.items():
|
rewritten_html_content = html_content
|
||||||
if roam_id is not None and isinstance(rewritten_html_content, str) and roam_id in rewritten_html_content:
|
for roam_id, slug in articles_roam_id_to_slugs.items():
|
||||||
print(f'{roam_id} -> {slug}')
|
if roam_id is not None and isinstance(rewritten_html_content, str) and roam_id in rewritten_html_content:
|
||||||
rewritten_html_content = rewritten_html_content.replace(f'href="#{roam_id}"', f'href="{template_content["NDD"]}/{slug}"')
|
print(f'{roam_id} -> {slug}')
|
||||||
|
rewritten_html_content = rewritten_html_content.replace(f'href="#{roam_id}"', f'href="{template_content["NDD"]}/{slug}"')
|
||||||
info['rewritten_roam_links_html'] = rewritten_html_content
|
|
||||||
|
info['rewritten_roam_links_html'] = rewritten_html_content
|
||||||
|
|
||||||
|
|
||||||
# Ajouter les infos des articles suivant et précédent dans la liste des articles
|
# Ajouter les infos des articles suivant et précédent dans la liste des articles
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
:CUSTOM_ID: ça-donne-faim
|
:CUSTOM_ID: ça-donne-faim
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
[[https://tykayn.fr/wp-content/uploads/i/2013/10octobre/vraie_cuisine/g/lit_strip_vraie_cuisine.jpg][https://tykayn.fr/wp-content/uploads/i/2013/10octobre/vraie_cuisine/lit_strip_vraie_cuisine.jpg]]voilà
|
[[https://tykayn.fr/wp-content/uploads/i/2013/10octobre/vraie_cuisine/g/lit_strip_vraie_cuisine.jpg][https://tykayn.fr/wp-content/uploads/i/2013/10octobre/vraie_cuisine/lit_strip_vraie_cuisine.jpg]]
|
||||||
|
|
||||||
|
voilà
|
||||||
donc à quoi je suis occupé pour poster si peu par ici. mvoyez. La
|
donc à quoi je suis occupé pour poster si peu par ici. mvoyez. La
|
||||||
cuisine ça prend du temps.
|
cuisine ça prend du temps.
|
||||||
|
|
||||||
|
@ -87,6 +87,8 @@
|
|||||||
<div class="article-main-content">
|
<div class="article-main-content">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
|
{% set sorted_files = files|sort(reverse=true) %}
|
||||||
|
{% set files = sorted_files %}
|
||||||
{% for file in files %}
|
{% for file in files %}
|
||||||
{% if articles_info[file] %}
|
{% if articles_info[file] %}
|
||||||
<li>
|
<li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user