davec / radiant-polls-extension forked from nuex/radiant-polls-extension

Adds web polls to Radiant. This fork contains additional features.

This URL has Read+Write access

name age message
file LICENSE Sun Jan 25 20:03:24 -0800 2009 updated readme [nuex]
file README.rdoc Wed Jun 03 21:07:33 -0700 2009 Add ability to process collections of polls Th... [davec]
file Rakefile Loading commit data...
directory app/
directory db/
directory lib/
file polls_extension.rb
directory public/
directory spec/
README.rdoc

Polls Extension

Web polls for Radiant CMS.

Installation

Via Git Submodules:

  git submodule add git://github.com/nuex/radiant-polls-extension.git vendor/extensions/polls
  rake radiant:extensions:polls:migrate
  rake radiant:extensions:polls:update

This extension uses will_paginate to allow you to create a paginated list of "archived" polls. You must provide the will_paginate gem; it is not included with this extension.

Usage

  <r:poll title="My Poll">
    <r:unless_submitted>
      <r:form>
        <r:options:each>
          <p><r:input /> <r:title /></p>
        </r:options:each>
        <r:submit />
      </r:form>
    </r:unless_submitted>

    <r:if_submitted>
      <table>
        <tr>
          <th>Answer</th>
          <th>Result</th>
        </tr>
        <r:options:each>
          <tr>
            <td><r:title /></td>
            <td><r:number_responses /> (<r:percent_responses />)</td>
          </tr>
        </r:options:each>
      </table>
    </r:if_submitted>
  </r:poll>

If polls are defined with a start date, then the current poll (defined as the poll that has the latest start date that is no later than the current date) can be accessed without the use of the title attribute (i.e., <r:poll>…</r:poll>).

Poll "archives" can also be listed, using pagination via the will_paginate plugin.

  <r:polls per_page="10" by="start_date" order="desc">
    <r:each:poll>
      <p><r:title /></p>
      <table>
        <tr>
          <th>Answer</th>
          <th>Result</th>
        </tr>
        <r:options:each>
          <tr>
            <td><r:title /></td>
            <td><r:number_responses /> (<r:percent_responses />%)</td>
          </tr>
        </r:options:each>
      </table>
    </r:each:poll>
    <r:pages />
  </r:polls>

Acknowledgements

The date picker uses Dan Webb’s LowPro library and its associated date_selector behavior.

The pagination related code was borrowed liberally from the paginate extension, especially saturnflyer’s enhancements to it (github.com/saturnflyer/radiant-paginate-extension).