Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apostrophe-rss

Package Overview
Dependencies
Maintainers
10
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apostrophe-rss - npm Package Compare versions

Comparing version 0.5.4 to 0.5.5

85

index.js

@@ -35,54 +35,53 @@ var feedparser = require('feedparser');

apos.itemTypes.rss = {
widget: true,
label: 'RSS Feed',
css: 'rss',
icon: 'rss',
sanitize: function(item) {
if (!item.feed.match(/^https?\:\/\//)) {
item.feed = 'http://' + item.feed;
}
item.limit = parseInt(item.limit, 10);
},
render: function(data) {
return apos.partial('rss', data, __dirname + '/views');
},
self.widget = true;
self.label = options.label || 'RSS Feed';
self.css = options.css || 'rss';
self.icon = options.icon || 'rss';
self.sanitize = function(item) {
if (!item.feed.match(/^https?\:\/\//)) {
item.feed = 'http://' + item.feed;
}
item.limit = parseInt(item.limit, 10);
};
self.renderWidget = function(data) {
return self.render('rss', data);
};
self.load = function(req, item, callback) {
// Asynchronously load the actual RSS feed
// The properties you add should start with an _ to denote that
// they shouldn't become data attributes or get stored back to MongoDB
item._entries = [];
load: function(req, item, callback) {
item._entries = [];
var now = new Date();
// Take all properties into account, not just the feed, so the cache
// doesn't prevent us from seeing a change in the limit property right away
var key = JSON.stringify({ feed: item.feed, limit: item.limit });
if (cache.hasOwnProperty(key) && ((cache[key].when + lifetime) > now.getTime())) {
item._entries = cache[key].data;
return callback();
}
var now = new Date();
// Take all properties into account, not just the feed, so the cache
// doesn't prevent us from seeing a change in the limit property right away
var key = JSON.stringify({ feed: item.feed, limit: item.limit });
if (cache.hasOwnProperty(key) && ((cache[key].when + lifetime) > now.getTime())) {
item._entries = cache[key].data;
return callback();
}
feedparser.parseUrl(item.feed).on('complete', function(meta, articles) {
articles = articles.slice(0, item.limit);
feedparser.parseUrl(item.feed).on('complete', function(meta, articles) {
articles = articles.slice(0, item.limit);
// map is native in node
item._entries = articles.map(function(article) {
return {
title: article.title,
body: article.description,
date: article.pubDate
};
});
// Cache for fast access later
cache[key] = { when: now.getTime(), data: item._entries };
return callback();
}).on('error', function(error) {
item._failed = true;
return callback();
// map is native in node
item._entries = articles.map(function(article) {
return {
title: article.title,
body: article.description,
date: article.pubDate
};
});
}
// Cache for fast access later
cache[key] = { when: now.getTime(), data: item._entries };
return callback();
}).on('error', function(error) {
item._failed = true;
return callback();
});
};
apos.addWidgetType('rss', self);
return setImmediate(function() { return callback(null); });
}
{
"name": "apostrophe-rss",
"version": "0.5.4",
"version": "0.5.5",
"description": "Adds an RSS feed widget to the Apostrophe content management system",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc