WMAU news feed

Fremantle

· WMAU · feeds · blogging · Wikimedia ·

This afternoon I've added a news feed to the Wikimedia Australia website: https://wikimedia.org.au/news.xml

(If you don't know what a feed is, have a read of aboutfeeds.com.)

The new feed is produced by Cargo's new 'feed' export format, that I worked on earlier this year. I think there are still some bugs, but it's working at least in some respects.

The feed is documented on the blog post template, and uses a query that looks a bit like the following (it doesn't actually use the query that's stored on that doc page; see below for where it's actually stored):

{{#cargo_query: tables=blog_posts
 | fields = _pageName, CONCAT(date, 'T12:00:00')=start, authors=author
 | format = feed
 | limit = 10
 | order by = date DESC
}}

Note the weird hack for the date, because date is a Date field (without time component) but the feed needs to have a time. I set it to midday UTC, but that's pretty arbitrary. The other weird thing is that the date field needs to be called start because Cargo looks for a Date type field and the concatenated string isn't of that type; it also, however, looks for a field named 'start', so this uses that workaround. I think this is a bug, but I haven't fully confirmed that (it seems to me that it should permit just a Date field, but I see the point of perhaps not because it's hard to know exactly when in time it should be — days being 52 hours long and all that).

The above query produces a URL for Special:CargoExport, which then can be added to the Apache config so that we can have a much nicer URL:

## Atom shortcut
RewriteRule ^news\.xml$ "/index.php?title=Special:CargoExport&tables=blog_posts&fields=_pageName,CONCAT(date,'T12:00:00')=start,authors=author&limit=10&format=feed&feed+type=atom&feed+title=Wikimedia+Australia+news&feed+description=Recent+posts+from+the+Australian+chapter+of+the+global+Wikimedia+movement.&order+by=date+DESC" [L,QSA]

Note the QSA a the end, which means the parts of the query can be changed — to get more items for example you can use news.xml?limit=20.

Then the site can be set to advertise the new feed URL by setting $wgOverrideSiteFeed['atom'], resulting in the following being added to the HTML head of every site page:

<link rel="alternate" type="application/atom+xml" title="Wikimedia Australia Atom feed" href="https://wikimedia.org.au/news.xml" />

MediaWiki does of course already have various feeds, but they're really aimed at people who want to keep up to date with the activity on the wiki, but they're not great if what you want is to follow the news of the organisation.

← PreviousNext →
Comments on this post
No comments yet