Content deleted Content added
Updating published sources: POTDPageCreator: * Update to handle multiple pictures situations, like Template:POTD/2017-07-01. |
Updating published sources: POTDPageCreator: * Adjust regex, people have started not leaving a newline. |
||
(3 intermediate revisions by the same user not shown) | |||
Line 70:
return $res if $res;
if ( $outtxt=~s!^\s*\Q{{POTD/$date/{{#invoke:random|number|\E(\d+)\Q}}|{{{1|{{{style|default}}}}}}}}\E\s*
my $n = $1;
for ( my $i = 1; $i <= $n; $i++ ) {
Line 79:
next if $res2;
unless ( $outtxt2=~s/^\s*\Q{{POTD {{{1|{{{style|default}}}}}}\E\s*\n/{{subst:POTD row|date=$date\n/ ) {
$api->warn( "$srcpage2 doesn't begin with expected wikitext\n$outtxt2" );
$api->whine( "[[$srcpage2]] has unexpected content", "While attempting to create [[$page]], I found that [[$srcpage2]] does not begin with <code><nowiki>{{POTD {{{1|{{{style|default}}}}}}</nowiki></code>. Please fix it, or create [[$page]] and its subpages manually.", Pagename => $talk );
Line 85:
}
push @edits, [ $page2, $tok2, $outtxt2, "Creating protected version of a [[WP:POTD]] template by substing from {{[[$srcpage2|POTD/$date/$i]]|row}}" ];
}
push @edits, [ $page, $tok, $outtxt, "Creating protected version of a [[WP:POTD]] template by adjusting [[$srcpage]]" ];
} elsif ( $outtxt=~s/^\s*\Q{{POTD {{{1|{{{style|default}}}}}}\E\s*\n/{{subst:POTD row\n/ ) {
push @edits, [ $page, $tok, $outtxt, "Creating protected version of a [[WP:POTD]] template by substing from {{[[$srcpage|POTD/$date]]|row}}" ];
} else {
$api->warn( "$srcpage doesn't begin with expected wikitext\n$outtxt" );
Line 98:
foreach my $edit (@edits) {
my ($page, $tok, $outtxt, $summary) = @$edit;
my $res = $api->edit($tok, $outtxt,
if($res->{'code'} ne 'success'){
$api->warn("Write for $page failed: " . $res->{'error'});
Line 141:
prop => 'revisions',
rvprop => 'content',
rvslots => 'main',
rvlimit => 1,
formatversion => 2,
Line 150 ⟶ 151:
}
my $intxt = $res->{'query'}{'pages'}[0]{'revisions'}[0]{'slots'}{'main'}{'content'} // '';
# Act like preloading does
my ($outtxt,$nowiki) = $api->strip_nowiki($intxt);
|