diff --git a/.gitignore b/.gitignore
index 748776a..e345553 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
build/*
+feed.xml
__pycache__/
-secrets.py
\ No newline at end of file
+secrets.py
+therss.py
\ No newline at end of file
diff --git a/build.sh b/build.sh
index a59ceba..ccc3175 100755
--- a/build.sh
+++ b/build.sh
@@ -2,6 +2,8 @@
rm -rf build
+rm -f feed.xml
+
mkdir build
python3 identify.py
@@ -11,6 +13,8 @@ for i in 20*.org; do
emacs --batch -l pre.el $i -l export.el -f org-html-export-to-html --kill
done
+python3 rssgen.py
+
for i in *.html; do
thebase="${i%%.*}"
dirname=${thebase//"-"/}
@@ -28,5 +32,7 @@ mv tempfile readme.org
rclone copy build prazevps:/var/www/tre/public/notes -P
+rclone copyto feed.xml prazevps:/var/www/tre/public/feed.xml -P
+
current_date=$(date +"%Y%m%d")
curl -i -d "source=https://tre.praze.net/notes/$current_date&target=https://fed.brid.gy/" https://fed.brid.gy/webmention
diff --git a/identify.py b/identify.py
index 577ea22..342fb97 100644
--- a/identify.py
+++ b/identify.py
@@ -26,6 +26,7 @@ while year < int(thisyear) + 1:
year = year + 1
posts = []
+rss = []
for file in concernedfiles:
filedate = file[-14:-4]
@@ -34,7 +35,28 @@ for file in concernedfiles:
for node in parsefile.children:
if node.heading == "site":
for post in node.children:
- if "post" in post.tags:
+ if "update" in post.tags:
+ thedict = {}
+ thedict["title"] = post.heading
+ thedict["desc"] = post.get_body(format="raw")
+ thedict["date"] = filedate
+ try:
+ thedict["time"] = post.properties["time"]
+ except:
+ pass
+ try:
+ if post.properties["url"] == "/index.html":
+ thedict["url"] = "https://tre.praze.net"
+ else:
+ thedict["url"] = "https://tre.praze.net" + post.properties["url"]
+ except:
+ pass
+ try:
+ thedict["categories"] = post.properties["categories"].split(",")
+ except:
+ pass
+ rss.append(thedict)
+ elif "post" in post.tags:
writefile = open(filedate + ".org","w")
writefile.write("#+TITLE: " + post.heading + "\n#+REALTITLE: " + post.properties["realtitle"] + "\n#+OGDESC: " + post.properties["ogdesc"]+ "\n#+CATEGORY: " + post.properties["category"] + "\n#+COMMENTS: " + post.properties["comments"] + "\n")
try:
@@ -54,8 +76,13 @@ for file in concernedfiles:
pass
writefile.close()
thedict = {}
+ thedict["title"] = post.heading
thedict["real"] = post.properties["realtitle"]
thedict["date"] = filedate
+ try:
+ thedict["time"] = post.properties["time"]
+ except:
+ pass
if post.properties["category"] == "reminding myself how to do stuff":
thedict["category"] = "techbro"
elif post.properties["category"] == "writing notes":
@@ -71,11 +98,45 @@ for file in concernedfiles:
except:
pass
posts.append(thedict)
+ rss.append(thedict)
except:
pass
posts = sorted(posts,key=lambda d: d["date"],reverse=True)
+for entry in rss:
+ try:
+ entry["combinedate"] = entry["date"] + " " + entry["time"]
+ except:
+ entry["combinedate"] = entry["date"] + " 03:00:00"
+ try:
+ if entry["category"]:
+ postcats = []
+ postcats.append("post")
+ postcats.append(entry["category"])
+ entry["categories"] = postcats
+ except:
+ pass
+ try:
+ if "post" in entry["categories"]:
+ entry["url"] = "https://tre.praze.net/notes/" + re.sub("-","",entry["date"])
+ entry["desc"] = "placeholder"
+ except:
+ pass
+ try:
+ if entry["real"]:
+ entry["real"] = re.sub("<[^<]+?>","",entry["real"])
+ except:
+ pass
+ entry["rssdatetime"] = datetime.strftime((datetime.strptime(entry["combinedate"],"%Y-%m-%d %H:%M:%S")),"%a, %d %b %Y %H:%M:%S +0000")
+rss = sorted(rss,key=lambda d: d["combinedate"],reverse=True)
+
+writersslist = open("therss.py","w")
+
+writersslist.write("rss = " + str(rss))
+
+writersslist.close()
+
writeindex = open("build/index.html","w")
writeindex.write("\n\n
\n \n \npraze • Notes \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n\n\n \nMenu \n\nFundamentals\n\n \nProjects\n\n \nFan content\n\n \nMisc.\n\n \n \n \n\n
\n\nNotes \nThis is the part of the site where I post long-ish-form writing I seem to have the embarrassing need to share … I guess you’d call it a blog.
\nPosts are listed in reverse chronological order. Please be aware of posting dates – my opinions are constantly changing and evolving, and the longer ago something was written, the more likely it is that I’ll have since come to disagree with it completely … or in the case of more technical stuff, details may simply be out of date.
\nSome of these posts were originally made on a now-deleted Dreamwidth account. Toggle the boxes to show/hide posts in the relevant category.
\n \nJournal memes \n \nMonthly roundup \n \nReminding myself how to do stuff \n \nRevues \n \nTumblr tag games \n \nWriting notes \n\n")
diff --git a/readme.org b/readme.org
index b0d5dc7..fceaf30 100644
--- a/readme.org
+++ b/readme.org
@@ -1,5 +1,4 @@
=secrets.py= should contain ~orgpath = "full path to journal root directory"~.
* to do
-- rss feed
- inject comments somehow (s’il y en a)
diff --git a/rssgen.py b/rssgen.py
new file mode 100644
index 0000000..3e30567
--- /dev/null
+++ b/rssgen.py
@@ -0,0 +1,42 @@
+import therss
+import re
+from bs4 import BeautifulSoup
+
+writerss = open("feed.xml","w")
+
+writerss.write("\n\n\n \n \n tre.praze.net \n https://tre.praze.net\n A feed for general updates at tre.praze.net \n en-gb \n")
+
+rssno = len(therss.rss)
+
+for entry in therss.rss:
+ writerss.write(" - \n")
+ try:
+ if entry["real"]:
+ writerss.write("
" + entry["real"] + " \n")
+ except:
+ writerss.write(" " + entry["title"] + " \n")
+ writerss.write(" " + entry["rssdatetime"] + " \n " + entry["url"] + "\n tre" + str(rssno) + " \n ")
+ if entry["desc"] == "placeholder":
+ htmlfile = open(entry["date"] + ".html","r")
+ soup = BeautifulSoup(htmlfile,features="lxml")
+ thepost = soup.find("div",class_="e-content")
+ try:
+ thetitle = soup.find("h1",class_="p-name")
+ writerss.write("","\">",re.sub("\n","",str(thepost)))))) + "]]>")
+ except:
+ writerss.write("","\">",re.sub("\n","",str(thepost)))))) + "]]>")
+ else:
+ writerss.write(entry["desc"])
+ writerss.write(" \n")
+ try:
+ for category in entry["categories"]:
+ writerss.write(" " + category + " \n")
+ except:
+ pass
+ writerss.write(" \n")
+ rssno -= 1
+
+writerss.write(" \n ")
+
+writerss.close()
+