r65229 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65228‎ | r65229 | r65230 >
Date:14:09, 18 April 2010
Author:siebrand
Status:ok
Tags:
Comment:
Rename rss extension to RSSNews per it's only file.
Modified paths:
  • /trunk/extensions/RSSNews (added) (history)
  • /trunk/extensions/RSSNews/RSSNews.php (modified) (history)
  • /trunk/extensions/rss (deleted) (history)

Diff [purge]

Index: trunk/extensions/RSSNews/RSSNews.php
@@ -0,0 +1,58 @@
 2+<?php
 3+# RSS News Feed extension
 4+# Adds news from an RSS feed to your wiki
 5+# To use, include this file from your LocalSettings.php
 6+
 7+$wgExtensionFunctions[] = "wfRSSFeedExtension";
 8+
 9+function wfRSSFeedExtension() {
 10+ global $wgParser;
 11+ $wgParser->setHook( "rss", "renderRSS" );
 12+}
 13+
 14+function renderRSS( $paramstring ) {
 15+ global $wgOut;
 16+
 17+ if ( ! @include_once( 'magpierss-0.71.1/rss_fetch.inc' ) ) {
 18+ return "<br /><b>Error: Missing magpierss-0.71.1. Download from <a href=\"http://magpierss.sourceforge.net/\">Sourceforge</a> " .
 19+ "and unpack to extensions/rss</b><br />";
 20+ }
 21+
 22+ $count = 99; # limit to 99 news entries by default
 23+
 24+ $wgOut->setSquidMaxage( 300 ); # Cache for 5 minutes only
 25+ $wgOut->enableClientCache( false );
 26+
 27+ $options = explode( "\n", trim( $paramstring ) );
 28+
 29+ if ( isset( $options[0] ) ) {
 30+ $url = $options[0];
 31+ if ( isset( $options[1] ) ) {
 32+ $count = IntVal( $options[1] );
 33+ }
 34+ } else {
 35+ return "<br /><b>Error: no RSS feed given.</b><br />";
 36+ }
 37+
 38+ $rss = fetch_rss( $url );
 39+ if ( ! $rss ) {
 40+ return "<br /><b>Error opening RSS feed $url.</b><br />";
 41+ }
 42+
 43+ $text = "<div class=\"rssfeed\"><h2>" . $rss->channel['title'] . "</h2>\n";
 44+ $text .= "<ul>\n";
 45+ $n = 1;
 46+
 47+ foreach ( $rss->items as $item ) {
 48+ $href = $item['link'];
 49+ $title = $item['title'];
 50+ $text .= "<li><a href=\"$href\">$title</a></li>\n";
 51+ $n++;
 52+ if ( $n > $count ) {
 53+ break;
 54+ }
 55+ }
 56+
 57+ $text .= "</ul></div>\n";
 58+ return $text;
 59+}
Property changes on: trunk/extensions/RSSNews/RSSNews.php
___________________________________________________________________
Name: svn:keywords
160 + Author Date Id Revision
Name: svn:eol-style
261 + native
Index: trunk/extensions/RSSNews/README
@@ -0,0 +1,21 @@
 2+This extension allows adding of RSS news feeds to a wiki page.
 3+The wikicode to include a feed is:
 4+
 5+ <rss>
 6+ http://url/of/some/feed.rss
 7+ 5
 8+ </rss>
 9+
 10+The number is optional and specifies how many items to show. The default
 11+is 99.
 12+
 13+You can customize the look of the generated news list using CSS. The
 14+generated HTML is within a <div class="rssfeed">:
 15+
 16+<div class="rssfeed">
 17+ <h2>TITLE OF RSS FEED</h2>
 18+ <ul>
 19+ <li><a href="...">HEADER LINE</a></li>
 20+ ...
 21+ </ul>
 22+</div>
Property changes on: trunk/extensions/RSSNews/README
___________________________________________________________________
Name: svn:keywords
123 + Author Date Id Revision
Name: svn:eol-style
224 + native

Status & tagging log