2006-02-15 19:29:39 +00:00
|
|
|
# Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
|
2006-02-15 07:24:10 +00:00
|
|
|
#
|
|
|
|
|
# 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
|
|
|
|
|
|
2006-02-15 19:29:39 +00:00
|
|
|
$ModulesDescription .= '<p>$Id: grep.pl,v 1.3 2006/02/15 19:29:39 as Exp $</p>';
|
2006-02-15 07:24:10 +00:00
|
|
|
|
|
|
|
|
push(@MyRules, \&GrepRule);
|
|
|
|
|
|
|
|
|
|
sub GrepRule {
|
|
|
|
|
if (/\G(<grep "(.*?)">)/cgis) {
|
|
|
|
|
# <search "regexp">
|
|
|
|
|
Clean(CloseHtmlEnvironments());
|
|
|
|
|
Dirty($1);
|
|
|
|
|
my $oldpos = pos;
|
|
|
|
|
print '<ul class="grep">';
|
|
|
|
|
PrintGrep($2);
|
|
|
|
|
print '</ul>';
|
|
|
|
|
pos = $oldpos; # restore \G after searching
|
2006-02-15 19:29:39 +00:00
|
|
|
return '';
|
2006-02-15 07:24:10 +00:00
|
|
|
}
|
|
|
|
|
return undef;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub PrintGrep {
|
|
|
|
|
my $regexp = shift;
|
|
|
|
|
foreach my $id (AllPagesList()) {
|
2006-02-15 19:08:20 +00:00
|
|
|
my $text = GetPageContent($id);
|
|
|
|
|
next if (TextIsFile($text)); # skip files
|
|
|
|
|
while ($text =~ m{($regexp)}ig) {
|
2006-02-15 07:24:10 +00:00
|
|
|
print $q->li(GetPageLink($id) . ': ' . $1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|