This patch allows you to generate an RSS feed of the page edits on your wiki. It is not part of 'Tavi 0.20, though it will be included in 'Tavi 0.21.

Return to TaviPatches.

  1. Edit allpages in lib/pagestore.php so that it returns the page version. Add the following in bold:
    $list[] = array($auth_res[1], $result[0], $auth_res[0], $auth_res[2],
    $auth_res[3], $auth_res[4], $auth_res[5] == 'on', $result[1]);
  2. Add the function listed below, html_gmtime, to parse/html.php.
  3. Create actions/rss.php as indicated below.
  4. Create template/rss.php as indicated below.
  5. Add the following item to the $ActionList array in index.php:
    'rss' => array('action/rss.php', 'action_rss', 'view')
  6. Add the following to config.php:
    // $InterWikiPrefix determines what interwiki prefix you recommend other
    // wikis use to link to your wiki. Usually it is similar to your WikiName.
    $InterWikiPrefix = 'your wiki's prefix';

Note that the RSS specification used to generate this is at meatball:ModWiki?. This implementation is subject to change as the specification changes, and as it is critiqued in light of the specification. ;-)

You may use the RSS feed as follows:


parse/html.php

function html_gmtime($timestamp)
{
  $time = mktime(substr($timestamp, 8, 2),  substr($timestamp, 10, 2),
                 substr($timestamp, 12, 2), substr($timestamp, 4, 2),
                 substr($timestamp, 6, 2),  substr($timestamp, 0, 4));
  return gmdate('Y-m-d', $time) . 'T' . gmdate('H:i:s', $time) . 'Z';
}

action/rss.php

<?php
require('template/rss.php');
require('parse/html.php');
require('parse/macros.php');

function action_rss()
{
  global $pagestore, $min, $days;

  $itemseq  = '';
  $itemdesc = '';

  if($min == 0)  { $min = 10; }
  if($days == 0) { $days = 2; }

  $pages = $pagestore->allpages();

  usort($pages, 'catSort');
  $now = time();

  for($i = 0; $i < count($pages); $i++)
  {
    $editTime = mktime(substr($pages[$i][0], 8, 2),  substr($pages[$i][0], 10, 2),
                       substr($pages[$i][0], 12, 2), substr($pages[$i][0], 4, 2),
                       substr($pages[$i][0], 6, 2),  substr($pages[$i][0], 0, 4));
    if($days >= 0 && ($now - $editTime) > $days * 24 * 60 * 60 && $i >= $min)
      { break; }

    $itemseq = $itemseq .
               '                <rdf:li rdf:resource="' .
               viewURL($pages[$i][1], $pages[$i][7]) . '" />' . "\n";
    $itemdesc = $itemdesc .
                '    <item rdf:about="' . viewURL($pages[$i][1], $pages[$i][7]) . '">' . "\n" .
                '        <title>' . $pages[$i][1] . '</title>' . "\n" .
                '        <link>' . viewURL($pages[$i][1]) . '</link>' . "\n" .
                '        <description>' . $pages[$i][5] . '</description>' . "\n" .
                '        <dc:date>' . html_gmtime($pages[$i][0]) . '</dc:date>' . "\n" .
                '        <dc:contributor>' . "\n" .
                '            <rdf:Description wiki:host="' . $pages[$i][2] . '"'. ($pages[$i][3] == '' ? '' : (' link="' . viewURL($pages[$i][3]) . '"')) . '>' . "\n" .
                ($pages[$i][3] == '' ? '' : ('                <rdf:value>' . $pages[$i][3] . '</rdf:value>' . "\n")) .
                '            </rdf:Description>' . "\n" .
                '        </dc:contributor>' . "\n" .
                '        <wiki:status>updated</wiki:status>' . "\n" .
                '        <wiki:importance>major</wiki:importance>' . "\n" .
                '        <wiki:diff>' . historyURL($pages[$i][1]) . '</wiki:diff>' . "\n" .
                '        <wiki:version>' . $pages[$i][7] . '</wiki:version>' . "\n" .
                '        <wiki:history>' . historyURL($pages[$i][1]) . '</wiki:history>' . "\n" .
                '    </item>' . "\n";
  }

  template_rss($itemseq, $itemdesc);
}

?>

template/rss.php

<?php
function template_rss($itemseq, $itemdesc)
{
  global $ScriptBase, $WikiName, $MetaDescription, $InterWikiPrefix;

  header('Content-type: text/plain');
?>
<?php print '<?xml '; ?>version="1.0" encoding="ISO-8859-1"?>
<rdf:RDF
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns="http://purl.org/rss/1.0/"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:wiki="http://purl.org/rss/1.0/modules/wiki/"
>
    <!--
        Add a "days=nnn" URL parameter to get nnn days of information
        (the default is 2).  Use days=-1 to show entire history.
        Add a "min=nnn" URL parameter to force a minimum of nnn entries
        in the output (the default is 10).
    -->
    <channel rdf:about="<?php print $ScriptBase; ?>">
        <title><?php print $WikiName; ?></title>
        <link><?php print $ScriptBase; ?></link>
        <description><?php print $MetaDescription; ?></description>
        <wiki:interwiki>
            <rdf:Description link="<?php print $ScriptBase . '?'; ?>">
                <rdf:value><?php print $InterWikiPrefix; ?></rdf:value>
            </rdf:Description>
        </wiki:interwiki>
        <items>
            <rdf:Seq>
<?php
  print $itemseq;
?>
            </rdf:Seq>
        </items>
    </channel>

<?php
  print $itemdesc;
?>

</rdf:RDF>
<?php
}
?>