Extension:WikiArticleFeeds

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
WikiArticleFeeds

Release status: stable

Implementation Tag
Description Makes RSS/Atom feeds out of wiki articles.
Author(s) Jim R. Wilson (jimbojw), Thomas Gries
Latest version 0.71 (2012-03-19)
MediaWiki 1.19+

not working in 1.19-svn before r110716

License The MIT License
Download
Example Blog - Trephine.org
Hooks used
UnknownAction

ArticlePurge
SkinTemplateToolboxEnd
OutputPageBeforeHTML
ParserBeforeTidy
ParserFirstCallInit
LinkEnd

Translate the WikiArticleFeeds extension if it is available at translatewiki.net

Check usage and version matrix; code metrics
Bugs: list open list all report

The WikiArticleFeeds Extension makes regular wiki articles generating RSS and Atom feeds. The extension is compatible with Extension:RSS, which renders ("displays") RSS feeds on MediaWiki page.

Installation[edit | edit source]

The extension can be retrieved directly from Git [?]:

  • Browse code
  • Some extensions have tags for stable releases.
  • Each branch is associated with a past MediaWiki release. There is also a "master" branch containing the latest alpha version (might require an alpha version of MediaWiki).

Extract the snapshot and place it in the extensions/WikiArticleFeeds/ directory of your MediaWiki installation.

If you are familiar with git and have shell access to your server, you can also obtain the extension as follows:

cd extensions/
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/WikiArticleFeeds.git
  • Download and extract the file(s) in a directory called WikiArticleFeeds in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/WikiArticleFeeds/WikiArticleFeeds.php";
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

Configuration (optional)[edit | edit source]

If you'd like to disable the default link interpretation behavior (see the example), you can do so by adding this to your LocalSettings.php:

$wgForceArticleFeedSectionLinks = true;

Usage[edit | edit source]

Once installed, editors of your wiki may begin feeding pages immediately, no further system configuration is required.

The extension registers three tags:

  • <startFeed> (Required) - Denotes the beginning of an article segment containing feed data.
  • <endFeed> (Required) - Denotes the end of a feed data segment.
  • <feedBurner> (Optional) - Specifies that FeedBurner is to serve the feed, rather than publishing it directly.

If an article contains a feed section, links titled 'RSS' and 'Atom' will appear in the Toolbox. Additionally, because the appropriate <meta> tags are supplied, your browser may show a feed icon in the address bar.

Note: In the Monobook skin, the Toolbox is in the left-hand sidebar column, towards the bottom.

As mentioned before, a feed section is delimited by the <startFeed /> and <endFeed /> flags. Note that these are closed tags, and are functionally equivalent to <startFeed></startFeed> and <endFeed></endFeed> respectively.

The <feedBurner> tag, when specified, must have a single attribute called 'name'. This is the final URL component of the feedburner.com feed URL.

For example, consider this url:

http://jimbojw.com/wiki/index.php?title=Blog

The Atom feed URL for this page would be:

http://jimbojw.com/wiki/index.php?title=Blog&action=feed

Suppose this has been mapped via feedburner.com to:

http://feeds.feedburner.com/Jimbojwcom-Blog

And thus, the following is added to the original article text to complete the circle:

<feedBurner name="Jimbojwcom-Blog" />

Note that using FeedBurner in this fashion does not prevent users from still trying to access the generated feeds directly, but it does change all the links to point to feedburner rather than back to the wiki.

Example[edit | edit source]

<startFeed />
Description of my feed.

=== Second Feed Item ===
Brand New! I just made a [[Main page|new item]]! --[[User:Anon|Anon]] 10:12, 8 December 2006 (MST)

=== First Feed Item ===
Here is the content for my first item ever. --[[User:Anon|Anon]] 08:42, 4 December 2006 (MST)
<endFeed />

The description for the rendered RSS or Atom feed will be "Description of my feed." The feed will have two items, both authored by "User:Anon".

Feed item publication dates are determined automatically from wiki signatures with or without talk page link and determine the feed item sorting sequence when it is generated: usually descending dates, but this can be reversed.

The generated feed item URLs are links to the matching page section title, unless a link is found in the feed item text. In the above, the "First Feed Item" links to the section "[[#First Item]]", while the "Second Feed Item" links to "[[Main page]]". This behaviour can be changed per wiki see below.

Tagging and Filtering[edit | edit source]

As of version 0.6, WikiArticleFeeds supports tagging by way of either the <itemTags> tag or {{itemTags}} parser function.

To tag a feed item, insert either the <itemTags> tag, or the a call to the {{itemTags}} parser function somewhere between the opening header of the item (== Item Title ==) and the header of the next item.

