An RSS Dashboard in F#, part one
Posted by Brian on November 2, 2009
As you may know, I am quite active answering questions on forums like StackOverflow and hubfs. I want F# users to get prompt and useful answers to their questions (and yes, I also wanted to be the first person to earn the F# badge on SO). But of course I cannot afford to spend all my time hitting the refresh button in my web browser, just waiting to pounce on new questions. So I need a tool to make it easy for me to keep abreast of forum topics. while still getting my other work done. I’ve created such a tool for myself, which I’ll describe in this blog series.
Setting goal for the app
Any reasonable web forum will be publishing an RSS feed (or Atom feed) of its posts, so it’s easy to get the data I wanted. The only thing I needed to do was figure out an effective way to present the information. The requirements I set up for myself were
- I wanted a “dashboard”-style app. That is, I wanted to be able to view a summary of all the forum topics I care about on a single screen.
- Of course I needed to be able to control the set of forum feeds/topics the app listens to.
- I wanted the ability to get audio notification for new posts on interesting topics. This way I can leave the app running in the background during the day while I’m doing other work, but still be able to react quickly to new questions.
- I wanted to easily visualize the “diff” over longer periods of time. For example, when I get in on Monday morning, I want to quickly be able to see “what’s new and different” since the last time I looked at the forums from the weekend.
Now, perhaps there is already a great tool out there which I could download that already meets all those requirements. But like many developers, I personally set a few more (selfish) requirements, namely
- I wanted to build it myself in F#,
- so I could experiment with some new-to-me technologies I don’t typically use in my day job,
- and so I could blog about it.
So without further ado, I present…
Brian’s RSS Dashboard
Here’s a screenshot of the app, which tells half the story by itself (sometimes a picture really is worth a thousand words):
The window is divided up into a grid where each cell is a different topic/forum. Within each cell are the six threads with the most recent activity, sorted in order of recency. Each thread displays its title (long titles are truncated with an ellipsis) and how long ago the thread began. The threads are hyperlinks, so if I click one it opens the corresponding thread in my web browser.
The app polls the various RSS feeds periodically for new activity. When new activity is detected, a few things happen:
- a new entry appears in the listing for the corresponding topic (or, if the thread was already displayed in the list, it gets moved to the top)
- the thread gets a yellow highlight so that it visually stands out as new
- (optionally) the title is read aloud over the speakers using the text-to-speech built in to Windows
The audio is great for when I’m at my desk working on something else. If I’m in “flow” with whatever I’m working on, I just ignore the audio (my brain seems to tune it out automatically), but otherwise if I can take a break or afford a distraction, I’ll go have a look. This helps me provide quick replies to questions, which makes for happy customers and good StackOverflow reputation points. I only have the “audio” option turned on for a select few feeds (to minimize distraction).
The yellow highlight is great for when I return after being away from my desk for a while. When I log on in the morning, first thing I’ll do is glance at the dashboard to see what’s new (yellow). I click on any threads I’m interested in reading (and perhaps responding to) to go visit them in my browser. And then when I’m caught up, I click the big button at the top labeled “Mark all as seen”, which just erases all the yellow highlights.
That’s pretty much it! It’s a simple app, nothing fancy, but I’m very pleased with it, because it makes it super-easy for me to keep track of a number of different forums on different web sites.
In subsequent blog entries I’ll walk through all the F# code. Today I’ll just give an overview of the breakdown of the app and the various technologies/APIs that underlie each portion. The app conceptually has four main pieces:
- Observable Feeds. I already know plenty about RSS/Atom feeds, seeing as I was part of the team that created the SyndicationFeed class in .Net Framework 3.5. IObservable<T> (the push-vs.-pull dual of IEnumerable<T>) is, on the other hand, new technology that I wanted an excuse to play around with. For this app, an important piece of the code is about making feeds be IObservables.
- Speech. Though the .Net speech synthesis APIs are dirt-simple to use, there’s still a bit of futzing around to do here if, for example, you want your computer to pronounce “GUI” like “gooey”.
- The WPF UI. This is undoubtedly the most complex UI I’ve ever created on my own. Since the app is basically a grid of text and a single button, you would be correct to infer that my prior UI experience is practically zero. :) When you have no UI experience, it is easy to be tickled pink when you first get your pretty icons or yellow highlights to appear on the screen. I enjoyed this bit.
And of course for any UI app, even though there is various background work going on (speech/audio, polling feeds, …) we want to ensure the UI stays up-to-date and responsive. Of course my code never mentions “Thread” or “BackgroundWorker”; instead it’s F# async, MailboxProcessor, and .Net SynchronizationContext FTW! I was very pleased how easy that part was.
For next time…
Hopefully you’re aware of RSS feeds (and you’re subscribed to my blog’s feed :), right?), but if not, at least read the paragraph summary on wikipedia.
Next time we’ll jump into the code for observable feeds. Fun stuff ahead!