+ if (num_blogposts > 0) {
+ int start_here = 0;
+ /* Sort newest-to-oldest */
+ qsort(blogposts, num_blogposts, sizeof(void *), blogview_sortfunc);
+
+ /* allow the user to select a starting point in the list */
+ for (i=0; i<num_blogposts; ++i) {
+ if (blogposts[i]->top_level_id == firstp) {
+ start_here = i;
+ }
+ }
+
+ /* FIXME -- allow the user (or a default setting) to select a maximum number of posts to display */
+
+ /* Now go through the list and render what we've got */
+ for (i=start_here; i<num_blogposts; ++i) {
+ if ((i > 0) && (i == start_here)) {
+ int j = i - maxp;
+ if (j < 0) j = 0;
+ wc_printf("<div class=\"newer_blog_posts\"><a href=\"readfwd?go=");
+ urlescputs(ChrPtr(WC->CurRoom.name));
+ wc_printf("?firstp=%d?maxp=%d\">", blogposts[j]->top_level_id, maxp);
+ wc_printf("%s →</a></div>\n", _("Newer posts"));
+ }
+ if (i < (start_here + maxp)) {
+ blogpost_render(blogposts[i], with_comments);
+ }
+ else if (i == (start_here + maxp)) {
+ wc_printf("<div class=\"older_blog_posts\"><a href=\"readfwd?go=");
+ urlescputs(ChrPtr(WC->CurRoom.name));
+ wc_printf("?firstp=%d?maxp=%d\">", blogposts[i]->top_level_id, maxp);
+ wc_printf("← %s</a></div>\n", _("Older posts"));
+ }
+ }
+
+ /* Done. We are only freeing the array of pointers; the data itself
+ * will be freed along with the hash list.
+ */
+ free(blogposts);
+ }