diff options
Diffstat (limited to 'blog')
| -rw-r--r-- | blog/articles/test.xml | 8 | ||||
| -rw-r--r-- | blog/feed.xml | 31 | ||||
| -rwxr-xr-x | blog/generate.py | 30 | ||||
| -rw-r--r-- | blog/template.html | 46 | 
4 files changed, 115 insertions, 0 deletions
diff --git a/blog/articles/test.xml b/blog/articles/test.xml new file mode 100644 index 0000000..51d440b --- /dev/null +++ b/blog/articles/test.xml @@ -0,0 +1,8 @@ +<article> +  <header> +    <h1>Over thinking</h1> +    <p> +      I over think a lot tbh. +    </p> +  </header> +</article> diff --git a/blog/feed.xml b/blog/feed.xml new file mode 100644 index 0000000..a504f41 --- /dev/null +++ b/blog/feed.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<rss version="2.0"> +  <channel> +    <title>Nathan's shitty blog</title> +    <description>The coffee powered blog of chaos</description> +    <link>http://nathansmith117.beevomit.org/blog</link> +    <image> +      <url>http://nathansmith117.bevomit.org/images/icon.png</url> +      <title>Nathan's shitty blog</title> +      <link>http://nathansmith117.beevomit.org</link> +    </image> + +    <item> +      <title>test post</title> +      <link>http://nathansmith117.bevomit.or/blog</link> +      <pubDate>Sat, 29 Mar 2025 00:00:00 GMT</pubDate> +      <description> +        <![CDATA[ +<article> +  <header> +    <h1>Over thinking</h1> +    <p> +      I over think a lot tbh. +    </p> +  </header> +</article> +        ]]> +      </description> +    </item> +  </channel> +</rss> diff --git a/blog/generate.py b/blog/generate.py new file mode 100755 index 0000000..3471ef9 --- /dev/null +++ b/blog/generate.py @@ -0,0 +1,30 @@ +#! /usr/bin/python3 + +""" +A script to generate html from the rss feed +""" + +import xml.etree.ElementTree as et + +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() + +    # Get articles from rss +    for item in channel.findall("item"): +        article = item.find("description").text + +        # Remove article tags. +        article = article[article.find("<article>")+9::] +        article = article[:article.find("</article>"):] +        print(article) + +if __name__ == "__main__": +    main() diff --git a/blog/template.html b/blog/template.html new file mode 100644 index 0000000..719d3f3 --- /dev/null +++ b/blog/template.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<html> +  +<head> +    <title>Nathan's shitty blog</title> +    <link rel="alternate" type="application/rss+xml" title="Nathan's shitty blog" href="feed.xml"> + +<style> +     +body { +    color: black; +    background-image: url(''); +} + +table { +	color: black; +	background-color: #bebebe; +	margin-top: 10px; +	margin-bottom: 10px; +	margin-left: 10px; +	margin-right: 10px; +} + +</style> + +</head> +  +<body> +    <a href="index.html"><img src="../images/back_home.png" alt="Back to home page"/></a> +     +    <center> +        <table border="1" width="60%"> +        	<tr> +        		<td> +                    <h1>Nathan's shitty blog</h1> +                    <p> +                    </p> +                </td> +            </tr> +        </table> + +        <!-- Python will insert the articles from rss here --> +        {articles} +    </center> +</body> +</html>  | 
