Wiki:Changes to RSS extension

From Vermont Area Group of Unix Enthusiasts

Jump to: navigation, search

These are changes to MW:Extension:RSS.

The following patch

  1. outputs a tighter, unordered ("bulleted") list instead of a definition list.
  2. decodes the XML entities so that they become HTML elements.
  3. strips HTML tags to give a text-only presentation of feeds.
  --- rss.php     2009/04/22 15:34:39
  +++ rss.php     2009/04/22 16:49:19
  @@ -132,7 +132,7 @@
   
          #Build items
          if ( !$short and $description ) { #full item list
  -               $output.= '<dl>';
  +               $output.= '<ul>';
   
                  foreach ( $rss->items as $item ) {
                          $d_text = true;
  @@ -151,12 +151,16 @@
                          #Build description text if desired
                          if ( $item['description'] ) {
                                  $text = trim( iconv( $charset, $wgOutputEncoding, $item['description'] ) );
  +                               $text = html_entity_decode($text);
                                  #Avoid pre-tags
                                  $text = str_replace( "\r", ' ', $text );
                                  $text = str_replace( "\n", ' ', $text );
                                  $text = str_replace( "\t", ' ', $text );
                                  $text = str_replace( '<br>', '', $text );
  - 
  +
  +                               #Avoid all-tags
  +                               $text = strip_tags( $text );
  +
                                  $d_text = wfRssFilter( $text, $rssFilter );
                                  $d_text = wfRssFilterout( $text, $rssFilterout );
                                  $text = wfRssHighlight( $text, $rssHighlight );
  @@ -166,15 +170,15 @@
                                  $display = $d_title;
                          }
                          if ( $display ) {
  -                               $output.= "<dt><a href='$href'><b>$title</b></a></dt>";
  +                               $output.= "<li><a href='$href'><strong>$title</strong></a>";
                                  if ( $date ) $output.= " ($pubdate)";
  -                               if ( $text ) $output.= "<dd>$text <b>[<a href='$href'>?</a>]</b></dd>";
  +                               if ( $text ) $output.= " - $text</li>";
                          }
                          #Cut off output when maxheads is reached:
                          if ( ++$headcnt == $maxheads ) break;
                  }
   
  -               $output.= '</dl>';
  +               $output.= '</ul>';
          } else { #short item list
                  ## HACKY HACKY HACKY
                  $output.= '<ul>';

Posted to MW:Extension talk:RSS#HTML stripped out.

Personal tools