Content deleted Content added
Updating published sources: WikiProjectWorker: * Run is complete. |
Updating published sources: WikiProjectTagger, WikiProjectWorker: * Retire these tasks, WikiProject templates have changed a bunch since I last ran these. |
||
(18 intermediate revisions by the same user not shown) | |||
Line 1:
{{ombox|type=notice|text= Approved 2009-04-08<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 28]]}}
{{ombox|type=notice|text= Retired 2024-01-29. Haven't had call to run this in a while, and the related templates have changed so I'd probably have to update this code to run it again.}}
<syntaxhighlight lang="perl">
package tasks::WikiProjectWorker;
Line 10 ⟶ 11:
Task: WikiProjectWorker
BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 28
Status:
Created: 2009-03-27
OnDemand: true
Line 32 ⟶ 33:
### Request link, for edit summary.
my $req="[[User:AnomieBOT/req/WikiProject
### 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=
### How to find the pages?
my
"Category:Articles using infobox university" => "WikiProject Higher education",
);
my @cats=keys %catmap;
my @iterators=(
{
Line 902 ⟶ 66:
}
my $always_copy_importance = 0;
my $set_empty_importance = 0;
sub copy_importance {
#return ($_[0]->WPBmax($_[2]))[1];
Line 908 ⟶ 74:
# Banner configurations.
my $main_banner='WikiProject
my %banner_cfgs=(
'WikiProject
meta => 1,
canonicalize => 'WikiProject Higher education',
},
);
# Extra parameters (e.g. workgroup).
my @extra_params=();
my $taggingwith = @extra_params ? '|' . join( '|', @extra_params ) : '';
# Regex fragment to match any aliases of params in @extra_params.
my %extra_param_aliases = ();
# Possible main banners, usually just $main_banner.
my @main_banners=(
$main_banner,
);
# Set this to merge these existing banners into $main_banner.
my @merge_banners=();
# Set this to tag WikiProject Biography workgroups in addition to the project's own banner.
my @bio_wg = (
);
Line 935 ⟶ 116:
=for info
Approved 2009-04-08<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 28]]
=for info
Retired 2024-01-29. Haven't had call to run this in a while, and the related templates have changed so I'd probably have to update this code to run it again.
=cut
Line 1,014 ⟶ 198:
$api->log("Checking $title...");
my $intxt=$tok->{'revisions'}[0]{'slots'}{'main'}{'*'} // '';
my ($outtxt,$nowiki)=$api->strip_nowiki($intxt);
my @params=
my $assess = undef;
Line 1,037 ⟶ 221:
}
my $copy_importance =
if($class eq '' || lc($class) eq lc($assess)){
$class='';
Line 1,052 ⟶ 236:
next;
}
push @params, "importance=$imp"
}
my $need_main_banner = ($api->WPBcheck($outtxt,
if(0){
# grr, already redirected so the above always returns true
$need_main_banner=1;
$api->WPBcheck($outtxt, sub {
}
Line 1,071 ⟶ 255:
my @merge=();
my @summary=();
my $no_summary = 0;
# Special: Different default parent banner depending on source category.
$main_banner = $catmap{$iter->iterval};
if(@
(undef,$outtxt)=$api->WPBcheck($outtxt, sub {
my $banner=shift;
Line 1,087 ⟶ 275:
$need_main_banner=0;
return "{{$main_banner}}";
}, @
if(ref($outtxt) eq 'HASH'){
$api->warn("Preprocessing $title failed: ".$outtxt->{'error'}."\n");
Line 1,095 ⟶ 283:
$merge[-1]='and '.$merge[-1] if @merge>1;
push @summary, "merging ".join((@merge>2)?', ':' ', @merge)." into $main_banner" if @merge;
$no_summary = 1 if @merge;
} else {
# $api->warn("$title contains ".$iter->iterval.", but not in section 0\n");
next;
}
}
if ( @bio_wg ) {
my %added_wg=();
(undef,$outtxt)=$api->WPBcheck($outtxt, sub {
my $banner=shift;
my $name=shift;
my $oname=shift;
my $params=shift;
my $wikitext=shift;
my %have = ();
foreach ($api->process_paramlist(@$params)) {
$have{$_->{'name'}} = 1;
}
my $any = 0;
foreach my $p (@bio_wg){
next if exists($have{$p});
push @$params, "$p=yes";
$added_wg{"$p=yes"}=1;
$any = 1;
}
return undef unless $any;
my $out="{{$oname";
$out.="|".join("|", @$params) if @$params;
$out.="}}";
return $out;
}, 'WikiProject Biography');
if(ref($outtxt) eq 'HASH'){
$api->warn("WPBIO workgroups in $title failed: ".$outtxt->{'error'}."\n");
next;
}
if(%added_wg){
my @added_wg = keys %added_wg;
$added_wg[-1]='and '.$added_wg[-1] if @added_wg>1;
push @summary, "added " . join((@added_wg>2)?', ':' ', @added_wg) . " to {{WikiProject Biography}}";
}
}
Line 1,118 ⟶ 345:
}
$api->WPBcheck( $outtxt, sub {
@process_banners = ( $main_banner
for my $process_banner (@process_banners)
my $
my $
my $params=shift;
my $wikitext=shift;
my $new=shift;
#return '' if $new;
return undef unless(grep $banner eq $_, @main_banners);
my %cfg=%{$banner_cfgs{$banner}};
my $any=0;
foreach my $p (@params){
next unless $p=~/^(.+?)=(.*)$/;
my ($k,$v)=($1,$2);
my $
$any=1 unless $v eq '';
if($k eq 'class' && exists($cfg{'meta'}) && ($cfg{'stubauto'}//'')){
my $aa=$cfg{'stubauto'};
$aa=~s/\s*=.*//;
push @$params, "$aa=inherit" unless(grep(s/^(\s*\Q$aa\E\s*=\s*?)(?:\S.*?)?(\s*)$/$1inherit$2/s, @$params));
}
}
}
if($new && $class && (grep /^class=/, @$params) && exists($cfg{'meta'}) && ($cfg{'stubauto'}//'')){
push @$params, "$aa=
if(defined($cfg{'canonicalize'})){
my $n=$cfg{'canonicalize'};
$oname=~s/_/ /g;
$oname=~s/^(\s*)\S(?:.*\S)?(\s*)$/$1$n$2/is;
}
my $out="{{$oname";
$out.="|".join("|", @$params) if @$params;
$out.="}}";
return $out;
}, $process_banner, @params);
if(ref($outtxt) eq 'HASH'){
$api->warn("Processing $title failed: ".$outtxt->{'error'}."\n");
next;
}
}
$outtxt=$api->replace_nowiki($outtxt, $nowiki);
Line 1,216 ⟶ 453:
return 600;
}
1;
</syntaxhighlight>
|