apostrophe-rss
Advanced tools
Comparing version 0.0.1 to 0.0.2
26
index.js
@@ -6,3 +6,3 @@ var feedparser = require('feedparser'); | ||
module.exports = function(options) { | ||
new widget(options); | ||
return new widget(options); | ||
}; | ||
@@ -14,5 +14,9 @@ | ||
var self = this; | ||
var lifetime = options.lifetime ? options.lifetime : 60000; | ||
self.pushAsset = function(type, name) { | ||
return apos.pushAsset(type, name, __dirname, '/apos-rss'); | ||
}; | ||
// This widget should be part of the default set of widgets for areas | ||
@@ -23,3 +27,3 @@ // (this isn't mandatory) | ||
// Include our editor template in the markup when aposTemplates is called | ||
apos.templates.push(__dirname + '/views/rssEditor'); | ||
self.pushAsset('template', 'rssEditor'); | ||
@@ -30,6 +34,5 @@ // Make sure that aposScripts and aposStylesheets summon our assets | ||
// resources needed also by non-editing users.) | ||
apos.scripts.push('/apos-rss/js/rss.js'); | ||
self.pushAsset('script', 'rss'); | ||
self.pushAsset('stylesheet', 'rss'); | ||
apos.stylesheets.push('/apos-rss/css/rss.css'); | ||
// Serve our assets | ||
@@ -46,5 +49,7 @@ app.get('/apos-rss/*', apos.static(__dirname + '/public')); | ||
} | ||
item.limit = parseInt(item.limit); | ||
console.log(item); | ||
}, | ||
render: function(data) { | ||
return apos.partial('rss.html', data, __dirname + '/views'); | ||
return apos.partial('rss', data, __dirname + '/views'); | ||
}, | ||
@@ -56,3 +61,3 @@ | ||
load: function(item, callback) { | ||
load: function(req, item, callback) { | ||
item._entries = []; | ||
@@ -64,5 +69,8 @@ | ||
return callback(); | ||
} | ||
} | ||
feedparser.parseUrl(item.feed).on('complete', function(meta, articles) { | ||
articles = articles.slice(0, item.limit); | ||
console.log('SLICED: ', articles.length); | ||
// map is native in node | ||
@@ -69,0 +77,0 @@ item._entries = articles.map(function(article) { |
{ | ||
"name": "apostrophe-rss", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Adds an RSS feed widget to the Apostrophe content management system", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,4 +14,6 @@ apos.widgetTypes.rss = { | ||
self.afterCreatingEl = function() { | ||
self.$feed = self.$el.find('.apos-rss-feed'); | ||
self.$feed = self.$el.find('[name="feed"]'); | ||
self.$feed.val(self.data.feed); | ||
self.$limit = self.$el.find('[name="limit"]'); | ||
self.$limit.val(self.data.limit); | ||
setTimeout(function() { | ||
@@ -21,6 +23,2 @@ self.$feed.focus(); | ||
}, 500); | ||
self.$el.find('.apos-preview-button').click(function() { | ||
self.preview(); | ||
return false; | ||
}); | ||
}; | ||
@@ -38,2 +36,3 @@ | ||
self.data.feed = self.$feed.val(); | ||
self.data.limit = self.$limit.val(); | ||
} | ||
@@ -40,0 +39,0 @@ return callback(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7416
9
141