WordPress.org

Ready to get started?Download WordPress

Forums

[NEW PLUGIN] Democracy AJAX Poll (90 posts)

  1. jalenack
    Member
    Posted 9 years ago #

    I’m announcing my second ever WordPress plugin, Democracy. Democracy adds polling functionality to your WordPress blog. It grew out of frustration with the only other WordPress polling option, WP-poll. It didn’t have valid markup, it was clunky, and it required one heck of an installation process. So I decided to create my own, using WP-poll as a reference. This plugin uses AJAX for quick sending and loading of poll data, although it doesn’t depend on javascript to function, like my other plugin. It is fully functional in non-javascript environments, meaning it will work in ALL browsers. The AJAX part is tested to work in Safari, Opera, Firefox, and IE6/Win. The poll is in my sidebar, so go ahead and see for yourself.

    For more information and the download: http://blog.jalenack.com/archives/democracy/

    It also has a full-featured admin panel, which allows one to manage their polls. You can activate, edit, delete, and add new polls from the admin panel. It is also harder to ballot-stuff than WP-poll. It uses cookies as well as IP logging to prevent users from working spamming the ballot box.

    And Installation is a piece of cake. Just upload it to your server, activate it, and place a template tag in your theme where you want the poll to appear.

    Note, this version is Alpha. However, it’s been thoroughly tested by around 10 people without problems, so it’s nothing like my shoutbox plugin that was so terrible in the early days. Please report any errors you encounter with it in the comments below. If you like it, saying thank you is all I ask.

  2. tomhanna
    Member
    Posted 9 years ago #

    If this is as good as WordSpew, I want it...unfortunately...

    The page you tried to navigate to does not exist. This could be because you typed in the wrong URL, you were given a bad link, or there was a server error. If you don't believe it was your problem, please contact the blog owner and alert them of this dead link. Ready to go back to the home page?

  3. jalenack
    Member
    Posted 9 years ago #

    Sorry, I've edited the link. Here it is again:

    http://blog.jalenack.com/archives/democracy/

  4. piginzen
    Member
    Posted 9 years ago #

    two words: badass.

    i can't spell,
    mat

  5. yesper
    Member
    Posted 9 years ago #

    I started to use Democracy and it seems to work ok
    http://www.turkku.com/blogi/

    However, I'd like to make cookie (and perhaps IP checking too?) to expire after 1 hour (polls on site are never serious but for fun).

    How do I do it? On 'Manage' panel you can't do nothing. What is that file requiring manual changes?

  6. jalenack
    Member
    Posted 9 years ago #

    Hey,

    That's kind of an odd request. But alright, it should be simple enough. You'll need to edit the democracy.php file. All of the action is at the bottom, whereas the functions are at the top.

    1. In the checkIP function (around the middle of the file [line 315 or so]) .. comment out the line that says
    die("Go stuff the ballot box elsewhere");

    2. At the bottom, edit the setcookie() information to only take one hour. Around line 489, change the time from time()+60*60*24*30*3 to time()+60*60

    3. Edit js.php, and look for document.cookie ... There should be some php around there. Again, change time to time()+60*60

    Good luck.

    On another note, I hope to release a new version of the poll in the near future.

  7. XeroCool
    Member
    Posted 9 years ago #

    n/m. Stupid tags.

  8. sunnyjpop
    Member
    Posted 9 years ago #

    Almost perfect...

    One thing, I am looking for the option to have some Polls allow for user submited answers? Is this possible in a future version?

  9. jalenack
    Member
    Posted 9 years ago #

    Sure, I could probably do that. As an option, of course. Not all people would want their users to be able to add answers.

  10. yesper
    Member
    Posted 9 years ago #

    # That's kind of an odd request.

    Well... basically, yes. If you have a site with a million voters per day, serious poll and a valuable prizes. But if there are only less than 100 visitors and poll is just for fun (with no prizes at all), then you perhaps like them to come back OFTEN and vote MORE! ;-)

    I made changes like you suggested. It's like this now.

    1. if (in_array($_SERVER['REMOTE_ADDR'], $results)) {
    // die("Go stuff the ballot box elsewhere!");
    }

    2. //set cookie for 3 months (now 1 hour!)
    setcookie("demVoted_" [...] aid,time()+60*60,'/');
    jal_checkIP();

    3. $offset = 60*60;

    Unfortunately cookie now seems not to work at all. You may try it here
    http://www.turkku.com/blogi/

    After voting the "Vote" button (in Finnish) won't fade from the results page and it's possible to go back and vote again. :-(

    Any suggestions?

  11. jalenack
    Member
    Posted 9 years ago #

    Hmm, when I vote, it works fine. I don't see the vote button again. And FYI, changing the $offset won't help. It is this line (126) of js.php that you need to change:

    ....expires=<?php echo gmdate("D, d M Y H:i:s",time() + 60*60)." UTC"; ?>;path=/;";

    Changing the $offset will just make the file cache more often, which is generally bad.

  12. jalenack
    Member
    Posted 9 years ago #

    Just updated to Alpha3, added a lot of new features:

    http://blog.jalenack.com/archives/democracy/

  13. yesper
    Member
    Posted 9 years ago #

    # Hmm, when I vote, it works fine. I don't see the vote button again.

    This was weird -- until I noticed that there were no troubles with Firefox (my default browser). As I "never" use IE myself and I had disabled everything possible there it didn't work. Restoring default (cookie etc.) settings fixed the problem.

    So the code is fine and so am I and my visitors. They now vote in every 12 hour. (60*60*12;)

    # Changing the $offset will just make the file cache more often, which is generally bad.

    That's good to know. Thanx!

  14. rafleet
    Member
    Posted 8 years ago #

    Got it installed, but don't find the admin button under MANAGE > (looking for Democrary, but it ain't there...)

    Running 1.5.1.3, using Connections template. Sidebar code is in, and shows "There are no polls in the database."

    Entire folder copied into plugings, aka.

    wp-content> plugins> democrary

    Is this correct? Look forward to using this one..

  15. editor
    Member
    Posted 8 years ago #

    Hello, I'm using Semiologic 2.5.2. I installed Democracy Alpha4. Apparently, everything was working fine, but when I cast a vote, I get a blank screen with the following error message:

    Hello! The page /&jal_no_js=true you requested is not available

    Any suggestions?

  16. juliano
    Member
    Posted 8 years ago #

    Here's some code I found useful with this plug-in.

    I wanted to associate a poll with a particular post, rather than having it visible throughout the blog.

    First, I put the code below in my theme's index.php, just after the call to the_content(). That's in the main page, not the sidebar.

    Then I created a poll and noted its number.

    Finally, I added a custom value to the post, called "pollNumber" with the value equal to the poll number.


    <?php
    $pollNumbers = get_post_custom_values('pollNumber');
    if($pollNumbers)
    {
    foreach (get_post_custom_values('pollNumber') as $pollNumber)
    {jal_democracy($pollNumber);}
    };
    ?>

  17. leliathomas
    Member
    Posted 8 years ago #

    Is it possible to order the poll results from greatest percentage of votes to least? Like this:

    Result1 - 25%
    Result2 - 13%
    Result3 - 5%
    Result4 - 2%

    This is an awesome plugin. Kudos to you. :D

  18. leliathomas
    Member
    Posted 8 years ago #

    Also, though this is unrelated, I thought you might like to know that IE6 on a screen resolution of 800x600 doesn't view your website correctly. Your header is fine, but your content and sidebar gets shoved to the left. Without looking at your code, it sort of makes me wonder if a CSS layer container isn't centered somewhere.

    Of course, it could just be this shit computer I'm on here at work. :-|

    Just thought I'd let you know in case you didn't already. :)

  19. jalenack
    Member
    Posted 8 years ago #

    Rafleet, it looks like you got it right. That is very strange. Have you figured it out yet?

    Editor, yeah....I found that bug last night. It is fixed in the svn, and I hope to release a new version some time. You can download the file here: http://dev.wp-plugins.org/file/democracy/trunk/democracy/democracy.php?rev=2681

    Also, that tells me that the javascript is not functioning properly. Perhaps your theme does not have <?php wp_head(); ?> in the header.php file

    juliano, cool. Note that that will only work with the AJAX for one poll per page. It should function though, without the AJAX. Get the fixed file I mentioned for Editor

    Leliathomas, that should be easy enough. I'll make it an option for the next version :) ... I had no idea about my site. I've got a huge 23" monitor and a Mac (I've got virtual PC though). I just checked and there is indeed a problem...Thanks for the heads up.

    Finally, I'll be gone this weekend, but after that I can deliver more Democracy update goodness. Cya

  20. rslonik
    Member
    Posted 8 years ago #

    Your plugin don't like PERMALINKS.

    The requested URL /operario/&jal_no_js=true was not found on this server.

    If you can fix it, please send me a "ping" at: rslonik[at]gmail[dot]com

  21. jalenack
    Member
    Posted 8 years ago #

    rslonik, it's designed to work with them. The problem you experienced is a bug that I highlighted earlier and I will update the download very soon.

    By the way, you should only be getting that error if you have javascript off or if you modified the header.php to get rid of the necessary hook: <?php wp_head(); ?>

    It is supposed to work with javascript both on and off, but the bug I mentioned is making it nonfunctional with javascript off. I'll update it!

  22. rslonik
    Member
    Posted 8 years ago #

    ok, i don't know if my js is on or off.
    I've made my own template, can this be a problem ?

    I'll watch this post by RSS,
    -waiting the update...

    ya's

  23. jalenack
    Member
    Posted 8 years ago #

    Ok, I've updated the download. Democracy Beta 1 fixes this and a small css problem in IE. It also allows you to set the order of the results, by vote or by id. Just change the options in the democracy.php file.

    rslonik, yes that could be a problem, but it is easy to fix. When I made my first theme, I did not know what <?php wp_head(); ?> did, so I deleted it. You may have done that too. Here's how to fix it:

    open the header.php file of your theme. Then, anywhere inside the <head> element, add <?php wp_head(); ?> To make sure it works, have my plugin active and then View Source. Somewhere near the top, you should see <!-- Added by Democracy Beta 1 --> or something like that, and then a reference to a css file and a javascript file. That means you're set up correctly.

    P.S. I'm going to be gone over the weekend, so get out your questions now or possibly early tomorrow morning. Cheers

  24. editor
    Member
    Posted 8 years ago #

    Jalenack: actually, it started working immediately after my post here :)
    I kept the old version, updated to Semiologic 2.5.4, and it keeps working....

  25. jalenack
    Member
    Posted 8 years ago #

    Another update is done. Fixes IP logging and validation errors, and many other things. Get it now!

  26. richschmidt
    Member
    Posted 8 years ago #

    Do you know why, in IE, I'm getting boxes around the radio buttons? I'm sure it's simple, but I'm still learning CSS, etc.

    Also, this only works with one poll on the screen at a time, correct? So there's no good way to show all the past polls on a single page?

  27. jalenack
    Member
    Posted 8 years ago #

    richschmidt, this is probably because your theme puts borders around all input elements. Try this CSS:

    #democracy label input {
    border: 0;
    }

    For the other question, I'm working on an archive function that will display past polls. I've got a ton on my plate right now, so have patience and I'll get to that as soon as I can.

  28. gutielua
    Member
    Posted 8 years ago #

    What I need to center the VOTE bottom on sidebar?

    I will like do to same for TAG question...

    Tnx

  29. Jesstech
    Member
    Posted 8 years ago #

    Rock on!! I'm so sick of screwing with WP-Poll's faulty syntax and horrid output.

    I can't wait to dive into this one. And AJAX, to boot! Thanks a bunch, Andrew!

  30. Ciryaquen
    Member
    Posted 8 years ago #

    Can someone post a link to the newest download please? I've only found the "alpha" version. (No doubt I'm getting something mixed up.)

Topic Closed

This topic has been closed to new replies.

About this Topic