Glogger/create_feeds.py
2025-04-01 19:24:36 +01:00

34 lines
1.3 KiB
Python

import posts
import users
import config
def create_rss():
from datetime import datetime
with open(f"{config.webroot}/rss", "w") as main_rss_file:
file_content = f'''<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>{config.site_name}</title>
<link>{config.site_url}</title>
<description>{config.site_description}</description>
<pubDate>{datetime.now().strftime("%a, %d %b %Y %H:%M:%S %z")}</pubDate>
<lastBuildDate>{datetime.now().strftime("%a, %d %b %Y %H:%M:%S %z")}</lastBuildDate>
'''
for current_post_index in range(len(posts.posts)):
file_content += f'''
<item>
<title>{posts.posts[current_post_index]["title"]}</title>
<link>{config.site_url}/post/{current_post_index}.{config.file_extension}</link>
<description>{posts.posts[current_post_index]["content"]}</descriptiont>
<pubDate>{posts.posts[current_post_index]["pubdate"]}</pubDate>
<editDate>{posts.posts[current_post_index]["editdate"]}</editDate>
</item>'''
file_content += '''
</channel>
</rss>'''
main_rss_file.write(file_content)
def create_atom():
print("Atom generation under development")