Use permalinks as the <link> tag content for Blog room feeds
authorArt Cancro <ajc@uncensored.citadel.org>
Tue, 7 Jun 2011 15:43:47 +0000 (11:43 -0400)
committerArt Cancro <ajc@uncensored.citadel.org>
Tue, 7 Jun 2011 15:43:47 +0000 (11:43 -0400)
webcit/feed_generator.c
webcit/roomviews.c

index 8aa3f0912cfceab4c9d1e74c55c82738037758e4..40ee30f7c33813cddf01026d2a5ce530f88d90c4 100644 (file)
@@ -36,6 +36,7 @@ void feed_rss_one_message(long msgnum) {
        const char *BufPtr = NULL;
        StrBuf *Line = NewStrBufPlain(NULL, 1024);
        char buf[1024];
+       int permalink_hash = 0;
 
        /* Phase 1: read the message into memory */
        serv_printf("MSG4 %ld", msgnum);
@@ -49,10 +50,19 @@ void feed_rss_one_message(long msgnum) {
        /* Phase 2: help SkyNet become self-aware */
        BufPtr = NULL;
        while (StrBufSipLine(Line, ServerResponse, &BufPtr), ((BufPtr!=StrBufNOTNULL)&&(BufPtr!=NULL)) ) {
-               if (StrLength(Line) == 0) ++in_body;
-               if ((StrLength(Line) > 5) && (!strncasecmp(ChrPtr(Line), "wefw=", 5))) {
+               if (in_body) {
+                       /* do nothing */
+               }
+               else if (StrLength(Line) == 0) {
+                       ++in_body;
+               }
+               else if ((StrLength(Line) > 5) && (!strncasecmp(ChrPtr(Line), "wefw=", 5))) {
                        is_top_level_post = 0;  /* presence of references means it's a reply/comment */
                }
+               else if ((StrLength(Line) > 5) && (!strncasecmp(ChrPtr(Line), "msgn=", 5))) {
+                       StrBufCutLeft(Line, 5);
+                       permalink_hash = ThreadIdHash(Line);
+               }
        }
 
        /*
@@ -63,7 +73,13 @@ void feed_rss_one_message(long msgnum) {
                wc_printf("<item>");
                wc_printf("<link>%s/readfwd?go=", ChrPtr(site_prefix));
                urlescputs(ChrPtr(WC->CurRoom.name));
-               wc_printf("?start_reading_at=%ld</link>", msgnum);
+               if ((WC->CurRoom.view == VIEW_BLOG) && (permalink_hash != 0)) {
+                       wc_printf("?p=%d", permalink_hash);
+               }
+               else {
+                       wc_printf("?start_reading_at=%ld", msgnum);
+               }
+               wc_printf("</link>");
        
                BufPtr = NULL;
                in_body = 0;
index c1f23fa1adc7060d4a448812d28a3365e4a3472d..f8261cf50506a5526ac3d7b368ba7f74c0b9a52a 100644 (file)
@@ -22,7 +22,7 @@ ROOM_VIEWS allowed_default_views[VIEW_MAX] = {
        0, /* VIEW_CALBRIEF     Brief Calendar */
        0, /* VIEW_JOURNAL      Journal */
        0, /* VIEW_DRAFTS       Drafts */
-       0  /* VIEW_BLOG         Blog */
+       1  /* VIEW_BLOG         Blog */
 };
 
 /*