For example, to mark an item about dogs and cats, you could do any of the following:

<itemTags>dogs, cats</itemTags>
{{#itemTags:dogs, cats}}
{{#itemTags:dogs|cats}}

Tagging an item does nothing to the finished page itself other than add an HTML comment indicating the tag. Also, it will not affect the feed directly as this does not inject real actual RSS or Atom categories.

However, once you've tagged items, you can filter a feed by the item tags. For example consider the following URL:

http://jimbojw.com/wiki/index.php?title=Blog&action=feed

This will generate a feed from the page called [[Blog]], containing all items therein. Now consider this variant:

http://jimbojw.com/wiki/index.php?title=Blog&action=feed&tags=mediawiki

This will also generate a feed, but it will only contain items which have been tagged as 'mediawiki' articles.

Extended Example[edit | edit source]

For an article to be considered a feed, it must have at least one feed section.

To delimit a section use the <startFeed /> and <endFeed /> tags respectively. These tags are merely flags, and any attributes specified, or content inside the tags themselves will be ignored.

Mixed Level Headings[edit | edit source]

Having a mix of level headings is ok, but only the sections highest level heading (lowest number) will be considered feed items:

<startFeed />
=== More Rain ===
Nope. Today it was rainy, again. Blah.

==== This is not a new Item ====
This text and the preceding heading both belong to the "More Rain" item.

=== Not Sunny Today ===
Not quite rainy, just foggy, maybe it'll get better?
<endFeed />

Attribution[edit | edit source]

A single instance of the default signature gives credit to the author of an item: "~~~~" when you edit the MediaWiki page and when the feed is rendered. WikiArticleFeeds is smart enough to detect it as a declaration of the Author and Date.

Although attribution is not required, you are strongly recommended to follow this convention. Externally, it aids the reader of the feed by providing more meta-data about the item. Internally, it permits aggregation to operate more smoothly (see next section).

Aggregation[edit | edit source]

WikiArticleFeeds can combine or aggregate feeds. For example, consider the following wiki markup:

<startFeed />
=== More Rain ===
Nope. Today it was rainy, again. Blah. --[[User:Anon|Anon]] 08:42, 4 December 2006 (MST)
<endFeed />

...

<startFeed />
=== Not Sunny Today ===
Not quite rainy, just foggy, maybe it'll get better? --[[User:Anon|Anon]] 09:56, 3 December 2006 (MST)
<endFeed />

When this page is converted into a single feed, both the "Not Sunny Today" and "More Rain" items will appear, in reverse chronological order (newest first) and permits the pulling together of feeds on separate pages via MediaWiki Template notation (also sometimes referred to as Transclusion).

For example, consider the following three articles:

Rainy Feed
<startFeed />
=== More Rain ===
Nope. Today it was rainy, again. Blah. --[[User:Anon|Anon]] 08:42, 4 December 2006 (MST)

=== Not Sunny Today ===
Not quite rainy, just foggy, maybe it'll get better? --[[User:Anon|Anon]] 09:56, 3 December 2006 (MST)
<endFeed />
Sunshiny Feed
<startFeed />
=== More Sunshiny ===
Just another beautiful day. --[[User:Anon|Anon]] 06:37, 18 August 2006 (MST)

=== Hoping for more Sun ===
Hope it's nice out tomorrow, too cloudy today ... --[[User:Anon|Anon]] 10:08, 14 August 2006 (MST)
<endFeed />
Aggregate Feed
== Rainy Feed ==
Contents of the Rainy Feed:
{{:Rainy Feed}}

== Sunshiny Feed ==
Contents of the Sunshiny Feed ==
{{:Sunshiny Feed}}

Rendering the article "Aggregate Feed" as a feed will result in a combination of all items in both "Rainy Feed" and "Sunshiny Feed".

Automatic Linking[edit | edit source]

There are two options for automatically creating the feed's link URL. First, if there are no URLs, or the only URLs in the feed text itself are part of the attribution, then the feed URL will be simply a link to the item in the page.

This behavior can be disabled by setting $wgForceArticleFeedSectionLinks to true in LocalSettings.php. See the installation section for details.

So for example, in this feed the feed item URL

== Some Item ==
Some blog text. --[[User:Anon|Anon]] 10:08, 14 August 2006 (MST)

will become a link to [[#Some Item]].

The other method of auto-linking is based on non-attribution links, wherein the first non-attribution link found in the feed text becomes the feed item URL as in

== Some Item ==
Checkout my new [[Main Page]] - it's great, and check also the [[Announcements]]). --[[User:Anon|Anon]] 10:08, 14 August 2006 (MST)

where the feed item URL will become link to [[Main Page]].