mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
refs #5091, refs #9192 - This is similar to #9218, in that I'm revealing bits of code that are "controllers" in our codebase. As opposed to routes, services, renderers etc. - This also reveals some code which is identical to the channels controller - There is more to do here, but for now I've got the module split up, and the tests split and improved. - Next I'll split RSS into controller + service, DRY up the controller code, etc
16 lines
489 B
JavaScript
16 lines
489 B
JavaScript
var crypto = require('crypto'),
|
|
generateFeed = require('./generate-feed'),
|
|
feedCache = {};
|
|
|
|
module.exports.getXML = function getFeedXml(path, data) {
|
|
var dataHash = crypto.createHash('md5').update(JSON.stringify(data)).digest('hex');
|
|
if (!feedCache[path] || feedCache[path].hash !== dataHash) {
|
|
// We need to regenerate
|
|
feedCache[path] = {
|
|
hash: dataHash,
|
|
xml: generateFeed(data)
|
|
};
|
|
}
|
|
|
|
return feedCache[path].xml;
|
|
};
|