diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-03-10 07:27:11 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-03-10 07:27:11 +0000 |
commit | 10b2ae520d269b051fccc1511cd1b3c162e65117 (patch) | |
tree | 3d60609a292529f69bc946f3172d06707d379682 | |
parent | d3d8890ee904982e3b1ae81c8a5f6571bfcf3eab (diff) |
pretty!
-rwxr-xr-x | ikiwiki | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -218,12 +218,20 @@ sub linkbacks ($$) { my @links; foreach my $p (keys %links) { + next if bestlink($page, $p) eq $page; if (grep { length $_ && bestlink($p, $_) eq $page } @{$links{$p}}) { my $href=File::Spec->abs2rel(htmlpage($p), dirname($page)); - # TODO: if $p is joey/foo/bar and - # the $page is joey/foo/baz, make the link text - # just be "bar". - push @links, "<a href=\"$href\">$p</a>"; + + # Trim common dir prefixes from both pages. + my $p_trimmed=$p; + my $page_trimmed=$page; + my $dir; + 1 while (($dir)=$page_trimmed=~m!^([^/]+/)!) && + defined $dir && + $p_trimmed=~s/^\Q$dir\E// && + $page_trimmed=~s/^\Q$dir\E//; + + push @links, "<a href=\"$href\">$p_trimmed</a>"; } } |