1 # Blosxom Plugin: rating
2 # Author(s): Rael Dornfest <rael@oreilly.com>
4 # Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/
5 # Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml
9 # --- Configurable variables -----
11 # What's the default rating minimum?
14 # What's the default rating maximum?
17 # What's the width per rating point for graphical style?
20 # What's the height for graphical style?
23 # Where are the graphical images (rating_below.gif, rating.gif,
24 # rating_above.gif) kept?
25 my $image_url = "/images";
27 # --------------------------------
29 $numerical; # use as $rating::numerical in flavour templates
30 $textual; # use as $rating::textual in flavour templates
31 $graphical; # use as $rating::graphical in flavour templates
32 $star; # use as $rating::star in flavour templates
34 my $min = $meta::rating_min || $default_min;
35 my $max = $meta::rating_max || $default_max;
37 $image_url =~ s!/+$!!;
44 my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
46 # Don't bother unless there's a rating; clear out previous ratings
47 unless ($meta::rating) {
48 ($numerical, $textual, $graphical, $star) = (undef, undef, undef, undef);
52 # The numerical representation
53 $numerical = $meta::rating || 0;
56 $numerical < $min and $numerical = $min;
57 $numerical > $max and $numerical = $max;
59 # The textual representation
62 . '=' x ($numerical - $min)
64 . '=' x ($max - $numerical)
67 # The star representation
68 $star ='*' x $numerical;
70 # The graphical representation
72 qq{<img src="$image_url/rating_below.gif" height="$height" width="}
73 . ( $width * ( $numerical - $min ) ) . qq{" align="absmiddle">}
74 . qq{<img src="$image_url/rating.gif" height="$height" width="$width" align="absmiddle">}
75 . qq{<img src="$image_url/rating_above.gif" height="$height" width="}
76 . ( $width * ( $max - $numerical ) ) . qq{" align="absmiddle">};
87 Blosxom Plug-in: rating
91 For stories specifying a meta-rating value (using the meta plug-in),
92 this plug-in generates numerical, textual, star, and graphical representations
93 of said rating for use in a flavour template.
95 For example, a story specifying:
99 results in the following flavour template variables and associated
100 representations (the minimum, in this case, being 1 and maximum being 5):
102 $rating::numerical: 4
104 $rating::textual: <===O=>
109 <img src="/images/rating_below.gif" height="10" width="30">
110 <img src="/images/rating.gif" height="10" width="10">
111 <img src="/images/rating_above.gif" height="10" width="10">
113 Simply add one of these template variables wherever you please in your
114 story.{flavour} (e.g. story.html) flavour template and it'll be replaced
115 on the fly with your rating in the selected style.
117 A rating lower than the minimum is set to the minimum; a rating higher than
118 the maximum is set to the maximum.
122 The rating plug-in requires the meta plug-in, available at:
124 http://www.raelity.org/apps/blosxom/plugins/meta/meta.individual
128 Drop the rating plug-in into your Blosxom plugins folder.
132 The plug-in will just work out of the box without any configuration. All
133 further configuration is entirely optional.
135 # What's the default rating minimum?
138 The default minimum ($default_min) specifies the default minimum for the
139 rating scale. Besides adjusting the value of $default_min in the
140 plug-in's configuration section, you can override the minimum on a weblog
141 posting by posting basis by setting a meta-rating_min value in the entry
144 # What's the default rating maximum?
147 The default maximum ($default_max) specifies the default maximum for the
148 rating scale. Besides adjusting the value of $default_max in the
149 plug-in's configuration section, you can override the maximum on a weblog
150 posting by posting basis by setting a meta-rating_max value in the entry
153 # What's the width per rating point for graphical style?
156 Sets the width in pixels for each rating point (e.g. a rating of 2 with
157 $width set to 10 results in a bar of 20 pixels wide)..
159 # What's the height for graphical style?
162 Sets the height in pixels for each rating point.
164 # Where are the graphical images (rating_below.gif, rating.gif,
165 # rating_above.gif) kept?
166 my $image_url = "/images";
168 A relative or absolute URL pointing at the location of 1-pixel
169 rating_below.gif, rating.gif, and rating_above.gif images for use
170 in creating the graphical representation of the rating.
178 Rael Dornfest <rael@oreilly.com>, http://www.raelity.org/
182 Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/
184 Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml
188 Address bug reports and comments to the Blosxom mailing list
189 [http://www.yahoogroups.com/group/blosxom].
193 Blosxom and this Blosxom Plug-in
194 Copyright 2003, Rael Dornfest
196 Permission is hereby granted, free of charge, to any person obtaining a
197 copy of this software and associated documentation files (the "Software"),
198 to deal in the Software without restriction, including without limitation
199 the rights to use, copy, modify, merge, publish, distribute, sublicense,
200 and/or sell copies of the Software, and to permit persons to whom the
201 Software is furnished to do so, subject to the following conditions:
203 The above copyright notice and this permission notice shall be included
204 in all copies or substantial portions of the Software.
206 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
207 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
208 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
209 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
210 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
211 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
212 OTHER DEALINGS IN THE SOFTWARE.