[Pmwiki-users] Generating RSS from pmwiki

Carlisson Galdino bardo
Sat Dec 11 11:48:52 CST 2004


Saluton,


I'm Carlisson Galdino, from Brazil.

Chris Lott wrote:

>>My users would like a simple way to display RSS feeds in their wiki
>>pages. Feed2JS (http://jade.mcli.dist.maricopa.edu/feed/index.php)
>>seems to be a good answer, creating a simple javascript they can place
>>in their pages where they want to see the feed, except I don't see a
>>way to embed the javascript on the selected pages. How can I enable
>>this or facilitate their request?
>>    
>>
And to make pmWiki generate a RSS? I have hacked pmwiki today 
(literally) to add this feature.

The idea is: to search in pagefile (in wiki-syntax) for chapter titles 
(^\!Something$). Each title become an item and the next line (if it is 
not a chapter title too) will be its description. To make a RSS from a 
page, the only thing is to call action=rss.

I have used the Feed Creator class, under GNU LGPL 
(http://www.bitfolge.de/rsscreator-en.html), added to local directory). 
Below, there is the function HandleRSS. To use it, it is necessary to 
add 'rss'= 'HandleRSS' to HandleActions hash.

-------------------------------------------
function HandleRSS($pagename) {
  include "local/feedcreator.class.php";
  global $WikiTitle, $PageFileFmt, $ScriptUrl;
 
  $page = RetrieveAuthPage($pagename,"read");
  $rss = new UniversalFeedCreator();
  $rss->title = "$WikiTitle | $pagename";
  $rss->link = $ScriptUrl . "/" .  FmtPageName($PageFileFmt, $pagename);
  $rss->syndicationURL = "$rss->link?action=rss";
  if (!$page) Abort("?cannot source $pagename");
  Lock(0);
  $lines = explode("\n", $page["text"]);
  $count = 0;
  $descr = 0;
  foreach ($lines as $line) {
    if (preg_match("/^\!(.*)/", $line, $matches)) {
      if ($descr == 1) {
        $rss->addItem($feed);
      }
      $feed = new FeedItem();
      $feed->title = $matches[1];
      $feed->link = $rss->link . "#p" . ++$count;
     //It's not working. It's needed add <a name="pX" to every h1 in 
wikipage-text-body-html-generated.

      $descr = 0;
    } else {
      if (($count > 0) && ($descr == 0)) {
        $feed->description = $line;
        $descr = 1;
      }
    }
  }
  if ($descr == 1) {
    $rss->addItem($feed);
  }
  echo $rss->createFeed();
}
------------------------------------------------------------

It is now in use at http://www.cyaneus.net. Most precisely at 
http://www.cyaneus.net/wiki/index.php/Main/CyanNews (click RSS).


Cordial,

-- 
::::::::: C?rlisson Galdino ::::::::::
|| "Para as coisas mudarem e o mundo
|| melhorar, precisa virar tudo de
|| cabeca pra baixo. ...QUE VIRE!"
||                             --Bardo
... http://bardo.cyaneus.net       ...
... Jabber: andarilho at 12jabber.com ...
... Linux Counter:          309019 ...





More information about the pmwiki-users mailing list