Format RSS items as HTML files
This commit is contained in:
parent
9719fbf303
commit
432fcf4308
@ -34,3 +34,6 @@ static const int logLevel = 3;
|
|||||||
// Set the maximum amount of redirects curl will follow.
|
// Set the maximum amount of redirects curl will follow.
|
||||||
// Use 0 to disable redirects, and -1 for no limit.
|
// Use 0 to disable redirects, and -1 for no limit.
|
||||||
static const int maxRedirs = 10;
|
static const int maxRedirs = 10;
|
||||||
|
|
||||||
|
// File extension used for each article.
|
||||||
|
static const char fileExt[] = ".html";
|
||||||
|
12
minrss.c
12
minrss.c
@ -22,7 +22,9 @@ itemAction(itemStruct *item, const char *folder)
|
|||||||
|
|
||||||
if (fileName[0])
|
if (fileName[0])
|
||||||
filePath = ecalloc(
|
filePath = ecalloc(
|
||||||
strlen(folder) + strlen(fileName) + 2,
|
strlen(folder)
|
||||||
|
+ strlen(fileName) + 2
|
||||||
|
+ strlen(fileExt),
|
||||||
sizeof(char));
|
sizeof(char));
|
||||||
else {
|
else {
|
||||||
logMsg(1, "Invalid article title.\n");
|
logMsg(1, "Invalid article title.\n");
|
||||||
@ -42,6 +44,8 @@ itemAction(itemStruct *item, const char *folder)
|
|||||||
strcat(filePath, fileName);
|
strcat(filePath, fileName);
|
||||||
free(fileName);
|
free(fileName);
|
||||||
|
|
||||||
|
strcat(filePath, fileExt);
|
||||||
|
|
||||||
FILE *itemFile = fopen(filePath, "a");
|
FILE *itemFile = fopen(filePath, "a");
|
||||||
free(filePath);
|
free(filePath);
|
||||||
|
|
||||||
@ -49,9 +53,9 @@ itemAction(itemStruct *item, const char *folder)
|
|||||||
if (!ftell(itemFile)) {
|
if (!ftell(itemFile)) {
|
||||||
newItems++;
|
newItems++;
|
||||||
|
|
||||||
fprintf(itemFile, "%s\n\n", cur->title);
|
fprintf(itemFile, "<h1>%s</h1><br>\n", cur->title);
|
||||||
fprintf(itemFile, "%s\n", san(cur->description, 0));
|
fprintf(itemFile, "<a href=\"%s\">Link</a><br>\n", san(cur->link, 0));
|
||||||
fprintf(itemFile, "%s\n", san(cur->link, 0));
|
fprintf(itemFile, "%s", san(cur->description, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(itemFile);
|
fclose(itemFile);
|
||||||
|
Loading…
Reference in New Issue
Block a user