changeset 67:afc15d39fede

allow paging of categories Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Thu, 09 Apr 2009 21:39:10 -0400
parents 629dc5db2f70
children 3adfcfbcc97f
files category.c html.c templates/category-pager.html templates/index-pager.html templates/sidebar-top.html
diffstat 5 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/category.c	Thu Apr 09 18:00:39 2009 -0400
+++ b/category.c	Thu Apr 09 21:39:10 2009 -0400
@@ -95,6 +95,7 @@
 	char *path_info;
 	struct post post;
 	int catn;
+	char *pn;
 
 	clock_gettime(CLOCK_REALTIME, &s);
 
@@ -138,6 +139,12 @@
 		}
 	}
 
+	pn = getenv("QUERY_STRING");
+	if (!pn)
+		post.page = 0;
+	else
+		post.page = atoi(pn);
+
 	html_header(&post);
 	html_category(&post, post.title);
 	html_sidebar(&post);
--- a/html.c	Thu Apr 09 18:00:39 2009 -0400
+++ b/html.c	Thu Apr 09 21:39:10 2009 -0400
@@ -115,6 +115,8 @@
 			    post->page*HTML_INDEX_STORIES, HTML_INDEX_STORIES);
 
 	closedir(dir);
+
+	cat(post, NULL, "templates/index-pager.html", repltab_story_html);
 }
 
 static void __each_feed_index_helper(struct post *post, char *name, void *data)
@@ -183,7 +185,6 @@
 {
 	char path[FILENAME_MAX];
 	DIR *dir;
-	int page=0; //FIXME
 
 	snprintf(path, FILENAME_MAX, "data/by-category/%s/", catname);
 
@@ -192,9 +193,12 @@
 		return;
 
 	sorted_readdir_loop(dir, post, __each_index_helper, NULL, SORT_DESC,
-			    HTML_CATEGORY_STORIES*page, HTML_CATEGORY_STORIES);
+			    HTML_CATEGORY_STORIES*post->page,
+			    HTML_CATEGORY_STORIES);
 
 	closedir(dir);
+
+	cat(post, NULL, "templates/category-pager.html", repltab_story_html);
 }
 
 /************************************************************************/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/category-pager.html	Thu Apr 09 21:39:10 2009 -0400
@@ -0,0 +1,2 @@
+<a href="?cat=@@TITLE@@&amp;paged=@@NEXT_PAGENO@@">(newer posts)</a>
+<a href="?cat=@@TITLE@@&amp;paged=@@PREV_PAGENO@@">(older posts)</a>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/index-pager.html	Thu Apr 09 21:39:10 2009 -0400
@@ -0,0 +1,2 @@
+<a href="?paged=@@NEXT_PAGENO@@">(newer posts)</a>
+<a href="?paged=@@PREV_PAGENO@@">(older posts)</a>
--- a/templates/sidebar-top.html	Thu Apr 09 18:00:39 2009 -0400
+++ b/templates/sidebar-top.html	Thu Apr 09 21:39:10 2009 -0400
@@ -1,5 +1,3 @@
-<a href="?paged=@@NEXT_PAGENO@@">(newer)</a>
-<a href="?paged=@@PREV_PAGENO@@">(older)</a>
 </div>
 
 <!-- begin sidebar -->