wiki.pl: Port some fixes from upstream
[Orgmuse.git] / modules / index.pl
blobb84c92441b26e1427d77c410083f09fb59da5db3
1 # Copyright (C) 2004, 2007 Alex Schroeder <alex@emacswiki.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
19 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/index.pl">index.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Index_Extension">Index Extension</a></p>';
21 $Action{'printable-index'} = \&DoPrintableIndex;
23 sub DoPrintableIndex {
24 print GetHeader('', T('Index'), '');
25 my @pages = PrintableIndexPages();
26 my %hash;
27 map { push(@{$hash{GetPageDirectory($_)}}, $_); } @pages;
28 print '<div class="content printable index">';
29 print $q->p($q->a({-name=>"top"}),
30 map { $q->a({-href=>"#$_"}, $_); } sort keys %hash);
31 foreach my $title (sort keys %hash) {
32 print '<div class="letter">';
33 print $q->h2($q->a({-name=>$title}, $title));
34 foreach my $id (@{$hash{$title}}) {
35 PrintPage($id);
37 print '</div>';
39 print '</div>';
40 PrintFooter();
43 # Mostly DoIndex() without the printing.
44 sub PrintableIndexPages {
45 my @pages;
46 push(@pages, AllPagesList()) if GetParam('pages', 1);
47 push(@pages, keys %PermanentAnchors) if GetParam('permanentanchors', 1);
48 push(@pages, keys %NearSource) if GetParam('near', 0);
49 @pages = grep /$match/i, @pages if GetParam('match', '');
50 return sort @pages;