Censorship banner.png

Difference between revisions of "Help:RSS"

From Wiki - Hipatia
Jump to: navigation, search
(Undo revision 15506 by Argon (talk))
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
===The <nowiki><rss></nowiki> tag===
+
{{Help}}
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.  
+
==Usage==
 +
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:
 +
{| 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
 +
|}
  
;multiple feeds
+
This extension supports '''filtering-out''' (i.e. <code>grep -v</code>) items based on title when in short list mode.
: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:
+
 
;''number''
+
==Templates for channel subelements and styling the RSS Feed ==
: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.
+
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.
;''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: <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.
+
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.
;''desc=off''
+
 
:Hides the description provided by the feed.
+
===Example===
;''width''
+
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>
: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''
+
==Configuration settings==
:Hides the title (and description in <code>desc=off</code>) of the feed.
+
{| class="wikitable"
;''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
 +
|}

Latest revision as of 16:51, 21 September 2011

The help pages are provided by Hipatia volunteers to help wiki contributors.
Help index: Mediawiki Server configuration LaTeX Streaming Templates

Search for help:


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:

Parameters in the RSS tag
parameter (optional) comment
template="name" '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
templatename="Pagename" or

templatename="Namespace:Pagename"

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

This extension supports filtering-out (i.e. grep -v) items based on title when in short list mode.

Templates for channel subelements and styling the RSS Feed

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.

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 <item> of the RSS feed and substitutes the value of each element found there, e.g. <title>, <link>, <date>, <author>, etc.

Example

The following code renders the 5 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=5 highlight="wiki foundation public donation research community">http://blog.wikimedia.org/feed/</rss>

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 5 read timeout in seconds
$wgRSSUserAgent 'MediaWikiRSS/0.01 (+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

$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

false: no proxy used