Web polls for Radiant CMS.
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.
<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>
If you are using the Oracle Enhance Adapter, you may want to add this to your environment.rb, in the after_initialize block: # By default, OracleEnhancedAdapter typecasts all columns of type DATE to Time or DateTime. # This will force DATE values with hour, min and secs equal to 0 to be typecasted to Date. ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates = true # The above can obviously cause problems, therefore this is to be preferred, # since it will typecast to DATE, only columns with “date” in their name (e.g. “creation_date“) ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
Thanks to David Coto (github.com/davec) for the many enhancements and specs.
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).