[pmwiki-users] detect new SimpleForum messages
Patrick R. Michaud
pmichaud at pobox.com
Fri Jan 5 08:31:17 CST 2007
On Fri, Jan 05, 2007 at 01:26:26AM -0600, JB wrote:
> * Patrick R. Michaud wrote, On 1/4/2007 5:12 PM:
> > I've duplicated the problem on with Newsfox on my site, and I'm
> > troubleshooting it there. This is also something that people have
> > commented on in the past.
>
> I think I found the source code that checks the feed.
> Look for "function checkFeed(index, xml)" which is
> one pagescroll down for me.
>
> http://tinyurl.com/yxufdp
>
> Perhaps you can see if there is something wrong with it.
> I think there might be something around wrong around the
> oldestEntryDate variable.
>
> I would think if the article name already exists they should
> compare the just read xml pubDate to the original article date
> and if it is newer it should replace the article (meaning it should
> remove the original article and put the newer version up as unread).
> ...
I agree with you with how it ought to work.
I'm not familiar with the newsfox code (or writing extensions
in Firefox), but I think the attached patch will make things
work way you've described. I don't have a handy way of testing
it, though -- but perhaps it would be useful to the Newsfox
authors.
Pm
-------------- next part --------------
--- rss-orig.js 2007-01-05 07:44:15.000000000 -0600
+++ rss.js 2007-01-05 08:23:48.000000000 -0600
@@ -155,23 +155,7 @@
if( lastNewestEntryDate < item.pubDate )
newItemsCount++;
}
-
- if (doesArticleExist(feed, item.link)) continue;
-
- art = new Article();
- art.title = encodeString(item.title);
- art.link = item.link;
- art.date = item.pubDate;
- art.body = encodeString(item.content);
- art.read = false;
- art.flag = false;
- // AG: added category
- art.category = encodeString(item.category);
-
- if (art.date == "") art.date = new Date();
- if (art.title == "") art.title = (item.content != "") ? encodeString(item.content.substr(0, 70)) + "..." : "...";
-
- feed.add(art);
+ updateArticle(feed, item);
}
feed.sort();
@@ -317,3 +301,41 @@
return true;
return false;
}
+
+
+/**
+ * Update an item in a feed. First, we see if
+ * an article in the feed already exists, if so,
+ * and if it has the same pubDate, then we leave
+ * it alone and we're done. Otherwise, any
+ * matching article(s) are removed from the feed,
+ * and we create a new one based on the incoming
+ * item.
+ */
+function updateArticle(feed, item)
+{
+ var art;
+ for (var i=0; i<feed.size(); i++)
+ art = feed.get(i);
+ // skip non-matching articles
+ if (art.link != item.link) continue;
+ // if matching article has identical pubdate, we're done
+ if (art.pubDate == item.pubDate) return;
+ // remove outdated article
+ feed.remove(i--)
+ }
+
+ art = new Article();
+ art.title = encodeString(item.title);
+ art.link = item.link;
+ art.date = item.pubDate;
+ art.body = encodeString(item.content);
+ art.read = false;
+ art.flag = false;
+ art.category = encodeString(item.category);
+
+ if (art.date == "") art.date = new Date();
+ if (art.title == "") art.title = (item.content != "") ? encodeString(item.content.substr(0, 70)) + "..." : "...";
+
+ feed.add(art);
+}
More information about the pmwiki-users
mailing list