diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-03-31 08:48:10 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-03-31 08:48:10 +0000 |
commit | a2cfdaaec5666a08af864ebad8133e18d7cbbcb3 (patch) | |
tree | 0d2b9c644d4124d3d20c1958ecde277025f78e0a /IkiWiki | |
parent | f9e8c6012903cb98b9885ff8b76d897fa151dadb (diff) |
* Hide excess backlinks and expand using CSS trick; control quantiy via
the numbacklinks setting.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Render.pm | 11 |
1 files changed, 8 insertions, 3 deletions
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), ); |