Extension:RSS

From MediaWiki.org
Jump to: navigation, search
shortcut: RSS
MediaWiki extensions manual - list
Crystal Clear action run.png
Extension:RSS Feed-icon.svg

Release status: stable

Implementation Tag
Description Display RSS feeds on a wiki page
Author(s) K. Elliott-McCrea, mutante, D. Kinzler, Rdb, Mafs, Alxndr, T. Gries, C. Reigrut, K001, J. De Dauw, J. Phoenix, M.A. Hershberger
Latest version 2.25.0 (2014-03-28)
MediaWiki 1.21, 1.22, 1.23+
PHP all versions since 5.3 ... 5.5
License GPL
Download
README

RELEASE-NOTES

Parameters

$wgRSSCacheAge
$wgRSSCacheFreshOnly
$wgRSSCacheCompare
$wgRSSOutputEncoding
$wgRSSInputEncoding
$wgRSSDetectEncoding
$wgRSSFetchTimeout
$wgRSSUserAgent

Hooks used
ParserFirstCallInit

Translate the RSS extension if possible

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

The RSS extension renders ("displays") one or more RSS feeds on a wiki page in a standard or user-definable format. Since version 2.00, the extension is compatible with Extension:WikiArticleFeeds which generates RSS or ATOM feeds from MediaWiki pages (authoring tool).

Download[edit | edit source]

You can download the extension directly from the MediaWiki source code repository (browse code). You can get:

One of the extensions tags

Not all extensions have tags. Some extensions have tags for each release, in which case those tags have the same stability as the release. To download a tag

  • Go to the tags list
  • Click the name of the tag you want to download
  • Click "snapshot"
The latest version of one of the extensions branches

Each extension has a master branch containing the latest code (might be unstable). Extensions can have further branches as well.

  • Go to the branches list
  • Click the branch name
  • Click "snapshot"
A snapshot made during the release of a MediaWiki version.

This might be unstable and is not guaranteed to work with the associated MediaWiki version.

After you've got the code, save it into the extensions/RSS directory of your wiki.

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

cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/RSS.git

Installation[edit | edit source]

  • Download and extract the files in a directory called RSS in your extensions/ folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository.
  • Add the following code at the bottom of your LocalSettings.php:
require_once( "$IP/extensions/RSS/RSS.php" );
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

Usage[edit | edit source]

Use one section between <rss>-tags for each feed. The rss element may contain parameters if you provide them as attributes to the rss element:

Parameters in the RSS tag
optional tag attributes comment
template="name" 'name' (default: rss-item) is the name of a page in the MediaWiki template namespace (default: MediaWiki:Rss-item), which is a template which comprises the name of another template (default: MediaWiki:Rss-feed since version 1.90; Template:RSSPost before version 1.90) and a list of named variables of RSS Feed channel subelements (item), these values then being passed to this other template to finally format the RSS items
templatename="Pagename" or

templatename="Namespace:Pagename"

'Pagename' is the name of a template page which is used in the default template MediaWiki:Rss-item (defining the channel subelements) to finally format the RSS items; the template can be in the template namespace (first example denotes a page Template:Pagename) or any other namespace (second example uses the full specified form Namespace:Pagename)
max="n" show at most n channel subelements (items)
highlight="term1 term2 ..." highlight terms in different colours
filter="term1 term2 ..." show only RSS items with at least one of the terms
filterout="term1 term2 ..." do not show any RSS item containing any of these terms
reverse display the RSS items in reverse order
date="(Y-m-d H:i:s)" date format string[1]
(since r111347)
item-max-length="1000" limits the number of character in item descriptions (since r111350)

This is not correctly working in v2.18 see bug 30377.

Templates for channel subelements and styling the RSS Feed[edit | edit source]

A manual setup is not necessarily required. You can skip this complicated documentation section.
One template name has been changed: MediaWiki:Rss-feed since version 1.90; Template:RSSPost before version 1.90.[2]

The RSS extension renders feeds on wiki page by using two templates in the MediaWiki system namespace, which can be changed, or which wiki admins can redirected to user-editable namespaces. The mechanism is perhaps not easy to understand, but after its installation, the extension starts with a useful set of templates; a manual set-up is not required.

If a template is not specified, then the one in MediaWiki:Rss-item is used and determines only which RSS feed channel subelements (items) are used. The other template MediaWiki:Rss-feed determines how the complete feed is shown on wiki pages i.e. how and which channel items are shown are listed.

This is the template MediaWiki:Rss-item (since version 1.90) which determines which item elements are used[2]

{{ MediaWiki:Rss-feed \
| title = {{{title}}} \
| link = {{{link}}} \
| date = {{{date}}} \
| author = {{{author}}} \
| description = {{{description}}} }}

The selected items are passed to the other template MediaWiki:Rss-feed (since version 1.90)[2] which determines how the RSS Feed is rendered on the wiki pages. It iterates over each <item> of the RSS feed and substitutes the value of each element found there, e.g. <title>, <link>, <date>, <author>, etc.

Basic MediaWiki:Rss-item template:

