DekiScript Star Rater

    TEMPLATEDOC WARNING: documentation URL in template 'StarRater' does not point to this page (should be 'http://developer.mindtouch.com/User:neilw/Templates_and_Extensions/DekiScript_Star_Rater')

    Description

    Simple DekiScript-based Star Rater, either for page ratings or anything else you want to rate.  It is inherently insecure, so it is only recommended for light-duty, non-critical usage.

    Requirements

    • MindTouch 10.0 or later.
    • You must attach the star.gif file to your template page.

    Version

    Version Date Author Description
    1.00b 6-May-2011 Neil Weinstock First "official" release

    How to Install

    These instructions will help you install the template'StarRater' on your wiki quickly and correctly.

    Perform the following steps:

    1. Copy the template source code:
      1. If the code in the "HTML Source" area below is not already visible and selected, click the "View" button to display and select it.
      2. Copy it to your clipboard (CTRL-C).
    2. Create a new template on your wiki:
      1. Select the Tools->Templates menu item on your wiki
      2. Click "New Page" button. This will open the editor on a new page with the title "Template:Page Title".
      3. Replace "Page Title" with the name of the template.
    3. Paste in the source code:
      1. In the editor, click the "View->Source" menu item to view the HTML source of the page.
      2. Select all text (CTRL-A).
      3. Paste in the template source code from the clipboard (CTRL-V).
    4. Click "Save" button.

    HTML Source for Template:StarRater

    Parameters

    Name Type Default Description
    property str? "star_data"

    Name of the property in which the voting data will be stored.  If you plan to have multiple StarRaters on a page, you should assign each one a unique property name to avoid collisions, otherwise, just leave this blank.

    The ID of the page is always tacked onto the end of the property name, so you can safely store the ratings data from multiple pages in the same page, without collision.

    msg str?

    <none> or

    "Rate this page:" if page==true

    This is the little "please vote" message that gets placed above the stars.  If this is not specified, and page==true (see below), this value will default to "Rate this page:".  If the current user does not have voting rights, then the message is not displayed
    page bool? false

    Page mode.  This is a convenience for when you use this as a page rating mechanism.  If true, then two things happen:

    1. The star rater is floated to the right
    2. The message (if not specified above) defaults to "Rate this page:"
    path str? page.path Path of the page where the voting data property will be stored.

    A note about security and related matters

    The description above includes a disclaimer that states that this is intended for "light, non-critical use".  There are three reasons for this: security, reliability, and scaleability.

    Security

    The page property used to store the ratings data must be updatable by the user.  That means that the user is free, if he or she wishes, to go and mess with out.  Most users neither know how to do this nor care, but the bottom line is that these ratings are inherently insecure, and that is a prime reason for the "non-critical" recommendation.

    You can improve your situation a bit by locating the property (using the path argument) on a separate page.  That gives you the option of protecting the page containing the ratings, although you may not always want this.

    Finally, I have (for now) put the property into the namespace where it is accessible by going to the "Set Page Properties" page from the "More" menu.  This makes it much easier to see what's going on (including seeing who voted how), and also to delete the property if you want to reset the ratings.  This makes it easier to go in and hack the ratings.  If folks want, I'll add an option one day to put the property into a "hidden" namespace, where it'll be more resistant to casual hackers, but also more difficult to go and fix if problems arise.

    Reliability

    If a lot of folks are trying to update the ratings at the same time, it'd probably be pretty easy to cause updates to fail.  This won't bring down the system (or even corrupt the ratings), but it will cause error messages to show to the user.  This is because the data storage method does not really support a proper atomic read/modify/write operation.

    Also, this has been tested on a good number of browsers, but browser incompatibility is always a possibility.  If so, please report the problem to the forum thread.

    Scalability

    This template has not been tested when a very large number of people vote.  I don't know if it'll run into problems or not.  It shouldn't, but you never know!

    Examples

    The page rater at the top right corner of the page is done like this:

    StarRater{page:true};
    

    Its data is stored in the "star_data" property (which you can see if you go to view the page properties for this page).

    Here's a non-page version with a custom message:

    StarRater("docs", "Rate the documentation:");
    

    This one also uses a different property name, to avoid colliding with the page rating.

    You get the idea!

    Credits

    The Star Rater CSS is based on the Komodo CSS Star Rater.

    Tag page
    Viewing 1 of 1 comments: view all
    Works great on Firefox 3.6
    Posted 11:24, 12 Mar 2010
    Viewing 1 of 1 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by