Item Sorting Order
I just released FeedTools 0.2.16 with some handy new goodies. It should hopefully work with Ruby 1.8.3 now, and should properly sort items by date. (It used to occaisionally leave the time field as nil, which would cause those entries to end up getting sorted to the very end.)
The parser now assumes that feeds are published in reverse chronological order, and so if a timestamp is missing, it tries to fix the problem and assign a timestamp of 1 second after the previous entry in order to maintain proper sorting order. It’s all nicely unit tested and should work for all feeds that aren’t intentionally designed to break it. (For example, cases where items 1 and 3 have no timestamp, but item 2 does.) I’ll probably deal with that situation in the next release, but since it’s highly unlikely to ever happen and has only mild side-effects, I’m not overly concerned. At worst, some items show up in the wrong order.
More importantly, if you’re playing around with the Universal Subscription Mechanism, FeedTools should properly figure out what the real url of the feed is. It will override the default feed url with the url within the feed if you gave FeedTools a url that doesn’t use http or https as the protocol. For example, a feed accessed via the file protocol that’s been stored in some temporary folder somewhere. Obviously, if you can retrieve the feed over http, you don’t really need to worry about correcting the subscription url, so it won’t override it in those cases.
Atom 0.3 became a headache this time round. As it turns out, there’s a namespace issue of sorts between Atom 1.0 and Atom 0.3. Or well, at least, they have different namespaces, but the same element names, so I have to check for the elements twice, once with the Atom 1.0 namespace, and then again with the Atom 0.3 namespace. Kind of irritating. But less so than, say, RSS, where there’s no namespace at all.
Speaking of which, I thought I should mention that, even if someone has messed up namespaces, FeedTools usually still won’t break. FeedTools checks for the elements it’s looking for, both in a namespace aware mode, as well as a namespace ignorant mode.
Anyways.
Leave a Response