Extension:WikiArticleFeeds

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
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)
Last version 0.6.6
MediaWiki 1.12+

not working in 1.19-svn before r110716

License The MIT License
Download Download snapshot
Subversion [Help]

Browse source code
View code changes

Example Blog - Trephine.org
Hooks used
UnknownAction

ArticlePurge
SkinTemplateToolboxEnd
OutputPageBeforeHTML
ParserBeforeTidy
ParserFirstCallInit

Check usage (experimental)
Bugs: list open list all report

The WikiArticleFeeds Extension is a MediaWiki extension for converting regular wiki articles into RSS and Atom feeds.

Contents

[edit] Installation

Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

  1. Download the files from SVN and place them under $IP/extensions/WikiArticleFeeds
  2. Add
    require_once("$IP/extensions/WikiArticleFeeds/WikiArticleFeeds.php");
    into your wiki's LocalSettings.php
  3. Installation can be verified through Special:Version

[edit] Configuration (optional)

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;

[edit] Usage

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.

[edit] Example

<startFeed />
Description of my feed.

=== Second Feed Item ===
Brand New! I just made a 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".

To add a new item, simply add a new wiki section between the startFeed and endFeed delimiters. Continuing the previous example:

<startFeed />
Description of my feed.
=== Third Item ===
When you get a chance, please check out the [[Main Page]]. --~~~~

=== Second Feed Item ===
Brand New! I just made a 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 />
Warning Warning: The current version of the extension requires plain signatures with timestamp without the talk page link to determine the feed item publication date from it.

Feed item publication dates are determined automatically from wiki signatures without talk page link, so in the above's "Third Item", the "--~~~~" results in a format which WikiArticleFeeds can parse (as in the first and second items).

Finally, the generated feed item URLs will be links to the matching page section, unless a link is made in the feed item text. In the above, the first two items would link to "[[#First Item]]" and "[[#Second Item]]", while the third would link to "[[Main Page]]".

[edit] Tagging and Filtering

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.

[edit] Extended Example

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.

For example, the following segment contains two feed items.

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

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

Note that the choice of level-3 heading ('===') is purely coincidental. Any normal heading depth is acceptable - from '=' (1) to '======' (6) as long as they're consistent within the feed block.

[edit] Mixed Level Headings

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

For example, the following is perfectly legitimate:

<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 />

[edit] Attribution

To give credit to the author of an item, the only thing that's required is a single instance of the default signature - "~~~~". This will be converted by MediaWiki at submit-time into the fully expanded user name and date of submission.

WikiArticleFeeds is smart enough to know that if it sees such a construct, it should treat this as a declaration of the Author and Date.

Although attribution is certainly 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).

[edit] Aggregation

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).

Although this particular use case may not seem too exciting, it does permit 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}}

As you can imagine, rendering the article "Aggregate Feed" as an RSS or Atom feed will result in a combination of all items in both "Rainy Feed" and "Sunshiny Feed".

[edit] Automatic Linking

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.

Note: 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 like in the example

== 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]].

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox