From: joey Date: Fri, 10 Mar 2006 07:27:11 +0000 (+0000) Subject: pretty! X-Git-Tag: 1.0~555 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=10b2ae520d269b051fccc1511cd1b3c162e65117;p=ikiwiki.git pretty! --- diff --git a/ikiwiki b/ikiwiki index f42be3b01..72b1021ec 100755 --- a/ikiwiki +++ b/ikiwiki @@ -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, "$p"; + + # 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, "$p_trimmed"; } }