aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar neptune 2022-12-27 08:25:04 -0300
committerLibravatar neptune 2022-12-27 08:25:04 -0300
commitbe1daf645af908863fbb012e889979f2ef1aed48 (patch)
treecf0ea2b53f3b308ce330c7e9b0092914facd0e15
parent15242f613190f053c541679b61f5db293f79b98a (diff)
downloadweabot-be1daf645af908863fbb012e889979f2ef1aed48.tar.gz
weabot-be1daf645af908863fbb012e889979f2ef1aed48.tar.xz
weabot-be1daf645af908863fbb012e889979f2ef1aed48.zip
a
-rw-r--r--cgi/post.py24
-rw-r--r--cgi/templates/home.rss1
2 files changed, 20 insertions, 5 deletions
diff --git a/cgi/post.py b/cgi/post.py
index ba08ad2..b84b753 100644
--- a/cgi/post.py
+++ b/cgi/post.py
@@ -1016,7 +1016,7 @@ def cut_msg(message, limit):
short_message = re.compile(r"&(.(?!;))*$", re.DOTALL | re.IGNORECASE).sub("", short_message) # Removes incomplete HTML
return short_message
-def getLastAge(board_type, limit, rss=False):
+def getLastAge(board_type, limit):
threads = []
if board_type in [0, 1]:
@@ -1029,15 +1029,29 @@ def getLastAge(board_type, limit, rss=False):
for post in threads:
post['content'] = cut_msg(post['content'], Settings.HOME_LASTPOSTS_LENGTH)
- if rss:
- post['timestamp_formatted'] = datetime.datetime.fromtimestamp(post['timestamp']).strftime('%Y-%m-%dT%H:%M:%S%Z')
-
if post['board_type'] == 1:
post['url'] = '/%s/read/%d/l10' % (post['dir'], post['timestamp'])
else:
post['url'] = '/%s/res/%d.html' % (post['dir'], post['id'])
return threads
+
+def getNewPosts(limit, rss=False):
+ sql = "SELECT posts.id, boards.name AS board_fulln, board_type, boards.dir, timestamp, posts.message FROM posts INNER JOIN boards ON posts.boardid = boards.id WHERE IS_DELETED = 0 AND boards.secret = 0 ORDER BY timestamp DESC LIMIT %s"
+ posts = FetchAll(sql, (limit,))
+
+ for post in posts:
+ post['content'] = cut_msg(post['message'], Settings.HOME_LASTPOSTS_LENGTH)
+
+ if rss:
+ post['timestamp_formatted'] = datetime.datetime.fromtimestamp(post['timestamp']).strftime('%Y-%m-%dT%H:%M:%S%Z')
+
+ if post['board_type'] == 1:
+ post['url'] = '/%s/read/%d/l10' % (post['dir'], post['timestamp'])
+ else:
+ post['url'] = '/%s/res/%d.html' % (post['dir'], post['id'])
+
+ return posts
def getNewThreads(limit):
threads = []
@@ -1083,7 +1097,7 @@ def regenerateHome():
f.close()
if Settings.ENABLE_RSS:
- rss_rendered = renderTemplate('home.rss', {'posts': getLastAge(-1, 10, True)} )
+ rss_rendered = renderTemplate('home.rss', {'posts': getNewPosts(10, True)} )
f = open(Settings.HOME_DIR + "bai.rss", "w")
try:
f.write(rss_rendered)
diff --git a/cgi/templates/home.rss b/cgi/templates/home.rss
index d293861..1e5f552 100644
--- a/cgi/templates/home.rss
+++ b/cgi/templates/home.rss
@@ -18,6 +18,7 @@
<title>${post['board_fulln']}: #{post['content']}</title>
<pubDate>${post['timestamp_formatted']}</pubDate>
<link>https://bienvenidoainternet.org#{post['url']}</link>
+ <description>${post['message']}</description>
</item>
<?py #endfor ?>
</channel>