1 # Blosxom Plugin: seemore -*- perl -*-
2 # Author: Todd Larason (jtl@molehill.org)
4 # Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
5 # SeeMore plugin Home/Docs/Licensing:
6 # http://molelog.molehill.org/blox/Computers/Internet/Web/Blosxom/SeeMore/
8 # Modified 25-Sept-2004 Steve Schwarz
9 # Added $show_all_of_stories_until to not apply the plugin until the indicated
10 # story number is parsed.
14 # --- Configuration Variables ---
15 # regular expression to split on
16 $seemore_split ||= qr/\f|<!-- more -->/;
18 # show the whole article on individual article pages? Good for summaries,
19 # not so good for spoiler protection
20 $more_on_article = 1 unless defined $more_on_article;
22 # show the entire story (no "See More..." link) until the specified number
23 # of stories are shown. This allows index pages to show the entire story
24 # for the specified number of stories; afterwhich the "See More..." link
25 # is added to subsequent stories. This test is performed last so if
26 # $more_on_article is set it will be honored correctly.
27 # Default to applying to all stories.
28 $show_all_of_stories_until = 0 unless defined $show_all_of_stories_until;
30 $debug_level = 0 unless defined $debug_level;
31 # ----------------------------------------------------------------------
35 my $package = 'seemore';
36 my $story_cnt = 0; # current count of stories on this page
39 my ($level, @msg) = @_;
41 if ($debug_level >= $level) {
42 print STDERR "$package debug $level: @msg\n";
48 return $blosxom::template->('', "$package.$bit", $blosxom::flavour);
52 my ($bit, $path, $fn) = @_;
54 my $f = load_template($bit);
55 $f =~ s/((\$[\w:]+)|(\$\{[\w:]+\}))/$1 . "||''"/gee;
60 return 1 if $more_on_article and $blosxom::path_info =~ m:\.:;
61 return 1 if (CGI::param("seemore"));
62 return 1 if $story_cnt <= $show_all_of_stories_until;
63 # XXX return 1 if google/&c spider?
68 debug(1, "start() called, enabled");
69 $story_cnt = 0; # current count of stories on this page
71 last if /^(__END__)?$/;
72 my ($flavour, $comp, $txt) = split ' ',$_,3;
74 $blosxom::template{$flavour}{"$package.$comp"} = $txt;
80 my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
82 debug(2, "story() called");
85 ($$body_ref, $more) = split $seemore_split, $$body_ref, 2;
87 debug(2, "story() found more");
89 $$body_ref .= report('divider', $path, $filename) . $more;
91 $$body_ref .= report('showmore', $path, $filename);
98 error divider <hr class="seemore">\n
99 error showmore <p><a href="$blosxom::url$path/$fn.$blosxom::flavour?seemore=y" class="seemore">See more ...</a></p>\n
100 rss showmore <p><a href="$blosxom::url$path/$fn.$blosxom::default_flavour?seemore=y" class="seemore">See more ...</a></p>\n
105 Blosxom Plug-in: seemore
109 Purpose: Allows for long or spoiler-y posts to be split, with a "See more..." link
119 Todd Larason <jtl@molehill.org>, http://molelog.molehill.org/
121 This plugin is now maintained by the Blosxom Sourceforge Team,
122 <blosxom-devel@lists.sourceforge.net>.
126 None known; please send bug reports and feedback to the Blosxom
127 development mailing list <blosxom-devel@lists.sourceforge.net>.
131 =head2 Configuration variables
133 C<$seemore_split> is the regular expression used to find where to
134 split stories; the default matches either a form-feed character (as in
135 0+1i) or the string "<!-- more -->" (recommended for most peoples'
138 C<$more_on_article> controls whether the full article is shown on
139 individual article pages, or only on pages with the special 'seemore'
140 argument; it defaults to on (0+3i: this is a change of behavior from
141 previous versions). Turning this on makes sense if you're using seemore
142 to put summaries on a main index paage, but probably not if you're using it
143 for spoiler protection.
145 C<$show_all_of_stories_until> controls whether the plugin will not apply
146 until the indicated story number is parsed. This allows index pages to show
147 the entire story for the specified number of stories;
148 afterwhich the "See More..." link is added to subsequent stories.
150 C<$debug_level> can be set to a value between 0 and 5; 0 will output
151 no debug information, while 5 will be very verbose. The default is 1,
152 and should be changed after you've verified the plugin is working
155 =head2 Classes for CSS control
157 There's a class used, available for CSS customization.
159 * C<seemore> -- the <hr> dividing the short version of the story
160 from the rest, in the full-story view, and the <a> for the "See
161 more ..." link in the short view.
163 =head2 Flavour-style files
165 If you want a format change that can't be made by CSS, you can
166 override the HTML generated by creating files similar to Blosxom's
167 flavour files. They should be named seemore.I<bit>.I<flavour>; for
168 available I<bit>s and their default meanings, see the C<__DATA__>
169 section in the plugin.
174 Copyright 2003, Todd Larason
176 (This license is the same as Blosxom's)
178 Permission is hereby granted, free of charge, to any person obtaining a
179 copy of this software and associated documentation files (the "Software"),
180 to deal in the Software without restriction, including without limitation
181 the rights to use, copy, modify, merge, publish, distribute, sublicense,
182 and/or sell copies of the Software, and to permit persons to whom the
183 Software is furnished to do so, subject to the following conditions:
185 The above copyright notice and this permission notice shall be included
186 in all copies or substantial portions of the Software.
188 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
189 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
190 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
191 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
192 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
193 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
194 OTHER DEALINGS IN THE SOFTWARE.