=====New RSS Action, powered with Magpie RSS=====
>>**See also**
~-[[RSSHandler]]
~-JwRssTest
**Demos:** --Demo off--
>>For this action to work, you'll have to first download [[http://magpierss.sourceforge.net/ | Magpie RSS]] and put it in the **./3rdparty/plugins/magpierss/**.
(Note : **./** is the wikka base directory.)
After this is done, create a **./cache/** directory and make it writable.
::c::
And now, make a backup of the current RSS action (./actions/rss.php) and replace the old by this one :
%%(php)
cleanUrl(trim($rss_path));
if (preg_match("/^(http|https):\/\/([^\\s\"<>]+)$/i", $rss_path))
{
// Set Your Proxy Settings Here
define('MAGPIE_PROXY_HOST', '');
define('MAGPIE_PROXY_PORT', '');
// Path To MagpieRSS
define('MAGPIE_DIR', '3rdparty/plugins/magpierss/');
// Cache Settings
define('MAGPIE_CACHE_DIR', $rss_cache_path);
define('MAGPIE_CACHE_ON', $caching);
// Not sure how to use this one, so i'll stick with commenting it, default aging with Magpie is set to 1 hour.
#define('MAGPIE_CACHE_AGE', 10);
require_once(MAGPIE_DIR.'rss_fetch.inc');
$rss = fetch_rss( $rss_path );
if ($rss) {
$i = 1;
$cached_output = "
".$rss->channel['title']."
";
if ($rss->channel['link']) {
$cached_output .= '';
}
$cached_output .= "\n";
foreach ($rss->items as $item) {
$href = $item['link'];
$title = $item['title'];
if ($item['content']) {
$description = implode($item['content']);
}
else {
$description = $item['description'];
}
$cached_output .= "- $title
$description ";
if ($i >= $maxitems) {
break;
}
$i++;
}
$cached_output .= "
\n";
echo $this->ReturnSafeHTML($cached_output);
} else {
echo "An error occured when fetching or parsing the feed.
Check that the feed is compliant.";
}
} else {
echo 'Error: Invalid RSS syntax.
Proper usage: {{rss http://domain.com/feed.xml}} or {{rss url="http://domain.com/feed.xml" maxitems="5"}}';
}
?>
%%
You also need to patch the ##rss_fetch.inc## file included with magpierss. This patch adds proxy support. Save the file below as ##magpierss_proxy_support.patch## in the same directory as ##rss_fetch.inc## (usually ##3rdparty/plugins/magpierss##).
%%(patch)diff -u --recursive magpierss-0.71.1/rss_fetch.inc magpierss-0.71.1-proxy/rss_fetch.inc
--- magpierss-0.71.1/rss_fetch.inc 2005-02-09 13:59:01.000000000 -0600
+++ magpierss-0.71.1-proxy/rss_fetch.inc 2005-08-06 16:52:02.000000000 -0500
@@ -270,6 +270,8 @@
$client->agent = MAGPIE_USER_AGENT;
$client->read_timeout = MAGPIE_FETCH_TIME_OUT;
$client->use_gzip = MAGPIE_USE_GZIP;
+ $client->proxy_host = MAGPIE_PROXY_HOST;
+ $client->proxy_port = MAGPIE_PROXY_PORT;
if (is_array($headers) ) {
$client->rawheaders = $headers;
}
@@ -391,6 +393,14 @@
if ( !defined('MAGPIE_USE_GZIP') ) {
define('MAGPIE_USE_GZIP', true);
}
+
+ if ( !defined('MAGPIE_PROXY_HOST') ) {
+ define ('MAGPIE_PROXY_HOST', '');
+ }
+
+ if ( !defined('MAGPIE_PROXY_PORT', '') ) {
+ define ('MAGPIE_PROXY_PORT', '');
+ }
}
// NOTE: the following code should really be in Snoopy, or at least
%%
Change the the magpeirss directory. Then apply the patch by using the following command (in Linux):
%%(shell) patch -Np1