* instead of writing it to the template)
*/
void tmplput_blog_permalink(StrBuf *Target, WCTemplputParams *TP) {
- char perma[SIZ];
-
- strcpy(perma, "/readfwd?go=");
- urlesc(&perma[strlen(perma)], sizeof(perma)-strlen(perma), (char *)ChrPtr(WC->CurRoom.name));
- snprintf(&perma[strlen(perma)], sizeof(perma)-strlen(perma), "?p=%d", WC->bptlid);
- if (!Target) {
- wc_printf("%s", perma);
- }
- else {
- StrBufAppendPrintf(Target, "%s", perma);
- }
+ StrBuf *buf = NewStrBufPlain(HKEY("/readfwd?go="));
+ StrBufUrlescAppend(buf, WC->CurRoom.name, 0);
+ StrBufAppendPrintf(buf, "?p=%d", WC->bptlid);
+ StrBufAppendTemplate(Target, TP, buf, 0);
+ FreeStrBuf(&buf);
}
urlescputs(ChrPtr(WC->CurRoom.name));
wc_printf("#comments\">");
wc_printf(_("%d comments"), bp->num_msgs - 1);
+ wc_printf(" %d %s", bp->unread_oments, _("new"));
wc_printf("</a> | <a class=\"blog_permalink_link\" href=\"");
tmplput_blog_permalink(NULL, NULL);
wc_printf("\">%s</a>", _("permalink"));
}
bp->msgs[bp->num_msgs++] = Msg->msgnum;
if ((Msg->Flags & MSGFLAG_READ) != 0) {
- syslog(LOG_DEBUG, "****************** unread %ld", Msg->msgnum);
-
bp->unread_oments++;
}
}
/* Comments are shown if we are only viewing a single blog post */
with_comments = (BL->p != 0);
- firstp = atoi(BSTR("firstp")); /* start reading at... */
- maxp = atoi(BSTR("maxp")); /* max posts to show... */
- if (maxp < 1) maxp = 5; /* default; move somewhere else? */
+ firstp = ibstr("firstp"); /* start reading at... */
+ maxp = ibstr("maxp"); /* max posts to show... */
+ if (maxp < 1) maxp = 5; /* default; move somewhere else? */
+ it = GetNewHashPos(BL->BLOG, 0);
- //// bp->unread_oments++;
+ if ((BL->gotonext) && (BL->p == 0)) {
+ /* did we come here via gotonext? lets find out whether
+ * this blog has just one blogpost with new comments just display
+ * this one.
+ */
+ struct blogpost *unread_bp = NULL;
+ int unread_count = 0;
+ while (GetNextHashPos(BL->BLOG, it, &len, &Key, &Data)) {
+ struct blogpost *one_bp = (struct blogpost *) Data;
+ if (one_bp->unread_oments > 0) {
+ unread_bp = one_bp;
+ unread_count++;
+ }
+ }
+ if (unread_count == 1) {
+ blogpost_render(unread_bp, 1);
+
+ DeleteHashPos(&it);
+ return 0;
+ }
+
+ RewindHashPos(BL->BLOG, it, 0);
+ }
/* Iterate through the hash list and copy the data pointers into an array */
- it = GetNewHashPos(BL->BLOG, 0);
while (GetNextHashPos(BL->BLOG, it, &len, &Key, &Data)) {
if (num_blogposts >= num_blogposts_alloc) {
if (num_blogposts_alloc == 0) {
blogview_render,
blogview_Cleanup
);
- RegisterNamespace("BLOG:PERMALINK", 0, 0, tmplput_blog_permalink, NULL, CTX_NONE);
+ RegisterNamespace("BLOG:PERMALINK", 0, 1, tmplput_blog_permalink, NULL, CTX_NONE);
}