projects
/
blerg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add post formatting help
[blerg.git]
/
cgi
/
rss.c
diff --git
a/cgi/rss.c
b/cgi/rss.c
index
746d556
..
f143e55
100644
(file)
--- a/
cgi/rss.c
+++ b/
cgi/rss.c
@@
-1,10
+1,15
@@
+/* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
+ * BSD-style license. Please see the COPYING file for details.
+ */
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include <cgi-util.h>
#include "database.h"
#include "escapery.h"
#include "canned_responses.h"
#include "app.h"
#include <cgi-util.h>
#include "database.h"
#include "escapery.h"
#include "canned_responses.h"
#include "app.h"
+#include "config.h"
int fprint_rss(FILE *f, const char *username) {
struct blerg *b = blerg_open(username);
int fprint_rss(FILE *f, const char *username) {
struct blerg *b = blerg_open(username);
@@
-12,27
+17,36
@@
int fprint_rss(FILE *f, const char *username) {
uint64_t i = (record_count > 50 ? record_count - 50 : 0);
char *data;
char *tmp;
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,
int len;
fprintf(f,
- "<?xml version=\"1.0\" encoding=\"utf8\" ?>\n"
+ "<?xml version=\"1.0\" encoding=\"utf
-
8\" ?>\n"
"<rss version=\"2.0\">\n"
"<channel>\n"
"<rss version=\"2.0\">\n"
"<channel>\n"
- "<title>%s's bl
ë
rg</title>\n"
- "<link>%s</link>\n"
+ "<title>%s's bl
ë
rg</title>\n"
+ "<link>%s
#%s
</link>\n"
"<description>%s</description>\n",
"<description>%s</description>\n",
- "blërg",
- "http://blerg.dominionfawesome.com/",
+ username,
+ BASEURL,
+ username,
"Textual vomit"
);
while (i < record_count) {
blerg_fetch(b, i, &data, &len);
tmp = xml_escape_data(data, len);
"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"
fprintf(f,
"<item>\n"
+ "<pubDate>%s</pubDate>\n"
+ "<guid>%sget/%s/%llu</guid>\n"
"<description>%s</description>\n"
"</item>\n",
"<description>%s</description>\n"
"</item>\n",
+ date,
+ BASEURL, username, i,
tmp
);
free(tmp);
tmp
);
free(tmp);
@@
-76,18
+90,18
@@
int main (int argc, char *argv) {
}
ret = parse_url_info(path + 1, &info);
}
ret = parse_url_info(path + 1, &info);
- if ((ret & URL_INFO_
AUTHOR
) == 0) {
+ if ((ret & URL_INFO_
NAME
) == 0) {
respond_404();
exit(0);
}
respond_404();
exit(0);
}
- if (!blerg_exists(info.
author
)) {
+ if (!blerg_exists(info.
name
)) {
respond_404();
exit(0);
}
printf("Content-type: application/rss+xml\r\n\r\n");
respond_404();
exit(0);
}
printf("Content-type: application/rss+xml\r\n\r\n");
- fprint_rss(stdout,
"chip"
);
+ fprint_rss(stdout,
info.name
);
}
}