Table of Contents

stars Plugin

Compatible with DokuWiki

2008-05-05+

plugin Show stars for rating, difficulty etc.

Last updated on
2008-10-28
Provides
Syntax

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to howhard, rater, skill

Tagged with poll

Overview

Stars makes it easy to add a rating/difficulty system represented by a number of stars like 2.5 stars or 3/5 stars, etc. It has a simple markup and can handle whole and half stars.

It started as a different plugin called Skill, but it needed some changes suggested in the comments, and the author hadn’t done anything with the plugin since 2005 and didn’t respond to any emails wasn't interested in maintaining the plugin. Upgrades from the original plugin include:

Usage

Usage: [stars=num] where num

Screenshots

Stars Screenshot

Download and Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Change Log

Discussion

I found a few bugs in your otherwise nice plugin:

Here's a code-snippet with my updates, including improved alt text for the images:

function _Stars($d)
{
	$string="";
 
	// render full stars
	for($i=1; $i<=$d[0]; $i++)
		$string .= '<img class="starimage" src="/lib/plugins/stars/star.png" alt="' . $d[0] . '/' . $d[1] . ' stars"  />';
 
	// render half star if necessary
	if($i-.5 <= $d[0])
	{
		$string .= '<img class="halfstarimage" src="/lib/plugins/stars/halfstar.png" alt="' . $d[0] . '/' . $d[1] . ' stars"  />';
		$i++;
	} // end if($i-$d[0] > 0)
 
	for($i;$i<=$d[1];$i++)
		$string .= '<img class="emptystarimage" src="/lib/plugins/stars/emptystar.png" alt="' . $d[0] . '/' . $d[1] . ' stars" />';
 
	return $string;
} // end function _Stars($d)

Martin Bast 2008/09/29 15:52


Thanks Martin. I've made changes addressing the items you brought up. Looking back at the code, I fixed the line 114 problem so it works correctly now. I added alt text to the span, not the images (your way would display '7/10 stars' 10 times in a row if the images didn't load). I also tried to solve the relative path problem for pages nested in deeper directories – I don't have a wiki set up that way though, so it isn't tested.
Collin Green 2008/10/28 16:10


To display correctly the star images just change DOKU_PATH with DOKU_URL in lib/plugins/stars/syntax.php
Frank Contrepois 2008/12/30 10:06

It would be awesome if people could vote how many stars they want to give and the number of stars given would automatically adjust.

1)
Note: Stars automatically limits the number of stars to 10 – ratios over ten, e.g.: 100/500, will be reduced, e.g.: 2/10