summaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm46
1 files changed, 36 insertions, 10 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 207ca87fb..67cd2147d 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -647,8 +647,19 @@ sub newpagefile ($$) { #{{{
sub targetpage ($$) { #{{{
my $page=shift;
my $ext=shift;
-
- if (! $config{usedirs} || $page eq 'index') {
+
+ 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') {
return $page.".".$ext;
}
else {
@@ -796,6 +807,7 @@ sub will_render ($$;$) { #{{{
sub bestlink ($$) { #{{{
my $page=shift;
my $link=shift;
+ my $res=undef;
my $cwd=$page;
if ($link=~s/^\/+//) {
@@ -810,25 +822,35 @@ sub bestlink ($$) { #{{{
$l.=$link;
if (exists $links{$l}) {
- return $l;
+ $res=$l;
}
elsif (exists $pagecase{lc $l}) {
- return $pagecase{lc $l};
+ $res=$pagecase{lc $l};
}
- } while $cwd=~s{/?[^/]+$}{};
+ } while ($cwd=~s{/?[^/]+$}{} && ! defined $res);
- if (length $config{userdir}) {
+ if (! defined $res && length $config{userdir}) {
my $l = "$config{userdir}/".lc($link);
if (exists $links{$l}) {
- return $l;
+ $res=$l;
}
elsif (exists $pagecase{lc $l}) {
- return $pagecase{lc $l};
+ $res=$pagecase{lc $l};
}
}
- #print STDERR "warning: page $page, broken link: $link\n";
- return "";
+ if (defined $res) {
+ run_hooks(tweakbestlink => sub {
+ $res=shift->(
+ page => $page,
+ link => $res);
+ });
+ return $res;
+ }
+ else {
+ #print STDERR "warning: page $page, broken link: $link\n";
+ return "";
+ }
} #}}}
sub isinlinableimage ($) { #{{{
@@ -933,6 +955,10 @@ sub beautify_urlpath ($) { #{{{
$url =~ s!/index.$config{htmlext}$!/!;
}
+ run_hooks(tweakurlpath => 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 !~ /^\//) {