Extension:RSS
|
RSS Release status: stable |
|||
|---|---|---|---|
| Implementation | Tag | ||
| Description | Display RSS feeds on a wiki page | ||
| Author(s) | Kellan Elliott-McCrea, mutante, Daniel Kinzler, Rdb, Mafs, Alxndr, Wikinaut, Chris Reigrut, K001, Jeroen De Dauw, Jack Phoenix, Mark A. Hershberger | ||
| Last version | 2.16 (2012-04-24) | ||
| MediaWiki | 1.17+ | ||
| License | GPL | ||
| Download | latest RSS version on GitHub Download snapshot (Git master)
Git [?]: repo summary • tree • code changes SVN [?]: checkout-url • tree • code changes Change Log |
||
|
|||
|
|||
|
Check usage (experimental) |
|||
The RSS extension displays one or more RSS feeds on a wiki page in a standard or user-definable format. Since version 2.00, the extension is also compatible with wiki-page-generated feeds (RSS or ATOM).
Contents |
[edit] Download
You can download the code directly via Git from the MediaWiki source code repository (browse code) or download a snapshot (select your version of MediaWiki) and save it into the extensions/RSS directory of your wiki. To get the latest version of RSS, just clone the git master.
If you have shell access to your server, you may do this to download the extension:
cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/RSS.git
[edit] Installation
Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
- Place the following text in your LocalSettings.php file: require_once("$IP/extensions/RSS/RSS.php");
- Installation can now be verified through your wiki's Special:Version
[edit] Usage
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:
| 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
|
'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 extension supports filtering-out (i.e. grep -v) items based on title when in short list mode.
[edit] Templates for channel subelements and styling the RSS Feed
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 -->
[edit] Example
The following code renders the three recent items of the wikimedia blog feed on the present page and highlights some terms. The layout depends on the content of feed template Template:RSSPost and also of the item template MediaWiki:Rss-item as mentioned above:
<rss max=3 highlight="wiki foundation community">http://blog.wikimedia.org/feed/</rss>
- Cairo Pilot of Wikipedia Education Program nearing end of term
- As students in Cairo enter their last month of Wikipedia-editing before their final exam period, we are more than happy to report that the outcomes of the Cairo Pilot so far have been truly impressive. In an earlier blog post one of us (Annie Lin) described the plans and goals of the Cairo Pilot — [...]
- — Fri, 25 May 2012 16:35:11 +0000
- Wikimedia Foundation endorses mandates for free access to publicly funded research
- Scholarly information is often too expensive to access. Academic publishers sell journal subscriptions for thousands of dollars per journal per year. Typically, only universities and large libraries, not individuals, are able to pay those fees, which limits access to researchers and others affiliated with institutions with money. Are these costs justifiable when the underlying research [...]
- — Fri, 25 May 2012 15:00:34 +0000
- Commons Picture of the Day: Hippo kiss
- William Warby actually prefers photographing animals to humans because “animals don’t get impatient while you’re adjusting camera settings.” In this Picture of the Day, however, it was Warby’s patience that was running out. On a trip to the ZSL Whipsnade Zoo in Dunstable, England, Warby could not believe his luck when he chanced upon a [...]
- — Fri, 25 May 2012 13:00:18 +0000
[edit] Configuration settings
| 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
|
| $wgRSSUrlWhitelist
|
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
|
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
|
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 |
| $wgAllowImageTag | false | If you want to see images in feed items: then you need to globally allow image tags in your wiki by setting this MediaWiki parameter true |
[edit] It does not work: Message "Error parsing XML for RSS" shown - a solved problem
This was an old and ubiquitous problem, which is solved now. Former versions could not parse ATOM feeds and suffered from other HTTP fetch related problems. Problems have been solved in r112465 version 2.10 in February 2012.
[edit] Technical history and attributions
RSS extension is a heavily modified version of the engines RSS by Mafs, RSS by Rdb78, RSS by Duesentrieb, and RSSFeed by Mutante.
[edit] See also
- ↑ 1.0 1.1 http://www.php.net/date
- ↑ 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}}} }} - ↑ bug30377
- Alternate extensions:
|
|
This extension is being used on one or more of Wikimedia's wikis. This means that the extension is stable and works well enough to be used by such high traffic websites. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. |