From 61cbae386b256bb6adb0adaa52cd00585a0820e2 Mon Sep 17 00:00:00 2001 From: nathansmith117 Date: Sun, 30 Mar 2025 21:50:32 -0600 Subject: Made blogging system better --- blog/generate.py | 59 -------------------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100755 blog/generate.py (limited to 'blog/generate.py') diff --git a/blog/generate.py b/blog/generate.py deleted file mode 100755 index 09c2320..0000000 --- a/blog/generate.py +++ /dev/null @@ -1,59 +0,0 @@ -#! /usr/bin/python3 - -""" -A script to generate html from the rss feed -""" - -import xml.etree.ElementTree as et - -# Generates a html table for the article -# I use table layout because fuck you -def make_article_table(article_info, article): - html_text = """ - - - -

{title}

--- {date}
{article}
- """ - - html_text = html_text.format( - title=article_info["title"], - date=article_info["pubDate"], - article=article - ) - - return html_text - -def main(): - tree = et.parse("feed.xml") - root = tree.getroot() - channel = root[0] - - template = "" - - # Open html template - with open("template.html", "r") as fp: - template = fp.read() - - article_html = "" - - # Get articles from rss - for item in channel.findall("item"): - article_info = { - "title": item.find("title").text, - "pubDate": item.find("pubDate").text - } - - article = item.find("description").text - - # Remove article tags. - article = article[article.find("
")+9::] - article = article[:article.find("
"):] - article_html += make_article_table(article_info, article) - - # Format the articles into the html - template = template.format(articles=article_html) - print(template) - -if __name__ == "__main__": - main() -- cgit v1.2.3