From 8ce59823a22dc51a4e671bb863a9c7544850f2a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Sun, 24 Mar 2024 20:21:56 +0000 Subject: [PATCH] Add basic RSS feed functionality --- README.org | 1 + history.py | 13 +++++++++++-- skeleton.py | 2 +- variables-template.py | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index e20e2fa..2822412 100644 --- a/README.org +++ b/README.org @@ -12,6 +12,7 @@ Rename =variables-template.py= to =variables.py= and edit: - =orgpath=: absolute path to the root directory in which =.org= files are stored, including trailing slash - =localpath=: absolute path to this directory, including trailing slash - =serverpath=: path to directory on the server where files will be uploaded, including trailing slash +- =domain=: =https://yourdomain.tld= without trailing slash - =rclonesiteroot=: path =rclone= uses to access your webserver - =description=: content for the “about” section (can include HTML tags) - =hue=: theme colour expressed as a hue from 0 to 360 diff --git a/history.py b/history.py index 4680b40..ca6f775 100644 --- a/history.py +++ b/history.py @@ -3,15 +3,17 @@ import gamesort,skeleton,variables from datetime import datetime,timedelta """ -Generates history page +Generates history page and RSS feed """ def history(local=False): - # delete existing file + # delete existing files if not os.path.isdir("build/history"): os.mkdir("build/history") if os.path.exists("build/history/index.html"): os.remove("build/history/index.html") + if os.path.exists("build/feed.xml"): + os.remove("build/feed.xml") # write header skeleton.headerwrite("build/history/index.html","history",local) output = "build/history/index.html" @@ -19,6 +21,9 @@ def history(local=False): filewrite.write("
\n
\n") + feedwrite = open("build/feed.xml", "a") + feedwrite.write("\n\n \n \n Static backlog\n " + variables.domain + variables.serverpath + "backlog\n Feed for gaming updates\n en-gb") + theyear = int(gamesort.thisyear) while theyear > 2016: yearlist = [] @@ -60,9 +65,13 @@ def history(local=False): else: filewrite.write(event["action"]) filewrite.write("\">
\n \n
" + event["name"] + "\n (" + event["console"] + ")\n
\n \n \n") + feedwrite.write(" \n " + event["action"] + " " + event["name"] + " (" + event["console"] + ")\n " + event["date"].strftime("%a, %-d %b %Y") + " 00:00:00 UT\n " + variables.domain + variables.serverpath + "history\n " + event["action"] + "-" + event["name"].replace(" ","-") + "-" + event["console"] + "\n " + event["action"] + " " + event["name"] + " (" + event["console"] + ")\n \n") checkdate = event["date"] theyear -= 1 + feedwrite.write(" \n") + feedwrite.close() + filewrite.write(" \n") theyear = int(gamesort.thisyear) diff --git a/skeleton.py b/skeleton.py index 6785a70..fcfdfe4 100644 --- a/skeleton.py +++ b/skeleton.py @@ -14,7 +14,7 @@ def headerwrite(output,section,local=False): hexstring = "" for element in rgb: hexstring += str(hex(int(element * 255)))[2:] - header.write("\n\n \n \n \n \n \n \n Static backlog\n \n\n \n \n \n \n \n \n Static backlog\n \n