From a2cfdaaec5666a08af864ebad8133e18d7cbbcb3 Mon Sep 17 00:00:00 2001 From: joey Date: Sat, 31 Mar 2007 08:48:10 +0000 Subject: * Hide excess backlinks and expand using CSS trick; control quantiy via the numbacklinks setting. --- IkiWiki/Render.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index c5d885810..7fd7daf11 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -30,7 +30,6 @@ sub backlinks ($) { #{{{ calculate_backlinks(); my @links; - return unless $backlinks{$page}; foreach my $p (keys %{$backlinks{$page}}) { my $href=abs2rel(htmlpage($p), dirname($page)); @@ -45,8 +44,11 @@ sub backlinks ($) { #{{{ push @links, { url => $href, page => pagetitle($p_trimmed) }; } + @links = sort { $a->{page} cmp $b->{page} } @links; - return sort { $a->{page} cmp $b->{page} } @links; + return \@links, [] if @links <= $config{numbacklinks}; + return [@links[0..$config{numbacklinks}-1]], + [@links[$config{numbacklinks}..$#links]]; } #}}} sub parentlinks ($) { #{{{ @@ -107,6 +109,8 @@ sub genpage ($$$) { #{{{ $template->param(have_actions => 1); } + my ($backlinks, $more_backlinks)=backlinks($page); + $template->param( title => $page eq 'index' ? $config{wikiname} @@ -114,7 +118,8 @@ sub genpage ($$$) { #{{{ wikiname => $config{wikiname}, parentlinks => [parentlinks($page)], content => $content, - backlinks => [backlinks($page)], + backlinks => $backlinks, + more_backlinks => $more_backlinks, mtime => displaytime($mtime), baseurl => baseurl($page), ); -- cgit v1.2.3