handlers.c: add feed name to output

This commit is contained in:
dogeystamp 2023-06-16 15:24:51 -04:00
parent 66fd0886a7
commit d8f2ad2361
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
2 changed files with 11 additions and 5 deletions

View File

@ -1,5 +1,5 @@
PREFIX = ~/.local PREFIX = ~/.local
VERSION = 0.3.1 VERSION = 0.4.0
PKG_CONFIG = pkg-config PKG_CONFIG = pkg-config

View File

@ -155,10 +155,13 @@ openFile(const char *folder, char *fileName, char *fileExt)
} }
static void static void
outputHtml(itemStruct *item, FILE *f) outputHtml(itemStruct *item, FILE *f, const char *folder)
{ {
if (item->fields[FIELD_TITLE]) if (item->fields[FIELD_TITLE])
fprintf(f, "<h1>%s</h1><br>\n", item->fields[FIELD_TITLE]); fprintf(f, "<h1>%s</h1><br>\n", item->fields[FIELD_TITLE]);
fprintf(f, "From feed <b>%s</b><br>\n", folder);
if (item->fields[FIELD_LINK]) if (item->fields[FIELD_LINK])
fprintf(f, "<a href=\"%s\">Link</a><br>\n", item->fields[FIELD_LINK]); fprintf(f, "<a href=\"%s\">Link</a><br>\n", item->fields[FIELD_LINK]);
if (item->fields[FIELD_ENCLOSURE_URL]) if (item->fields[FIELD_ENCLOSURE_URL])
@ -171,10 +174,13 @@ outputHtml(itemStruct *item, FILE *f)
#ifdef JSON #ifdef JSON
static void static void
outputJson(itemStruct *item, FILE *f) outputJson(itemStruct *item, FILE *f, const char *folder)
{ {
json_object *root = json_object_new_object(); json_object *root = json_object_new_object();
json_object_object_add(root, "feedname",
json_object_new_string(folder));
if (item->fields[FIELD_TITLE]) if (item->fields[FIELD_TITLE])
json_object_object_add(root, "title", json_object_object_add(root, "title",
json_object_new_string(item->fields[FIELD_TITLE])); json_object_new_string(item->fields[FIELD_TITLE]));
@ -211,7 +217,7 @@ processItem(itemStruct *item, const char *folder)
int ret = 0; int ret = 0;
char fileExt[10]; char fileExt[10];
void (*outputFunction)(itemStruct *, FILE *); void (*outputFunction)(itemStruct *, FILE *, const char *);
switch (outputFormat) { switch (outputFormat) {
case OUTPUT_HTML: case OUTPUT_HTML:
@ -247,7 +253,7 @@ processItem(itemStruct *item, const char *folder)
// Do not overwrite files // Do not overwrite files
if (!ftell(itemFile)) { if (!ftell(itemFile)) {
outputFunction(item, itemFile); outputFunction(item, itemFile, folder);
ret = 1; ret = 1;
if (summaryFormat == SUMMARY_FILES) if (summaryFormat == SUMMARY_FILES)
logMsg(LOG_OUTPUT, "%s%c%s%s\n", folder, fsep(), basename, fileExt); logMsg(LOG_OUTPUT, "%s%c%s%s\n", folder, fsep(), basename, fileExt);