[dokuwiki] RSS feed tweaks

  • From: "Joe Lapp" <joe.lapp@xxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 10 Sep 2005 17:32:20 -0500 (CDT)

Well, I made two tweaks to feed.php that may interest others:

(1) When $conf['rss_useheading'] evaluates true, the RSS entry is titled after 
the first heading on the page, rather than after the page ID.  I wasn't sure if 
I should use $conf['useheading'].

(2) When $conf['rss_skiptopara'] evaluates true, the RSS entry description 
begins at the first <p> tag of the page.  This allows a person browsing RSS to 
get readable text from the get-go, rather than requiring the user to have to 
wade through the page title, technorati tags, the date (if you're using #dt()#, 
as I am), etc., in order to get to the first sentence on the page.  Maybe 
someone can suggest a better config variable name.

This requires changing rssRecentChanges() so that the foreach begins as follows:

  foreach(array_keys($recents) as $id){
  
    list($title, $desc) = rssGetContent($id);
  
    $item = new FeedItem();
    $item->title = $title;

And it requires adding this function:

function rssGetContent($id) {
    global $conf;

    $title = $id;
    $xhtml = p_wiki_xhtml($id,'',false);

    if($conf['rss_useheading']) {
        $heading = p_get_first_heading($id);
        if(!empty($heading))
            $title = trim($heading);
    }
    if($conf['rss_skiptopara']) {
        $startPara = strpos($xhtml, '<p>');
        if($startPara !== false)
            $xhtml = substr($xhtml, $startPara);
    }
    return array($title, cleanDesc($xhtml));
}

~joe
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: