Update perldocs in general plugins to point to current website/mailing list.
[blosxom-plugins.git] / general / seemore
blob04af4d2ae3c1646925a44128e56dcc8838372aed
1 # Blosxom Plugin: seemore                                          -*- perl -*-
2 # Author: Todd Larason (jtl@molehill.org)
3 # Version: 0+3i
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 package seemore;
10 # --- Configuration Variables ---
11 # regular expression to split on
12 $seemore_split ||= qr/\f|<!-- more -->/;
14 # show the whole artcile on individual article pages?  Good for summaries,
15 # not so good for spoiler protection
16 $more_on_article = 1 unless defined $more_on_article;
18 $debug_level = 1 unless defined $debug_level;
19 # ----------------------------------------------------------------------
21 use FileHandle;
22 use CGI;
23 my $package = 'seemore';
25 sub debug {
26     my ($level, @msg) = @_;
28     if ($debug_level >= $level) {
29         print STDERR "$package debug $level: @msg\n";
30     }
33 sub load_template {
34     my ($bit) = @_;
35     return $blosxom::template->('', "$package.$bit", $blosxom::flavour);
38 sub report {
39     my ($bit, $path, $fn) = @_;
41     my $f = load_template($bit);
42     $f =~ s/((\$[\w:]+)|(\$\{[\w:]+\}))/$1 . "||''"/gee;
43     return $f;
46 sub show_more_p {
47   return 1 if $more_on_article and $blosxom::path_info =~ m:\.:;
48   return 1 if (CGI::param("seemore"));
49 # XXX return 1 if google/&c spider?
50   return 0;
53 sub start {
54   debug(1, "start() called, enabled");
55   while (<DATA>) {
56     last if /^(__END__)?$/;
57     my ($flavour, $comp, $txt) = split ' ',$_,3;
58     $txt =~ s:\\n:\n:g;
59     $blosxom::template{$flavour}{"$package.$comp"} = $txt;
60   }
61   return 1;
64 sub story {
65   my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
67   debug(2, "story() called");
68   my $more;
69   ($$body_ref, $more) = split $seemore_split, $$body_ref, 2;
70   if ($more) {
71     debug(2, "story() found more");
72     if (show_more_p()) {
73       $$body_ref .= report('divider', $path, $filename) . $more;
74     } else {
75       $$body_ref .= report('showmore', $path, $filename);
76     }
77   }
78   return 1;
81 __DATA__
82 error divider <hr class="seemore">\n
83 error showmore <p><a href="$blosxom::url$path/$fn.$blosxom::flavour?seemore=y" class="seemore">See more ...</a></p>\n
84 rss showmore <p><a href="$blosxom::url$path/$fn.$blosxom::default_flavour?seemore=y" class="seemore">See more ...</a></p>\n
85 __END__
87 =head1 NAME
89 Blosxom Plug-in: seemore
91 =head1 SYNOPSIS
93 Purpose: Allows for long or spoiler-y posts to be split, with a "See more..." link
95 =head1 VERSION
97 0+2i
99 2nd test release
101 =head1 AUTHOR
103 Todd Larason  <jtl@molehill.org>, http://molelog.molehill.org/
105 This plugin is now maintained by the Blosxom Sourceforge Team,
106 <blosxom-devel@lists.sourceforge.net>.
108 =head1 BUGS
110 None known; please send bug reports and feedback to the Blosxom
111 development mailing list <blosxom-devel@lists.sourceforge.net>.
113 =head1 Customization
115 =head2 Configuration variables
117 C<$seemore_split> is the regular expression used to find where to
118 split stories; the default matches either a form-feed character (as in
119 0+1i) or the string "<!-- more -->" (recommended for most peoples'
120 use).
122 C<$more_on_article> controls whether the full article is shown on
123 individual article pages, or only on pages with the special 'seemore' 
124 argument; it defaults to on (0+3i: this is a change of behavior from
125 previous versions).  Turning this on makes sense if you're using seemore
126 to put summaries on a main index paage, but probably not if you're using it
127 for spoiler protection.
129 C<$debug_level> can be set to a value between 0 and 5; 0 will output
130 no debug information, while 5 will be very verbose.  The default is 1,
131 and should be changed after you've verified the plugin is working
132 correctly.
134 =head2 Classes for CSS control
136 There's a class used, available for CSS customization.
138   * C<seemore> -- the <hr> dividing the short version of the story
139     from the rest, in the full-story view, and the <a> for the "See
140     more ..." link in the short view.
142 =head2 Flavour-style files
144 If you want a format change that can't be made by CSS, you can
145 override the HTML generated by creating files similar to Blosxom's
146 flavour files.  They should be named seemore.I<bit>.I<flavour>; for
147 available I<bit>s and their default meanings, see the C<__DATA__>
148 section in the plugin.
150 =head1 LICENSE
152 this Blosxom Plug-in
153 Copyright 2003, Todd Larason
155 (This license is the same as Blosxom's)
157 Permission is hereby granted, free of charge, to any person obtaining a
158 copy of this software and associated documentation files (the "Software"),
159 to deal in the Software without restriction, including without limitation
160 the rights to use, copy, modify, merge, publish, distribute, sublicense,
161 and/or sell copies of the Software, and to permit persons to whom the
162 Software is furnished to do so, subject to the following conditions:
164 The above copyright notice and this permission notice shall be included
165 in all copies or substantial portions of the Software.
167 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
168 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
169 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
170 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
171 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
172 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
173 OTHER DEALINGS IN THE SOFTWARE.