]> code.citadel.org Git - citadel.git/blobdiff - webcit/blogview_renderer.c
blog renderer
[citadel.git] / webcit / blogview_renderer.c
index 1a18297f07ec035bfbbfb4ede8c688936e5ba72d..cd2a52efd3d63719959ad4fd0eb18c192afc68d6 100644 (file)
@@ -121,7 +121,9 @@ int blogview_sortfunc(const void *s1, const void *s2) {
 void blogview_learn_thread_references(struct blogpost *bp)
 {
        StrBuf *Buf;
+       StrBuf *r;
        Buf = NewStrBuf();
+       r = NewStrBuf();
        serv_printf("MSG0 %ld|1", bp->msgnum);          /* top level citadel headers only */
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 1) {
@@ -132,12 +134,13 @@ void blogview_learn_thread_references(struct blogpost *bp)
                        }
                        else if (!strncasecmp(ChrPtr(Buf), "wefw=", 5)) {
                                StrBufCutLeft(Buf, 5);          /* trim the field name */
-                               StrBufCutAt(Buf, 0, "|");       /* trim all but the first thread ref */
-                               bp->refs = HashLittle(ChrPtr(Buf), StrLength(Buf));
+                               StrBufExtract_token(r, Buf, 0, '|');
+                               bp->refs = HashLittle(ChrPtr(r), StrLength(r));
                        }
                }
        }
        FreeStrBuf(&Buf);
+       FreeStrBuf(&r);
 }
 
 
@@ -146,7 +149,7 @@ void blogview_learn_thread_references(struct blogpost *bp)
 int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
 {
        struct blogview *BLOG = (struct blogview *) *ViewSpecific;
-       int i;
+       int i, j;
 
        /* Pass #1 - sort */
        if (Stat->nummsgs > 0) {
@@ -172,21 +175,36 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
         * * Comments
         * * etc
         */
+
        for (i=0; (i<BLOG->num_msgs); ++i) {
                if (BLOG->msgs[i].msgnum > 0L) {
-                       if (BLOG->msgs[i].refs == 0) {
-                               wc_printf("<b>");
-                       }
-                       wc_printf("Message %d, #%ld, id %d, refs %d",
+                       wc_printf("Message %d, #%ld, id %d, refs %d<br>\n",
+                               i,
+                               BLOG->msgs[i].msgnum,
+                               BLOG->msgs[i].id,
+                               BLOG->msgs[i].refs
+                       );
+               }
+       }
+
+       wc_printf("<hr>\n");
+
+       for (i=0; (i<BLOG->num_msgs); ++i) {
+               if ((BLOG->msgs[i].msgnum > 0L) && (BLOG->msgs[i].refs == 0)) {
+                       const StrBuf *Mime;
+                       wc_printf("<b>Message %d, #%ld, id %d, refs %d</b><br>\n",
                                i,
                                BLOG->msgs[i].msgnum,
                                BLOG->msgs[i].id,
                                BLOG->msgs[i].refs
                        );
-                       if (BLOG->msgs[i].refs == 0) {
-                               wc_printf("</b>");
+                       read_message(WC->WBuf, HKEY("view_message"), BLOG->msgs[i].msgnum, NULL, &Mime);
+                       for (j=0; (j<BLOG->num_msgs); ++j) {
+                               if (BLOG->msgs[j].refs == BLOG->msgs[i].id) {
+                                       wc_printf("     * comment %d<br>\n", j);
+                               }
                        }
-                       wc_printf("<br>\n");
+                       wc_printf("<hr>\n");
                }
        }