It took me about an hour of work in total to put this together. Most of the parts were already there - Chris Double's Atom/RSS library, which uses Daniel Ehrenberg's XML library is the cornerstone here, and of course the HTTP server itself.
A thread fetches the feeds every 30 minutes. Entries are then concatenated and sorted by date, and stored in a global variable. The Planet Factor web app together with the news box on the Factor home page access this variable and present the results in a nice way.
The Planet Factor source is relatively short. (And on a somewhat related note, that pastebin is a Factor web app too...) This is my favorite part:
dup [
second
dup "Fetching " diagnostic
dup news-get feed-entries
swap "Done fetching " diagnostic
] parallel-map
Ignoring the diagnostic message logging, you basically have
[ news-get ] parallel-map
Where
news-get
makes a network connection, downloads the XML and parses it. While the XML parsing is not parallelized, the network I/O is. Not many languages make it this easy to fire off overlapping I/O operations...
4 comments:
Is there a feed for Factor Planet? Maybe I'm not looking hard enough, but I not seeing one...
It's coming soon. For now you just have to subscribe to the individual feeds.
You can add mine if you wish: http://www.rfc1149.net/blog/tag/factor/
There is an associated RSS feed at http://www.rfc1149.net/blog/tag/factor/feed/.
Seems to break IE7 if you go to planet.factorcode.org and view the page source it just shows </html>. Works fine in Firefox on the same machine.
Post a Comment