04/07/2017

The archive contains older posts which may no longer reflect my current views.

# Going to have to rethink the way I construct the OPML file. Loading each site's HTML to find the feed creates too much of a delay when loading the Directory page.

Perhaps I can capture it when the original webmention is received and write it to the database. ?

1 comment: click to read or leave your own Comments

# In reply to: 04/07/2017, 07:33...

I think I've cracked it! When a webmention is received I should be able to get the details from the comment meta and work from there.

Setting up a new DOMDocument and loading it with the contents of the page that sent the webmention I can loop through the link tags until I find the first one that is an RSS or Atom feed. From here I pull the href attribute and write it back to the comment meta.

Should the feed URL be a relative path (as used by at least one person) I have had to construct the full path based on the root address. Hopefully it will be a reliable process.

Once the feed URL is in the comment meta it can be pulled from the database and inserted into the OPML file as it is constructed.

Now I just need to ensure that the OPML file is properly formatted and that the action to hook into comment_post actually works properly.

# Success!

# My OPML file can now be downloaded (or subscribed to directly) from the Directory page. It is more an experiment than a useful file (I just wanted to see if I could do it) but it may grow in size and utility over time.

When visiting the Directory the file is recreated dynamically based on the latest webmentions received on the blog. It is filtered to only those with a valid feed (obviously) but no JSON Feed for now.

Maybe I'll include that later once more feed readers support it.

I've had to take a couple of liberties; for example, sites using the Known CMS appear to create an RSS feed on all pages - even a single post - by adding ?_t=rss to the URL. Not much use when it only contains that specific post!

If the feed URL discovered includes this then I change it to http(s)://{domain}/?_t=rss instead.

I'm sure I'll come across other peculiarities in future.

Although it may not be 100% up to date you can use the direct link to the OPML - because it is recreated when anyone visits the Directory you get the benefit of newer versions without needing to revisit the Directory yourself.