# Blosxom3 Plugin: Summarize # Author: Bernie Simon # Version: 2005-01-22 # More notes at the bottom of this file or type: perldoc Summarize package Blosxom::Plugin::Summarize; #---------------------------------------------------------------------- # Configuration Section # Length of displayed summary use constant SUMMARY_LENGTH => 300; #---------------------------------------------------------------------- # call from handlers.entry sub run { my ($self) = @_; my $text = $self->{state}->{current_entry}->{body}; $text =~ s// /gs; $text =~ s/<[^>]*>/ /gs; $text =~ s/ / /g; $text =~ tr/\t\r\n / /s; my $summary = substr ($text, 0, SUMMARY_LENGTH); $summary =~ s/&/&/g; $summary =~ s//>/g; $summary =~ s/^\S*\s+//g; $summary =~ s/\s+\S*$//g; $summary =~ s/([^\?\!\.])$/$1 .../; $self->{state}->{current_entry}->{Plugin}->{Summarize}->{Summary} = $summary; return 1; } 1; __END__ =head1 NAME Blosxom Plug-in: Summarize.pm =head1 SYNOPSIS Creates a summary of a post by excerpting the first N characters. =head1 CONFIGURABLE VARIABLES Set SUMMARY_LENGTH to control the length of the excerpt. =head1 INSTALLATION Place this file in the plugins directory and add the following line to the handlers.entry file after Blosxom::read_entry_file Blosxom::Plugin::Summarize::run Add $Plugin::Summarize::Summary to your entry template file where you wish the summary to appear. The summary will be SUMMARY_LENGTH characters long annd have all html removed. =head1 AUTHOR Bernie Simon (http://carelesshand.net) =head1 LICENSE Copyright Bernard Simon, 2005. You may use this file as you wish as long as this copyright notice is maintained.