# Blosxom Plugin: seemore # Author: Todd Larason (jtl@molehill.org) # ported to Blosxom3 by Stu MacKenzie # Version: 0+3i # 2004-05-30 (v3.0a) port # Blosxom Home/Docs/Licensing: http://www.raelity.org/blosxom # SeeMore plugin Home/Docs/Licensing: # http://molelog.molehill.org/blox/Computers/Internet/Web/Blosxom/SeeMore/ # ported to Blosxom 3_0+3i by Stu MacKenzie, for the educational experience # Debug routines are gone package Blosxom::Plugin::seemore; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Configuration Section # # # # # # # # # # # # # # # # # # # my $seemore_split ||= qr/\f|/; # my $more_on_article = 1 unless defined $more_on_article; # # leave empty to call the current flavour; enter # a value to call the flavour of your choice when # displaying an individual entry my $flavor = ''; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $pkg_name = 'seemore'; # param $bit is 'divider' or 'showmore' sub report { my $self = shift; my $bit = shift; # couldn't get the template to interpolate correctly # without these local copies of Blosxom vars... my $url = $self->{request}->{url}; my $path = $self->{state}->{current_entry}->{path}; my $filename = $self->{state}->{current_entry}->{fn}; my $f = $self->{templates}->{$flavor}->{"$pkg_name.$bit"}; $f =~ s/((\$[\w:]+)|(\$\{[\w:]+\}))/$1 . "||''"/gee; return $f; } sub show_more_p { my $self = shift; return 1 if $more_on_article and $self->{request}->{path_info} =~ m:\.:; return 1 if $self->{cgi}->param('seemore'); return 0; } sub start { my $self = shift; $flavor or $flavor = $self->{request}->{flavour}; # exists $self->{request}->{flavor} or $flavor = $self->{request}->{flavour}; ## NOTE: template behavior will change when Rael restores fallback templates while () { last if /^(__END__)?$/; my ($flavour, $comp, $txt) = split ' ', $_, 3; # there's no more error templates built-in; 2nd best # choice seems to be swapping in current/called flavour if ($flavour eq 'error') { $flavour = $flavor} $txt =~ s:\\n:\n:g; $self->{templates}->{$flavour}->{"$pkg_name.$comp"} = $txt; } return 1; } sub story { my $self = shift; my $more; ($self->{state}->{current_entry}->{body}, $more) = split $seemore_split, $self->{state}->{current_entry}->{body}, 2; if ($more) { if (show_more_p($self)) { $self->{state}->{current_entry}->{body} .= report($self,'divider') . $more } else { $self->{state}->{current_entry}->{body} .= report($self,'showmore') } } return 1; } 1; __DATA__ error divider
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 2004-05-07 ported to Blosxom3 alpha by Stu MacKenzie =head1 AUTHOR Todd Larason , http://molelog.molehill.org/ ported to Blosxom3 alpha by Stu MacKenzie =head1 BUGS None known; address bug reports and comments to me or to the Blosxom mailing list [http://www.yahoogroups.com/groups.blosxom]. N O T E: this is just a port of Todd's original. If it doesn't work, there's nothing he should do about it ;-) =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 INSTALLATION 1) Enter configuration values per CONFIGURATION SECTION; 2) Make sure this file is named seemore3.pm and drop it into your blosxom3 plugins folder; 3) Add two lines to the handler files -- in the handlers.flow file, just _before_ 'Blosxom::find_entries' add: 'Blosxom::Plugin::seemore::start' (no quotes) and in the handlers.entry file, just _after_ 'Blosxom::read_entry_file' add: 'Blosxom::Plugin::seemore::story' (no quotes) NOTE: make sure you save the handler files with unix line-ends; 4) blog on. =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.