summaryrefslogtreecommitdiff
path: root/pages.c
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-01-12 01:46:00 +1030
committerDaniel Jones <admin@danieljon.es>2020-01-12 01:46:00 +1030
commit154c94f59045d1f0af52ca4a058b42d7f8790220 (patch)
tree0fdce772f1c4b25b2254d2bd9ba1c689133fd0bf /pages.c
parentb57adf7a8c5ba78fdfdbf9f33dbd4837f10dd5a3 (diff)
downloadwebsitegenerator-154c94f59045d1f0af52ca4a058b42d7f8790220.tar.gz
websitegenerator-154c94f59045d1f0af52ca4a058b42d7f8790220.zip
finished rss generation
added rss button to template
Diffstat (limited to 'pages.c')
-rw-r--r--pages.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/pages.c b/pages.c
index 5afd8c3..b905290 100644
--- a/pages.c
+++ b/pages.c
@@ -757,6 +757,23 @@ char
str[idx-1] = '\0';
return str;
}
+
+char
+*rfc822date(char *date, size_t size)
+{
+ /*
+ * convert a dumb d/m/y date string into something rfc822 compliant
+ * absolutely not portable
+ */
+ struct tm tm;
+ char buff[size];
+ strptime(date, "%d/%m/%Y", &tm);
+ strftime(buff, size, "%d %b %Y", &tm);
+ strncpy(date, buff, size);
+ snprintf(date, size, "%s 00:00:00 GMT", buff);
+ return date;
+}
+
int
writerss(FILE *out, int post)
{
@@ -811,6 +828,7 @@ writerss(FILE *out, int post)
striphtml(date, strlen(date));
striphtml(description, strlen(description));
strcat(description, " ...");
+ rfc822date(date, 512);
//printf("title is: %s date is: %s: desc is: %s\n", title, date, description);
snprintf(item, 4096, "<item>\n\t<title>%s</title>\n\t<pubDate>%s</pubDate>\n\t<link>https://danieljon.es/posts/direct/%d</link>\n\t<guid>https://danieljon.es/posts/direct/%d</guid>\n\t<description>%s</description>\n</item>\n", title, date, post, post, description);
@@ -853,13 +871,15 @@ generaterss(const int *posts, size_t totalposts)
struct fileorstring src = {"rss.tmp", NULL};
+ /* we need to flush the file, so just close it */
+ fclose(tmp);
+
if (!replaceinpage(rss_output, rss_string, &src))
{
fprintf(stderr, "unable to replace %s in %s, unrecoverable failure\n", rss_string, rss_output);
return 0;
}
- fclose(tmp);
- //remove("rss.tmp");
+ remove("rss.tmp");
return 1;
}