commit 92cc91f7591a51e97a93a2c2a77409fc21228013
parent d9c9d42c90296f4d901bc249049506a3074df78e
Author: Paco Esteban <paco@e1e0.net>
Date: Thu, 2 Jul 2020 17:12:47 +0200
fix rss generation and bump revision
Diffstat:
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/ssnail.c b/ssnail.c
@@ -33,7 +33,7 @@
#include "helpers.h"
#include "ssnail_error.h"
-#define VERSION "1.0"
+#define VERSION "1.1"
struct article {
size_t htmlz;
@@ -646,10 +646,13 @@ write_rss(char *dst_path, char *rss_listing, char *title, char *url)
struct tm *timeinfo;
time_t now;
FILE *fout;
- char *rss_path = NULL, *pub_date = NULL;
+ char *rss_path = NULL, *pub_date = NULL,
+ *rss_url = NULL;
char *rss_format =
- "<rss version=\"2.0\">\n"
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n"
"<channel>\n"
+ "<atom:link href=\"%s\" rel=\"self\" type=\"application/rss+xml\" />\n"
"<title>%s</title>\n"
"<link>%s</link>\n"
"<lastBuildDate>%s</lastBuildDate>\n"
@@ -667,12 +670,15 @@ write_rss(char *dst_path, char *rss_listing, char *title, char *url)
if ((rss_path = build_full_path(dst_path, "rss.xml")) == NULL)
goto out;
+ if ((rss_url = build_full_path(url, "rss.xml")) == NULL)
+ goto out;
+
if ((fout = fopen(rss_path, "w")) == NULL) {
error = ssnail_error_from_errno("openw rss");
goto out;
}
- int ret = fprintf(fout, rss_format, title, url, pub_date,
+ int ret = fprintf(fout, rss_format, rss_url, title, url, pub_date,
title, rss_listing);
if (ret < 0) {
error = ssnail_error_from_errno("write rss");
@@ -683,5 +689,8 @@ write_rss(char *dst_path, char *rss_listing, char *title, char *url)
error = ssnail_error_from_errno("close fout");
out:
+ free(pub_date);
+ free(rss_path);
+ free(rss_url);
return error;
}