User:AnomieBOT/source/tasks/PERTableUpdater.pm: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: PERTableUpdater: * Use a unicode-safe URI encoding function.
AnomieBOT (talk | contribs)
Updating published sources: PERTableUpdater: * I didn't know there was a global title blacklist.
Line 65:
my $res;
 
$api->task('PERTableUpdater', 0, 10, qw/d::Sections d::Timestamp d::Talk d::IWNS/);
 
my $screwup=' Errors? [[User:'.$api->user.'/shutoff/PERTableUpdater]]';
Line 72:
# that mechanism
my %tb=();
my %optssources=();
my $tb 'Title blacklist' =$api->rawpage( 'MediaWiki:Titleblacklist');,
if($tb->{'code'} ne 'success'){
'Global title blacklist' => 'meta:Title blacklist',
$api->warn("Failed to load MediaWiki:Titleblacklist: ".$tb->{'error'}."\n");
return 60);
while(my ($k,$page)=each %sources){
}
for my $line (split /\r?\n/,my $tb=$api->{'content'}rawpage($page){;
my if($re=$line;tb->{'code'} ne 'success'){
$api->warn("Failed to load MediaWiki:Titleblacklist$page: ".$tb->{'error'}."\n");
my %opts=();
$re=~s/^\s*([^#]*?)\s*(?:#.*)?$/$1/ return 60;
if($re=~s/\s*<([^<>]*)>$//){}
for my $line (split my/\r?\n/, $opts=$1;tb->{'content'}){
my $optsre=~s/^\s+|\s+$//gline;
for my $opt %opts=(split /\s*\|\s*/, $opts){;
if($optre=~s/^\s*([^=#]*?)\s*=\s*(?:#.+*)?$/){$1/;
$opts{lcif($1)}re=~s/\s*<([^<>]*)>$2;//){
}my else {$opts=$1;
$opts{lc($opt)}=1~s/^\s+|\s+$//g;
for my $opt (split /\s*\|\s*/, $opts){
if($opt=~/^([^=]*?)\s*=\s*(.+)$/){
$opts{lc($1)}=$2;
} else {
$opts{lc($opt)}=1;
}
}
}
} $re=~s/_/ /g;
$re=~s/_/"(?-i:$re)" if($opts{'casesensitive'}//g0);
$re="(?-i:$re)" if($opts{'casesensitive'}//0);
 
$re=~s!({{\s*ns\s*:\s*(.+?)\s*}})! replace_ns($api,$2) // $1 !ge;
# Let's just hope no one ever uses {{ns:}} or {{int:}} here...
 
# Let's just hope no one ever uses {{ns:}} or {{int:}} here...
$tb{$re}={ line=>$line, opts=>\%opts } if($opts{'noedit'}//0);
 
$tb{$re}={ source=>"[[$page|$k]]", line=>$line, opts=>\%opts } if($opts{'noedit'}//0);
}
}
 
Line 134 ⟶ 142:
}
$api->store->{'pages'.$sper}=\%pages;
 
if(%pages){
$iter=$api->iterator(
Line 164 ⟶ 172:
next unless $t=~/^(?:$re)$/si;
$pd->{'color'}='yellow' unless(exists($data->{'opts'}{'autoconfirmed'}) && !$sper);
$pd->{'prottype'}=$data->{'[[MediaWiki:Titleblacklist|Title blacklist]]source'};
my $line=$data->{'line'};
$pd->{'reason'}=qq(Matching line: <syntaxhighlight lang="text" enclose="none">$line</syntax).qq(highlight>);
Line 299 ⟶ 307:
$t=uri_escape_utf8($t, '^A-Za-z0-9_\-.:/~');
return $t;
}
 
sub replace_ns {
my ($api,$ns)=@_;
 
if($ns=~/^([+-]?[0-9]+)/){
$ns=int($1);
} else {
$ns=~s/_/ /g;
my %x=$api->namespace_map();
$ns=$x{$ns} // undef;
return undef unless defined($ns);
}
my %x=$api->namespace_reverse_map();
return $x{$ns} // undef;
}