From 92bffd78de23699d7bb5ae0cf1b8de0443da2b4b Mon Sep 17 00:00:00 2001 From: Alejandro Fanjul Date: Tue, 2 May 2017 18:38:54 +0200 Subject: [PATCH] RSS Improvements to allow more template Tags like ([RSS_ENTRY_TITLE], [RSS_ENTRY_DATE], [RSS_ENTRY_LINK], [RSS_ENTRY_CONTENT], [RSS_ENTRY_SUMMARY], [RSS_ENTRY_IMAGE_URL]) --- lib/feed.js | 4 +++- services/feedcheck.js | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/feed.js b/lib/feed.js index 6758f798..10611eb2 100644 --- a/lib/feed.js +++ b/lib/feed.js @@ -50,7 +50,9 @@ module.exports.fetch = (url, callback) => { date: item.date || item.pubdate || item.pubDate || new Date(), guid: item.guid || item.link, link: item.link, - content: item.description || item.summary + content: item.description || item.summary, + summary: item.summary || item.description, + image_url: item.image.url, }; entries.push(entry); } diff --git a/services/feedcheck.js b/services/feedcheck.js index 3c506154..5f43c479 100644 --- a/services/feedcheck.js +++ b/services/feedcheck.js @@ -132,8 +132,11 @@ function checkEntries(parent, entries, callback) { let entryId = result.insertId; let html = (parent.html || '').toString().trim(); - if (/\[RSS_ENTRY\]/i.test(html)) { - html = html.replace(/\[RSS_ENTRY\]/, entry.content); + if (/\[RSS_ENTRY[\w]*\]/i.test(html)) { + html = html.replace(/\[RSS_ENTRY\]/, entry.content); //for backward compatibility + Object.keys(entry).forEach(key => { + html = html.replace('\[RSS_ENTRY_'+key.toUpperCase()+'\]', entry[key]) + }); } else { html = entry.content + html; }