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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: PERTableUpdater: * Add a comment to document the structure of the @data array.
AnomieBOT (talk | contribs)
Updating published sources: PERTableUpdater: * Adjust coloring for cascading protection. Even though cascading semi-protection isn't possible, we'd want it red on CAT:ESP if it were. * Consider the cascade-protected page itself as cascading too * I...
Line 128:
# 0: unprotected
# 1: semi-protected
# 2: semi-protected via title blacklist or cascading
# 3: User CSS/JS page
# 4: fully protected
# 5: fully protected via title blacklist, or cascading protection
# 6: MediaWiki-namespace page
my @data=(
Line 204:
 
# Protection scoring "bitmap":
# 0x800x100 = MediaWiki-namespace auto-protection
# 0x40 0x80 = FullCascading protection
# 0x20 =0x40 User= scriptFull auto-protection
# 0x10 0x20 = SemiUser script auto-protection
# 0x08 0x10 = DirectlySemi-applied protection
# 0x04 0x08 = CascadingDirectly-applied protection
# 0x02 = Title blacklist protection
# Highest score by int value "wins".
my $protscore=0;
Line 217:
if($p->{'ns'}==8){
$pd->{'prottype'}='MediaWiki page';
$protscore=0x800x100;
} elsif($p->{'ns'}==2 && $t=~m!/.*\.js$!){
$pd->{'prottype'}='User JS page';
Line 241:
next unless $pp->{'type'} eq 'edit';
my $sc=0;
$sc|=(0x40 if $pp->{'level'} eq 'sysop')?0x40:0x10;
$sc|=exists(0x10 if $pp->{'sourcelevel'})?0x04:0x08 eq 'autoconfirmed';
$sc|=exists($pp->{'source'})?0x80:0x08;
$sc|=0x80 if exists($pp->{'cascade'});
next if $sc<$protscore;
if(exists($pp->{'source'})){
Line 251 ⟶ 253:
$pd->{'prottype'}='Fully protected' if $pp->{'level'} eq 'sysop';
$pd->{'prottype'}='Semiprotected' if $pp->{'level'} eq 'autoconfirmed';
$pd->{'prottype'}.=' with cascading' if exists($pp->{'cascade'});
}
$pd->{'prottype'}.=strftime(', expires %F at %T UTC', gmtime ISO2timestamp($pp->{'expiry'})) if $pp->{'expiry'} ne 'infinity';
Line 260 ⟶ 263:
if($protscore & 0x10){
$pd->{'color'}=$colors->[1];
$pd->{'color'}=$colors->[2] if($protscore & 0x060x02);
}
$pd->{'color'}=$colors->[3] if($protscore & 0x20);
if($protscore & 0x40){
$pd->{'color'}=$colors->[4];
$pd->{'color'}=$colors->[5] if($protscore & 0x060x02);
}
$pd->{'color'}=$colors->[65] if($protscore & 0x80);
$pd->{'color'}=$colors->[6] if($protscore & 0x100);
$pd->{'color'}='green' if($pd->{'color'} eq 'clear' && grep($p->{'ns'}==$_, @$greenns));