our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
bestlink htmllink readfile writefile pagetype srcfile pagename
displaytime will_render gettext urlto targetpage
+ add_underlay
%config %links %renderedfiles %pagesources %destsources);
our $VERSION = 2.00; # plugin interface version, next is ikiwiki version
our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
wiki_link_regexp => qr{
\[\[ # beginning of link
(?:
- ([^\]\|]+) # 1: link text
+ ([^\]\|\n\s]+) # 1: link text
\| # followed by '|'
)? # optional
pingurl => [],
templatedir => "$installdir/share/ikiwiki/templates",
underlaydir => "$installdir/share/ikiwiki/basewiki",
+ underlaydirs => [],
setup => undef,
adminuser => undef,
adminemail => undef,
my $file=shift;
return "$config{srcdir}/$file" if -e "$config{srcdir}/$file";
- return "$config{underlaydir}/$file" if -e "$config{underlaydir}/$file";
- error("internal error: $file cannot be found in $config{srcdir} or $config{underlaydir}");
+ foreach my $dir (@{$config{underlaydirs}}, $config{underlaydir}) {
+ return "$dir/$file" if -e "$dir/$file";
+ }
+ error("internal error: $file cannot be found in $config{srcdir} or underlay");
return;
} #}}}
+sub add_underlay ($) { #{{{
+ my $dir=shift;
+
+ if ($dir=~/^\//) {
+ unshift @{$config{underlaydirs}}, $dir;
+ }
+ else {
+ unshift @{$config{underlaydirs}}, "$config{underlaydir}/../$dir";
+ }
+
+ return 1;
+} #}}}
+
sub readfile ($;$$) { #{{{
my $file=shift;
my $binary=shift;
if (! $destsources{$bestlink}) {
return $linktext unless length $config{cgiurl};
- return "<span><a href=\"".
+ return "<span class=\"createlink\"><a href=\"".
cgiurl(
do => "create",
page => pagetitle(lc($link), 1),
if (defined $opts{rel}) {
push @attrs, ' rel="'.$opts{rel}.'"';
}
+ if (defined $opts{class}) {
+ push @attrs, ' class="'.$opts{class}.'"';
+ }
return "<a href=\"$bestlink\"@attrs>$linktext</a>";
} #}}}
} #}}}
sub loadindex () { #{{{
+ %oldrenderedfiles=%pagectime=();
+ if (! $config{rebuild}) {
+ %pagesources=%pagemtime=%oldlinks=%links=%depends=
+ %destsources=%renderedfiles=%pagecase=();
+ }
open (my $in, "<", "$config{wikistatedir}/index") || return;
while (<$in>) {
$_=possibly_foolish_untaint($_);
my @ret=(
filter => sub {
my $text_ref = shift;
- ${$text_ref} = Encode::decode_utf8(${$text_ref});
+ ${$text_ref} = decode_utf8(${$text_ref});
},
filename => $filename,
loop_context_vars => 1,
if $bestlink eq IkiWiki::bestlink($page, $p);
}
else {
- return IkiWiki::SuccessReason->new("$page links to page matching $link")
+ return IkiWiki::SuccessReason->new("$page links to page $p matching $link")
if match_glob($p, $link, %params);
}
}