; '''<span class='plainlinks'>[{{{link}}} {{{title}}}]</span>'''
: {{{description}}}
: {{{author}}} {{{date}}}<!-- don't use newline here -->

An alternative improved MediaWiki:Rss-item template requires the Extension:ParserFunctions:

<!-- The second is an improved version which requires Extension:ParserFunctions --> \
; '''<span class='plainlinks'>[{{{link}}} {{{title}}}]</span>''' \
{{#if: {{{description|}}} \
|: {{{description}}}}}{{#if: {{{author|}}} \
| {{#if: {{{date|}}} |: — {{{author}}} {{{date}}}}} \
| {{#if: {{{author|}}}|: — {{{author}}}}} {{#if: {{{date|}}}|:{{{date}}}}}|}}<!-- don't use newline here -->

Example[edit | edit source]

The following code renders the four recent items of the wikimedia blog feed on the present page and highlights some terms. The layout depends on the content of feed template MediaWiki:Rss-feed and also of the item template MediaWiki:Rss-item as mentioned above:

<rss max=4 highlight="community wiki foundation">http://blog.wikimedia.org/feed/</rss>
VisualEditor gadgets
This post was written by two recipients of Individual Engagement Grants. These grants are awarded by the Wikimedia Foundation and aim to support Wikimedians in completing projects that benefit the...
— 2014-04-22 21:02:49
Wikimedia engineering report, March 2014
Major news in March include: an overview of webfonts, and the advantages and challenges of using them on Wikimedia sites; a series of essays written by Google Code-in students who shared their impr...
— 2014-04-18 12:37:55
Luis Villa: “I wanted to be an Internet lawyer”
Around legal circles, the Wikimedia Foundation is often seen as a curiosity. With a fraction of the staff of other top ten websites, the Foundation arguably does more with less. The core of this co...
— 2014-04-17 01:21:30
Katherine Maher joins the Wikimedia Foundation as Chief Communications Officer
Katherine Maher We’re happy to announce that Katherine Maher has joined the Wikimedia Foundation as Chief Communications Officer. She officially stepped into her new role as head of WMF communica...
— 2014-04-15 19:22:35



Configuration settings[edit | edit source]

Configuration settings in RSS.php
parameter default comment
$wgRSSCacheAge 3600 (one hour) Store entries in memcached for this many seconds
$wgRSSCacheCompare false Check cached content, if available, against remote. $wgRSSCacheCompare should be set to false or a timeout in seconds which is less than $wgRSSCacheAge after which a comparison will be made.
$wgRSSFetchTimeout 15 (since version 1.94)

5 (until version 1.93)

read timeout in seconds
$wgRSSUserAgent 'MediaWikiRSS/<Version> (+http://www.mediawiki.org/wiki/Extension:RSS) / MediaWiki RSS extension' User-Agent to use for fetching feeds
$wgRSSNamespaces null Ignore the RSS tag in all but the namespaces listed here

null means the <rss> tag can be used anywhere

$wgRSSUrlWhitelist


(since version 1.94)

array() (deny any URL = no whitelisted URLs) URL whitelist of RSS Feeds, the whitelist is empty by default and no URLs are allowed. If there are items in the array, and the used feed URL isn't in the array, it will not be allowed.
Use array( "*" ) if you as admin want to allow anyone to use any feed Url.
$wgRSSAllowedFeeds


(until version 1.93)

array() (allow any URL ) URL whitelist of RSS Feeds: if there are items in the array, and the used URL isn't in the array, it will not be allowed (originally proposed in bug 27768)
$wgRSSUrlNumberOfAllowedRedirects


(since version 2.10)

0 (no redirects are allowed) Maximum number of redirects to follow (defaults to 0). This should only be used when the target URLs are trusted to avoid attacks on intranet services accessible by HTTP.
$wgRSSProxy false Optional proxy server to be used for fetching feeds

false: no proxy used

$wgRSSDateDefaultFormat "Y-m-d H:i:s" default date format[1] for RSS publication dates (since r111347)
$wgRSSItemMaxLength

(deactivated in version 2.12 r113297; will be activated later.)[3]

200 default maximum length of item descriptions (since r111350)
$wgRSSAllowLinkTag false to allow active links in feed items
$wgRSSAllowImageTag false If you allow to see images in feed items. Do not confuse this parameter with $wgAllowImageTag of MediaWiki core, Display of images causes privacy problems, because the image is fetched in the browser context, so the (image-) server log will contain data of the requesting browser, see the discussion here.

Technical history and attributions[edit | edit source]

RSS extension is a heavily modified version of the engines RSS by Mafs, RSS by Rdb78, RSS by Duesentrieb, and RSSFeed by Mutante.

See also[edit | edit source]

  1. 1.0 1.1 http://php.net/date
  2. 2.0 2.1 2.2 Former versions before 1.90 used the name Template:RSSPost in the template MediaWiki:Rss-item which thus had the default value
    {{ RSSPost | title = {{{title}}} | link = {{{link}}} | date = {{{date}}} | author = {{{author}}} }}
    
  3. bug30377