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
|
2016-08-16 14:59:13 +02:00
|
|
|
# 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
|
2016-08-16 14:59:13 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-09-26 10:59:48 +00:00
|
|
|
|
2015-03-27 03:01:01 +02:00
|
|
|
use strict;
|
2015-08-18 10:48:03 +02:00
|
|
|
use v5.10;
|
2015-03-27 03:01:01 +02:00
|
|
|
|
2014-08-21 22:23:23 +02:00
|
|
|
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);
|
2015-03-27 03:01:01 +02:00
|
|
|
|
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 {
|
2015-08-23 21:22:12 +03:00
|
|
|
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
|
|
|
}
|
2015-02-27 12:10:18 +02:00
|
|
|
return;
|
2004-09-26 10:59:48 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-11 23:41:33 +03:00
|
|
|
*OldPartialPrintJournal = \&PrintJournal;
|
|
|
|
|
*PrintJournal = \&NewPartialPrintJournal;
|
2004-09-26 10:59:48 +00:00
|
|
|
|
|
|
|
|
sub NewPartialPrintAllPages {
|
|
|
|
|
my $links = shift;
|
|
|
|
|
my $comments = shift;
|
2011-11-19 15:26:44 +00:00
|
|
|
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
|
2015-04-12 22:50:50 +03:00
|
|
|
*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!
|
2015-04-12 22:50:50 +03:00
|
|
|
*PrintAllPages = \&OldPartialPrintAllPages;
|
2004-09-26 10:59:48 +00:00
|
|
|
return $out;
|
|
|
|
|
}
|