mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 00:11:49 +03:00
e41d0c76fb
refs #9192, refs #5091 - Moved all url generation into generate-feed.js, so we can see as much data processing as possible in a single place. - Refactored the way res.locals were used, to be more like how express uses them prior to rendering - Removed a bunch of code & tests todo with context for RSS - I can't see any way that'd be used, unless we switched the rendering to use a template. - moved the RSS rendering to be part of the service, not controller - updated the tests significantly Note: RSS generate-feed has a complete duplication of the code used in the excerpt helper in order to create an item description
16 lines
469 B
JavaScript
16 lines
469 B
JavaScript
var _ = require('lodash'),
|
|
rssCache = require('./cache');
|
|
|
|
module.exports.render = function render(res, baseUrl, data) {
|
|
// Format data - this is the same as what Express does
|
|
var rssData = _.merge({}, res.locals, data);
|
|
|
|
// Fetch RSS from the cache
|
|
return rssCache
|
|
.getXML(baseUrl, rssData)
|
|
.then(function then(feedXml) {
|
|
res.set('Content-Type', 'text/xml; charset=UTF-8');
|
|
res.send(feedXml);
|
|
});
|
|
};
|