mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-06-20 09:04:42 +02:00
build with latest articles on homepage
This commit is contained in:
parent
e6ec57e576
commit
579e9116b7
22 changed files with 1013 additions and 3544 deletions
|
@ -27,18 +27,21 @@ org_files = []
|
|||
limit_articles_feed=1000
|
||||
count_articles=0
|
||||
print('atom generate: fichiers dans le dossier: ',len((blog_dir)))
|
||||
|
||||
# Parcourt le dossier source à la recherche de fichiers org-mode
|
||||
for root, dirs, files in os.walk(blog_dir):
|
||||
print('fichiers fr dans le dossier source',len(files))
|
||||
print(files)
|
||||
for file in files:
|
||||
if file.endswith(".org"):
|
||||
print(os.path.join(root, file))
|
||||
print("org: ",file)
|
||||
date_str, annee, slug = find_year_and_slug_on_filename(file)
|
||||
# Ouvre le fichier et recherche la première date dans le contenu de l'article
|
||||
with open(os.path.join(root, file), "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
extract = find_extract_in_content_org(content)
|
||||
count_articles+=1
|
||||
match = date_regex_org.search(content)
|
||||
match = date_regex_org.search(date_str)
|
||||
if match:
|
||||
date = datetime.strptime(match.group(1), "%Y-%m-%d")
|
||||
# Ajoute le fichier à la liste avec sa date correspondante
|
||||
|
@ -49,12 +52,15 @@ for root, dirs, files in os.walk(blog_dir):
|
|||
if count_articles > limit_articles_feed:
|
||||
break
|
||||
# Tri des fichiers par ordre décroissant de date
|
||||
print(org_files)
|
||||
org_files.sort(reverse=True)
|
||||
|
||||
print(org_files)
|
||||
print("org_files:",org_files)
|
||||
# Génération du flux Atom
|
||||
atom_feed = {"title": "Flux Atom des articles de "+args.blog_dir,
|
||||
"link": f"{website_ndd}/feed",
|
||||
# "updated": org_files[0][0].strftime("%Y-%m-%dT%H:%M:%SZ"),
|
||||
# "updated": org_files[0][0],
|
||||
"updated": org_files[0][0],
|
||||
"entries": []}
|
||||
|
||||
|
@ -100,21 +106,20 @@ with open(f"index_{args.blog_dir}.xml", "w", encoding="utf-8") as f:
|
|||
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"].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>')
|
||||
|
||||
os.rename(f"index_{args.blog_dir}.xml", f"html-websites/{args.blog_dir}/feed/index.xml")
|
||||
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"].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(f" <name>{configs_sites[args.blog_dir]['AUTHOR']}</name>\n")
|
||||
f.write(f" <email>{configs_sites[args.blog_dir]['EMAIL']}</email>\n")
|
||||
f.write(' </author>\n')
|
||||
f.write(' </entry>\n')
|
||||
f.write('</feed>')
|
||||
# os.rename(f"index_{args.blog_dir}.xml", f"html-websites/{args.blog_dir}/feed/index.xml")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue