Content deleted Content added
Updating published source |
Updating published sources: General: * BUGFIX: UTF-8 encode all parameters in all API requests * NEW: Persistant storage * NEW: Nowiki/comment handling * NEW: Template search-and-replace * NEW: Mode for BRFA trials * Testing mode should keep going un |
||
Line 1:
{{ombox|type=notice|text=Per [[WP:BOT#Approval]], any bot or automated editing process that only
affects only the operators' user and talk pages (or subpages thereof),
and which are not otherwise disruptive, may be run without prior
approval.}}
<source lang="perl">
package tasks::SourceUploader;
Line 21 ⟶ 25:
sub approved {
### notice type=notice
# Per [[WP:BOT#Approval]], any bot or automated editing process that only
# affects only the operators' user and talk pages (or subpages thereof),
Line 40 ⟶ 45:
return $self;
}
$self->{'summary'}='Updating published sources: ';
if(!open(X, "<", 'ChangeLog')){
$self->warn("Cannot load changelog\n");
return $self;
}
local $_;
my $intro=1;
while(<X>){
if(/^==.*==$/){
$self->{'summary'}.=$_ if !$intro;
}
close(X);
$self->{'summary'}=~s/\s+/ /g;
$self->{'summary'}=~s/\s+$//;
$self->{'summary'}=substr($self->{'summary'},0,255);
my %pages=();
Line 76 ⟶ 101:
};
close(X);
# Pull out most recent 32K of changelog entries
last if $x=~/^==.*==$/ && length($x)>32767;
$pages{$pp}.="\x7b\x7bombox|type=notice|See the \x7b\x7bsubst:history|\x7b\x7bFULLPAGENAME\x7d\x7d|page history|subst=subst:\x7d\x7d for further ChangeLog entries\x7d\x7d\n" if @x;
} elsif($page=~/\.([^.]+)$/ && exists($extensions{$1})){
if($extensions{$1} eq 'perl'){
# Try to construct POD documentation
my $parser=Pod::Simple::Wiki->new('mediawiki');
my $x='';
Line 84 ⟶ 119:
$parser->parse_string_document($pages{$pp});
$pages{"$pp/doc"}=$x if($parser->content_seen);
if($pages{$pp}=~/^\s*### notice( .*\S)?\s+((?:^\s*# .*\s+^)+)/m){
$p=~s/^\s+|\s+$//g;
$t=~s/^\s+# |\s+$//gm;
$top.="\x7b\x7bombox|$p|text=$t\x7d\x7d\n";
}
$pages{$pp}="<source lang=\"".$extensions{$1}."\">\n".$pages{$pp}."\n</so"."urce>";
Line 89 ⟶ 132:
$pages{$pp}="<pre>\n".$pages{$pp}."\n</pre>";
}
$
$pages{$pp}=$top.$pages{$pp};
$img='Gnome-fs-regular.svg';
} else {
Line 120 ⟶ 164:
return undef unless @keys;
$api->task('SourceUploader
$api->read_throttle(6);
$api->edit_throttle(10);
Line 144 ⟶ 188:
}
if(exists($res->{'query-continue'})){
▲ while(($k2,$v2)=each(%$v)){
▲ $q{$k2}=$v2;
▲ }
▲ }
}
push @
▲ } else {
▲ next;
▲ }
▲ for(my $i=0; $i<@x; $i++){
▲ if(!exists($self->{'pages'}{$v2})){
▲ $self->{'pages'}{$v2}='';
▲ push @keys, $v2;
▲ }
}
}
Line 179 ⟶ 210:
if(exists($tok->{'missing'}) ||
$tok->{'revisions'}[0]{'*'} ne $self->{'pages'}{$k}){
my $r=$api->edit($tok, $self->{'pages'}{$k}, $self->{'summary'}, 0, 1);
▲ 'Updating published source', 0, 1);
if($r->{'code'} ne 'success'){
$self->warn("Write error for $k: ".$r->{'error'});
Line 194 ⟶ 224:
return 0;
}
1;
</source>
|