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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: SourceUploader: * Sort directory pages by last modified date. * Use <nowiki><syntaxhighlight></nowiki> instead of <nowiki><source></nowiki>. d::NoWiki: * Add support for <nowiki><syntaxhighlight></nowiki>. General: * Vario
AnomieBOT (talk | contribs)
Updating published sources: WikiProjectWorker: * Start run for WikiProject Physics, re-tagging or de-tagging redirects depending on whether the target is tagged.
Line 33:
 
### Request link, for edit summary.
my $req="[[User:AnomieBOT/req/WikiProject FoodPhysics and drink 12|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=1314;
 
### How to find the pages?
Line 45:
{
generator => 'embeddedin',
geititle => ['Template:WikiProject Physics',
'Template:WPMIX', 'Template:Cocktails Project', 'Template:WikiProject Mixed Drinks', 'Template:Wpmix', 'Template:WP Mixed Drinks',
'Template:WPSD', 'Template:Soda', 'Template:WikiProject Soft Drinks',
'Template:WikiProject Ice Cream', 'Template:WP Ice Cream',
'Template:WikiProject Bartending', 'Template:WPBAR',
],
geilimit => '100',
geinamespace => 1,
},
);
Line 65 ⟶ 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 Food and drinkPhysics';
my @preprocess_templates=('WikiProject Food and drink');
my %banner_cfgs=(
'WikiProject Food and drinkPhysics' => {
meta => 1,
},
Line 85 ⟶ 81:
my @main_banners=(
$main_banner,
'Food and drink',
'WPFOOD',
'WPCUISINE',
'F&D',
'Wpfood',
'WikiProject Food and Drink',
'Food',
'Wikiproject Food and drink',
'WP Food',
'Wikiproject Food and Drink',
'WikiProject Food',
'WikiProject FOOD',
'Wpf',
);
 
Line 248 ⟶ 231:
 
return undef if(grep $name eq $_, @main_banners);
 
my $soda=undef;
$soda='soda=yes' if(grep $name eq $_, ('WPSD','Soda','WikiProject Soft Drinks'));
my $mix=undef;
$mix='mix=yes' if(grep $name eq $_, ('WPMIX', 'Cocktails Project', 'WikiProject Mixed Drinks', 'Wpmix', 'WP Mixed Drinks'));
$mix='bar=yes' if(grep $name eq $_, ('WikiProject Bartending', 'WPBAR'));
my $icecream=undef;
$icecream='ice cream=yes' if(grep $name eq $_, ('WikiProject Ice Cream', 'WP Ice Cream'));
push @merge, $name;
my $pp='';
foreach (@$params){
$soda="$1=yes" if /^\s*(coffee|tea|c&t)\s*=/;
$mix="$1=yes" if /^\s*(bar)\s*=/;
$pp.="|$_" if /^\s*(class|importance|needs-photo)\s*=/;
}
push @params, $soda if defined($soda);
push @params, $mix if defined($mix);
push @params, $icecream if defined($icecream);
 
return '' unless $need_main_banner;
$need_main_banner=0;
return "{{$main_banner$pp}}";
}, @preprocess_templates);
if(ref($outtxt) eq 'HASH'){
Line 284 ⟶ 249:
}
 
my $pp=''tag;
my $pg=$title;
$pg=~s/^Talk://;
Line 289 ⟶ 255:
$page=$api->query(
titles => $pg,
pushprop @merge, $name; => 'info',
myredirects $icecream=undef;> 1,
);
if($page->{'code'} eq 'shutoff'){
$api->warn("Task disabled: ".$page->{'content'}."\n");
return 300;
}
if($page->{'code'} ne 'success'){
$api->warn("Could not load $pg info: ".$page->{'error'}."\n");
myreturn $soda=undef60;
], }
 
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'} eqne 'shutoffsuccess'){
$api->warn("TaskCould disablednot load Talk:".$page->{'query'}{'redirects'}[0]{'to'}." info: ".$page->{'contenterror'}."\n");
return 60;
}
$page=(values %{$page->{'query'}{'pages'}})[0];
$tag=grep $_->{'title'} eq "Template:$main_banner", @{$page->{'templates'}};
}
 
$outtxt=$api->WPBadd($outtxt, $assess, sub {
my $banner=shift; # banner
my $name=shift; # name
my $oname=shift;
Line 310 ⟶ 282:
return '' if $new;
 
return undef unless(grep $namebanner eq $_, @main_banners);
 
foreach unless(@$paramstag){
push @summary, "Removing {{$main_banner}} from redirect where target is not tagged by with {{$main_banner}}";
myreturn $mix=undef'';
}
 
foreach my $p (@params){
next unless $p=~/^(.+?)=(.*)$/;
my ($k,$v)=($1,$2);
#my $re=qr/\S/;
unless(grepmy $re=($k eq 'importance')?qr/^\s*(?i:\Q$kv\E|)/:qr/(?i:\s*=\s*Q$re/, @$paramsv\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');
}
}
Line 325 ⟶ 303:
$out.="|".join("|", @$params) if @$params;
$out.="}}";
push @summary, "Re-tagging {{$main_banner}} as class=redirect";
return $out;
}, $main_banner, @params);