Index: trunk/extensions/RSS/RELEASE-NOTES |
— | — | @@ -1,24 +1,70 @@ |
2 | | -Extension page on mediawiki.org: http://www.mediawiki.org/wiki/Extension:RSS |
| 2 | +RELEASE NOTES of the MediaWiki extension RSS |
| 3 | +http://www.mediawiki.org/wiki/Extension:RSS |
3 | 4 | |
4 | | -== Change Log == |
5 | | -*original by mutante 25.03.2005 |
6 | | -*extended by Duesentrieb 30.04.2005 |
7 | | -*extended by Rdb78 07.07.2005 |
8 | | -*extended by Mafs 10.07.2005, 24.07.2005 |
9 | | -*extended by Niffler 28.02.2006 |
10 | | -*modified by Dzag 07.2006 |
11 | | -*modified by Alxndr 09.2006 |
| 5 | +=== TO DO === |
| 6 | +* bug 30377 add a new parameter to limit the number of characters when rendering |
| 7 | + the channel item <description> |
| 8 | +* set an upper default limit for HttpRequest request size when fetching feeds |
| 9 | + doing a HEAD request first to ask for the size but that value may not be |
| 10 | + available. Check how much data is returned as its coming back |
| 11 | + in which case you'd override the content fetch callback and count data as it |
| 12 | + comes in or check the header, again, if it's provided, at the start of data |
| 13 | + coming in. Then you could abort cleanly once it's gotten too much |
| 14 | + (otherwise using the defaults - PHP will abort the entire program when your |
| 15 | + memory usage gets too high) |
| 16 | +* bug 30028 "Error parsing XML for RSS" - improve and harden Extension:RSS when |
| 17 | + parsing differently flavoured RSS feeds |
| 18 | + |
| 19 | +=== Version 1.90 2011-08-15 === |
| 20 | +* removed parsing of each single channel subelement (item) |
| 21 | +* only the finally constructed feed is sent to the recursive parser: |
| 22 | + in pre-1.9 versions, each channel subelement (item) was sent to the parser |
| 23 | +* [[MediaWiki:Rss-item]] default has channel subelement <description> added |
| 24 | +* Rss template default name has been changed: |
| 25 | + |
| 26 | + until 1.8: [[Template:RSSPost]] |
| 27 | + 1.9: [[MediaWiki:Rss-feed]], an existing [[Template:RSSPost]] |
| 28 | + takes precedence to be compatible to pre-1.9 versions |
| 29 | +* introducing [[MediaWiki:Rss-feed]] with a meaningful default. |
| 30 | + The channel subelements which make the feed are rendered in this |
| 31 | + new standard layout: |
| 32 | + * <title> |
| 33 | + : <description> |
| 34 | + : <author> <date> |
| 35 | +* There are several ways to customize the final layout of feed items: |
| 36 | + 1. Admins can change the [[MediaWiki:Rss-feed]] default page |
| 37 | + 2. Users can use the optional template= parameter to tell the extension |
| 38 | + to render the feed with a different layout |
| 39 | + <rss template=Pagename>...</rss> use layout as in [[Template:Pagename]] |
| 40 | + 3. <rss template=Namespace:Pagename>...</rss> use [[Namespace:Pagename]] |
| 41 | + |
| 42 | +=== Version 1.8 2010-10-19 === |
| 43 | +* removed dependencies on Snoopy in favor of MediaWiki's internal HttpRequest |
| 44 | +* removed MagpieRSS (perhaps to be replaced later with SimplePie) |
| 45 | + because of concerns about MagpieRSS's security problems and |
| 46 | + lack of maintenance. |
| 47 | +* Added ability to do more with the layout of RSS feeds. |
| 48 | + |
| 49 | +=== Version 1.7 2010-07-23 === |
| 50 | +* cleaned up, included MagpieRSS library |
| 51 | +* put into the WMF subversion repository by Jeroen De Dauw |
| 52 | + http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw |
| 53 | +* i18n file added by TranslateWiki.net people |
| 54 | + |
| 55 | +== Change Log of pre-1.7 versions 2010 and before == |
| 56 | +(latest on top) |
| 57 | +*modified by [[User:K001|K001]] 15:15, 26 January 2010 (UTC): version 1.6, added support for date formats |
| 58 | +*modified by Peter Newman: 03:15, 7 October 2009 (UTC) Added htmlspecialchars escaping to the displayed strings |
| 59 | +*modified by [[User:Cmreigrut|Cmreigrut]] 19:05, 19 November 2008 (UTC): added date (if specified) to short output |
| 60 | +*modified by --[[User:Wikinaut|Wikinaut]] 11:17, 7 May 2008 (UTC) : changed method to disable chaching; Extension is now compatible to MediaWiki 1.12 |
12 | 61 | *modified by Svanslyck 02.2008, replacing all « and » with " |
13 | 62 | *<del>This has been updated to work better on newer (1.9) MediaWiki software, with the help of [[User:Duesentrieb]]. --[[User:CryptoQuick|CryptoQuick]] 14:26, 24 January 2007 (UTC)</del> |
14 | 63 | **This appears not to be true; I have received numerous emails about it not working with 1.9+. I would love to help debug and fix the extension, but my host has not upgraded to PHP 5 and I'm thus stuck at MediaWiki 1.6.8, so that's as far as this is guaranteed to work properly. If anyone develops a fix, please post a link to it here! —[[User:Alxndr|Alxndr]] <sup>([[User talk:Alxndr|t]])</sup> 02:02, 16 June 2007 (UTC) |
15 | 64 | ***I just found [http://nako.us/2007/03/16/mediawiki-19-fix-for-wfstrencode/ this fork] that purports to have a fix for the new loss of wfStrEncode(). I can't test it though so can anyone else verify that it works? —[[User:Alxndr|Alxndr]] <sup>([[User talk:Alxndr|t]])</sup> 02:18, 16 June 2007 (UTC) |
16 | | -*modified by --[[User:Wikinaut|Wikinaut]] 11:17, 7 May 2008 (UTC) : changed method to disable chaching; Extension is now compatible to MediaWiki 1.12 |
17 | | -*modified by [[User:Cmreigrut|Cmreigrut]] 19:05, 19 November 2008 (UTC): added date (if specified) to short output |
18 | | -*modified by Peter Newman: 03:15, 7 October 2009 (UTC) Added htmlspecialchars escaping to the displayed strings |
19 | | -*modified by [[User:K001|K001]] 15:15, 26 January 2010 (UTC): version 1.6, added support for date formats |
20 | | - |
21 | | -=== Version 1.7 === |
22 | | -2010-7-23 |
23 | | - |
24 | | -* Cleaned up, included MagpieRSS library and put onto the WMF subversion repository by Jeroen De Dauw - http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw |
25 | | -* i18n file added by TranslateWiki.net people |
\ No newline at end of file |
| 65 | +*modified by Alxndr 09.2006 |
| 66 | +*modified by Dzag 07.2006 |
| 67 | +*extended by Niffler 28.02.2006 |
| 68 | +*extended by Mafs 10.07.2005, 24.07.2005 |
| 69 | +*extended by Rdb78 07.07.2005 |
| 70 | +*extended by Duesentrieb 30.04.2005 |
| 71 | +*original by mutante 25.03.2005 |
Index: trunk/extensions/RSS/RSSParser.php |
— | — | @@ -65,13 +65,42 @@ |
66 | 66 | $this->filterOut = self::explodeOnSpaces( $args['filterout'] ); |
67 | 67 | } |
68 | 68 | |
| 69 | + // 'template' is the pagename of a user's itemTemplate including |
| 70 | + // a further pagename for the feedTemplate |
| 71 | + // In that way everything is handled via these two pages |
| 72 | + // and no default pages or templates are used. |
| 73 | + |
| 74 | + // 'templatename' is an optional pagename of a user's feedTemplate |
| 75 | + // In that way it substitutes $1 (default: RSSPost) in MediaWiki:Rss-item |
| 76 | + |
69 | 77 | if ( isset( $args['template'] ) ) { |
70 | | - $titleObject = Title::newFromText( $args['template'], NS_TEMPLATE ); |
71 | | - $article = new Article( $titleObject, 0 ); |
72 | | - $this->itemTemplate = $article->fetchContent(); |
| 78 | + $itemTemplateTitleObject = Title::newFromText( $args['template'], NS_TEMPLATE ); |
| 79 | + $itemTemplateArticleObject = new Article( $itemTemplateTitleObject, 0 ); |
| 80 | + $this->itemTemplate = $itemTemplateArticleObject->fetchContent(); |
73 | 81 | } else { |
74 | | - $templateName = isset( $args['templatename'] ) ? $args['templatename'] : 'RSSPost'; |
75 | | - $this->itemTemplate = wfMsgNoTrans( 'rss-item', $templateName ); |
| 82 | + if ( isset( $args['templatename'] ) ) { |
| 83 | + $feedTemplatePagename = $args['templatename']; |
| 84 | + } else { |
| 85 | + |
| 86 | + // compatibility patch for rss extension |
| 87 | + |
| 88 | + $feedTemplatePagename = 'RSSPost'; |
| 89 | + $feedTemplateTitleObject = Title::newFromText( $feedTemplatePagename, NS_TEMPLATE ); |
| 90 | + |
| 91 | + if ( !$feedTemplateTitleObject->exists() ) { |
| 92 | + $feedTemplatePagename = Title::makeTitleSafe( NS_MEDIAWIKI, 'Rss-feed' ); |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + // MediaWiki:Rss-item = {{ feedTemplatePagename | title = {{{title}}} | ... }} |
| 97 | + |
| 98 | + // if the attribute parameter templatename= is not present |
| 99 | + // then it defaults to |
| 100 | + // {{ Template:RSSPost | title = {{{title}}} | ... }} - if Template:RSSPost exists from pre-1.9 versions |
| 101 | + // {{ MediaWiki:Rss-feed | title = {{{title}}} | ... }} - otherwise |
| 102 | + |
| 103 | + $this->itemTemplate = wfMsgNoTrans( 'rss-item', $feedTemplatePagename ); |
| 104 | + |
76 | 105 | } |
77 | 106 | } |
78 | 107 | |
— | — | @@ -213,8 +242,11 @@ |
214 | 243 | * @param $frame the frame param to pass to recursiveTagParse() |
215 | 244 | */ |
216 | 245 | function renderFeed( $parser, $frame ) { |
217 | | - $output = ''; |
218 | | - if ( isset( $this->itemTemplate ) ) { |
| 246 | + |
| 247 | + $renderedFeed = ''; |
| 248 | + |
| 249 | + if ( isset( $this->itemTemplate ) && isset( $parser ) && isset( $frame ) ) { |
| 250 | + |
219 | 251 | $headcnt = 0; |
220 | 252 | if ( $this->reversed ) { |
221 | 253 | $this->rss->items = array_reverse( $this->rss->items ); |
— | — | @@ -226,43 +258,48 @@ |
227 | 259 | } |
228 | 260 | |
229 | 261 | if ( $this->canDisplay( $item ) ) { |
230 | | - $output .= $this->renderItem( $item, $parser, $frame ); |
| 262 | + $renderedFeed .= $this->renderItem( $item ) . "\n"; |
231 | 263 | $headcnt++; |
232 | 264 | } |
233 | 265 | } |
234 | | - } |
235 | | - return $output; |
| 266 | + |
| 267 | + $renderedFeed = $parser->recursiveTagParse( $renderedFeed, $frame ); |
| 268 | + |
| 269 | + } |
| 270 | + |
| 271 | + return $renderedFeed; |
236 | 272 | } |
237 | 273 | |
238 | 274 | /** |
239 | 275 | * Render each item, filtering it out if necessary, applying any highlighting. |
240 | 276 | * |
241 | | - * @param $item Array: an array produced by RSSData where keys are the |
242 | | - * names of the RSS elements |
243 | | - * @param $parser Parser the parser param to pass to recursiveTagParse() |
244 | | - * @param $frame the frame param to pass to recursiveTagParse() |
| 277 | + * @param $item Array: an array produced by RSSData where keys are the names of the RSS elements |
245 | 278 | */ |
246 | | - protected function renderItem( $item, $parser, $frame ) { |
247 | | - $output = ""; |
248 | | - if ( isset( $parser ) && isset( $frame ) ) { |
249 | | - $rendered = $this->itemTemplate; |
250 | | - // $info will only be an XML element name, so we're safe |
251 | | - // using it. $item[$info] is handled by the XML parser -- |
252 | | - // and that means bad RSS with stuff like |
253 | | - // <description><script>alert("hi")</script></description> will find its |
254 | | - // rogue <script> tags neutered. |
255 | | - foreach ( array_keys( $item ) as $info ) { |
256 | | - if ( $info != 'link' ) { |
257 | | - $txt = $this->highlightTerms( $this->escapeTemplateParameter( $item[ $info ] ) ); |
258 | | - } else { |
259 | | - $txt = $this->sanitizeUrl( $item[ $info ] ); |
260 | | - } |
261 | | - $rendered = str_replace( '{{{' . $info . '}}}', $txt, $rendered ); |
| 279 | + protected function renderItem( $item ) { |
| 280 | + |
| 281 | + $renderedItem = $this->itemTemplate; |
| 282 | + |
| 283 | + // $info will only be an XML element name, so we're safe using it. |
| 284 | + // $item[$info] is handled by the XML parser -- |
| 285 | + // and that means bad RSS with stuff like |
| 286 | + // <description><script>alert("hi")</script></description> will find its |
| 287 | + // rogue <script> tags neutered. |
| 288 | + |
| 289 | + foreach ( array_keys( $item ) as $info ) { |
| 290 | + if ( $info != 'link' ) { |
| 291 | + $txt = $this->highlightTerms( $this->escapeTemplateParameter( $item[ $info ] ) ); |
| 292 | + } else { |
| 293 | + $txt = $this->sanitizeUrl( $item[ $info ] ); |
262 | 294 | } |
| 295 | + $renderedItem = str_replace( '{{{' . $info . '}}}', $txt, $renderedItem ); |
| 296 | + } |
263 | 297 | |
264 | | - $output = $parser->recursiveTagParse( $rendered, $frame ); |
265 | | - } |
266 | | - return $output; |
| 298 | + // nullify all remaining info items in the template |
| 299 | + // without a corresponding info in the current feed item |
| 300 | + |
| 301 | + $renderedItem = preg_replace( "!{{{[^}]+}}}!U", "", $renderedItem ); |
| 302 | + |
| 303 | + return $renderedItem; |
267 | 304 | } |
268 | 305 | |
269 | 306 | /** |
Index: trunk/extensions/RSS/RSS.i18n.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | * @author Łukasz Garczewski (TOR) <tor@wikia-inc.com> |
14 | 14 | */ |
15 | 15 | $messages['en'] = array( |
16 | | - 'rss-desc' => 'Displays an RSS feed on a wiki page', |
| 16 | + 'rss-desc' => 'Displays RSS feeds on MediaWiki pages in a standard or in user-definable formats using template pages', |
17 | 17 | 'rss-error' => 'Failed to load RSS feed from $1: $2', |
18 | 18 | 'rss-empty' => 'Failed to load RSS feed from $1!', |
19 | 19 | 'rss-fetch-nourl' => 'Fetch called without a URL!', |
— | — | @@ -20,9 +20,25 @@ |
21 | 21 | 'rss-parse-error' => 'Error parsing XML for RSS', |
22 | 22 | 'rss-ns-permission' => 'RSS is not allowed in this namespace', |
23 | 23 | 'rss-url-permission' => 'This URL is not allowed to be included', |
24 | | - 'rss-item' => '{{$1 | title = {{{title}}} | link = {{{link}}} | date = {{{date}}} | author = {{{author}}} }}', |
| 24 | + 'rss-item' => '{{$1 | title = {{{title}}} | link = {{{link}}} | date = {{{date}}} | author = {{{author}}} | description = {{{description}}} }}', |
| 25 | + 'rss-feed' => "<!-- the following are two alternative templates. The first is the basic default template for feeds -->; '''<span class='plainlinks'>[{{{link}}} {{{title}}}]</span>''' |
| 26 | +: {{{description}}} |
| 27 | +: {{{author}}} {{{date}}}<!-- don't use newline here --><!-- 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}}}}}|}} -->", |
25 | 28 | ); |
26 | 29 | |
| 30 | +$messages['qqq'] = array( |
| 31 | + 'rss-item' => " |
| 32 | +; $1 |
| 33 | +: ''not to be localised'' |
| 34 | +: The RSS extension substitutes this placeholder with the name of a template page. The content of this template page determines the final layout of the RSS feed on the rendered wiki page. The Extension:RSS currently uses 'MediaWiki:Rss-feed' as default for $1. This means that the content of [[MediaWiki:Rss-feed]] determines how RSS feed items are rendered. |
| 35 | +: It allows users to let RSS feeds rendered differently by using different (optional) 'template=<pagename>' parameters in the rss wiki tags. |
| 36 | +; title = {{{title}}} | link = {{{link}}} | ... |
| 37 | +: 'title' (left) is the variable name under which the content of an RSS feed field 'title' (right) is passed to the Template $1 where this is then used in the feed rendering. |
| 38 | +: This ''may'' be localised, but the content of the template $1 page (default [[MediaWiki:Rss-feed]] and potentially other RSS feed template pages on this wiki) needs then to be localised, too. |
| 39 | +: 'title' (right) is a name (property) of RSS feeds and is certainly not to be localised in any way. |
| 40 | +: ''I suggest not to localise anything.''", |
| 41 | +); |
| 42 | + |
27 | 43 | /** Afrikaans (Afrikaans) |
28 | 44 | * @author Naudefj |
29 | 45 | */ |
Index: trunk/extensions/RSS/RSS.php |
— | — | @@ -4,13 +4,13 @@ |
5 | 5 | * |
6 | 6 | * @file |
7 | 7 | * @ingroup Extensions |
8 | | - * @version 1.8 |
9 | | - * @author mutante, Daniel Kinzler, Rdb, Mafs, Alxndr, Chris Reigrut, K001 |
| 8 | + * @version 1.90 |
| 9 | + * @author mutante, Daniel Kinzler, Rdb, Mafs, Thomas Gries, Alxndr, Chris Reigrut, K001 |
10 | 10 | * @author Kellan Elliott-McCrea <kellan@protest.net> -- author of MagpieRSS |
11 | 11 | * @author Jeroen De Dauw |
12 | 12 | * @author Jack Phoenix <jack@countervandalism.net> |
13 | 13 | * @copyright © Kellan Elliott-McCrea <kellan@protest.net> |
14 | | - * @copyright © mutante, Daniel Kinzler, Rdb, Mafs, Alxndr, Chris Reigrut, K001 |
| 14 | + * @copyright © mutante, Daniel Kinzler, Rdb, Mafs, Thomas Gries, Alxndr, Chris Reigrut, K001 |
15 | 15 | * @link http://www.mediawiki.org/wiki/Extension:RSS Documentation |
16 | 16 | */ |
17 | 17 | |
— | — | @@ -21,21 +21,11 @@ |
22 | 22 | // Extension credits that will show up on Special:Version |
23 | 23 | $wgExtensionCredits['parserhook'][] = array( |
24 | 24 | 'name' => 'RSS feed', |
25 | | - 'author' => array( |
26 | | - 'Kellan Elliott-McCrea', |
27 | | - 'mutante', |
28 | | - 'Daniel Kinzler', |
29 | | - 'Rdb', |
30 | | - 'Mafs', |
31 | | - 'Alxndr', |
32 | | - 'Wikinaut', |
33 | | - 'Chris Reigrut', |
34 | | - 'K001', |
35 | | - 'Jack Phoenix', |
36 | | - 'Jeroen De Dauw', |
37 | | - 'Mark A. Hershberger' |
| 25 | + 'author' => array( 'Kellan Elliott-McCrea', 'mutante', 'Daniel Kinzler', |
| 26 | + 'Rdb', 'Mafs', 'Alxndr', 'Thomas Gries', 'Chris Reigrut', |
| 27 | + 'K001', 'Jack Phoenix', 'Jeroen De Dauw', 'Mark A. Hershberger' |
38 | 28 | ), |
39 | | - 'version' => '1.9', |
| 29 | + 'version' => '1.90 20110815', |
40 | 30 | 'url' => 'http://www.mediawiki.org/wiki/Extension:RSS', |
41 | 31 | 'descriptionmsg' => 'rss-desc', |
42 | 32 | ); |
— | — | @@ -49,16 +39,24 @@ |
50 | 40 | |
51 | 41 | $wgHooks['ParserFirstCallInit'][] = 'RSSHooks::parserInit'; |
52 | 42 | |
53 | | -$wgRSSCacheAge = 3600; // one hour |
54 | | -$wgRSSCacheCompare = false; // Check cached content, if available, against remote. |
55 | | - // $wgRSSCacheCompare should be set to false or a timeout |
56 | | - // (less than $wgRSSCacheAge) after which a comparison will |
57 | | - // be made. |
58 | | -$wgRSSFetchTimeout = 5; // 5 second timeout |
59 | | -$wgRSSNamespaces = null; // Ignore the RSS tag in all but the namespaces listed here. |
60 | | - // null (the default) means the <rss> tag can be used |
61 | | - // anywhere. |
| 43 | + // one hour |
| 44 | + $wgRSSCacheAge = 3600; |
62 | 45 | |
| 46 | +// Check cached content, if available, against remote. |
| 47 | +// $wgRSSCacheCompare should be set to false or a timeout |
| 48 | +// (less than $wgRSSCacheAge) after which a comparison will be made. |
| 49 | +$wgRSSCacheCompare = false; |
| 50 | + |
| 51 | +// 5 second timeout |
| 52 | +$wgRSSFetchTimeout = 5; |
| 53 | + |
| 54 | +// Ignore the RSS tag in all but the namespaces listed here. |
| 55 | +// null (the default) means the <rss> tag can be used anywhere. |
| 56 | +$wgRSSNamespaces = null; |
| 57 | + |
| 58 | +// URL whitelist of RSS Feeds: |
| 59 | +// if there are items in the array, and the used URL isn't in the array, |
| 60 | +// it will not be allowed (originally proposed in bug 27768) |
63 | 61 | $wgRSSAllowedFeeds = array(); |
64 | 62 | |
65 | 63 | // Agent to use for fetching feeds |