Content deleted Content added
Updating published sources: DatedCategoryCreator: * Allow certain cats to have backdated dates (currently just Category:Wikipedia articles in need of updating). TagDater: * Don't check years in missingcats logic, due to the above change. |
Updating published sources: DatedCategoryCreator: * Use correct key from allcategories response. |
||
(11 intermediate revisions by the same user not shown) | |||
Line 35:
# here.
my %catmap=(
'
'Articles needing expert attention by month' => 'Articles needing expert attention from ',
'Wikipedia articles with style issues by month' => 'Wikipedia articles with style issues from ',
);
my %rcatmap=reverse %catmap;
Line 48 ⟶ 49:
my %oldcats=(
'Wikipedia articles in need of updating' => 1
);
# Categories to allow future dates, as well as the valid timespan in seconds
# (otherwise, the default is 86400)
my %futurecats=(
'Articles containing potentially dated statements' => 31622400,
'Articles that include images for deletion' => 8*86400,
'Clean-up categories' => 31622400,
);
Line 59 ⟶ 68:
$monthnum{$months[$i]}=$i+1;
}
sub new {
Line 81 ⟶ 88:
sub approved {
return
}
Line 94 ⟶ 101:
my @t=gmtime(time()+86400);
my $curmonth=strftime('%B %Y', @t);
$curyear=($t[5]+1900);▼
# Part 1: Create needed categories for the current month
Line 138 ⟶ 144:
);
while(my $p=$iter->next){
if(!$p->{'_ok_'}){
$api->warn("Could not retrieve category members from iterator: ".$p->{'error'}."\n");
return 60;
}
for my $c (@{$p->{'categories'} // []}) {
# Minimal sanity check; make_dated_cat() will do more
Line 146 ⟶ 156:
return $res if $res;
}
}
# Part 3: Look for missing dated categories beginning with "Clean-up categories from".
$iter = $api->iterator(
list => 'allcategories',
acprefix => 'Clean-up categories from ',
acprop => 'size|hidden',
aclimit => 'max',
formatversion => 2,
);
while ( my $c = $iter->next ) {
if ( ! $c->{'_ok_'} ) {
$api->warn( "Could not retrieve category list from iterator: " . $c->{'error'} . "\n" );
return 60;
}
next unless $c->{'category'} =~ / $monthre \d{4}$/;
next if $c->{'hidden'} || $c->{'size'} <= 0;
next if exists( $did{'Category:' . $c->{'category'}} );
$did{'Category:' . $c->{'category'}}=1;
$res = $self->make_dated_cat( $api, 'Category:' . $c->{'category'}, 'non-empty month' );
return $res if $res;
}
Line 167 ⟶ 198:
# Figure out the parent cat, and calculate the parameters for {{Monthly
# clean
my $parent=$title;
my $
$parent=~s/^Category://;
$parent=~s/($monthre) (\d{4})$//;
Line 175 ⟶ 206:
if(exists($rcatmap{$parent})){
$parent=$rcatmap{$parent};
$
} else {
return 0 unless $parent=~s/ from $//;
return 0 if exists($skipcat{$parent});
}
my @t=gmtime(time()+$dt);
return 0 if(!exists($oldcats{$parent}) && $y<2004);▼
return 0 if($y==$t[5]+1900 && $monthnum{$m}>$t[4]+1);
# Check whether the parent cat actually exists and is a subcat of the meta
Line 188 ⟶ 221:
my $res=$api->query(
titles => "Category:$parent",
prop => 'categories|templates',
clcategories => 'Category:Wikipedia maintenance categories sorted by month|Category:Wikipedia categories sorted by month',
tltemplates => 'Template:Parent monthly maintenance category',
);
if($res->{'code'} ne 'success'){
Line 200 ⟶ 234:
return 0;
}
my ($type, $txt);
if(grep $_->{'title'} eq 'Category:Wikipedia maintenance categories sorted by month', @{$res->{'categories'}}){
if ( grep $
$type='maintenance category';
$txt="{{Monthly maintenance category$tmplparams}}";
} else {
$type='clean-up category';
$txt="{{Monthly clean-up category$tmplparams}}";
}
} elsif(grep $_->{'title'} eq 'Category:Wikipedia categories sorted by month', @{$res->{'categories'}}){
$type='category';
$txt="{{Monthly maintenance category$tmplparams}}";
} else {
$api->warn("Did not create category $title, because parent category $parent is not in Category:Wikipedia maintenance categories sorted by month or Category:Wikipedia categories sorted by month");
|