[Home]WikiPatches/RichSiteSummary

UseModWiki | WikiPatches | RecentChanges | Preferences

Here is my slightly refactored spike solution ... it hooks in at the point the RC log gets updated (but only if not a minor edit). To save trawling over the entire rclog it keeps it's own recent-recent-log, rebuilding it each time to keep only the last 15 unique entries. The code still needs a bunch of config variables instead of hard coding.

([more] bugs fixed)

See also MeatBall:RssExtensionModuleForWikis as implemented in /ModWiki.



use vars qw($RSSdataFile $RSS092File $SiteDomain);

# ...

$SiteDomain  = "www.IAwiki.net";                  # Domain of this wiki site
$RSSdataFile = "$DataDir/rss.data";               # List of recent page edits
$RSS092File  = "/var/www/html/rss092.xml";        # RSS XML of recent page edits

# ...

sub WriteRcLog {
# ... 
  if (!$isEdit) {
    &UpdateRSS($editTime, $id, $summary, $name);
  }
}

#---------------------------------------------------------------------------------------

sub UpdateRSS {
  my ($editTime, $id, $summary, $name) = @_;
  my ($status, $fileData) = &ReadFile($RSSdataFile);
  
  my $rss_data = join($FS, $editTime, $id, $summary, $name);

  my $newData = $rss_data . "\n";  # start the new datafile with the current RSS line
  my $i = 1;
  my $line;
  foreach $line (split("\n",$fileData)) {
    if ($i == 15) { 
      last;      # only keep track of 15 lines
    } else {
      my ($LineEditTime, $LineId, $LineSummary, $LineName) = split($FS, $line);
      if ($id ne $LineId) {
        # add line to new data, increment count
        $newData .=  $line . "\n";
        $i = $i + 1;
      }
    }
  }

  &WriteStringToFile($RSSdataFile, $newData);
  &GenerateRSSfile();
}

#---------------------------------------------------------------------------------------

sub GenerateRSSfile {
  my $RssXml = "";
  $RssXml .= '<?xml version="1.0"?>' . "\n";
  $RssXml .= '<rss version="0.92">' . "\n";
  $RssXml .= '<channel>' . "\n";
  $RssXml .= '<title>' . $SiteName . '</title>' . "\n";
  $RssXml .= "\t" . '<link>http://' . $SiteDomain . '/</link>' . "\n";
  $RssXml .= "\t" . '<description>The Information Architect\'s Wiki</description>' . "\n";
  $RssXml .= "\t" . '<language>en-us</language>' . "\n";
  $RssXml .= "\t" . '<lastBuildDate>' . &TimeToText(time) . '</lastBuildDate>' . "\n";
  $RssXml .= "\t" . '<docs>http://backend.userland.com/rss092</docs>' . "\n";
  $RssXml .= "\t" . '<managingEditor>IAwiki@ironclad.net.au (Eric Scheid)</managingEditor>' . "\n";
  $RssXml .= "\t" . '<webMaster>IAwiki@ironclad.net.au (Eric Scheid)</webMaster>' . "\n";

  my ($status, $fileData) = &ReadFile($RSSdataFile);
  my $line;
  foreach $line (split("\n", $fileData)) {
    my ($LineEditTime, $LineId, $LineSummary, $LineName) = split($FS, $line);
    $RssXml .= "\t<item>\n";
    $RssXml .= "\t\t<title>" . $LineId . "</title>\n";
    if (($LineSummary ne "")&&($LineSummary ne "*")) {
      $RssXml .= "\t\t<description>" . &QuoteHtml($LineSummary) . "</description>\n";
    }
    $RssXml .= "\t\t<link>http://" . $SiteDomain . "/cgi-bin/wiki.pl?" . $LineId . "</link>\n";
    $RssXml .= "\t</item>\n";
  }

  $RssXml .= "</channel>\n";
  $RssXml .= "</rss>\n";

  &WriteStringToFile($RSS092File, $RssXml);
  return;
}

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited October 21, 2007 11:43 am by JuanmaMP (diff)
Search: