From 7178ddb5e858af2ebff93944c2e09b671a85ceb2 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 6 Jun 2011 12:42:06 -0400 Subject: [PATCH] blogview: allow 'firstp=' parameter to determine where to start reading --- webcit/blogview_renderer.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/webcit/blogview_renderer.c b/webcit/blogview_renderer.c index 16a5116be..83a835988 100644 --- a/webcit/blogview_renderer.c +++ b/webcit/blogview_renderer.c @@ -249,10 +249,16 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper) int num_blogposts = 0; int num_blogposts_alloc = 0; int with_comments = 0; + int firstp = 0; + int maxp = 0; /* Comments are shown if we are only viewing a single blog post */ if (atoi(BSTR("p"))) with_comments = 1; + firstp = atoi(BSTR("firstp")); /* start reading at... */ + maxp = atoi(BSTR("maxp")); /* max posts to show... */ + if (maxp < 1) maxp = 5; /* default; move somewhere else? */ + /* Iterate through the hash list and copy the data pointers into an array */ it = GetNewHashPos(BLOG, 0); while (GetNextHashPos(BLOG, it, &len, &Key, &Data)) { @@ -273,16 +279,21 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper) * which they point are still owned by the hash list. */ if (num_blogposts > 0) { - /* Sort newest-to-oldest */ qsort(blogposts, num_blogposts, sizeof(void *), blogview_sortfunc); - /* FIXME -- allow the user to select a starting point in the list */ + /* allow the user to select a starting point in the list */ + int start_here = 0; + for (i=0; itop_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=0; i