Censorship banner.png

Difference between revisions of "Help:RSS"

From Wiki - Hipatia
Jump to: navigation, search
m (Configuration settings)
Line 1: Line 1:
==Usage==
+
===The <nowiki><rss></nowiki> tag===
Use one section between <nowiki><rss></nowiki>-tags for each feed. The rss element may contain parameters if you provide them as attributes to the rss element:
+
The custom tag is called ''<nowiki><rss></nowiki>''. For instance, if you put ''<nowiki><rss>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml</rss></nowiki>'' then you will create a feed to BBC World news.  
{| style="border: solid 1px grey;"
 
|+ '''Parameters in the RSS tag'''
 
|- style="background: #8da7d6; cellpadding: 0; cellspacing: 0; border: solid 1px grey;"
 
! parameter (optional)
 
! comment
 
|- style="border: solid 1px grey;"
 
| <code>template="''name''"</code>
 
| 'name' (default: rss-item) is the name of a page in the MediaWiki template namespace, which is a template which comprises the name of another template 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
 
|- style="border: solid 1px grey;"
 
| <code>templatename="''Pagename''"</code> or<br/>
 
<code>templatename="''Namespace:Pagename''"</code><br/>
 
| 'Pagename' is the name of a template page which is used in the default template (defining the channel subelements) to finally format the RSS items; the template can be in the template namespace (first example denotes a page or any other namespace (second example uses the full specified form)
 
|- style="border: solid 1px grey;"
 
| <code>max="''n''"</code>
 
| show at most <code>''n''</code> channel subelements (items)
 
|- style="border: solid 1px grey;"
 
| <code>highlight="''term1 term2 ...''"</code>
 
| highlight terms in different colours
 
|- style="border: solid 1px grey;"
 
| <code>filter="''term1 term2 ...''"</code>
 
| show only RSS items with at least one of the <code>''term''</code>s
 
|- style="border: solid 1px grey;"
 
| <code>filterout="''term1 term2 ...''"</code>
 
| do not show any RSS item containing any of these terms
 
|- style="border: solid 1px grey;"
 
| <code>reverse</code>
 
| display the RSS items in reverse order
 
|}
 
  
This extension supports '''filtering-out''' (i.e. <code>grep -v</code>) items based on title when in short list mode.
+
;multiple feeds
 
+
:You can add more than one feed in a single ''<nowiki><rss></nowiki>'' tag to have them display in columns. Do so by adding "|" between the feed urls. Thus, ''<nowiki><rss>firsturl|secondurl|thirdurl</rss></nowiki>'' will create a reader with 3 columns, displaying items from all 3 feeds. Inside the ''<rss>'' tag you can include optional settings, which are detailed below:
==Templates for channel subelements and styling the RSS Feed ==
+
;''number''
If a template is not specified, then the one in [[MediaWiki:Rss-item]] is used and determines which RSS feed channel subelements (items) are used.
+
:By default, the reader will display all the items in the feed. If you want to display upto a maximum of a certain number of items, then add ''number='''n''''' (where '''n''' is the max number) inside the rss tag: <br><code><nowiki><rss number=10>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml</rss></nowiki></code><br> will display the last 10 stories from BBC World.
 
+
;''time''
The selected items are passed to another template [[Template:RSSPost]] which determines how the RSS Feed is rendered on the wiki pages. It iterates over each &lt;item&gt; of the RSS feed and substitutes the [http://cyber.law.harvard.edu/rss/rss.html#hrelementsOfLtitemgt value of each element found there], e.g. &lt;title&gt;, &lt;link&gt;, &lt;date&gt;, &lt;author&gt;, etc.
+
:By default, the reader will take the value of ''$egCacheTime'' as the amount of time (in seconds) between each local caching of the RSS feed. If you want a certain feed to refresh its cache more or less frequently, then add ''time='''t''''' (where '''t''' is the refresh time in seconds) inside the rss tag: <br><code><nowiki><rss time=7200>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml</rss></nowiki></code><br> will refresh the cache of stories from BBC World every 7200 seconds (2 hours). <br />The max and min time allowed for the time argument is governed by ''$egCacheTimeMin'' and ''$egCacheTimeMax'' in ''LocalSettings.php''. If the specified time falls outside this range, then it will revert to the default ''$egCacheTime'' value.
 
+
;''desc=off''
===Example===
+
:Hides the description provided by the feed.
The following code renders the 5 recent items of the wikimedia [http://blog.wikimedia.org/feed/ 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:<pre><rss max=5 highlight="wiki foundation public donation research community">http://blog.wikimedia.org/feed/</rss></pre>
+
;''width''
 
+
:If set to a legal value (between ''$egWidthMin'' and ''$egWidthMax'') it turns the RSS section into a floating div, aligned to the right, of the width specified (in pixels)
==Configuration settings==
+
;''title=off''
{| class="wikitable"
+
:Hides the title (and description in <code>desc=off</code>) of the feed.
|+
+
;''text''
|--
+
:By default, the reader will display the items as a bullet list of title links, but often the desired format is for each item to contain the description text. Add the "text" parameter to render the items in a div tag of class "rss", for example: <br><code><nowiki><rss text>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml</rss></nowiki></code><br>See [[OrganicDesign:Home]] for an example of this format, the CSS rules used in this example are shown in the CSS section below.
! 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 <code>false</code> or a timeout in seconds which is less than $wgRSSCacheAge after which a comparison will be made.
 
|--
 
| $wgRSSFetchTimeout
 
| 5
 
| read timeout in seconds
 
|--
 
| $wgRSSUserAgent
 
| <nowiki>'MediaWikiRSS/0.01 (+http://www.mediawiki.org/wiki/Extension:RSS) / MediaWiki RSS extension'</nowiki>
 
| User-Agent to use for fetching feeds<br/>
 
|--
 
| $wgRSSNamespaces
 
| null
 
| Ignore the RSS tag in all but the namespaces listed here<br/>
 
<code>null</code> means the <nowiki><rss></nowiki> tag can be used anywhere
 
|--
 
| $wgRSSAllowedFeeds
 
| array()
 
| 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
 
|--
 
| $wgRSSProxy
 
| false
 
| Optional proxy server to be used for fetching feeds<br/>
 
false: no proxy used
 
|}
 

Revision as of 18:01, 21 August 2011

The <rss> tag

The custom tag is called <rss>. For instance, if you put <rss>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml</rss> then you will create a feed to BBC World news.

multiple feeds
You can add more than one feed in a single <rss> tag to have them display in columns. Do so by adding "|" between the feed urls. Thus, <rss>firsturl|secondurl|thirdurl</rss> will create a reader with 3 columns, displaying items from all 3 feeds. Inside the <rss> tag you can include optional settings, which are detailed below:
number
By default, the reader will display all the items in the feed. If you want to display upto a maximum of a certain number of items, then add number=n (where n is the max number) inside the rss tag:
<rss number=10>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml</rss>
will display the last 10 stories from BBC World.
time
By default, the reader will take the value of $egCacheTime as the amount of time (in seconds) between each local caching of the RSS feed. If you want a certain feed to refresh its cache more or less frequently, then add time=t (where t is the refresh time in seconds) inside the rss tag:
<rss time=7200>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml</rss>
will refresh the cache of stories from BBC World every 7200 seconds (2 hours).
The max and min time allowed for the time argument is governed by $egCacheTimeMin and $egCacheTimeMax in LocalSettings.php. If the specified time falls outside this range, then it will revert to the default $egCacheTime value.
desc=off
Hides the description provided by the feed.
width
If set to a legal value (between $egWidthMin and $egWidthMax) it turns the RSS section into a floating div, aligned to the right, of the width specified (in pixels)
title=off
Hides the title (and description in desc=off) of the feed.
text
By default, the reader will display the items as a bullet list of title links, but often the desired format is for each item to contain the description text. Add the "text" parameter to render the items in a div tag of class "rss", for example:
<rss text>http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml</rss>
See OrganicDesign:Home for an example of this format, the CSS rules used in this example are shown in the CSS section below.