1 # Copyright (C) 2004 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/compilation.pl">compilation.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Compilation_Extension">Compilation Extension</a></p>';
21 $Action{compilation
} = \
&DoCompilation
;
24 my $match = GetParam
('match', '') or ReportError
(T
('The match parameter is missing.'));
25 print GetHeader
('', Ts
('Compilation for %s', $match), '');
26 my @pages = PrintCompilation
(undef, $match, GetParam
('reverse', 0));
27 print $q->p(Ts
('%s pages found.', ($#pages + 1)));
32 sub PrintCompilation
{
33 return if $CollectingJournal; # avoid infinite loops
34 local $CollectingJournal = 1;
35 my ($num, $regexp, $mode) = @_;
36 return $q->p($q->strong(T
('Compilation tag is missing a regular expression.'))) unless $regexp;
37 my @pages = SearchTitleAndBody
($regexp);
38 if (defined &CompilationSort
) {
39 @pages = sort CompilationSort
@pages;
43 if ($mode eq 'reverse') {
44 @pages = reverse @pages;
46 @pages = @pages[0 .. $num - 1] if $num and $#pages >= $num;
48 # Now save information required for saving the cache of the current page.
50 local $OpenPageName='';
51 print '<div class="compilation">';
52 PrintAllPages
(1, 1, undef, @pages);
58 push(@MyRules, \
&CompilationRule
);
61 if ($bol && m/\G(\<compilation(\s+(\d*))?(\s+"(.*)")(\s+(reverse))?\>[ \t]*\n?)/cgi) {
62 # <journal 10 "regexp"> includes 10 pages matching regexp
63 Clean
(CloseHtmlEnvironments
());
66 PrintCompilation
($3, $5, $7);
67 pos = $oldpos; # restore \G after call to ApplyRules
68 return AddHtmlEnvironment
('p');