1 # Blosxom Plugin: rating
2 # Author(s): Rael Dornfest <rael@oreilly.com>
4 # Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
8 # --- Configurable variables -----
10 # What's the default rating minimum?
13 # What's the default rating maximum?
16 # What's the width per rating point for graphical style?
19 # What's the height for graphical style?
22 # Where are the graphical images (rating_below.gif, rating.gif,
23 # rating_above.gif) kept?
24 my $image_url = "/images";
26 # --------------------------------
28 $numerical; # use as $rating::numerical in flavour templates
29 $textual; # use as $rating::textual in flavour templates
30 $graphical; # use as $rating::graphical in flavour templates
31 $star; # use as $rating::star in flavour templates
33 my $min = $meta::rating_min || $default_min;
34 my $max = $meta::rating_max || $default_max;
36 $image_url =~ s!/+$!!;
43 my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
45 # Don't bother unless there's a rating; clear out previous ratings
46 unless ($meta::rating) {
47 ($numerical, $textual, $graphical, $star) = (undef, undef, undef, undef);
51 # The numerical representation
52 $numerical = $meta::rating || 0;
55 $numerical < $min and $numerical = $min;
56 $numerical > $max and $numerical = $max;
58 # The textual representation
61 . '=' x ($numerical - $min)
63 . '=' x ($max - $numerical)
66 # The star representation
67 $star ='*' x $numerical;
69 # The graphical representation
71 qq{<img src="$image_url/rating_below.gif" height="$height" width="}
72 . ( $width * ( $numerical - $min ) ) . qq{" align="absmiddle">}
73 . qq{<img src="$image_url/rating.gif" height="$height" width="$width" align="absmiddle">}
74 . qq{<img src="$image_url/rating_above.gif" height="$height" width="}
75 . ( $width * ( $max - $numerical ) ) . qq{" align="absmiddle">};
86 Blosxom Plug-in: rating
90 For stories specifying a meta-rating value (using the meta plug-in),
91 this plug-in generates numerical, textual, star, and graphical representations
92 of said rating for use in a flavour template.
94 For example, a story specifying:
98 results in the following flavour template variables and associated
99 representations (the minimum, in this case, being 1 and maximum being 5):
101 $rating::numerical: 4
103 $rating::textual: <===O=>
108 <img src="/images/rating_below.gif" height="10" width="30">
109 <img src="/images/rating.gif" height="10" width="10">
110 <img src="/images/rating_above.gif" height="10" width="10">
112 Simply add one of these template variables wherever you please in your
113 story.{flavour} (e.g. story.html) flavour template and it'll be replaced
114 on the fly with your rating in the selected style.
116 A rating lower than the minimum is set to the minimum; a rating higher than
117 the maximum is set to the maximum.
121 The rating plug-in requires the meta plug-in, available at:
123 http://www.raelity.org/apps/blosxom/plugins/meta/meta.individual
127 Drop the rating plug-in into your Blosxom plugins folder.
131 The plug-in will just work out of the box without any configuration. All
132 further configuration is entirely optional.
134 # What's the default rating minimum?
137 The default minimum ($default_min) specifies the default minimum for the
138 rating scale. Besides adjusting the value of $default_min in the
139 plug-in's configuration section, you can override the minimum on a weblog
140 posting by posting basis by setting a meta-rating_min value in the entry
143 # What's the default rating maximum?
146 The default maximum ($default_max) specifies the default maximum for the
147 rating scale. Besides adjusting the value of $default_max in the
148 plug-in's configuration section, you can override the maximum on a weblog
149 posting by posting basis by setting a meta-rating_max value in the entry
152 # What's the width per rating point for graphical style?
155 Sets the width in pixels for each rating point (e.g. a rating of 2 with
156 $width set to 10 results in a bar of 20 pixels wide)..
158 # What's the height for graphical style?
161 Sets the height in pixels for each rating point.
163 # Where are the graphical images (rating_below.gif, rating.gif,
164 # rating_above.gif) kept?
165 my $image_url = "/images";
167 A relative or absolute URL pointing at the location of 1-pixel
168 rating_below.gif, rating.gif, and rating_above.gif images for use
169 in creating the graphical representation of the rating.
177 Rael Dornfest <rael@oreilly.com>, http://www.raelity.org/
179 This plugin is now maintained by the Blosxom Sourceforge Team,
180 <blosxom-devel@lists.sourceforge.net>.
184 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
186 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
190 None known; please send bug reports and feedback to the Blosxom
191 development mailing list <blosxom-devel@lists.sourceforge.net>.
195 Blosxom and this Blosxom Plug-in
196 Copyright 2003, Rael Dornfest
198 Permission is hereby granted, free of charge, to any person obtaining a
199 copy of this software and associated documentation files (the "Software"),
200 to deal in the Software without restriction, including without limitation
201 the rights to use, copy, modify, merge, publish, distribute, sublicense,
202 and/or sell copies of the Software, and to permit persons to whom the
203 Software is furnished to do so, subject to the following conditions:
205 The above copyright notice and this permission notice shall be included
206 in all copies or substantial portions of the Software.
208 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
209 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
210 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
211 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
212 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
213 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
214 OTHER DEALINGS IN THE SOFTWARE.