summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/comments.pm16
-rw-r--r--IkiWiki/Plugin/conditional.pm4
-rw-r--r--IkiWiki/Plugin/git.pm4
-rw-r--r--IkiWiki/Plugin/goodstuff.pm1
-rw-r--r--IkiWiki/Plugin/pinger.pm2
-rw-r--r--IkiWiki/Plugin/rename.pm35
-rw-r--r--IkiWiki/Plugin/repolist.pm51
-rw-r--r--IkiWiki/Plugin/skeleton.pm.example4
-rw-r--r--IkiWiki/Plugin/table.pm42
9 files changed, 123 insertions, 36 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 1c10417c3..1c4ab4895 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -508,7 +508,7 @@ sub sessioncgi ($$) {
# Jump to the new comment on the page.
# The trailing question mark tries to avoid broken
# caches and get the most recent version of the page.
- IkiWiki::redirect($cgi, urlto($page, undef, 1)."#$location?updated");
+ IkiWiki::redirect($cgi, urlto($page, undef, 1)."?updated#$location");
}
else {
@@ -604,6 +604,12 @@ sub pagetemplate (@) {
}
}
+ # everything below this point is only relevant to the comments
+ # themselves
+ if (!exists $commentstate{$page}) {
+ return;
+ }
+
if ($template->query(name => 'commentuser')) {
$template->param(commentuser =>
$commentstate{$page}{commentuser});
@@ -628,6 +634,14 @@ sub pagetemplate (@) {
$template->param(commentauthorurl =>
$commentstate{$page}{commentauthorurl});
}
+
+ if ($template->query(name => 'removeurl') &&
+ IkiWiki::Plugin::remove->can("check_canremove") &&
+ length $config{cgiurl}) {
+ $template->param(removeurl => IkiWiki::cgiurl(do => 'remove',
+ page => $page));
+ $template->param(have_actions => 1);
+ }
}
package IkiWiki::PageSpec;
diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm
index 4f3577b34..7445dbdad 100644
--- a/IkiWiki/Plugin/conditional.pm
+++ b/IkiWiki/Plugin/conditional.pm
@@ -87,6 +87,8 @@ sub match_sourcepage ($$;@) {
shift;
my $glob=shift;
my %params=@_;
+
+ $glob=derel($glob, $params{location});
return IkiWiki::FailReason->new("cannot match sourcepage") unless exists $params{sourcepage};
if (match_glob($params{sourcepage}, $glob, @_)) {
@@ -102,6 +104,8 @@ sub match_destpage ($$;@) {
my $glob=shift;
my %params=@_;
+ $glob=derel($glob, $params{location});
+
return IkiWiki::FailReason->new("cannot match destpage") unless exists $params{destpage};
if (match_glob($params{destpage}, $glob, @_)) {
return IkiWiki::SuccessReason->new("destpage matches $glob");
diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm
index 6a7f6c3ae..3085a3b67 100644
--- a/IkiWiki/Plugin/git.pm
+++ b/IkiWiki/Plugin/git.pm
@@ -94,8 +94,8 @@ sub getsetup () {
},
diffurl => {
type => "string",
- example => "http://git.example.com/gitweb.cgi?p=wiki.git;a=blobdiff;h=[[sha1_to]];hp=[[sha1_from]];hb=[[sha1_parent]];f=[[file]]",
- description => "gitweb url to show a diff ([[sha1_to]], [[sha1_from]], [[sha1_parent]], [[sha1_commit]] and [[file]] substituted)",
+ example => "http://git.example.com/gitweb.cgi?p=wiki.git;a=blobdiff;f=[[file]];h=[[sha1_to]];hp=[[sha1_from]];hb=[[sha1_commit]];hpb=[[sha1_parent]]",
+ description => "gitweb url to show a diff ([[file]], [[sha1_to]], [[sha1_from]], [[sha1_commit]], and [[sha1_parent]] substituted)",
safe => 1,
rebuild => 1,
},
diff --git a/IkiWiki/Plugin/goodstuff.pm b/IkiWiki/Plugin/goodstuff.pm
index 46f2380cf..451cd6f84 100644
--- a/IkiWiki/Plugin/goodstuff.pm
+++ b/IkiWiki/Plugin/goodstuff.pm
@@ -22,6 +22,7 @@ my @bundle=qw{
template
toc
toggle
+ repolist
};
sub import {
diff --git a/IkiWiki/Plugin/pinger.pm b/IkiWiki/Plugin/pinger.pm
index 4a8088661..c20ecb5d4 100644
--- a/IkiWiki/Plugin/pinger.pm
+++ b/IkiWiki/Plugin/pinger.pm
@@ -106,7 +106,7 @@ sub ping {
# will still be avoided.
next if $url=~/^\Q$config{cgiurl}\E/;
- $ua->head($url);
+ $ua->get($url);
}
exit 0;
diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm
index 82639a073..f79349561 100644
--- a/IkiWiki/Plugin/rename.pm
+++ b/IkiWiki/Plugin/rename.pm
@@ -413,22 +413,8 @@ sub sessioncgi ($$) {
$template->param(error => $rename->{error});
if ($rename->{src} ne $rename->{dest}) {
$template->param(brokenlinks_checked => 1);
- $template->param(brokenlinks => [
- map {
- {
- page => htmllink($rename->{dest}, $rename->{dest}, $_,
- noimageinline => 1)
- }
- } @{$rename->{brokenlinks}}
- ]);
- $template->param(fixedlinks => [
- map {
- {
- page => htmllink($rename->{dest}, $rename->{dest}, $_,
- noimageinline => 1)
- }
- } @{$rename->{fixedlinks}}
- ]);
+ $template->param(brokenlinks => linklist($rename->{dest}, $rename->{brokenlinks}));
+ $template->param(fixedlinks => linklist($rename->{dest}, $rename->{fixedlinks}));
}
$renamesummary.=$template->output;
}
@@ -442,6 +428,23 @@ sub sessioncgi ($$) {
exit 0;
}
}
+
+sub linklist {
+ # generates a list of links in a form suitable for FormBuilder
+ my $dest=shift;
+ my $list=shift;
+ # converts a list of pages into a list of links
+ # in a form suitable for FormBuilder.
+
+ [map {
+ {
+ page => htmllink($dest, $dest, $_,
+ noimageinline => 1,
+ linktext => pagetitle($_),
+ )
+ }
+ } @{$list}]
+}
sub renamelink_hook ($$$$) {
my ($page, $src, $dest, $content)=@_;
diff --git a/IkiWiki/Plugin/repolist.pm b/IkiWiki/Plugin/repolist.pm
new file mode 100644
index 000000000..f69ec3988
--- /dev/null
+++ b/IkiWiki/Plugin/repolist.pm
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+package IkiWiki::Plugin::repolist;
+
+use warnings;
+use strict;
+use IkiWiki 3.00;
+
+sub import {
+ hook(type => "getsetup", id => "repolist", call => \&getsetup);
+ hook(type => "checkconfig", id => "repolist", call => \&checkconfig);
+}
+
+sub getsetup () {
+ return
+ plugin => {
+ safe => 1,
+ rebuild => undef,
+ },
+ repositories => {
+ type => "string",
+ example => ["svn://svn.example.org/wiki/trunk"],
+ description => "URIs of repositories containing the wiki's source",
+ safe => 1,
+ rebuild => undef,
+ },
+}
+
+my $relvcs;
+
+sub checkconfig () {
+ if (defined $config{rcs} && $config{repositories}) {
+ $relvcs=join("\n", map {
+ s/"//g; # avoid quotes just in case
+ qq{<link rel="vcs-$config{rcs}" href="$_" title="wiki $config{rcs} repository" />}
+ } @{$config{repositories}});
+
+ hook(type => "pagetemplate", id => "repolist", call => \&pagetemplate);
+ }
+}
+
+sub pagetemplate (@) {
+ my %params=@_;
+ my $page=$params{page};
+ my $template=$params{template};
+
+ if (defined $relvcs && $template->query(name => "relvcs")) {
+ $template->param(relvcs => $relvcs);
+ }
+}
+
+1
diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example
index ea7500a70..0bd5edeef 100644
--- a/IkiWiki/Plugin/skeleton.pm.example
+++ b/IkiWiki/Plugin/skeleton.pm.example
@@ -6,7 +6,7 @@ package IkiWiki::Plugin::skeleton;
use warnings;
use strict;
-use IkiWiki 2.00;
+use IkiWiki 3.00;
sub import {
hook(type => "getopt", id => "skeleton", call => \&getopt);
@@ -90,7 +90,7 @@ sub linkify (@) {
return $params{content};
}
-sub scan (@) { #{{{a
+sub scan (@) {
my %params=@_;
debug("skeleton plugin running as scan");
diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm
index 479f3d745..96d63f455 100644
--- a/IkiWiki/Plugin/table.pm
+++ b/IkiWiki/Plugin/table.pm
@@ -8,7 +8,7 @@ use IkiWiki 3.00;
sub import {
hook(type => "getsetup", id => "table", call => \&getsetup);
- hook(type => "preprocess", id => "table", call => \&preprocess);
+ hook(type => "preprocess", id => "table", call => \&preprocess, scan => 1);
}
sub getsetup () {
@@ -27,13 +27,31 @@ sub preprocess (@) {
);
if (exists $params{file}) {
- if (! $pagesources{$params{file}}) {
+ if (! exists $pagesources{$params{file}}) {
error gettext("cannot find file");
}
$params{data} = readfile(srcfile($params{file}));
add_depends($params{page}, $params{file});
}
+ if (! defined wantarray) {
+ # scan mode -- if the table uses an external file, need to
+ # scan that file too.
+ return unless exists $params{file};
+
+ IkiWiki::run_hooks(scan => sub {
+ shift->(
+ page => $params{page},
+ content => $params{data},
+ );
+ });
+
+ # Preprocess in scan-only mode.
+ IkiWiki::preprocess($params{page}, $params{page}, $params{data}, 1);
+
+ return;
+ }
+
if (lc $params{format} eq 'auto') {
# first try the more simple format
if (is_dsv_data($params{data})) {
@@ -50,22 +68,18 @@ sub preprocess (@) {
defined $params{delimiter} ? $params{delimiter} : ",",);
# linkify after parsing since html link quoting can
# confuse CSV parsing
- if (! exists $params{file}) {
- @data=map {
- [ map {
- IkiWiki::linkify($params{page},
- $params{destpage}, $_);
- } @$_ ]
- } @data;
- }
+ @data=map {
+ [ map {
+ IkiWiki::linkify($params{page},
+ $params{destpage}, $_);
+ } @$_ ]
+ } @data;
}
elsif (lc $params{format} eq 'dsv') {
# linkify before parsing since wikilinks can contain the
# delimiter
- if (! exists $params{file}) {
- $params{data} = IkiWiki::linkify($params{page},
- $params{destpage}, $params{data});
- }
+ $params{data} = IkiWiki::linkify($params{page},
+ $params{destpage}, $params{data});
@data=split_dsv($params{data},
defined $params{delimiter} ? $params{delimiter} : "|",);
}