summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/aggregate.pm4
-rw-r--r--IkiWiki/Plugin/attachment.pm20
-rw-r--r--IkiWiki/Plugin/editpage.pm5
-rw-r--r--IkiWiki/Plugin/edittemplate.pm16
-rw-r--r--IkiWiki/Plugin/git.pm5
-rw-r--r--IkiWiki/Plugin/htmlscrubber.pm16
-rw-r--r--IkiWiki/Plugin/openid.pm2
-rw-r--r--IkiWiki/Plugin/progress.pm5
-rw-r--r--IkiWiki/Plugin/recentchanges.pm3
-rw-r--r--IkiWiki/Plugin/remove.pm21
-rw-r--r--IkiWiki/Plugin/rename.pm273
-rw-r--r--IkiWiki/Plugin/skeleton.pm.example2
-rw-r--r--IkiWiki/Plugin/tag.pm25
-rw-r--r--IkiWiki/Render.pm6
14 files changed, 288 insertions, 115 deletions
diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm
index 2b40625db..8044f1ed4 100644
--- a/IkiWiki/Plugin/aggregate.pm
+++ b/IkiWiki/Plugin/aggregate.pm
@@ -420,11 +420,11 @@ sub expire () { #{{{
next unless $feed->{expireage} || $feed->{expirecount};
my $count=0;
my %seen;
- foreach my $item (sort { $IkiWiki::pagectime{$b->{page}} <=> $IkiWiki::pagectime{$a->{page}} }
+ foreach my $item (sort { ($IkiWiki::pagectime{$b->{page}} || 0) <=> ($IkiWiki::pagectime{$a->{page}} || 0) }
grep { exists $_->{page} && $_->{feed} eq $feed->{name} }
values %guids) {
if ($feed->{expireage}) {
- my $days_old = (time - $IkiWiki::pagectime{$item->{page}}) / 60 / 60 / 24;
+ my $days_old = (time - ($IkiWiki::pagectime{$item->{page}} || 0)) / 60 / 60 / 24;
if ($days_old > $feed->{expireage}) {
debug(sprintf(gettext("expiring %s (%s days old)"),
$item->{page}, int($days_old)));
diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm
index 999fa4a86..f1a9b1939 100644
--- a/IkiWiki/Plugin/attachment.pm
+++ b/IkiWiki/Plugin/attachment.pm
@@ -311,6 +311,26 @@ sub match_user ($$;@) { #{{{
}
} #}}}
+sub match_admin ($$;@) { #{{{
+ shift;
+ shift;
+ my %params=@_;
+
+ if (! exists $params{user}) {
+ return IkiWiki::FailReason->new("no user specified");
+ }
+
+ if (defined $params{user} && IkiWiki::is_admin($params{user})) {
+ return IkiWiki::SuccessReason->new("user is an admin");
+ }
+ elsif (! defined $params{user}) {
+ return IkiWiki::FailReason->new("not logged in");
+ }
+ else {
+ return IkiWiki::FailReason->new("user is not an admin");
+ }
+} #}}}
+
sub match_ip ($$;@) { #{{{
shift;
my $ip=shift;
diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm
index e07052497..687ebf51e 100644
--- a/IkiWiki/Plugin/editpage.pm
+++ b/IkiWiki/Plugin/editpage.pm
@@ -85,8 +85,9 @@ sub cgi_editpage ($$) { #{{{
});
decode_form_utf8($form);
- # This untaint is safe because we check file_pruned.
- my $page=$form->field('page');
+ # This untaint is safe because we check file_pruned and
+ # wiki_file_regexp.
+ my ($page)=$form->field('page')=~/$config{wiki_file_regexp}/;
$page=possibly_foolish_untaint($page);
my $absolute=($page =~ s#^/+##);
if (! defined $page || ! length $page ||
diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm
index 98308de13..84c28a9d0 100644
--- a/IkiWiki/Plugin/edittemplate.pm
+++ b/IkiWiki/Plugin/edittemplate.pm
@@ -54,10 +54,14 @@ sub preprocess (@) { #{{{
error gettext("match not specified")
}
- $pagestate{$params{page}}{edittemplate}{$params{match}}=$params{template};
+ my $link=IkiWiki::linkpage($params{template});
+ $pagestate{$params{page}}{edittemplate}{$params{match}}=$link;
+ return "" if ($params{silent} && IkiWiki::yesno($params{silent}));
+ add_depends($params{page}, $link);
return sprintf(gettext("edittemplate %s registered for %s"),
- $params{template}, $params{match});
+ htmllink($params{page}, $params{destpage}, $link),
+ $params{match});
} # }}}
sub formbuilder (@) { #{{{
@@ -65,7 +69,7 @@ sub formbuilder (@) { #{{{
my $form=$params{form};
return if $form->field("do") ne "create" ||
- length $form->field("editcontent");
+ (defined $form->field("editcontent") && length $form->field("editcontent"));
my $page=$form->field("page");
@@ -87,8 +91,12 @@ sub formbuilder (@) { #{{{
if (exists $pagestate{$registering_page}{edittemplate}) {
foreach my $pagespec (sort keys %{$pagestate{$registering_page}{edittemplate}}) {
if (pagespec_match($p, $pagespec, location => $registering_page)) {
+ my $template=$pagestate{$registering_page}{edittemplate}{$pagespec};
$form->field(name => "editcontent",
- value => filltemplate($pagestate{$registering_page}{edittemplate}{$pagespec}, $page));
+ value => filltemplate($template, $page));
+ $form->field(name => "type",
+ value => pagetype($pagesources{$template}))
+ if $pagesources{$template};
return;
}
}
diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm
index 08ee4cb63..14b0ab285 100644
--- a/IkiWiki/Plugin/git.pm
+++ b/IkiWiki/Plugin/git.pm
@@ -308,13 +308,16 @@ sub parse_diff_tree ($@) { #{{{
my $sha1_to = shift(@tmp);
my $status = shift(@tmp);
+ # git does not output utf-8 filenames, but instead
+ # double-quotes them with the utf-8 characters
+ # escaped as \nnn\nnn.
if ($file =~ m/^"(.*)"$/) {
($file=$1) =~ s/\\([0-7]{1,3})/chr(oct($1))/eg;
}
$file =~ s/^\Q$prefix\E//;
if (length $file) {
push @{ $ci{'details'} }, {
- 'file' => decode_utf8($file),
+ 'file' => decode("utf8", $file),
'sha1_from' => $sha1_from[0],
'sha1_to' => $sha1_to,
};
diff --git a/IkiWiki/Plugin/htmlscrubber.pm b/IkiWiki/Plugin/htmlscrubber.pm
index 923907b04..7398c8478 100644
--- a/IkiWiki/Plugin/htmlscrubber.pm
+++ b/IkiWiki/Plugin/htmlscrubber.pm
@@ -41,10 +41,26 @@ sub getsetup () { #{{{
safe => 1,
rebuild => undef,
},
+ htmlscrubber_skip => {
+ type => "pagespec",
+ example => "!*/Discussion",
+ description => "PageSpec specifying pages not to scrub",
+ link => "ikiwiki/PageSpec",
+ safe => 1,
+ rebuild => undef,
+ },
} #}}}
sub sanitize (@) { #{{{
my %params=@_;
+
+ if (exists $config{htmlscrubber_skip} &&
+ length $config{htmlscrubber_skip} &&
+ exists $params{destpage} &&
+ pagespec_match($params{destpage}, $config{htmlscrubber_skip})) {
+ return $params{content};
+ }
+
return scrubber()->scrub($params{content});
} # }}}
diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm
index 1818f5283..f12cbdaa3 100644
--- a/IkiWiki/Plugin/openid.pm
+++ b/IkiWiki/Plugin/openid.pm
@@ -48,7 +48,7 @@ sub formbuilder_setup (@) { #{{{
# needing to depend on it.
eval q{use Net::OpenID::Consumer};
if ($@) {
- debug("unable to load Net::OpenID::Consumer, not enabling OpenID login");
+ debug("unable to load Net::OpenID::Consumer, not enabling OpenID login ($@)");
return;
}
diff --git a/IkiWiki/Plugin/progress.pm b/IkiWiki/Plugin/progress.pm
index 2c015284e..e536f4e23 100644
--- a/IkiWiki/Plugin/progress.pm
+++ b/IkiWiki/Plugin/progress.pm
@@ -29,12 +29,11 @@ sub preprocess (@) { #{{{
if (defined $params{percent}) {
$fill = $params{percent};
($fill) = $fill =~ m/($percentage_pattern)/; # fill is untainted now
+ $fill=~s/%$//;
if (! defined $fill || ! length $fill || $fill > 100 || $fill < 0) {
error(sprintf(gettext("illegal percent value %s"), $params{percent}));
}
- elsif ($fill !~ /%$/) {
- $fill.="%";
- }
+ $fill.="%";
}
elsif (defined $params{totalpages} and defined $params{donepages}) {
add_depends($params{page}, $params{totalpages});
diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm
index dbb9065d4..bef0e7085 100644
--- a/IkiWiki/Plugin/recentchanges.pm
+++ b/IkiWiki/Plugin/recentchanges.pm
@@ -4,6 +4,7 @@ package IkiWiki::Plugin::recentchanges;
use warnings;
use strict;
use IkiWiki 2.00;
+use Encode;
sub import { #{{{
hook(type => "getsetup", id => "recentchanges", call => \&getsetup);
@@ -86,7 +87,7 @@ sub cgi ($) { #{{{
# page they link to is deleted, or newly created, or
# changes for whatever reason. So this CGI handles that
# dynamic linking stuff.
- my $page=$cgi->param("page");
+ my $page=decode_utf8($cgi->param("page"));
if (!defined $page) {
error("missing page parameter");
}
diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm
index b1cb6233d..772be07b5 100644
--- a/IkiWiki/Plugin/remove.pm
+++ b/IkiWiki/Plugin/remove.pm
@@ -21,11 +21,10 @@ sub getsetup () { #{{{
},
} #}}}
-sub check_canremove ($$$$) { #{{{
+sub check_canremove ($$$) { #{{{
my $page=shift;
my $q=shift;
my $session=shift;
- my $attachment=shift;
# Must be a known source file.
if (! exists $pagesources{$page}) {
@@ -45,11 +44,15 @@ sub check_canremove ($$$$) { #{{{
# Must be editiable.
IkiWiki::check_canedit($page, $q, $session);
- # This is sorta overkill, but better safe
- # than sorry. If a user can't upload an
- # attachment, don't let them delete it.
- if ($attachment) {
- IkiWiki::Plugin::attachment::check_canattach($session, $page, $file);
+ # If a user can't upload an attachment, don't let them delete it.
+ # This is sorta overkill, but better safe than sorry.
+ if (! defined IkiWiki::pagetype($pagesources{$page})) {
+ if (IkiWiki::Plugin::attachment->can("check_canattach")) {
+ IkiWiki::Plugin::attachment::check_canattach($session, $page, $file);
+ }
+ else {
+ error("renaming of attachments is not allowed");
+ }
}
} #}}}
@@ -94,7 +97,7 @@ sub removal_confirm ($$@) { #{{{
my $attachment=shift;
my @pages=@_;
- check_canremove($_, $q, $session, $attachment) foreach @pages;
+ check_canremove($_, $q, $session) foreach @pages;
# Save current form state to allow returning to it later
# without losing any edits.
@@ -167,7 +170,7 @@ sub sessioncgi ($$) { #{{{
# and that the user is allowed to edit(/remove) it.
my @files;
foreach my $page (@pages) {
- check_canremove($page, $q, $session, $q->param("attachment"));
+ check_canremove($page, $q, $session);
# This untaint is safe because of the
# checks performed above, which verify the
diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm
index 77aed9556..4ee377b86 100644
--- a/IkiWiki/Plugin/rename.pm
+++ b/IkiWiki/Plugin/rename.pm
@@ -21,14 +21,15 @@ sub getsetup () { #{{{
},
} #}}}
-sub check_canrename ($$$$$$$) { #{{{
+sub check_canrename ($$$$$$) { #{{{
my $src=shift;
my $srcfile=shift;
my $dest=shift;
my $destfile=shift;
my $q=shift;
my $session=shift;
- my $attachment=shift;
+
+ my $attachment=! defined IkiWiki::pagetype($pagesources{$src});
# Must be a known source file.
if (! exists $pagesources{$src}) {
@@ -47,7 +48,12 @@ sub check_canrename ($$$$$$$) { #{{{
# Must be editable.
IkiWiki::check_canedit($src, $q, $session);
if ($attachment) {
- IkiWiki::Plugin::attachment::check_canattach($session, $src, $srcfile);
+ if (IkiWiki::Plugin::attachment->can("check_canattach")) {
+ IkiWiki::Plugin::attachment::check_canattach($session, $src, $srcfile);
+ }
+ else {
+ error("renaming of attachments is not allowed");
+ }
}
# Dest checks can be omitted by passing undef.
@@ -123,6 +129,18 @@ sub rename_form ($$$) { #{{{
$f->field(name => "type", type => 'select',
options => \@page_types,
value => $ext, force => 1);
+
+ foreach my $p (keys %pagesources) {
+ if ($pagesources{$p}=~m/^\Q$page\E\//) {
+ $f->field(name => "subpages",
+ label => "",
+ type => "checkbox",
+ options => [ [ 1 => gettext("Also rename SubPages and attachments") ] ],
+ value => 1,
+ force => 1);
+ last;
+ }
+ }
}
$f->field(name => "attachment", type => "hidden");
@@ -136,7 +154,7 @@ sub rename_start ($$$$) { #{{{
my $page=shift;
check_canrename($page, $pagesources{$page}, undef, undef,
- $q, $session, $attachment);
+ $q, $session);
# Save current form state to allow returning to it later
# without losing any edits.
@@ -147,11 +165,10 @@ sub rename_start ($$$$) { #{{{
$session->param(postrename => scalar $q->Vars);
IkiWiki::cgi_savesession($session);
- my ($f, $buttons)=rename_form($q, $session, $page);
if (defined $attachment) {
- $f->field(name => "attachment", value => $attachment, force => 1);
+ $q->param(-name => "attachment", -value => $attachment);
}
-
+ my ($f, $buttons)=rename_form($q, $session, $page);
IkiWiki::showform($f, $buttons, $session, $q);
exit 0;
} #}}}
@@ -243,76 +260,97 @@ sub sessioncgi ($$) { #{{{
postrename($session);
}
elsif ($form->submitted eq 'Rename' && $form->validate) {
+ # Queue of rename actions to perfom.
+ my @torename;
+
# These untaints are safe because of the checks
- # performed in check_canrename below.
+ # performed in check_canrename later.
my $src=$q->param("page");
my $srcfile=IkiWiki::possibly_foolish_untaint($pagesources{$src});
my $dest=IkiWiki::possibly_foolish_untaint(IkiWiki::titlepage($q->param("new_name")));
-
my $destfile=$dest;
if (! $q->param("attachment")) {
my $type=$q->param('type');
if (defined $type && length $type && $IkiWiki::hooks{htmlize}{$type}) {
$type=IkiWiki::possibly_foolish_untaint($type);
- } else {
+ }
+ else {
my ($ext)=$srcfile=~/\.([^.]+)$/;
$type=$ext;
}
$destfile.=".".$type;
}
-
- check_canrename($src, $srcfile, $dest, $destfile,
- $q, $session, $q->param("attachment"));
-
- # Ensures that the dest directory exists and is ok.
- IkiWiki::prep_writefile($destfile, $config{srcdir});
-
- # Do rename, update other pages, and refresh site.
- IkiWiki::disable_commit_hook() if $config{rcs};
- require IkiWiki::Render;
- if ($config{rcs}) {
- IkiWiki::rcs_rename($srcfile, $destfile);
- IkiWiki::rcs_commit_staged(
- sprintf(gettext("rename %s to %s"), $srcfile, $destfile),
- $session->param("name"), $ENV{REMOTE_ADDR});
+ push @torename, {
+ src => $src,
+ srcfile => $srcfile,
+ dest => $dest,
+ destfile => $destfile,
+ required => 1,
+ };
+
+ # See if any subpages need to be renamed.
+ if ($q->param("subpages") && $src ne $dest) {
+ foreach my $p (keys %pagesources) {
+ if ($pagesources{$p}=~m/^\Q$src\E\//) {
+ my $d=$pagesources{$p};
+ $d=~s/^\Q$src\E\//$dest\//;
+ push @torename, {
+ src => $p,
+ srcfile => $pagesources{$p},
+ dest => pagename($d),
+ destfile => $d,
+ required => 0,
+ };
+ }
+ }
}
- else {
- if (! rename("$config{srcdir}/$srcfile", "$config{srcdir}/$destfile")) {
- error("rename: $!");
+
+ require IkiWiki::Render;
+ IkiWiki::disable_commit_hook() if $config{rcs};
+ my %origpagesources=%pagesources;
+
+ # First file renaming.
+ foreach my $rename (@torename) {
+ if ($rename->{required}) {
+ do_rename($rename, $q, $session);
+ }
+ else {
+ eval {do_rename($rename, $q, $session)};
+ if ($@) {
+ $rename->{error}=$@;
+ next;
+ }
}
+
+ # Temporarily tweak pagesources to point to
+ # the renamed file, in case fixlinks needs
+ # to edit it.
+ $pagesources{$rename->{src}}=$rename->{destfile};
}
- my @fixedlinks;
- if ($src ne $dest) {
- foreach my $page (keys %links) {
- my $needfix=0;
- foreach my $link (@{$links{$page}}) {
- my $bestlink=bestlink($page, $link);
- if ($bestlink eq $src) {
- $needfix=1;
+ IkiWiki::rcs_commit_staged(
+ sprintf(gettext("rename %s to %s"), $srcfile, $destfile),
+ $session->param("name"), $ENV{REMOTE_ADDR}) if $config{rcs};
+
+ # Then link fixups.
+ foreach my $rename (@torename) {
+ next if $rename->{src} eq $rename->{dest};
+ next if $rename->{error};
+ foreach my $p (fixlinks($rename, $session)) {
+ # map old page names to new
+ foreach my $r (@torename) {
+ next if $rename->{error};
+ if ($r->{src} eq $p) {
+ $p=$r->{dest};
last;
}
}
- if ($needfix) {
- my $file=$pagesources{$page};
- my $oldcontent=readfile($config{srcdir}."/".$file);
- my $content=renamepage_hook($page, $src, $dest, $oldcontent);
- if ($oldcontent ne $content) {
- my $token=IkiWiki::rcs_prepedit($file);
- eval { writefile($file, $config{srcdir}, $content) };
- next if $@;
- my $conflict=IkiWiki::rcs_commit(
- $file,
- sprintf(gettext("update for rename of %s to %s"), $srcfile, $destfile),
- $token,
- $session->param("name"),
- $ENV{REMOTE_ADDR}
- );
- push @fixedlinks, $page if ! defined $conflict;
- }
- }
+ push @{$rename->{fixedlinks}}, $p;
}
}
+
+ # Then refresh.
+ %pagesources=%origpagesources;
if ($config{rcs}) {
IkiWiki::enable_commit_hook();
IkiWiki::rcs_update();
@@ -320,47 +358,51 @@ sub sessioncgi ($$) { #{{{
IkiWiki::refresh();
IkiWiki::saveindex();
- # Scan for any remaining broken links to $src.
- my @brokenlinks;
- if ($src ne $dest) {
+ # Find pages with remaining, broken links.
+ foreach my $rename (@torename) {
+ next if $rename->{src} eq $rename->{dest};
+
foreach my $page (keys %links) {
my $broken=0;
foreach my $link (@{$links{$page}}) {
my $bestlink=bestlink($page, $link);
- if ($bestlink eq $src) {
- $broken=1;
+ if ($bestlink eq $rename->{src}) {
+ push @{$rename->{brokenlinks}}, $page;
last;
}
}
- push @brokenlinks, $page if $broken;
}
}
- # Generate a rename summary, that will be shown at the top
+ # Generate a summary, that will be shown at the top
# of the edit template.
- my $template=template("renamesummary.tmpl");
- $template->param(src => $srcfile);
- $template->param(dest => $destfile);
- if ($src ne $dest) {
- $template->param(brokenlinks_checked => 1);
- $template->param(brokenlinks => [
- map {
- {
- page => htmllink($dest, $dest, $_,
- noimageinline => 1)
- }
- } @brokenlinks
- ]);
- $template->param(fixedlinks => [
- map {
- {
- page => htmllink($dest, $dest, $_,
- noimageinline => 1)
- }
- } @fixedlinks
- ]);
+ $renamesummary="";
+ foreach my $rename (@torename) {
+ my $template=template("renamesummary.tmpl");
+ $template->param(src => $rename->{srcfile});
+ $template->param(dest => $rename->{destfile});
+ $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}}
+ ]);
+ }
+ $renamesummary.=$template->output;
}
- $renamesummary=$template->output;
postrename($session, $src, $dest, $q->param("attachment"));
}
@@ -386,5 +428,70 @@ sub renamepage_hook ($$$$) { #{{{
return $content;
}# }}}
+
+sub do_rename ($$$) { #{{{
+ my $rename=shift;
+ my $q=shift;
+ my $session=shift;
+
+ # First, check if this rename is allowed.
+ check_canrename($rename->{src},
+ $rename->{srcfile},
+ $rename->{dest},
+ $rename->{destfile},
+ $q, $session);
+
+ # Ensure that the dest directory exists and is ok.
+ IkiWiki::prep_writefile($rename->{destfile}, $config{srcdir});
+
+ if ($config{rcs}) {
+ IkiWiki::rcs_rename($rename->{srcfile}, $rename->{destfile});
+ }
+ else {
+ if (! rename($config{srcdir}."/".$rename->{srcfile},
+ $config{srcdir}."/".$rename->{destfile})) {
+ error("rename: $!");
+ }
+ }
+
+} # }}}
+
+sub fixlinks ($$$) { #{{{
+ my $rename=shift;
+ my $session=shift;
+
+ my @fixedlinks;
+
+ foreach my $page (keys %links) {
+ my $needfix=0;
+ foreach my $link (@{$links{$page}}) {
+ my $bestlink=bestlink($page, $link);
+ if ($bestlink eq $rename->{src}) {
+ $needfix=1;
+ last;
+ }
+ }
+ if ($needfix) {
+ my $file=$pagesources{$page};
+ my $oldcontent=readfile($config{srcdir}."/".$file);
+ my $content=renamepage_hook($page, $rename->{src}, $rename->{dest}, $oldcontent);
+ if ($oldcontent ne $content) {
+ my $token=IkiWiki::rcs_prepedit($file);
+ eval { writefile($file, $config{srcdir}, $content) };
+ next if $@;
+ my $conflict=IkiWiki::rcs_commit(
+ $file,
+ sprintf(gettext("update for rename of %s to %s"), $rename->{srcfile}, $rename->{destfile}),
+ $token,
+ $session->param("name"),
+ $ENV{REMOTE_ADDR}
+ );
+ push @fixedlinks, $page if ! defined $conflict;
+ }
+ }
+ }
+
+ return @fixedlinks;
+} #}}}
1
diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example
index 7878d7c2b..f844ddb91 100644
--- a/IkiWiki/Plugin/skeleton.pm.example
+++ b/IkiWiki/Plugin/skeleton.pm.example
@@ -165,7 +165,7 @@ sub auth ($$) { #{{{
debug("skeleton plugin running in auth");
} #}}}
-sub sessionncgi ($$) { #{{{
+sub sessioncgi ($$) { #{{{
my $cgi=shift;
my $session=shift;
diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm
index 74d187cd2..bf53209fc 100644
--- a/IkiWiki/Plugin/tag.pm
+++ b/IkiWiki/Plugin/tag.pm
@@ -42,7 +42,6 @@ sub tagpage ($) { #{{{
my $tag=shift;
if ($tag !~ m{^\.?/} &&
- exists $config{tagbase} &&
defined $config{tagbase}) {
$tag=$config{tagbase}."/".$tag;
}
@@ -50,6 +49,21 @@ sub tagpage ($) { #{{{
return $tag;
} #}}}
+sub taglink ($$$;@) { #{{{
+ my $page=shift;
+ my $destpage=shift;
+ my $tag=shift;
+ my %opts=@_;
+
+ my $link=tagpage($tag);
+
+ # Force tag creation links to create the tag under /tagbase,
+ # if there is a tagbase and this tag used it.
+ $link="/".$link if $tag ne $link;
+
+ return htmllink($page, $destpage, $link, %opts);
+} #}}}
+
sub preprocess_tag (@) { #{{{
if (! @_) {
return "";
@@ -80,16 +94,14 @@ sub preprocess_taglink (@) { #{{{
my $tag=IkiWiki::linkpage($2);
$tags{$params{page}}{$tag}=1;
push @{$links{$params{page}}}, tagpage($tag);
- return htmllink($params{page}, $params{destpage},
- tagpage($tag),
+ return taglink($params{page}, $params{destpage}, $tag,
linktext => IkiWiki::pagetitle($1));
}
else {
my $tag=IkiWiki::linkpage($_);
$tags{$params{page}}{$tag}=1;
push @{$links{$params{page}}}, tagpage($tag);
- return htmllink($params{page}, $params{destpage},
- tagpage($tag));
+ return taglink($params{page}, $params{destpage}, $tag);
}
}
grep {
@@ -105,8 +117,7 @@ sub pagetemplate (@) { #{{{
$template->param(tags => [
map {
- link => htmllink($page, $destpage, tagpage($_),
- rel => "tag")
+ link => taglink($page, $destpage, $_, rel => "tag")
}, sort keys %{$tags{$page}}
]) if exists $tags{$page} && %{$tags{$page}} && $template->query(name => "tags");
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 752d17643..ceb7c842c 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -279,7 +279,11 @@ sub refresh () { #{{{
else {
$f=~s/^\Q$config{srcdir}\E\/?//;
push @files, $f;
- $exists{pagename($f)}=1;
+ my $pagename = pagename($f);
+ if ($exists{$pagename}) {
+ debug(sprintf(gettext("%s has multiple possible source pages"), $pagename));
+ }
+ $exists{$pagename}=1;
}
}
},