forked from github/kensanata.oddmuse
Replaced the $Id$ tags in $WikiDescription for all the modules and wiki.pl itself with a link to the source and an appropriate wiki page, if possible. This is shown in action=version and should help users figure out what another wiki has installed.
87 lines
3.3 KiB
Perl
87 lines
3.3 KiB
Perl
# Copyright (C) 2005 Alex Schroeder <alex@emacswiki.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 2 of the License, or
|
|
# (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, write to the
|
|
# Free Software Foundation, Inc.
|
|
# 59 Temple Place, Suite 330
|
|
# Boston, MA 02111-1307 USA
|
|
|
|
$ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/dynamic-comments.pl">dynamic-comments.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Dynamic_Comments_Extension">Dynamic Comments Extension</a></p>';
|
|
|
|
push(@MyInitVariables, \&DynamicCommentsAddScript);
|
|
|
|
sub DynamicCommentsAddScript {
|
|
$HtmlHeaders .= qq{
|
|
<script type="text/Javascript">
|
|
function togglecomments (id) {
|
|
var elem = document.getElementById(id);
|
|
if (elem.className=="commentshown") {
|
|
elem.className="commenthidden";
|
|
}
|
|
else {
|
|
elem.className="commentshown";
|
|
}
|
|
}
|
|
</script>
|
|
} unless $HtmlHeaders =~ /commenthidden/; # mod_perl?
|
|
}
|
|
|
|
sub SafeId {
|
|
my $id = shift;
|
|
my $regexp = "";
|
|
$regexp = "|\xc3[\x80-\x96\x98-\xb6\xb8-\xff]|[\xc4-\xca].|\xcb[\x00-\xbf]"
|
|
. "|\xcd[\xb0-\xbd\xbf-\xff]|[\xce-\xDF].|\xe0..|\xe1[\x00-\xbe]."
|
|
. "|\xe1\xbf[\x00-\xbf]|\xe2\x80[\x8c\x8d]"
|
|
if $HttpCharset eq 'UTF-8';
|
|
# Unicode Codepoint UTF-8 encoding
|
|
# [#xC0-#xD6] c3 80 - c3 96
|
|
# [#xD8-#xF6] c3 98 - c3 b6
|
|
# [#xF8-#x2FF] c3 b8 - cb bf
|
|
# [#x370-#x37D] cd b0 - cd bd
|
|
# [#x37F-#x1FFF] cd bf - e1 bf bf
|
|
# [#x200C-#x200D] e2 80 8c - e2 80 8d
|
|
# [#x2070-#x218F] e2 81 b0 - e2 86 8f -- FIXME \
|
|
# [#x2C00-#x2FEF] e2 b0 80 - e2 bf af -- FIXME |
|
|
# [#x3001-#xD7FF] e3 80 81 - ed 9f bf -- FIXME | these are missing
|
|
# [#xF900-#xFDCF] ef a4 80 - ef b7 8f -- FIXME | in the regexp above
|
|
# [#xFDF0-#xFFFD] ef b7 b0 - ef bf bd -- FIXME |
|
|
# [#x10000-#xEFFFF] f0 90 80 80 - f3 af bf bf -- FIXME /
|
|
$id = ":$id" unless $id =~ /^[:_A-Za-z]$regexp/;
|
|
return join('', $id =~ m/([-.:_A-Za-z0-9]$regexp)/g);
|
|
}
|
|
|
|
*DynamicCommentsOldGetPageLink = *GetPageLink;
|
|
*GetPageLink = *DynamicCommentsNewGetPageLink;
|
|
|
|
sub DynamicCommentsNewGetPageLink {
|
|
my ($id, @rest) = @_;
|
|
if ($CollectingJournal and $id =~ /^$CommentsPrefix/) {
|
|
my $title = $id;
|
|
$title =~ s/_/ /g;
|
|
my $page = PageHtml($id);
|
|
if ($page) {
|
|
my $safe = SafeId($id);
|
|
return qq{<a href="javascript:togglecomments('$safe')">$title</a>}
|
|
. '</p>' # close p before opening div
|
|
. $q->div({-class=>commenthidden, -id=>$safe},
|
|
$page,
|
|
$q->p(DynamicCommentsOldGetPageLink($id, T('Add Comment'))))
|
|
. '<p>'; # open an empty p that will be closed in PrintAllPages
|
|
} else {
|
|
return DynamicCommentsOldGetPageLink($id, T('Add Comment'));
|
|
}
|
|
} else {
|
|
return DynamicCommentsOldGetPageLink($id, @rest);
|
|
}
|
|
}
|