Jarloo

Menu

RumorMill 5 – RSS, RDF and ATOM Reader

RumorMill 5 is a C# WPF MVVM application that polls RSS feeds. It also supports the idea of categorizing your feeds by color and name so you can identify the topic of the feed simply by the color.

If a picture is worth a thousand words what a video worth? This should help clarify how it works:

 

 

Another thing I didn’t mention in the video (yes I’m too lazy to re-record it, is that if you click on the categories at the top it filters the view. So if I clicked “Games”, then all the items in the games category would disappear. If I clicked it again they would reappear. Also the time on the side that displays how old the article is, is dynamic. There is a timer in the background that changes the time so it always shows how old the article is while it’s on the display.

Download the Source Code

 

Configuration

RumorMill5 is rather simple. It consists of a single View, one ViewModel, 3 Models and a bunch of parsers to handle RSS, RDF, and ATOM feeds.

It has three files it uses.

  • Categories.xml – defines a list of categories
  • Feeds.xml – defines the feeds,polling intervals and categories to use per feed
  • Cache.dat – a cache of all the unique id’s so we can tell what is new and old when we poll

Categories

RumorMill has a grouping concept called categories. Each feed you assign to a category. The background color of the feed is then displayed in the color that was chosen for the category. This way if you have a category of “Finance” and “Games” you can tell the types of feeds by simply looking at the color.

The Categories.xml file defines the names and colors of the categories.

Feeds

RumorMill5 supports RSS, RDF and ATOM feeds. The feeds.xml file defines what feeds you want the program to poll and the interval you would like to poll them. It also assigns a CategoryName which links it to the categories.xml file listed above.

Cache

When RumorMill5 downloads a feed it gets the unique id of each item in the feed and adds it to the cache.dat file. The next time it polls it checks the cache.dat file to see if it has seen each item. Only new items are then displayed.

NOTE: RumorMill5 never erases the cache so if you planning on using this in a production scenario you will need to implement a janitor process to clean very old cache entries.

How the Polling Works

RumorMill5 polls each feed listed in the feeds.xml file, based on the interval specified in in the file. It does this via a single master loop. This master loop is called the feedTimer. It ticks each minute and looks for items that need refreshing. Each feed is handled on a separate thread using the .NET task framework. (see FetchFeed Method of ReaderViewModel)

How Parsing Works

Each feed being refreshed is interrogated by the FeedParser which determines what type of feed it is, ie: RSS, RDF, ATOM. Based on the feed a different parser is called. (yes it is really a factory pattern now that I look at it.)

The parsers are probably the most interesting part as they are done from scratch, without using any RSS, RDF or ATOM libraries. Just LINQ for XML which continues to amaze me. (someone give those LINQ devs a raise pls.)

Here is an example of the RssParser

if (doc.Elements().Count() == 0) return null;

XNamespace ns = "http://purl.org/rss/1.0/modules/slash/";

List items = (from item in doc.Descendants("item")
                        select new NewsItem
                {
                    Id = (item.Element("guid") != null ? item.Element("guid").Value : item.Element("link").Value),
                    Title = item.Element("title").Value,
                    Timestamp = Rfc822DateTime.Parse(Rfc822DateTime.Clean(item.Element("pubDate").Value) ?? DateTime.Now.ToString()),
                    Url = item.Element("link").Value,
                    Description = (item.Element("description").Value ?? ""),
                    NewsFeed = feed,
                    FetchTime = DateTime.Now.ToUniversalTime(),
                    Source = feed.Name
                }).ToList();

return items;

Categories:   Code

Tags:  , , , , , ,

Comments

Sorry, comments are closed for this item.