fix date format and author

This commit is contained in:
Tykayn 2025-01-03 22:58:47 +01:00 committed by tykayn
parent dcc9d000fb
commit 7632976b93
2 changed files with 53 additions and 2 deletions

View file

@ -75,19 +75,45 @@ for date, file, annee, slug, extract in org_files:
# if published > atom_feed["updated"]:
# atom_feed["updated"] = published
# Enregistrement du flux Atom dans un fichier
# Enregistrement du flux Atom dans un fichier XML
# Le flux Atom doit contenir:
# - Un ID unique pour le flux et chaque entrée
# - Une balise author avec name et email
# - Les dates au format ISO 8601 avec timezone
# - Un lien self vers le fichier XML
with open(f"index_{args.blog_dir}.xml", "w", encoding="utf-8") as f:
f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
f.write('<feed xmlns="http://www.w3.org/2005/Atom">\n')
f.write(f' <title>{atom_feed["title"]}</title>\n')
f.write(f' <link href="{atom_feed["link"]}"/>\n')
f.write(f' <updated>{atom_feed["updated"]}</updated>\n')
f.write(' <id>tag:' + website_ndd + ',2023:/feed</id>\n')
f.write(' <author>\n')
f.write(' <name>Auteur du blog</name>\n')
f.write(' <email>auteur@example.com</email>\n')
f.write(' </author>\n')
f.write(f' <link rel="self" href="{website_ndd}/feed"/>\n')
for entry in atom_feed["entries"]:
slug_id = entry["title"].lower().replace(" ", "-").replace("'", "-").replace("--", "-")
# Lire le contenu complet du fichier
with open(file, "r", encoding="utf-8") as article_file:
article_content = article_file.read()
f.write(' <entry>\n')
f.write(f' <id>tag:{website_ndd},2023:{entry["link"]}</id>\n')
f.write(f' <title>{entry["title"]}</title>\n')
f.write(f' <link href="{entry["link"]}"/>\n')
f.write(' <content type="html"><![CDATA[\n')
f.write(f' {article_content}\n')
f.write(' ]]></content>\n')
f.write(f' <summary>{entry["summary"]}</summary>\n')
f.write(f' <published>{entry["published"]}</published>\n')
f.write(f' <published>{entry["published"].strftime("%Y-%m-%dT%H:%M:%S+00:00")}</published>\n')
f.write(f' <updated>{entry["published"].strftime("%Y-%m-%dT%H:%M:%S+00:00")}</updated>\n')
f.write(' <author>\n')
f.write(' <name>{configs_sites[args.blog_dir]["AUTHOR"]}</name>\n')
f.write(' <email>{configs_sites[args.blog_dir]["EMAIL"]}</email>\n')
f.write(' </author>\n')
f.write(' </entry>\n')
f.write('</feed>')