summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-05-19 13:07:47 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-05-19 13:07:47 -0400
commitef003f48f4a3fe8fb67fda62c70a299b07d75976 (patch)
treecb5972026e6beed91b5eca2fa4962790244062bd /IkiWiki
parent53b1c6f559c1d09fbdbc28c8e4d5090dd455cd26 (diff)
parent4c5987d150b26f638494638f7861fb7646542a37 (diff)
Merge branch 'master' into po
Conflicts: debian/changelog
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/blogspam.pm17
-rw-r--r--IkiWiki/Plugin/brokenlinks.pm23
-rw-r--r--IkiWiki/Plugin/calendar.pm3
-rw-r--r--IkiWiki/Plugin/camelcase.pm2
-rw-r--r--IkiWiki/Plugin/comments.pm7
-rw-r--r--IkiWiki/Plugin/editpage.pm5
-rw-r--r--IkiWiki/Plugin/external.pm7
-rw-r--r--IkiWiki/Plugin/filecheck.pm18
-rw-r--r--IkiWiki/Plugin/img.pm2
-rw-r--r--IkiWiki/Plugin/inline.pm12
-rw-r--r--IkiWiki/Plugin/link.pm2
-rw-r--r--IkiWiki/Plugin/map.pm49
-rw-r--r--IkiWiki/Plugin/mdwn.pm2
-rw-r--r--IkiWiki/Plugin/meta.pm2
-rw-r--r--IkiWiki/Plugin/orphans.pm7
-rw-r--r--IkiWiki/Plugin/pagecount.pm10
-rw-r--r--IkiWiki/Plugin/pagestats.pm11
-rw-r--r--IkiWiki/Plugin/postsparkline.pm13
-rw-r--r--IkiWiki/Plugin/tag.pm6
-rw-r--r--IkiWiki/Plugin/textile.pm2
-rw-r--r--IkiWiki/Plugin/websetup.pm12
21 files changed, 108 insertions, 104 deletions
diff --git a/IkiWiki/Plugin/blogspam.pm b/IkiWiki/Plugin/blogspam.pm
index 58303418f..626c8ec42 100644
--- a/IkiWiki/Plugin/blogspam.pm
+++ b/IkiWiki/Plugin/blogspam.pm
@@ -9,6 +9,7 @@ my $defaulturl='http://test.blogspam.net:8888/';
sub import {
hook(type => "getsetup", id => "blogspam", call => \&getsetup);
+ hook(type => "checkconfig", id => "blogspam", call => \&checkconfig);
hook(type => "checkcontent", id => "blogspam", call => \&checkcontent);
}
@@ -43,17 +44,19 @@ sub getsetup () {
},
}
-sub checkcontent (@) {
- my %params=@_;
-
+sub checkconfig () {
+ # This is done at checkconfig time because printing an error
+ # if the module is missing when a spam is posted would not
+ # let the admin know about the problem.
eval q{
use RPC::XML;
use RPC::XML::Client;
};
- if ($@) {
- warn($@);
- return undef;
- }
+ error $@ if $@;
+}
+
+sub checkcontent (@) {
+ my %params=@_;
if (exists $config{blogspam_pagespec}) {
return undef
diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm
index bf0d7560d..da97dbc28 100644
--- a/IkiWiki/Plugin/brokenlinks.pm
+++ b/IkiWiki/Plugin/brokenlinks.pm
@@ -28,18 +28,17 @@ sub preprocess (@) {
add_depends($params{page}, $params{pages});
my %broken;
- foreach my $page (keys %links) {
- if (pagespec_match($page, $params{pages}, location => $params{page})) {
- my $discussion=gettext("discussion");
- my %seen;
- foreach my $link (@{$links{$page}}) {
- next if $seen{$link};
- $seen{$link}=1;
- next if $link =~ /.*\/\Q$discussion\E/i && $config{discussion};
- my $bestlink=bestlink($page, $link);
- next if length $bestlink;
- push @{$broken{$link}}, $page;
- }
+ foreach my $page (pagespec_match_list([keys %links],
+ $params{pages}, location => $params{page})) {
+ my $discussion=gettext("discussion");
+ my %seen;
+ foreach my $link (@{$links{$page}}) {
+ next if $seen{$link};
+ $seen{$link}=1;
+ next if $link =~ /.*\/\Q$discussion\E/i && $config{discussion};
+ my $bestlink=bestlink($page, $link);
+ next if length $bestlink;
+ push @{$broken{$link}}, $page;
}
}
diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm
index d473c8348..fe4b16072 100644
--- a/IkiWiki/Plugin/calendar.pm
+++ b/IkiWiki/Plugin/calendar.pm
@@ -369,8 +369,7 @@ sub preprocess (@) {
my $page =$params{page};
if (! defined $cache{$pagespec}) {
- foreach my $p (keys %pagesources) {
- next unless pagespec_match($p, $pagespec);
+ foreach my $p (pagespec_match_list([keys %pagesources], $pagespec)) {
my $mtime = $IkiWiki::pagectime{$p};
my $src = $pagesources{$p};
my @date = localtime($mtime);
diff --git a/IkiWiki/Plugin/camelcase.pm b/IkiWiki/Plugin/camelcase.pm
index 74a8397d7..088447d6b 100644
--- a/IkiWiki/Plugin/camelcase.pm
+++ b/IkiWiki/Plugin/camelcase.pm
@@ -61,7 +61,7 @@ sub scan (@) {
my $content=$params{content};
while ($content =~ /$link_regexp/g) {
- push @{$links{$page}}, linkpage($1) unless ignored($1)
+ add_link($page, linkpage($1)) unless ignored($1)
}
}
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 98f9f8b3d..e618d1a90 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -317,6 +317,13 @@ sub editcomment ($$) {
force => 1);
}
+ if (! defined $session->param('name')) {
+ # Make signinurl work and return here.
+ $form->tmpl_param(signinurl => IkiWiki::cgiurl(do => 'signin'));
+ $session->param(postsignin => $ENV{QUERY_STRING});
+ IkiWiki::cgi_savesession($session);
+ }
+
# The untaint is OK (as in editpage) because we're about to pass
# it to file_pruned anyway
my $page = $form->field('page');
diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm
index 0068a6b11..af42097ba 100644
--- a/IkiWiki/Plugin/editpage.pm
+++ b/IkiWiki/Plugin/editpage.pm
@@ -276,8 +276,9 @@ sub cgi_editpage ($$) {
my @page_types;
if (exists $hooks{htmlize}) {
- @page_types=grep { !/^_/ }
- keys %{$hooks{htmlize}};
+ foreach my $key (grep { !/^_/ } keys %{$hooks{htmlize}}) {
+ push @page_types, [$key, $hooks{htmlize}{$key}{longname} || $key];
+ }
}
$form->tmpl_param("page_select", 1);
diff --git a/IkiWiki/Plugin/external.pm b/IkiWiki/Plugin/external.pm
index 066f15cf1..0d292dfc2 100644
--- a/IkiWiki/Plugin/external.pm
+++ b/IkiWiki/Plugin/external.pm
@@ -230,10 +230,13 @@ sub hook ($@) {
}
sub pagespec_match ($@) {
- # convert pagespec_match's return object into a XML RPC boolean
+ # convert return object into a XML RPC boolean
my $plugin=shift;
+ my $page=shift;
+ my $spec=shift;
- return RPC::XML::boolean->new(0 + IkiWiki::pagespec_march(@_));
+ return RPC::XML::boolean->new(0 + IkiWiki::pagespec_match(
+ $page, $spec, @_));
}
1
diff --git a/IkiWiki/Plugin/filecheck.pm b/IkiWiki/Plugin/filecheck.pm
index 8575ee108..01d490961 100644
--- a/IkiWiki/Plugin/filecheck.pm
+++ b/IkiWiki/Plugin/filecheck.pm
@@ -71,13 +71,13 @@ sub match_maxsize ($$;@) {
my $page=shift;
my $maxsize=eval{IkiWiki::Plugin::filecheck::parsesize(shift)};
if ($@) {
- return IkiWiki::FailReason->new("unable to parse maxsize (or number too large)");
+ return IkiWiki::ErrorReason->new("unable to parse maxsize (or number too large)");
}
my %params=@_;
my $file=exists $params{file} ? $params{file} : $IkiWiki::pagesources{$page};
if (! defined $file) {
- return IkiWiki::FailReason->new("no file specified");
+ return IkiWiki::ErrorReason->new("no file specified");
}
if (-s $file > $maxsize) {
@@ -92,13 +92,13 @@ sub match_minsize ($$;@) {
my $page=shift;
my $minsize=eval{IkiWiki::Plugin::filecheck::parsesize(shift)};
if ($@) {
- return IkiWiki::FailReason->new("unable to parse minsize (or number too large)");
+ return IkiWiki::ErrorReason->new("unable to parse minsize (or number too large)");
}
my %params=@_;
my $file=exists $params{file} ? $params{file} : $IkiWiki::pagesources{$page};
if (! defined $file) {
- return IkiWiki::FailReason->new("no file specified");
+ return IkiWiki::ErrorReason->new("no file specified");
}
if (-s $file < $minsize) {
@@ -116,14 +116,14 @@ sub match_mimetype ($$;@) {
my %params=@_;
my $file=exists $params{file} ? $params{file} : $IkiWiki::pagesources{$page};
if (! defined $file) {
- return IkiWiki::FailReason->new("no file specified");
+ return IkiWiki::ErrorReason->new("no file specified");
}
# Use ::magic to get the mime type, the idea is to only trust
# data obtained by examining the actual file contents.
eval q{use File::MimeInfo::Magic};
if ($@) {
- return IkiWiki::FailReason->new("failed to load File::MimeInfo::Magic ($@); cannot check MIME type");
+ return IkiWiki::ErrorReason->new("failed to load File::MimeInfo::Magic ($@); cannot check MIME type");
}
my $mimetype=File::MimeInfo::Magic::magic($file);
if (! defined $mimetype) {
@@ -149,12 +149,12 @@ sub match_virusfree ($$;@) {
my %params=@_;
my $file=exists $params{file} ? $params{file} : $IkiWiki::pagesources{$page};
if (! defined $file) {
- return IkiWiki::FailReason->new("no file specified");
+ return IkiWiki::ErrorReason->new("no file specified");
}
if (! exists $IkiWiki::config{virus_checker} ||
! length $IkiWiki::config{virus_checker}) {
- return IkiWiki::FailReason->new("no virus_checker configured");
+ return IkiWiki::ErrorReason->new("no virus_checker configured");
}
# The file needs to be fed into the virus checker on stdin,
@@ -162,7 +162,7 @@ sub match_virusfree ($$;@) {
# used, clamd would fail to read it.
eval q{use IPC::Open2};
error($@) if $@;
- open (IN, "<", $file) || return IkiWiki::FailReason->new("failed to read file");
+ open (IN, "<", $file) || return IkiWiki::ErrorReason->new("failed to read file");
binmode(IN);
my $sigpipe=0;
$SIG{PIPE} = sub { $sigpipe=1 };
diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm
index d295b833b..a697fea19 100644
--- a/IkiWiki/Plugin/img.pm
+++ b/IkiWiki/Plugin/img.pm
@@ -43,7 +43,7 @@ sub preprocess (@) {
return '';
}
- push @{$links{$params{page}}}, $image;
+ add_link($params{page}, $image);
# optimisation: detect scan mode, and avoid generating the image
if (! defined wantarray) {
return;
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 9d7d4b0fd..27ea1c4a6 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -183,13 +183,9 @@ sub preprocess_inline (@) {
$params{template} = $archive ? "archivepage" : "inlinepage";
}
- my @list;
- foreach my $page (keys %pagesources) {
- next if $page eq $params{page};
- if (pagespec_match($page, $params{pages}, location => $params{page})) {
- push @list, $page;
- }
- }
+ my @list=pagespec_match_list(
+ [ grep { $_ ne $params{page} } keys %pagesources ],
+ $params{pages}, location => $params{page});
if (exists $params{sort} && $params{sort} eq 'title') {
@list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
@@ -346,7 +342,7 @@ sub preprocess_inline (@) {
my $content=get_inline_content($page, $params{destpage});
$template->param(content => $content);
}
- $template->param(pageurl => urlto(bestlink($params{page}, $page), $params{destpage}));
+ $template->param(pageurl => urlto($page, $params{destpage}));
$template->param(inlinepage => $page);
$template->param(title => pagetitle(basename($page)));
$template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}));
diff --git a/IkiWiki/Plugin/link.pm b/IkiWiki/Plugin/link.pm
index b79273f96..4c1add985 100644
--- a/IkiWiki/Plugin/link.pm
+++ b/IkiWiki/Plugin/link.pm
@@ -86,7 +86,7 @@ sub scan (@) {
my $content=$params{content};
while ($content =~ /(?<!\\)$link_regexp/g) {
- push @{$links{$page}}, linkpage($2);
+ add_link($page, linkpage($2));
}
}
diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm
index 328493116..120451b5d 100644
--- a/IkiWiki/Plugin/map.pm
+++ b/IkiWiki/Plugin/map.pm
@@ -32,32 +32,31 @@ sub preprocess (@) {
# Get all the items to map.
my %mapitems;
- foreach my $page (keys %pagesources) {
- if (pagespec_match($page, $params{pages}, location => $params{page})) {
- if (exists $params{show} &&
- exists $pagestate{$page} &&
- exists $pagestate{$page}{meta}{$params{show}}) {
- $mapitems{$page}=$pagestate{$page}{meta}{$params{show}};
- }
- else {
- $mapitems{$page}='';
- }
- # Check for a common prefix.
- if (! defined $common_prefix) {
- $common_prefix=$page;
- }
- elsif (length $common_prefix &&
- $page !~ /^\Q$common_prefix\E(\/|$)/) {
- my @a=split(/\//, $page);
- my @b=split(/\//, $common_prefix);
- $common_prefix="";
- while (@a && @b && $a[0] eq $b[0]) {
- if (length $common_prefix) {
- $common_prefix.="/";
- }
- $common_prefix.=shift(@a);
- shift @b;
+ foreach my $page (pagespec_match_list([keys %pagesources],
+ $params{pages}, location => $params{page})) {
+ if (exists $params{show} &&
+ exists $pagestate{$page} &&
+ exists $pagestate{$page}{meta}{$params{show}}) {
+ $mapitems{$page}=$pagestate{$page}{meta}{$params{show}};
+ }
+ else {
+ $mapitems{$page}='';
+ }
+ # Check for a common prefix.
+ if (! defined $common_prefix) {
+ $common_prefix=$page;
+ }
+ elsif (length $common_prefix &&
+ $page !~ /^\Q$common_prefix\E(\/|$)/) {
+ my @a=split(/\//, $page);
+ my @b=split(/\//, $common_prefix);
+ $common_prefix="";
+ while (@a && @b && $a[0] eq $b[0]) {
+ if (length $common_prefix) {
+ $common_prefix.="/";
}
+ $common_prefix.=shift(@a);
+ shift @b;
}
}
}
diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm
index 0e134c822..c62780cb8 100644
--- a/IkiWiki/Plugin/mdwn.pm
+++ b/IkiWiki/Plugin/mdwn.pm
@@ -8,7 +8,7 @@ use IkiWiki 3.00;
sub import {
hook(type => "getsetup", id => "mdwn", call => \&getsetup);
- hook(type => "htmlize", id => "mdwn", call => \&htmlize);
+ hook(type => "htmlize", id => "mdwn", call => \&htmlize, longname => "Markdown");
}
sub getsetup () {
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index 4a22fed30..cc5455d64 100644
--- a/IkiWiki/Plugin/meta.pm
+++ b/IkiWiki/Plugin/meta.pm
@@ -110,7 +110,7 @@ sub preprocess (@) {
}
elsif ($key eq 'link' && ! %params) {
# hidden WikiLink
- push @{$links{$page}}, $value;
+ add_link($page, $value);
return "";
}
elsif ($key eq 'author') {
diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm
index 605e6e43a..cf74c9b79 100644
--- a/IkiWiki/Plugin/orphans.pm
+++ b/IkiWiki/Plugin/orphans.pm
@@ -35,9 +35,10 @@ sub preprocess (@) {
my @orphans;
my $discussion=gettext("discussion");
- foreach my $page (keys %pagesources) {
- next if $linkedto{$page} || $page eq 'index';
- next unless pagespec_match($page, $params{pages}, location => $params{page});
+ foreach my $page (pagespec_match_list(
+ [ grep { ! $linkedto{$_} && $_ ne 'index' }
+ keys %pagesources ],
+ $params{pages}, location => $params{page})) {
# If the page has a link to some other page, it's
# indirectly linked to a page via that page's backlinks.
next if grep {
diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm
index a143f24d0..1955603b0 100644
--- a/IkiWiki/Plugin/pagecount.pm
+++ b/IkiWiki/Plugin/pagecount.pm
@@ -26,13 +26,9 @@ sub preprocess (@) {
# register a dependency.
add_depends($params{page}, $params{pages});
- my @pages=keys %pagesources;
- return $#pages+1 if $params{pages} eq "*"; # optimisation
- my $count=0;
- foreach my $page (@pages) {
- $count++ if pagespec_match($page, $params{pages}, location => $params{page});
- }
- return $count;
+ my @pages=pagespec_match_list([keys %pagesources], $params{pages}, location => $params{page})
+ if $params{pages} ne "*"; # optimisation;
+ return $#pages+1;
}
1
diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm
index dbe69539d..8ab5d3666 100644
--- a/IkiWiki/Plugin/pagestats.pm
+++ b/IkiWiki/Plugin/pagestats.pm
@@ -41,12 +41,11 @@ sub preprocess (@) {
my %counts;
my $max = 0;
- foreach my $page (keys %links) {
- if (pagespec_match($page, $params{pages}, location => $params{page})) {
- use IkiWiki::Render;
- $counts{$page} = scalar(IkiWiki::backlinks($page));
- $max = $counts{$page} if $counts{$page} > $max;
- }
+ foreach my $page (pagespec_match_list([keys %links],
+ $params{pages}, location => $params{page})) {
+ use IkiWiki::Render;
+ $counts{$page} = scalar(IkiWiki::backlinks($page));
+ $max = $counts{$page} if $counts{$page} > $max;
}
if ($style eq 'table') {
diff --git a/IkiWiki/Plugin/postsparkline.pm b/IkiWiki/Plugin/postsparkline.pm
index ba43561fb..d2e5c2378 100644
--- a/IkiWiki/Plugin/postsparkline.pm
+++ b/IkiWiki/Plugin/postsparkline.pm
@@ -50,15 +50,10 @@ sub preprocess (@) {
add_depends($params{page}, $params{pages});
- my @list;
- foreach my $page (keys %pagesources) {
- next if $page eq $params{page};
- if (pagespec_match($page, $params{pages}, location => $params{page})) {
- push @list, $page;
- }
- }
-
- @list = sort { $params{timehash}->{$b} <=> $params{timehash}->{$a} } @list;
+ my @list=sort { $params{timehash}->{$b} <=> $params{timehash}->{$a} }
+ pagespec_match_list(
+ [ grep { $_ ne $params{page} } keys %pagesources],
+ $params{pages}, location => $params{page});
my @data=eval qq{IkiWiki::Plugin::postsparkline::formula::$formula(\\\%params, \@list)};
if ($@) {
diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm
index 8fe9c6828..cdcfaf536 100644
--- a/IkiWiki/Plugin/tag.pm
+++ b/IkiWiki/Plugin/tag.pm
@@ -73,7 +73,7 @@ sub preprocess_tag (@) {
$tag=linkpage($tag);
$tags{$page}{$tag}=1;
# hidden WikiLink
- push @{$links{$page}}, tagpage($tag);
+ add_link($page, tagpage($tag));
}
return "";
@@ -88,14 +88,14 @@ sub preprocess_taglink (@) {
if (/(.*)\|(.*)/) {
my $tag=linkpage($2);
$tags{$params{page}}{$tag}=1;
- push @{$links{$params{page}}}, tagpage($tag);
+ add_link($params{page}, tagpage($tag));
return taglink($params{page}, $params{destpage}, $tag,
linktext => pagetitle($1));
}
else {
my $tag=linkpage($_);
$tags{$params{page}}{$tag}=1;
- push @{$links{$params{page}}}, tagpage($tag);
+ add_link($params{page}, tagpage($tag));
return taglink($params{page}, $params{destpage}, $tag);
}
}
diff --git a/IkiWiki/Plugin/textile.pm b/IkiWiki/Plugin/textile.pm
index b604aa3c5..8cc5a7951 100644
--- a/IkiWiki/Plugin/textile.pm
+++ b/IkiWiki/Plugin/textile.pm
@@ -11,7 +11,7 @@ use Encode;
sub import {
hook(type => "getsetup", id => "textile", call => \&getsetup);
- hook(type => "htmlize", id => "txtl", call => \&htmlize);
+ hook(type => "htmlize", id => "txtl", call => \&htmlize, longname => "Textile");
}
sub getsetup () {
diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm
index 95d044c08..9edd22d26 100644
--- a/IkiWiki/Plugin/websetup.pm
+++ b/IkiWiki/Plugin/websetup.pm
@@ -403,6 +403,7 @@ sub showform ($$) {
$form->reset(0); # doesn't really make sense here
}
else {
+ my $oldsetup=readfile($config{setupfile});
IkiWiki::Setup::dump($config{setupfile});
IkiWiki::saveindex();
@@ -426,16 +427,21 @@ sub showform ($$) {
"-refresh", "-wrappers", "-v");
}
+ close STDERR;
+ open(STDERR, ">&STDOUT");
my $ret=system(@command);
- print "\n<pre>";
+ print "\n<\/pre>";
if ($ret != 0) {
print '<p class="error">'.
- sprintf(gettext("<p class=\"error\">Error: %s exited nonzero (%s)"),
+ sprintf(gettext("Error: %s exited nonzero (%s). Discarding setup changes."),
join(" ", @command), $ret).
'</p>';
+ open(OUT, ">", $config{setupfile}) || error("$config{setupfile}: $!");
+ print OUT $oldsetup;
+ close OUT;
}
- print $tail;
+ print $tail;
exit 0;
}
}