# Blosxom Plugin: seemore -*- perl -*- # Author: Todd Larason (jtl@molehill.org) # Version: 0+3i # Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/ # SeeMore plugin Home/Docs/Licensing: # http://molelog.molehill.org/blox/Computers/Internet/Web/Blosxom/SeeMore/ package seemore; # --- Configuration Variables --- # regular expression to split on $seemore_split ||= qr/\f|/; # show the whole artcile on individual article pages? Good for summaries, # not so good for spoiler protection $more_on_article = 1 unless defined $more_on_article; $debug_level = 1 unless defined $debug_level; # ---------------------------------------------------------------------- use FileHandle; use CGI; my $package = 'seemore'; sub debug { my ($level, @msg) = @_; if ($debug_level >= $level) { print STDERR "$package debug $level: @msg\n"; } } sub load_template { my ($bit) = @_; return $blosxom::template->('', "$package.$bit", $blosxom::flavour); } sub report { my ($bit, $path, $fn) = @_; my $f = load_template($bit); $f =~ s/((\$[\w:]+)|(\$\{[\w:]+\}))/$1 . "||''"/gee; return $f; } sub show_more_p { return 1 if $more_on_article and $blosxom::path_info =~ m:\.:; return 1 if (CGI::param("seemore")); # XXX return 1 if google/&c spider? return 0; } sub start { debug(1, "start() called, enabled"); while () { last if /^(__END__)?$/; my ($flavour, $comp, $txt) = split ' ',$_,3; $txt =~ s:\\n:\n:g; $blosxom::template{$flavour}{"$package.$comp"} = $txt; } return 1; } sub story { my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; debug(2, "story() called"); my $more; ($$body_ref, $more) = split $seemore_split, $$body_ref, 2; if ($more) { debug(2, "story() found more"); if (show_more_p()) { $$body_ref .= report('divider', $path, $filename) . $more; } else { $$body_ref .= report('showmore', $path, $filename); } } return 1; } 1; __DATA__ error divider
\n error showmore

See more ...

\n rss showmore

See more ...

\n __END__ =head1 NAME Blosxom Plug-in: seemore =head1 SYNOPSIS Purpose: Allows for long or spoiler-y posts to be split, with a "See more..." link =head1 VERSION 0+2i 2nd test release =head1 AUTHOR Todd Larason , http://molelog.molehill.org/ This plugin is now maintained by the Blosxom Sourceforge Team, . =head1 BUGS None known; please send bug reports and feedback to the Blosxom development mailing list . =head1 Customization =head2 Configuration variables C<$seemore_split> is the regular expression used to find where to split stories; the default matches either a form-feed character (as in 0+1i) or the string "" (recommended for most peoples' use). C<$more_on_article> controls whether the full article is shown on individual article pages, or only on pages with the special 'seemore' argument; it defaults to on (0+3i: this is a change of behavior from previous versions). Turning this on makes sense if you're using seemore to put summaries on a main index paage, but probably not if you're using it for spoiler protection. C<$debug_level> can be set to a value between 0 and 5; 0 will output no debug information, while 5 will be very verbose. The default is 1, and should be changed after you've verified the plugin is working correctly. =head2 Classes for CSS control There's a class used, available for CSS customization. * C -- the
dividing the short version of the story from the rest, in the full-story view, and the for the "See more ..." link in the short view. =head2 Flavour-style files If you want a format change that can't be made by CSS, you can override the HTML generated by creating files similar to Blosxom's flavour files. They should be named seemore.I.I; for available Is and their default meanings, see the C<__DATA__> section in the plugin. =head1 LICENSE this Blosxom Plug-in Copyright 2003, Todd Larason (This license is the same as Blosxom's) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.