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);
/* 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);
+ }
}
/*
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;
*/
void tmplput_rssbutton(StrBuf *Target, WCTemplputParams *TP)
{
- wcsession *WCC = WC;
- char feed_link[1024];
- char encoded_link[1024];
+ StrBuf *FeedLink = NULL;
- strcpy(feed_link, "/feed_rss?go=");
- urlesc(&feed_link[20], sizeof(feed_link) - 20, (char *)ChrPtr(WCC->CurRoom.name) );
- CtdlEncodeBase64(encoded_link, feed_link, strlen(feed_link), 0);
+ FeedLink = NewStrBufPlain(HKEY("/feed_rss?go="));
+ StrBufUrlescAppend(FeedLink, WC->CurRoom.name, NULL);
- StrBufAppendPrintf(Target, "<a type=\"application/rss+xml\" href=\"/B64%s\">", encoded_link);
- StrBufAppendPrintf(Target, "<img border=\"0\" src=\"static/rss_16x.png\" alt=\"RSS\">");
+ StrBufAppendPrintf(Target, "<a type=\"application/rss+xml\" href=\"");
+ StrBufAppendBuf(Target, FeedLink, 0);
+ StrBufAppendPrintf(Target, "\"><img src=\"static/webcit_icons/essen/16x16/rss.png\" alt=\"RSS\">");
StrBufAppendPrintf(Target, "</a>");
+ FreeStrBuf(&FeedLink);
}