savetheinternet/Tinyboard — pull request #57 by Macil (2012-07-11 22:12:45+00:00)
Title: Adds "View Last 50 Posts" pages

This makes it so by default, if a thread goes over 100 posts (configurable), a separate page to view the last 50 posts (configurable) is added. I've called this feature in the code and config "noko50" after the feature of some other boards, though "noko50" isn't actually something interpreted in the email field, and the number of posts on the "View Last X Posts" page is configurable.

Every time a post is made to a thread, it's checked whether the thread has over 100 posts or if the noko50 page already exists ("%d+50.html" by default), and if so, it's updated. (This is so if a lot of posts are deleted from a thread bringing it back down below 100 posts, the noko50 page doesn't need to be deleted, and anyone on the noko50 page with a page auto-updating script isn't left in the dust.)

When building the noko50 page, the $thread object used to build the full thread page is re-used. For cases where the noko50 page needs to be generated without the full thread page (like from the mod interface), SQL is done similarly to how thread index previews are made that only gets the most recent 50 posts. The SQL in both of those places probably ought to be consolidated into a single function somewhere due to the similarities.