aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/poll.pm
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-11-26 20:50:46 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-11-26 20:50:46 +0000
commitfc11e4ad8106ffe9e2e27aeae72055e1f371e755 (patch)
tree3a7410d076b127a48ef9de5f0c3e75dca4e15121 /IkiWiki/Plugin/poll.pm
parentb1a0a59212731913108930a6466b5bfc9b392805 (diff)
downloadikiwiki-fc11e4ad8106ffe9e2e27aeae72055e1f371e755.tar
ikiwiki-fc11e4ad8106ffe9e2e27aeae72055e1f371e755.tar.gz
bugfixes
Diffstat (limited to 'IkiWiki/Plugin/poll.pm')
-rw-r--r--IkiWiki/Plugin/poll.pm26
1 files changed, 6 insertions, 20 deletions
diff --git a/IkiWiki/Plugin/poll.pm b/IkiWiki/Plugin/poll.pm
index e92d0292f..bca8f5d54 100644
--- a/IkiWiki/Plugin/poll.pm
+++ b/IkiWiki/Plugin/poll.pm
@@ -94,6 +94,7 @@ sub cgi ($) { #{{{
if (defined $oldchoice && $oldchoice eq $choice) {
# Same vote; no-op.
IkiWiki::redirect($cgi, "$config{url}/".htmlpage($page));
+ exit;
}
my $content=readfile(srcfile($pagesources{$page}));
@@ -104,28 +105,13 @@ sub cgi ($) { #{{{
my $escape=shift;
my $params=shift;
return "\\[[poll $params]]" if $escape;
- return $params unless --$num == 0;
- my @bits=split(' ', $params);
- my @ret;
- while (@bits) {
- my $n=shift @bits;
- if ($n=~/=/) {
- # val=param setting
- push @ret, $n;
- next;
+ if (--$num == 0) {
+ $params=~s/(^|\s+)(\d+)\s+"?\Q$choice\E"?(\s+|$)/$1.($2+1)." \"$choice\"".$3/se;
+ if (defined $oldchoice) {
+ $params=~s/(^|\s+)(\d+)\s+"?\Q$oldchoice\E"?(\s+|$)/$1.($2-1)." \"$oldchoice\"".$3/se;
}
- my $c=shift @bits;
- $c=~s/^"(.*)"/$1/g;
- next unless defined $n && defined $c;
- if ($c eq $choice) {
- $n++;
- }
- if (defined $oldchoice && $c eq $oldchoice) {
- $n--;
- }
- push @ret, $n, "\"$c\"";
}
- return "[[poll ".join(" ", @ret)."]]";
+ return "[[poll $params]]";
};
$content =~ s{(\\?)\[\[poll\s+([^]]+)\s*\]\]}{$edit->($1, $2)}seg;