Merge branch 'develop' into user-agent fix conflict.

This commit is contained in:
Rodrigo Ramírez Norambuena
2016-12-13 10:40:10 -03:00
13 changed files with 121 additions and 111 deletions

View File

@@ -44,9 +44,9 @@ var Fetcher = function(url, reloadInterval, encoding) {
parser.on("item", function(item) {
var title = item.title;
var description = item.description || item.summary || item.content || '';
var description = item.description || item.summary || item.content || "";
var pubdate = item.pubdate || item.published || item.updated;
var url = item.url || item.link || '';
var url = item.url || item.link || "";
if (title && pubdate) {

View File

@@ -25,8 +25,8 @@ Module.register("newsfeed",{
updateInterval: 10 * 1000,
animationSpeed: 2.5 * 1000,
maxNewsItems: 0, // 0 for unlimited
removeStartTags: '',
removeEndTags: '',
removeStartTags: "",
removeEndTags: "",
startTags: [],
endTags: []
@@ -93,33 +93,41 @@ Module.register("newsfeed",{
var sourceAndTimestamp = document.createElement("div");
sourceAndTimestamp.className = "light small dimmed";
if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== '') sourceAndTimestamp.innerHTML = this.newsItems[this.activeItem].sourceTitle;
if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== '' && this.config.showPublishDate) sourceAndTimestamp.innerHTML += ', ';
if (this.config.showPublishDate) sourceAndTimestamp.innerHTML += moment(new Date(this.newsItems[this.activeItem].pubdate)).fromNow();
if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== '' || this.config.showPublishDate) sourceAndTimestamp.innerHTML += ':';
if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== "") {
sourceAndTimestamp.innerHTML = this.newsItems[this.activeItem].sourceTitle;
}
if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== "" && this.config.showPublishDate) {
sourceAndTimestamp.innerHTML += ", ";
}
if (this.config.showPublishDate) {
sourceAndTimestamp.innerHTML += moment(new Date(this.newsItems[this.activeItem].pubdate)).fromNow();
}
if (this.config.showSourceTitle && this.newsItems[this.activeItem].sourceTitle !== "" || this.config.showPublishDate) {
sourceAndTimestamp.innerHTML += ":";
}
wrapper.appendChild(sourceAndTimestamp);
}
//Remove selected tags from the beginning of rss feed items (title or description)
if (this.config.removeStartTags == 'title' || 'both') {
if (this.config.removeStartTags == "title" || "both") {
for (f=0; f<this.config.startTags.length;f++) {
if (this.newsItems[this.activeItem].title.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) {
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].title.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].title.length);
}
}
}
}
if (this.config.removeStartTags == 'description' || 'both') {
if (this.config.removeStartTags == "description" || "both") {
if (this.config.showDescription) {
for (f=0; f<this.config.startTags.length;f++) {
if (this.newsItems[this.activeItem].description.slice(0,this.config.startTags[f].length) == this.config.startTags[f]) {
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].description.slice(this.config.startTags[f].length,this.newsItems[this.activeItem].description.length);
}
}
}
}
@@ -131,14 +139,14 @@ Module.register("newsfeed",{
for (f=0; f<this.config.endTags.length;f++) {
if (this.newsItems[this.activeItem].title.slice(-this.config.endTags[f].length)==this.config.endTags[f]) {
this.newsItems[this.activeItem].title = this.newsItems[this.activeItem].title.slice(0,-this.config.endTags[f].length);
}
}
}
if (this.config.showDescription) {
for (f=0; f<this.config.endTags.length;f++) {
if (this.newsItems[this.activeItem].description.slice(-this.config.endTags[f].length)==this.config.endTags[f]) {
this.newsItems[this.activeItem].description = this.newsItems[this.activeItem].description.slice(0,-this.config.endTags[f].length);
}
}
}
}
@@ -234,10 +242,10 @@ Module.register("newsfeed",{
for (var f in this.config.feeds) {
var feed = this.config.feeds[f];
if (feed.url === feedUrl) {
return feed.title || '';
return feed.title || "";
}
}
return '';
return "";
},
/* scheduleUpdateInterval()

View File

@@ -35,8 +35,8 @@ module.exports = NodeHelper.create({
createFetcher: function(feed, config) {
var self = this;
var url = feed.url || '';
var encoding = feed.encoding || 'UTF-8';
var url = feed.url || "";
var encoding = feed.encoding || "UTF-8";
var reloadInterval = config.reloadInterval || 5 * 60 * 1000;
if (!validUrl.isUri(url)) {