diff --git a/config/config.js.sample b/config/config.js.sample index 084bf017..99ab2ead 100644 --- a/config/config.js.sample +++ b/config/config.js.sample @@ -56,7 +56,13 @@ var config = { module: 'newsfeed', position: 'bottom_bar', config: { - feedUrl: 'http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml', + feeds: [ + { + title: "New York Times", + url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml" + } + ], + showSourceTitle: true, showPublishDate: true } }, diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 96f5588e..771ee5b3 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -43,8 +43,6 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe var today = moment().startOf("day").toDate(); var future = moment().startOf("day").add(maximumNumberOfDays, "days").subtract(1,"seconds").toDate(); // Subtract 1 second so that events that start on the middle of the night will not repeat. - - // FIXME: // Ugly fix to solve the facebook birthday issue. // Otherwise, the recurring events only show the birthday for next year. @@ -57,6 +55,8 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe if (event.type === "VEVENT") { + //console.log(event); + var startDate = (event.start.length === 8) ? moment(event.start, "YYYYMMDD") : moment(new Date(event.start)); var endDate; if (typeof event.end !== "undefined") { @@ -65,6 +65,9 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe endDate = startDate; } + // calculate the duration f the event for use with recurring events. + var duration = parseInt(endDate.format("x")) - parseInt(startDate.format("x")); + if (event.start.length === 8) { startDate = startDate.startOf("day"); } @@ -75,12 +78,15 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe for (var d in dates) { startDate = moment(new Date(dates[d])); - newEvents.push({ - title: (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary, - startDate: startDate.format("x"), - endDate: endDate.format("x"), - fullDayEvent: isFullDayEvent(event) - }); + endDate = moment(parseInt(startDate.format("x")) + duration, 'x'); + if (endDate.format("x") > now) { + newEvents.push({ + title: (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary, + startDate: startDate.format("x"), + endDate: endDate.format("x"), + fullDayEvent: isFullDayEvent(event) + }); + } } } else { // console.log("Single event ..."); @@ -119,6 +125,8 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe return a.startDate - b.startDate; }); + //console.log(newEvents); + events = newEvents.slice(0, maximumEntries); self.broadcastEvents(); diff --git a/modules/default/newsfeed/README.md b/modules/default/newsfeed/README.md index ae6ee061..936e5c2c 100644 --- a/modules/default/newsfeed/README.md +++ b/modules/default/newsfeed/README.md @@ -14,6 +14,18 @@ modules: [ // The config property is optional. // If no config is set, an example calendar is shown. // See 'Configuration options' for more information. + + feeds: [ + { + title: "New York Times", + url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml", + }, + { + title: "BBC + ", + url: "http://feeds.bbci.co.uk/news/video_and_audio/news_front_page/rss.xml?edition=uk", + }, + ] } } ] @@ -35,12 +47,25 @@ The following properties can be configured:
feedUrl
'http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml'
+ feeds
[
+ {
+ title: "New York Times",
+ url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml",
+ }
+ ]
showSourceTitle
true
or false
+ true
+ showPublishDate
2000
(2.5 seconds)
Option | +Description | +
---|---|
title |
+ The name of the feed source to be displayed above the news items. + This property is optional. + |
+
url |
+ The url of the feed used for the headlines. + Example: 'http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml'
+ |
+
encoding |
The encoding of the news feed. + This property is optional. Possible values: 'UTF-8' , 'ISO-8859-1' , etc ...
Default value: 'UTF-8'
|
diff --git a/modules/default/newsfeed/fetcher.js b/modules/default/newsfeed/fetcher.js
index 32081457..b155a80c 100644
--- a/modules/default/newsfeed/fetcher.js
+++ b/modules/default/newsfeed/fetcher.js
@@ -46,11 +46,13 @@ var Fetcher = function(url, reloadInterval, encoding) {
var regex = /(<([^>]+)>)/ig;
description = description.replace(regex, "");
- items.push({
- title: item.title,
- description: description,
- pubdate: item.pubdate,
- });
+ if (item.title && description && item.pubdate) {
+ items.push({
+ title: item.title,
+ description: description,
+ pubdate: item.pubdate,
+ });
+ }
});
parser.on("end", function() {
diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js
index ef0073e6..5d27a50a 100644
--- a/modules/default/newsfeed/newsfeed.js
+++ b/modules/default/newsfeed/newsfeed.js
@@ -11,13 +11,19 @@ Module.register("newsfeed",{
// Default module config.
defaults: {
- feedUrl: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml",
+ feeds: [
+ {
+ title: "New York Times",
+ url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml",
+ encoding: "UTF-8" //ISO-8859-1
+ }
+ ],
+ showSourceTitle: true,
showPublishDate: true,
showDescription: false,
reloadInterval: 5 * 60 * 1000, // every 5 minutes
updateInterval: 10 * 1000,
animationSpeed: 2.5 * 1000,
- encoding: "UTF-8" //ISO-8859-1
},
// Define required scripts.
@@ -36,21 +42,20 @@ Module.register("newsfeed",{
this.loaded = false;
this.activeItem = 0;
- this.fetchNews();
+ this.registerFeeds();
},
// Override socket notification handler.
socketNotificationReceived: function(notification, payload) {
if (notification === "NEWS_ITEMS") {
- if (payload.url === this.config.feedUrl) {
- this.newsItems = payload.items;
- if (!this.loaded) {
- this.scheduleUpdateInterval();
- }
+ this.generateFeed(payload);
- this.loaded = true;
+ if (!this.loaded) {
+ this.scheduleUpdateInterval();
}
+
+ this.loaded = true;
}
},
@@ -58,12 +63,11 @@ Module.register("newsfeed",{
getDom: function() {
var wrapper = document.createElement("div");
- // wrapper.className = "small";
- // for (var n in this.newsItems) {
- // var item = this.newsItems[n];
- // wrapper.innerHTML += item.title + '