Add pubDate to RSS generator
[blerg.git] / cgi / rss.c
index 746d556..24133f6 100644 (file)
--- a/cgi/rss.c
+++ b/cgi/rss.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <time.h>
 #include <cgi-util.h>
 #include "database.h"
 #include "escapery.h"
@@ -12,27 +13,34 @@ int fprint_rss(FILE *f, const char *username) {
        uint64_t i = (record_count > 50 ? record_count - 50 : 0);
        char *data;
        char *tmp;
+       time_t post_time;
+       char date[40];
        int len;
 
        fprintf(f,
                "<?xml version=\"1.0\" encoding=\"utf8\" ?>\n"
                "<rss version=\"2.0\">\n"
                "<channel>\n"
-               "<title>%s's bl&euml;rg</title>\n"
-               "<link>%s</link>\n"
+               "<title>%s's blërg</title>\n"
+               "<link>%s#%s</link>\n"
                "<description>%s</description>\n",
-               "bl&euml;rg",
+               username,
                "http://blerg.dominionfawesome.com/",
+               username,
                "Textual vomit"
        );
 
        while (i < record_count) {
                blerg_fetch(b, i, &data, &len);
                tmp = xml_escape_data(data, len);
+               post_time = blerg_get_timestamp(b, i);
+               strftime(date, 39, "%a, %d %b %Y %H:%M:%S %Z", gmtime(&post_time));
                fprintf(f,
                        "<item>\n"
+                       "<pubDate>%s</pubDate>\n"
                        "<description>%s</description>\n"
                        "</item>\n",
+                       date,
                        tmp
                );
                free(tmp);