mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-06-20 09:04:42 +02:00
script de stats
This commit is contained in:
parent
6d77de4696
commit
759f30f628
7 changed files with 196 additions and 109 deletions
|
@ -121,18 +121,47 @@ if generate_linkings_json :
|
|||
|
||||
gemini_content = ''
|
||||
html_content = ''
|
||||
# Vérifier l'existence du fichier HTML pour déterminer last_html_build
|
||||
html_path = f"html_websites/{args.blog}/{annee}/{slug}/index.html"
|
||||
last_html_build = None
|
||||
if os.path.exists(html_path):
|
||||
last_html_build = time.ctime(os.path.getmtime(html_path))
|
||||
# Vérifier l'existence du fichier Gemini pour déterminer last_gemini_build
|
||||
gemini_path = f"gemini-capsules/{args.blog}/{slug}.gmi"
|
||||
last_gemini_build = None
|
||||
rebuild_this_article_gemini = False
|
||||
if os.path.exists(gemini_path):
|
||||
last_gemini_build = time.ctime(os.path.getmtime(gemini_path))
|
||||
# Vérifier si l'article doit être reconstruit en comparant les dates de modification
|
||||
if last_gemini_build:
|
||||
file_modified_time = os.path.getmtime(file_path)
|
||||
last_build_time = time.mktime(time.strptime(last_gemini_build))
|
||||
rebuild_this_article_gemini = file_modified_time > last_build_time
|
||||
else:
|
||||
rebuild_this_article_gemini = True
|
||||
|
||||
if run_pandoc:
|
||||
# Vérifier si l'article doit être reconstruit en comparant les dates de modification
|
||||
rebuild_this_article_html = False
|
||||
if last_html_build:
|
||||
file_modified_time = os.path.getmtime(file_path)
|
||||
last_build_time = time.mktime(time.strptime(last_html_build))
|
||||
rebuild_this_article_html = file_modified_time > last_build_time
|
||||
else:
|
||||
rebuild_this_article_html = True
|
||||
|
||||
if run_pandoc and rebuild_this_article_html:
|
||||
# convertir le contenu d'article org vers html
|
||||
html_content = pypandoc.convert_text(content_without_h1, 'html', format='org')
|
||||
else:
|
||||
html_content = content_without_h1
|
||||
|
||||
if run_gemini:
|
||||
if run_gemini and rebuild_this_article_gemini:
|
||||
os.makedirs(destination_gmi, exist_ok=True)
|
||||
# convertir le contenu d'article org vers gmi pour la capsule gemini
|
||||
gemini_content = org_to_gmi(content_without_h1, slug)
|
||||
|
||||
|
||||
|
||||
files_dict[f"{annee}/{slug}"] = {
|
||||
'path': file_path,
|
||||
'basename': basename,
|
||||
|
@ -148,6 +177,7 @@ if generate_linkings_json :
|
|||
'title': title,
|
||||
'next': None,
|
||||
'previous': None,
|
||||
'last_html_build': last_html_build
|
||||
'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': html_content # Contenu HTML converti
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue