From: Art Cancro Date: Mon, 6 Jun 2011 16:42:06 +0000 (-0400) Subject: blogview: allow 'firstp=' parameter to determine where to start reading X-Git-Tag: v8.11~667 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=7178ddb5e858af2ebff93944c2e09b671a85ceb2 blogview: allow 'firstp=' parameter to determine where to start reading --- 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