Process comments from a file

This commit is contained in:
mez 2025-07-16 20:15:53 +01:00
parent e03e20aabf
commit ca068b23f0
5 changed files with 41 additions and 9 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
build/*
commentslist.py
feed.xml
__pycache__/
secrets.py

View file

@ -13,22 +13,30 @@ for i in 20*.org; do
emacs --batch --no-site-file -l pre.el $i -l export.el -f org-html-export-to-html --kill
done
python3 comproc.py
for i in 20*.html; do
if test -f comm-$i; then
sed -i -e "/<!-- comments go here -->/{r comm-$i" -e "d}" $i
fi
done
python3 rssgen.py
for i in *.html; do
for i in 20*.html; do
thebase="${i%%.*}"
dirname=${thebase//"-"/}
mkdir build/$dirname
mv $i build/$dirname/index.html
done
mv readme.org tempfile
for i in *.org; do
for i in 20*.org; do
rm -f $i
done
mv tempfile readme.org
for i in comm*.html; do
rm -f $i
done
rclone copy build prazevps:/var/www/tre/public/notes -P

23
comproc.py Normal file
View file

@ -0,0 +1,23 @@
import datetime
import commentslist
commented = []
for comment in commentslist.comments:
commented.append(comment["slug"])
commented = sorted(list(dict.fromkeys(commented)))
for slug in commented:
thefile = open("comm-" + str(slug)[0:4] + "-" + str(slug)[4:6] + "-" + str(slug)[6:8] + ".html","w")
commno = 1
for comment in commentslist.comments:
if comment["slug"] == slug:
thefile.write("<div class=\"comments\">\n<h2>n° " + str(commno) + "</h2>\n<p class=\"commenttime\"><code>" + datetime.datetime.strftime(comment["date"],"%Y-%m-%d") + "</code></p>\n<p>" + comment["body"] + "</p>\n")
try:
if len(comment["reply"]) > 0:
thefile.write("<div class=\"reply\">\n<p><span class=\"replystring\">reply: </span>" + comment["reply"] + "</p>\n</div>\n")
except:
pass
thefile.write("</div>\n")
commno += 1
thefile.close()

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,6 @@
=secrets.py= should contain ~orgpath = "full path to journal root directory"~. With trailing slash it looks like.
=commentslist.py= should be symlinked into this folder.
* to do
- inject comments somehow (s’il y en a)