bestlink htmllink readfile writefile pagetype srcfile pagename
displaytime will_render gettext urlto targetpage
add_underlay pagetitle titlepage linkpage newpagefile
+ inject
%config %links %pagestate %wikistate %renderedfiles
%pagesources %destsources);
our $VERSION = 2.00; # plugin interface version, next is ikiwiki version
},
default_plugins => {
type => "internal",
- default => [qw{mdwn link inline htmlscrubber passwordauth
+ default => [qw{mdwn link inline meta htmlscrubber passwordauth
openid signinedit lockedit conditional
recentchanges parentlinks editpage}],
description => "plugins to enable by default",
safe => 0,
rebuild => 0,
},
+ test_receive => {
+ type => "internal",
+ default => 0,
+ description => "running in receive test mode",
+ safe => 0,
+ rebuild => 0,
+ },
getctime => {
type => "internal",
default => 0,
safe => 0,
rebuild => 0,
},
+ wikistatedir => {
+ type => "internal",
+ default => undef,
+ description => "path to the .ikiwiki directory holding ikiwiki state",
+ safe => 0,
+ rebuild => 0,
+ },
setupfile => {
type => "internal",
default => undef,
rebuild => 0,
},
allow_symlinks_before_srcdir => {
- type => "string",
+ type => "boolean",
default => 0,
description => "allow symlinks in the path leading to the srcdir (potentially insecure)",
safe => 0,
}
$config{wikistatedir}="$config{srcdir}/.ikiwiki"
- unless exists $config{wikistatedir};
+ unless exists $config{wikistatedir} && defined $config{wikistatedir};
if (defined $config{umask}) {
umask(possibly_foolish_untaint($config{umask}));
sub targetpage ($$) { #{{{
my $page=shift;
my $ext=shift;
-
- my $targetpage='';
- run_hooks(targetpage => sub {
- $targetpage=shift->(
- page => $page,
- ext => $ext,
- );
- });
-
- if (defined $targetpage && (length($targetpage) > 0)) {
- return $targetpage;
- }
- elsif (! $config{usedirs} || $page eq 'index') {
+
+ if (! $config{usedirs} || $page eq 'index') {
return $page.".".$ext;
}
else {
} #}}}
sub displaytime ($;$) { #{{{
+ # Plugins can override this function to mark up the time to
+ # display.
+ return '<span class="date">'.formattime(@_).'</span>';
+} #}}}
+
+sub formattime ($;$) { #{{{
+ # Plugins can override this function to format the time.
my $time=shift;
my $format=shift;
if (! defined $format) {
$url =~ s!/index.$config{htmlext}$!/!;
}
- run_hooks(urlpath => sub {
- $url=shift->(url => $url);
- });
-
# Ensure url is not an empty link, and
# if it's relative, make that explicit to avoid colon confusion.
if ($url !~ /^\//) {
$hooks{rcs}{rcs_getctime}{call}->(@_);
} #}}}
+sub rcs_receive () { #{{{
+ $hooks{rcs}{rcs_receive}{call}->();
+} #}}}
+
sub globlist_to_pagespec ($) { #{{{
my @globlist=split(' ', shift);
return (defined $val && lc($val) eq gettext("yes"));
} #}}}
+sub inject { #{{{
+ # Injects a new function into the symbol table to replace an
+ # exported function.
+ my %params=@_;
+
+ # This is deep ugly perl foo, beware.
+ no strict;
+ no warnings;
+ if (! defined $params{parent}) {
+ $params{parent}='::';
+ $params{old}=\&{$params{name}};
+ $params{name}=~s/.*:://;
+ }
+ my $parent=$params{parent};
+ foreach my $ns (grep /^\w+::/, keys %{$parent}) {
+ $ns = $params{parent} . $ns;
+ inject(%params, parent => $ns) unless $ns eq '::main::';
+ *{$ns . $params{name}} = $params{call}
+ if exists ${$ns}{$params{name}} &&
+ \&{${$ns}{$params{name}}} == $params{old};
+ }
+ use strict;
+ use warnings;
+} #}}}
+
sub pagespec_merge ($$) { #{{{
my $a=shift;
my $b=shift;
my $sub=pagespec_translate($spec);
return ! $@;
} #}}}
-
+
sub glob2re ($) { #{{{
my $re=quotemeta(shift);
$re=~s/\\\*/.*/g;
else {
return IkiWiki::SuccessReason->new("$page links to page $p matching $link")
if match_glob($p, $link, %params);
+ $p=~s/^\///;
+ $link=~s/^\///;
+ return IkiWiki::SuccessReason->new("$page links to page $p matching $link")
+ if match_glob($p, $link, %params);
}
}
return IkiWiki::FailReason->new("$page does not link to $link");