aboutsummaryrefslogtreecommitdiff
path: root/cgi/post.py
diff options
context:
space:
mode:
Diffstat (limited to 'cgi/post.py')
-rw-r--r--cgi/post.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/cgi/post.py b/cgi/post.py
index c53e8a1..96b7cab 100644
--- a/cgi/post.py
+++ b/cgi/post.py
@@ -1080,11 +1080,13 @@ def cut_msg(message, limit):
def getLastAge(board_type, limit):
threads = []
+ sql = "SELECT posts.id, boards.name AS board_name, boards.subname AS board_abr, board_type, boards.dir, timestamp, bumped, length, CASE WHEN posts.subject = boards.subject THEN posts.message ELSE posts.subject END AS content FROM posts INNER JOIN boards ON boardid = boards.id WHERE parentid = 0 AND IS_DELETED = 0 AND boards.secret = 0 AND posts.locked < 3"
+
if board_type in [0, 1]:
- sql = "SELECT posts.id, boards.name AS board_fulln, boards.subname AS board_name, board_type, boards.dir, timestamp, length, CASE WHEN posts.subject = boards.subject THEN posts.message ELSE posts.subject END AS content FROM posts INNER JOIN boards ON boardid = boards.id WHERE parentid = 0 AND IS_DELETED = 0 AND boards.secret = 0 AND posts.locked < 3 AND boards.board_type = %s ORDER BY bumped DESC LIMIT %s"
+ sql += " AND boards.board_type = %s ORDER BY bumped DESC LIMIT %s"
threads = FetchAll(sql, (board_type, limit) )
else:
- sql = "SELECT posts.id, boards.name AS board_fulln, boards.subname AS board_name, board_type, boards.dir, timestamp, length, CASE WHEN posts.subject = boards.subject THEN posts.message ELSE posts.subject END AS content FROM posts INNER JOIN boards ON boardid = boards.id WHERE parentid = 0 AND IS_DELETED = 0 AND boards.secret = 0 AND posts.locked < 3 ORDER BY bumped DESC LIMIT %s"
+ sql += " ORDER BY bumped DESC LIMIT %s"
threads = FetchAll(sql, (limit,) )
for post in threads:
@@ -1098,7 +1100,7 @@ def getLastAge(board_type, limit):
return threads
def getNewPosts(limit, rss=False):
- sql = "SELECT posts.id, parentid, boardid, 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"
+ sql = "SELECT posts.id, parentid, boardid, boards.name AS board_name, 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:
@@ -1106,6 +1108,7 @@ def getNewPosts(limit, rss=False):
if rss:
post['timestamp_formatted'] = datetime.datetime.fromtimestamp(post['timestamp']).strftime('%Y-%m-%dT%H:%M:%S%Z')
+ post['content'] = cut_msg(post['message'], 100)
if post['board_type'] == 1:
post['url'] = '/%s/read/%d/l10' % (post['dir'], getParentTimestamp(post) or post['timestamp'])
@@ -1116,7 +1119,7 @@ def getNewPosts(limit, rss=False):
def getNewThreads(limit):
threads = []
- sql = "SELECT posts.id, boards.name AS board_fulln, boards.subname AS board_name, board_type, boards.dir, timestamp, CASE WHEN posts.subject = boards.subject THEN posts.message ELSE posts.subject END AS content FROM posts INNER JOIN boards ON boardid = boards.id WHERE parentid = 0 AND IS_DELETED = 0 AND boards.secret = 0 AND boards.id <> 13 AND posts.locked = 0 ORDER BY timestamp DESC LIMIT %s"
+ sql = "SELECT posts.id, boards.name AS board_name, boards.subname AS board_abr, board_type, boards.dir, timestamp, CASE WHEN posts.subject = boards.subject THEN posts.message ELSE posts.subject END AS content FROM posts INNER JOIN boards ON boardid = boards.id WHERE parentid = 0 AND IS_DELETED = 0 AND boards.secret = 0 AND boards.id <> 13 AND posts.locked = 0 ORDER BY timestamp DESC LIMIT %s"
threads = FetchAll(sql, (limit,) )
for post in threads:
@@ -1158,7 +1161,7 @@ def regenerateHome():
f.close()
if Settings.ENABLE_RSS:
- rss_rendered = renderTemplate('home.rss', {'posts': getNewPosts(10, True)} )
+ rss_rendered = renderTemplate('feed.rss', {'posts': getNewPosts(10, True)} )
f = open(Settings.HOME_DIR + "bai.rss", "w")
try:
f.write(rss_rendered)