hotsh/ostatus — pull request #12 by carols10cents (2012-11-24 17:26:56+00:00)
Title: Ssweeny problems

So I was trying to follow ssweeny on rstat.us, and i ran into multiple problems.

https://ssweeny.net/ is a wordpress site that uses the wordpress ostatus plugins to be ostatus enabled. It's certainly possible that the plugins are not complying exactly with the ostatus specs, but be liberal in what you accept, etc.

In the sidebar, ssweeny says:

> This blog is OStatus-enabled, meaning you can follow and comment on my posts from any OStatus-supporting service, such as identi.ca, StatusNet, or rstat.us. Please use my author URL when subscribing: http://ssweeny.net/author/ssweeny/

So I tried putting http://ssweeny.net/author/ssweeny/ into rstat.us and I got `LibXML::XML::Error: Error: Tag footer invalid at :550.` from `ostatus-0.0.12/lib/ostatus/feed.rb:42`.

Turns out LibXML/libxml2, when parsing HTML with `LibXML::XML::HTMLParser` as we were doesn't recognize HTML5 tags.

So the first commit in this PR switches from using LibXML to nokogiri, whose HTML parsing *does* recognize HTML5 tags as valid.

Once I got past that error, the parsing of the feed by ratom was throwing `XML document was missing atom:feed` exceptions. This was because the link chosen to follow was one of the `application/rss+xml` links.

Now, this may be an ratom bug since theoretically `application/rss+xml` is supported, but I'm punting on that for now. What I noticed in the source of http://ssweeny.net/author/ssweeny/ was that there WAS an `application/atom+xml` feed, but we weren't trying to use it since its @rel was `activities` rather than `alternate`.

This seems to come from the [wordpress activitystreams plugin](https://wordpress.org/extend/plugins/activitystream-extension/). This activities link looks like what we'd actually prefer; so in the 2nd commit I added that rel to the XPath that we're using to find links.

THEN I had the atom feed link in the set of links being considered, but the rss links were still being preferred! This ended up being a precedence problem with the sort condition, so the third commit adds parentheses to fix this issue. Finally, the test in the first commit doesn't throw any errors and we get a feed.

I then wanted to add unit tests for these issues, so I extracted the link finding logic into its own class and added unit tests in the fourth commit.