diff --git a/gulpfile.babel.js b/gulpfile.babel.js index ba03fc1..757c966 100755 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -401,7 +401,8 @@ gulp.task('templates', () => { fs.writeFileSync(`.tmp/thanks.html`, thanksPageHtml); }); -gulp.task('create-rss-feed', () => gulp.src('client/words.json') +gulp.task('create-rss-feed', () => { + gulp.src('client/words.json') .pipe(clone()) .pipe(jsonTransform(function(words) { let wordArray = Object.keys(words); @@ -410,26 +411,90 @@ gulp.task('create-rss-feed', () => gulp.src('client/words.json') }); const rssTitle = 'Guffipedia'; - const rssLink = 'http://ft.com/guff'; + const rssLink = 'https://ig.ft.com/sites/guffipedia/'; const rssDescription = 'Lucy Kellaway’s dictionary of business jargon and corporate nonsense'; - let rssString = `${rssTitle}${rssLink}${rssDescription}`; + let rssString = ''; + rssString += ``; + rssString += ''; + rssString += `${rssTitle}`; + rssString += `${rssLink}`; + rssString += `${rssDescription}`; + rssString += ``; for (const slug of dateIndex) { let currentWord = words[slug]; rssString += ''; - rssString += `${currentWord.word}http://ig.ft.com/sites/guffipedia/${slug}/http://ig.ft.com/sites/guffipedia/${slug}/${currentWord.tweettextrss}`; + rssString += `${currentWord.word}`; + rssString += `${rssLink}${slug}/`; + rssString += `${rssLink}${slug}/`; + rssString += `${currentWord.formatteddate}`; + rssString += `${currentWord.slug}`; + rssString += `${currentWord.wordid}`; + rssString += `${currentWord.submissiondate}`; + if (currentWord.definition) { + const definition = htmlEntities(currentWord.definition); + rssString += `${definition}`; + } + if (currentWord.usageexample) { + const usageexample = htmlEntities(currentWord.usageexample); + rssString += `${usageexample}`; + } + if (currentWord.lucycommentary) { + const lucycommentary = htmlEntities(currentWord.lucycommentary); + rssString += `${lucycommentary}`; + } + rssString += `${currentWord.commenturl}`; + if (currentWord.perpetrator) { + const perpetrator = htmlEntities(currentWord.perpetrator); + rssString += `${perpetrator}`; + } + if (currentWord.usagesource) { + const usagesource = htmlEntities(currentWord.usagesource); + rssString += `${usagesource}`; + } + if (currentWord.sourceurl) { + const sourceurl = htmlEntities(currentWord.sourceurl); + rssString += `${sourceurl}`; + } + rssString += `${currentWord.tweettextrss}`; + rssString += ''; + rssString += `${currentWord.previousWord.slug}`; + rssString += `${currentWord.previousWord.word}`; + rssString += ''; + rssString += ''; + rssString += `${currentWord.nextWord.slug}`; + rssString += `${currentWord.nextWord.word}`; + rssString += ''; + if (currentWord.relatedwords.length > 0) { + rssString += ''; + for (const relatedword of currentWord.relatedwords) { + rssString += ''; + rssString += `${relatedword.slug}`; + rssString += `${relatedword.word}`; + rssString += ''; + } + rssString += ''; + } rssString += ''; } - rssString += ''; + rssString += ''; + rssString += ''; return rssString; })) .pipe(rename('rss.xml')) - .pipe(prettyData({type: 'prettify'})) .pipe(gulp.dest('dist')) -); +}); // helpers + +//encode html entities +function htmlEntities(string) { + const template = Handlebars.compile('{{string}}'); + const html = template({string: string}); + return html; +} + let preventNextReload; // hack to keep a BS error notification on the screen function reload() { if (preventNextReload) {