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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: WikiProjectWorker: * Stopping task, seems like it may be done anyway.
AnomieBOT (talk | contribs)
Updating published sources: WikiProjectWorker: * Start task for WikiProject Albemarle County. d::WikiProjectTagging: * {{tl|WPBiography}} → {{tl|WikiProject Biography}}.
Line 33:
 
### Request link, for edit summary.
my $req="[[User:AnomieBOT/req/WikiProject PhysicsAlbemarle 2County 1|request]]";
 
### Increment this number every time a new run is started, so we don't have to
### mess around with deleting previous runs' database entries.
my $seq=1415;
 
### How to find the pages?
my @cats=(
'Category:Unassessed Albemarle County articles',
);
my @iterators=(
{
generator => 'embeddedincategorymembers',
geititle gcmtitle => 'Template:WikiProject Physics'[@cats],
geilimit gcmlimit => '100',
geinamespace => 1,
},
);
Line 61:
### How to copy other projects' assessments
sub copy_class {
#return ($_[0]->WPBmax($_[2]))[0];
return 'redirect';
}
 
sub copy_importance {
#return ($_[0]->WPBmax($_[2]))[1];
return 'NA';
}
 
# Banner configurations.
my $main_banner='WikiProject PhysicsAlbemarle County';
my @preprocess_templates=();
my %banner_cfgs=(
'WikiProject PhysicsAlbemarle County' => {
meta => 1,
canonicalize => 'WikiProject Albemarle County',
},
);
Line 101 ⟶ 100:
 
sub approved {
return -1;
}
 
Line 263 ⟶ 262:
}
 
next unless $pg eq ($page->{'query'}{'redirects'}[0]{'from'}//'');
$page=$api->query([],titles=>'Talk:'.$page->{'query'}{'redirects'}[0]{'to'}, prop=>'templates', tllimit=>'max');
if($page->{'code'} ne 'success'){
$api->warn("Could not load Talk:".$page->{'query'}{'redirects'}[0]{'to'}." info: ".$page->{'error'}."\n");
return 60;
}
$page=(values %{$page->{'query'}{'pages'}})[0];
$tag=grep $_->{'title'} eq "Template:$main_banner", @{$page->{'templates'}};
}
 
Line 283 ⟶ 275:
 
return undef unless(grep $banner eq $_, @main_banners);
my %cfg=%{$banner_cfgs{$banner}};
 
unless(my $tag){any=0;
push @summary, "Removing {{$main_banner}} from redirect where target is not tagged by with {{$main_banner}}";
return '';
}
 
foreach my $p (@params){
next unless $p=~/^(.+?)=(.*)$/;
my ($k,$v)=($1,$2);
#my $re=qr/\S/;
my $re=($k eq 'importance')?qr/(?i:\Q$v\E|)/:qr/(?i:\Q$v\E)/;
unless(grep(/^\s*\Q$k\E\s*=\s*$re\s*$/, @$params)){
next if(grep(/^\s*\Q$k\E\s*=\s*\Q$v\E\s*$/s, @$params));
unshift @$params, "$k=$v" unless(grep(s/^(\s*\Q$k\E\s*=\s*?)(?:\S.*?)?(\s*)$/$1$v$2/s, @$params) || $k eq 'importance');
return $any=1 unless $v eq '';
}
}
return $wikitext unless $any;
 
if(defined($cfg{'canonicalize'})){
my $n=$cfg{'canonicalize'};
return$oname=~s/_/ 60/g;
$oname=~s/^(\s*)\S(?:.*\S)?(\s*)$/$1$n$2/is;
}
my $out="{{$oname";
$out.="|".join("|", @$params) if @$params;
$out.="}}";
push @summary, "Re-tagging {{$main_banner}} as class=redirect";
return $out;
}, $main_banner, @params);