Files
oddmuse/modules/partial-journal.pl

67 lines
2.1 KiB
Perl
Raw Normal View History

2004-09-26 10:59:48 +00:00
# Copyright (C) 2004 Brock Wilcox <awwaiid@thelackthereof.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
2004-09-26 10:59:48 +00:00
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2004-09-26 10:59:48 +00:00
use strict;
use v5.10;
AddModuleDescription('partial-journal.pl', 'Partial Page Journal');
2004-09-26 10:59:48 +00:00
2015-04-10 13:31:28 +03:00
our ($q, %Page, @MyRules, $CommentsPrefix);
2004-09-26 10:59:48 +00:00
# Set up some rule so that we can mess with '-- cut --' (change to <hr>)
push(@MyRules, \&PartialCutRule);
sub PartialCutRule {
if (m/\G(?<=\n)\s*--\s*cut\s*--\s*(?=\n)/cg) {
2004-12-05 03:55:38 +00:00
return CloseHtmlEnvironments() . '<hr class="cut" />' . AddHtmlEnvironment('p');
2004-09-26 10:59:48 +00:00
}
return;
2004-09-26 10:59:48 +00:00
}
*OldPartialPrintJournal = \&PrintJournal;
*PrintJournal = \&NewPartialPrintJournal;
2004-09-26 10:59:48 +00:00
sub NewPartialPrintAllPages {
my $links = shift;
my $comments = shift;
my $num = shift;
2004-09-26 10:59:48 +00:00
for my $id (@_) {
OpenPage($id);
print $q->hr . $q->h1($links ? GetPageLink($id) : $q->a({-name=>$id},$id));
my $text = $Page{'text'};
if ($text =~ /((.*\n)*.*)\n\s*--\s*cut\s*--\s*/) {
$text = $1;
}
PrintWikiToHTML($text); # nocache, current, not locked
if ($comments and UserCanEdit($CommentsPrefix . $id, 0) and $id !~ /^$CommentsPrefix/) {
print $q->p({-class=>'comment'},
GetPageLink($CommentsPrefix . $id, T('Comments on this page')));
}
}
}
sub NewPartialPrintJournal {
# We redefine PrintAllPages temporarily
*OldPartialPrintAllPages = \&PrintAllPages;
*PrintAllPages = \&NewPartialPrintAllPages;
2004-09-26 10:59:48 +00:00
# Then we call the PrintJournal
my $out = OldPartialPrintJournal(@_);
# Then we put PrintAllPages back!
*PrintAllPages = \&OldPartialPrintAllPages;
2004-09-26 10:59:48 +00:00
return $out;
}