mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-06-20 09:04:42 +02:00
do not recreate not modified files already built by default
This commit is contained in:
parent
e1f8bf93e0
commit
17e935a3ca
3 changed files with 36 additions and 15 deletions
|
@ -95,6 +95,8 @@ Navigation:
|
||||||
if generate_linkings_json :
|
if generate_linkings_json :
|
||||||
count_articles = len(os.listdir(directory))
|
count_articles = len(os.listdir(directory))
|
||||||
counter=0
|
counter=0
|
||||||
|
rebuild_counter = 0
|
||||||
|
pandoc_runs_counter = 0
|
||||||
|
|
||||||
print(f"Génération des liens entre articles pour {count_articles} articles")
|
print(f"Génération des liens entre articles pour {count_articles} articles")
|
||||||
print(f"run_pandoc: {run_pandoc}")
|
print(f"run_pandoc: {run_pandoc}")
|
||||||
|
@ -128,10 +130,15 @@ if generate_linkings_json :
|
||||||
gemini_content = ''
|
gemini_content = ''
|
||||||
html_content = ''
|
html_content = ''
|
||||||
# Vérifier l'existence du fichier HTML pour déterminer last_html_build
|
# Vérifier l'existence du fichier HTML pour déterminer last_html_build
|
||||||
html_path = f"html_websites/{args.blog}/{annee}/{slug}/index.html"
|
html_path = f"html-websites/{args.blog}/{annee}/{slug}/index.html"
|
||||||
last_html_build = None
|
last_html_build_time = None
|
||||||
if os.path.exists(html_path):
|
if os.path.exists(html_path):
|
||||||
last_html_build = time.ctime(os.path.getmtime(html_path))
|
# Obtenir la date de création du fichier HTML
|
||||||
|
last_html_build_time = os.path.getctime(html_path)
|
||||||
|
|
||||||
|
print(f"last_html_build: {last_html_build_time} : {html_path}")
|
||||||
|
else:
|
||||||
|
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
|
||||||
gemini_path = f"gemini-capsules/{args.blog}/{slug}.gmi"
|
gemini_path = f"gemini-capsules/{args.blog}/{slug}.gmi"
|
||||||
last_gemini_build = None
|
last_gemini_build = None
|
||||||
|
@ -144,21 +151,32 @@ if generate_linkings_json :
|
||||||
last_build_time = time.mktime(time.strptime(last_gemini_build))
|
last_build_time = time.mktime(time.strptime(last_gemini_build))
|
||||||
rebuild_this_article_gemini = file_modified_time > last_build_time
|
rebuild_this_article_gemini = file_modified_time > last_build_time
|
||||||
else:
|
else:
|
||||||
|
|
||||||
rebuild_this_article_gemini = True
|
rebuild_this_article_gemini = True
|
||||||
|
|
||||||
# Vérifier si l'article doit être reconstruit en comparant les dates de modification
|
# Vérifier si l'article doit être reconstruit en comparant les dates de modification
|
||||||
rebuild_this_article_html = False
|
rebuild_this_article_html = False
|
||||||
if last_html_build:
|
if last_html_build_time:
|
||||||
file_modified_time = os.path.getmtime(file_path)
|
file_modified_time = os.path.getmtime(file_path)
|
||||||
last_build_time = time.mktime(time.strptime(last_html_build))
|
print(f"--------- file_modified_time: {file_path} : {file_modified_time}")
|
||||||
rebuild_this_article_html = file_modified_time > last_build_time
|
# Obtenir l'heure de dernière modification du fichier HTML
|
||||||
|
|
||||||
|
rebuild_this_article_html = file_modified_time > last_html_build_time
|
||||||
|
# print(f"--------- article modifié après le build de son rendu html: {file_path}, {rebuild_this_article_html}")
|
||||||
else:
|
else:
|
||||||
|
# si il n'y a pas de fichier html, on le construit pour la première fois
|
||||||
|
print('on reconstruit le html de l\'article', file_name)
|
||||||
|
|
||||||
rebuild_this_article_html = True
|
rebuild_this_article_html = True
|
||||||
|
|
||||||
|
if rebuild_this_article_html:
|
||||||
|
rebuild_counter += 1
|
||||||
|
|
||||||
if run_pandoc and rebuild_this_article_html:
|
if run_pandoc and rebuild_this_article_html:
|
||||||
# convertir le contenu d'article org vers html
|
# convertir le contenu d'article org vers html
|
||||||
print(f"{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')
|
||||||
|
pandoc_runs_counter += 1
|
||||||
else:
|
else:
|
||||||
html_content = content_without_h1
|
html_content = content_without_h1
|
||||||
|
|
||||||
|
@ -184,13 +202,15 @@ if generate_linkings_json :
|
||||||
'title': title,
|
'title': title,
|
||||||
'next': None,
|
'next': None,
|
||||||
'previous': None,
|
'previous': None,
|
||||||
'last_html_build': last_html_build,
|
'last_html_build': last_html_build_time,
|
||||||
'last_gemini_build': last_gemini_build,
|
'last_gemini_build': last_gemini_build,
|
||||||
'org_content': content, # Contenu Org original
|
'org_content': content, # Contenu Org original
|
||||||
'html_content_without_h1': re.sub(r'<h1>.*?</h1>', '', html_content), # Contenu HTML converti sans le titre de premier niveau
|
'html_content_without_h1': re.sub(r'<h1>.*?</h1>', '', html_content), # Contenu HTML converti sans le titre de premier niveau
|
||||||
'html_content': html_content # Contenu first_picture_urlHTML converti
|
'html_content': html_content # Contenu first_picture_urlHTML converti
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print(f"======= Nombre d'articles reconstruits: {rebuild_counter}")
|
||||||
|
print(f"======= Nombre de runs de pandoc: {pandoc_runs_counter}")
|
||||||
# Trier les basenames par ordre décroissant
|
# Trier les basenames par ordre décroissant
|
||||||
sorted_basenames = sorted(files_dict.keys(), reverse=True)
|
sorted_basenames = sorted(files_dict.keys(), reverse=True)
|
||||||
print(len(sorted_basenames), 'articles trouvés')
|
print(len(sorted_basenames), 'articles trouvés')
|
||||||
|
|
|
@ -23,13 +23,13 @@ Définir le temps que l'on souhaite consacrer.
|
||||||
Causer avec les autres contributeurs **avant** de se lancer dans le moindre travail, c'est super important si on veut éviter les frustrations.
|
Causer avec les autres contributeurs **avant** de se lancer dans le moindre travail, c'est super important si on veut éviter les frustrations.
|
||||||
Ne surtout pas se lancer dans douze fonctionnalités à la fois.
|
Ne surtout pas se lancer dans douze fonctionnalités à la fois.
|
||||||
|
|
||||||
Plan d'action
|
** Plan d'action
|
||||||
|
|
||||||
* Proposer de faire un truc
|
- Proposer de faire un truc
|
||||||
* Le réviser
|
- Le réviser
|
||||||
* Voir sa contribution approuvée par l'équipe, ou pas
|
- Voir sa contribution approuvée par l'équipe, ou pas
|
||||||
* ???
|
- ???
|
||||||
* profit (heu lol)
|
- profit (heu lol)
|
||||||
|
|
||||||
Liens:
|
Liens:
|
||||||
|
|
||||||
|
|
|
@ -316,7 +316,8 @@ Je vous donne mes sources sur [[https://we.tl/t-Ubd7Pil4Np][ce lien]] (attention
|
||||||
|
|
||||||
|
|
||||||
* *Annexe*
|
* *Annexe*
|
||||||
|
oh yeah
|
||||||
|
oh right
|
||||||
[[https://miro.medium.com/v2/resize:fit:629/1*1Iepu71t1QQjOppTrNy7OQ.png]]
|
[[https://miro.medium.com/v2/resize:fit:629/1*1Iepu71t1QQjOppTrNy7OQ.png]]
|
||||||
|
|
||||||
[[https://medium.com/tag/nuclearource=post_page-----f82c1d15ed58--------------------------------][Nuclear]]
|
[[https://medium.com/tag/nuclearource=post_page-----f82c1d15ed58--------------------------------][Nuclear]]
|
Loading…
Add table
Add a link
Reference in a new issue