make Perl::Critic a bit happier about wiki-upload
This commit is contained in:
parent
947e256216
commit
2eda5043b5
1 changed files with 6 additions and 6 deletions
12
wiki-upload
12
wiki-upload
|
@ -2,6 +2,7 @@
|
||||||
# Upload a file to a recent MediaWiki using the API.
|
# Upload a file to a recent MediaWiki using the API.
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use IO::File;
|
||||||
use MediaWiki::API 0.39;
|
use MediaWiki::API 0.39;
|
||||||
|
|
||||||
use constant API_URL => 'https://entropia.de/wiki/api.php';
|
use constant API_URL => 'https://entropia.de/wiki/api.php';
|
||||||
|
@ -18,19 +19,18 @@ if (!defined($comment)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# log in to the wiki
|
# log in to the wiki
|
||||||
my $mw = MediaWiki::API->new();
|
my $mw = MediaWiki::API->new({api_url => API_URL});
|
||||||
$mw->{config}->{api_url} = API_URL;
|
|
||||||
$mw->login( { lgname => $wikiuser, lgpassword => $wikipass } )
|
$mw->login( { lgname => $wikiuser, lgpassword => $wikipass } )
|
||||||
|| die $mw->{error}->{code} . ': ' . $mw->{error}->{details};
|
|| die $mw->{error}->{code} . ': ' . $mw->{error}->{details};
|
||||||
|
|
||||||
# upload file
|
# upload file
|
||||||
open FILE, $file or die $!;
|
my $fh = IO::File->new($file, 'r');
|
||||||
binmode FILE;
|
$fh->binmode();
|
||||||
my ($buffer, $data);
|
my ($buffer, $data);
|
||||||
while ( read(FILE, $buffer, 65536) ) {
|
while ( read($fh, $buffer, 65536) ) {
|
||||||
$data .= $buffer;
|
$data .= $buffer;
|
||||||
}
|
}
|
||||||
close(FILE);
|
close($fh);
|
||||||
|
|
||||||
$mw->upload( { title => $file,
|
$mw->upload( { title => $file,
|
||||||
summary => $comment,
|
summary => $comment,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue