Extension:RSS Reader

This RSS Reader extension tries to provide a tool for including RSS feeds inside various articles across your wiki. It is best used on specialty pages made so that users can easily track the news, etc. This extension was made because all the other RSS extensions did not work or performed poorly on MediaWiki 1.10.

Usage
This extension is a parser extension which can be used by any wiki user. The function adds an   tag to use inside articles. Some modification of its behaviour is possible from LocalSettings.php as well.

LocalSettings.php
All the global variables used by the extension and modifiable by the user are listed here. If you modify these variables do so after the require_once statement:
 * $egCache
 * The boolean value that determines if caching should be done or not ; enabled by default, although distributions possibly need to disable this by default or change egCacheDir.


 * $egCacheDir
 * The path where parsed feeds are cached if egCache is enabled; it must obviously be writable to the www-data user.


 * $egCacheTime
 * The default amount of time (in seconds) between cachings of a feed. By default it is set to 3600 (1 hour). If a user does not specify a time argument or their argument is somehow corrupt, this value will be used.


 * $egCacheTimeMin
 * The minimum amount of time (in seconds) between cachings of a feed. By default it is set to 1800 (30 minutes). This is the most often a user can ask a feed to be refetched. Settings this time too low on busy servers might eat up a lot of server resources


 * $egCacheTimeMax
 * The maximum amount of time (in seconds) between cachings of a feed. By default it is set to 7200 (2 hours). This is the least often a user can ask a feed to be refetched.


 * $egNoFollow
 * Determines if all links created by the extension should have the  attribute. Default value is , if set to   then the   attribute will be added. Keep in mind, that some popular search engines (Yahoo! and Ask, for instance) will still follow, index and rank the links.


 * $egWidthMin
 * The minimum size (in pixels) of the width to which the size of a floating RSSbar can be set.


 * $egWidthMax
 * The maximum size (in pixels) of the width to which the size of a floating RSSbar can be set.

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


 * multiple feeds
 * You can add more than one feed in a single   tag to have them display in columns. Do so by adding "|" between the feed urls. Thus,  firsturl|secondurl|thirdurl  will create a reader with 3 columns, displaying items from all 3 feeds. Inside the   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: will display the last 10 stories from BBC World.

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.
 * 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: will refresh the cache of stories from BBC World every 7200 seconds (2 hours).


 * 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 ) 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: See Home for an example of this format, the CSS rules used in this example are shown in the CSS section below.

Pre-Requisites
Ensure you have php_curl installed and configured.

Download the copy of the win32 PHP (not the installer one) from php.net (whichever php version that you want running on your webserver). Then from dll folder, copy these two files: libeay32.dll and ssleay32.dll to your Windows/System32 (whichever Windows you have).

Then from the extensions folder: get your php_curl.dll and place it under your PHP/extensions folder.

Change your php.ini where it specifies the extension folder for example: extension_dir = "./extensions/"

And uncomment your extension to php_curl.dll for example: extension=php_curl.dll

Install
If you want to install RSS Reader to use database-centric caching instead of file-centric caching, refer to alternative RSS parser below.
 * 1) Create a folder called RSSReader in your extensions directory
 * 2) Download the lastRSScode and save it in your newly created folder as lastRSS.php
 * 3) Patch lastRSS.php with this patch
 * 4) Create a file called RSSReader.php in your new folder
 * 5) Copy and paste the RSSReader.php code into your new file
 * 6) Create a file called RSSReader.css in your new folder
 * 7) Copy and paste the RSSReader.css code into your new file
 * 8) Create a folder called cache in your RSSReader folder and set write permission on it
 * 9) In LocalSettings.php, add the following line:
 * 10) Modify RSSReader.css to your liking to better fit your skin

RSSReader.php
Create a folder called RSSReader. Inside this folder create the file: RSSReader.php "; } //close main "else"  return $output; } ?>

Alternative RSS Parser
If you do not want to (or can't) use files for caching, then an alternative to lastRSS exists. The alternative, wikiRSS, is not recomended since benchmarks have shown it to be upto three times slower (not a super big deal since both are fast, but still a concern).

If you server does not, then you can not run lastRSS. An alternative exists, cURLRSS, this uses the cURL library (which you need to be configured already) instead of. This is the perfect solution for DreamHost users.

Possible Issues
The error checking in this extension has improved substantially since its first version, but the code is still far from foolproof. Therefore, it is possible to run into a number of issues or errors that you would have to fix yourself or report in the discussion section of this article. Some issues that you might run into are listed below.

Different Directory
If you do not install this code in $IP/extensions/RSSReader/ then there could be some issues. If the RSSReader.css file is not placed in $IP/extensions/RSSReader/ then you should add a new remote path name to LocalSettings.php. For reference, the default value is: Do not forget the $wgScriptPath at the start of the path.

RSSReader.php and lastRSS.php have fewer restrictions on them than RSSReader.css. The only thing you need to ensure is that the two files are in the same directory, and RSSReader.php is properly referenced in LocalSettings.php.

PHP support for allow_url_fopen
Both  and   require that your version of PHP include support for. You'll get an error like Error: It's not possible to get http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml if your PHP is missing this option. (Run  to get information about your PHP binary.) Some managed hosting services have this option turned off by default, for security reasons.

Warnings

 * This extension turns off parser caching for all the pages on which the   tag is present. This could result in server strain if rss tags are present on many high traffic pages.

Acknowledgement

 * lastRSS.php was not written by the author of this extension. lastRSS.php was written by Vojtech Semecky and licensed under GPL. If you want more information about lastRSS.php check its site

0.2.6

 * Update from Debian src:mediawiki-extensions 2.11 upload
 * Fixes a remotely exploitable user security hole wrt. HTML in feed titles and bodies
 * Add $egCacheDir parameter, to allow people to point it to a writable directory to avoid having to disable $egCache when ./ is not writable to www-data (in Debian, we disable egCache by default; here on the Wiki page, it is enabled by default in the source code)
 * Fix installation path
 * Fix rendering path to CSS
 * Fix id="RSSMainBody" being used multiple times by making it into a CSS class that can be used for styling RSS output instead
 * Fix XHTML/1.0 Transitional validity of output
 * Fix a bunch of PHP warnings
 * Stop using  and sanitise RSS bodies correctly

0.2.5

 * Added a parameter called "text" which allows rendering of items in a div element of class "rss" which contains the item's description text (added by User:Nad).

0.2.4

 * Allowed user to hide title area
 * added new "title" attribute inside tag
 * Modified code formating a little
 * Added recognition of cURLRSS

0.2.3

 * Gave more flexible control of placement and size of the RSS feed
 * added new "width" attribute inside tag
 * added new global variables $egWidthMin and $egWidthMax to govern the allowed values for width
 * Improved the data in $wgExtensionCredits

0.2.2

 * Added $egNoFollow global variable to determine if rel="nofollow" should be added to all links
 * Added a "desc=off" option when placing RSSReader on page

0.2.1

 * Added recognition if wikiRSS or lastRSS is present
 * Added dynamic object loading (wikiRSS or lastRSS)
 * Added $egCache global variable to determine if caching should be done
 * Moved object initialization outside of fields for loop
 * Fixed an error in the error output to show the url
 * Improvement to comments and white space placing

0.2

 * Added license
 * Decoupled HTML and CSS (creating a seperate file for the CSS)
 * Gave more flexible control over time between cache
 * added new "time" attribute inside tag
 * Improved commenting in code
 * Improved error checking

Future Improvements

 * Expand on error checking
 * Provide more options for the user both inside the article and from LocalSettings.php
 * Provide more skinning options with CSS
 * Allow users to view an entry summary along with title
 * Add some fancy looking JavaScript
 * Allow parser functions along with tags
 * Allow users to pass a template to format the output

See other
Alternate extensions:
 * http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/rss/ broken
 * Extension:RSS
 * More: Category:RSS extensions