changeset 42:afefc13cc84b

index/archive/category: display comment count
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sun, 15 Feb 2009 02:11:13 -0500
parents dc8164ee593d
children 2ddb3871e298
files html.c sar.c sar.h templates/story-bottom.html
diffstat 4 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/html.c	Sun Feb 15 02:09:43 2009 -0500
+++ b/html.c	Sun Feb 15 02:11:13 2009 -0500
@@ -93,7 +93,7 @@
 	__invoke_for_each_post_cat(&p, __story_cat_item);
 	cat(&p, NULL, "templates/story-middle.html", repltab_story_html);
 	cat_post(&p);
-	cat(&p, NULL, "templates/story-bottom.html", NULL);
+	cat(&p, NULL, "templates/story-bottom.html", repltab_story_numcomment_html);
 
 	destroy_post(&p);
 }
--- a/sar.c	Sun Feb 15 02:09:43 2009 -0500
+++ b/sar.c	Sun Feb 15 02:11:13 2009 -0500
@@ -35,7 +35,7 @@
 		1900+post->time.tm_year);
 }
 
-static void echo_comment_count(struct post *post, void *data)
+static void __echo_comment_count(struct post *post, void *data, int numeric)
 {
 	char path[FILENAME_MAX];
 	struct dirent *de;
@@ -46,7 +46,7 @@
 
 	dir = opendir(path);
 	if (!dir) {
-		fprintf(post->out, "No");
+		fprintf(post->out, numeric ? "0" : "No");
 		return;
 	}
 
@@ -63,6 +63,16 @@
 	fprintf(post->out, "%d", count);
 }
 
+static void echo_comment_count(struct post *post, void *data)
+{
+	__echo_comment_count(post, data, 0);
+}
+
+static void echo_comment_count_numeric(struct post *post, void *data)
+{
+	__echo_comment_count(post, data, 1);
+}
+
 static struct repltab_entry __repltab_story_html[] = {
 	{"POSTID",	echo_postid},
 	{"POSTDATE",	echo_postdate},
@@ -72,6 +82,15 @@
 	{"",		NULL},
 };
 
+static struct repltab_entry __repltab_story_numcomment_html[] = {
+	{"POSTID",	echo_postid},
+	{"POSTDATE",	echo_postdate},
+	{"POSTTIME",	echo_posttime},
+	{"TITLE",	echo_story_title},
+	{"COMCOUNT",	echo_comment_count_numeric},
+	{"",		NULL},
+};
+
 static void echo_comment_id(struct post *post, void *data)
 {
 	struct comment *comm = data;
@@ -150,6 +169,7 @@
 };
 
 struct repltab_entry *repltab_story_html = __repltab_story_html;
+struct repltab_entry *repltab_story_numcomment_html = __repltab_story_numcomment_html;
 struct repltab_entry *repltab_comm_html = __repltab_comm_html;
 struct repltab_entry *repltab_cat_html = __repltab_cat_html;
 struct repltab_entry *repltab_arch_html = __repltab_arch_html;
--- a/sar.h	Sun Feb 15 02:09:43 2009 -0500
+++ b/sar.h	Sun Feb 15 02:11:13 2009 -0500
@@ -15,6 +15,7 @@
 extern struct repltab_entry *repltab_comm_html;
 extern struct repltab_entry *repltab_cat_html;
 extern struct repltab_entry *repltab_arch_html;
+extern struct repltab_entry *repltab_story_numcomment_html;
 
 extern char* up_month_strs[12];
 
--- a/templates/story-bottom.html	Sun Feb 15 02:09:43 2009 -0500
+++ b/templates/story-bottom.html	Sun Feb 15 02:11:13 2009 -0500
@@ -1,7 +1,8 @@
 	</div>
 
 	<div class="feedback">
-					</div>
+		<a href="http://josefsipek.net/blahg/?p=@@POSTID@@#respond" title="Comment on @@TITLE@@">Comments (@@COMCOUNT@@)</a>
+	</div>
 
 </div>