This is an automated email from the git hooks/post-receive script. gregoa pushed a commit to branch master in repository libmediawiki-api-perl.
commit c7f8366bffd7b509d905819a2ab25981f3f8a132 Author: gregor herrmann <[email protected]> Date: Fri Oct 17 16:16:13 2014 +0200 Imported Upstream version 0.40 --- Changes | 5 +++ MANIFEST | 3 +- META.json | 45 ++++++++++++++++++++++++++ META.yml | 46 +++++++++++++-------------- README | 5 ++- lib/MediaWiki/API.pm | 90 +++++++++++++++++++++++----------------------------- 6 files changed, 119 insertions(+), 75 deletions(-) diff --git a/Changes b/Changes index 7d7a25a..eee3cd8 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Revision history for MediaWiki-API +0.40 2014-09-13 + Apologies for the lack of updates and the speed to implement some fixes but I have been busy on other projects. + Edit token code has been reworked somewhat to make it simpler, and a bugfix applied for an issue with downloading + images over https using the buildin Download() function. + 0.39 2012-05-20 Added automatic support for handling tokens in the MediaWiki::API->Edit function for (Un)watch, Send e-mail and Patrol changes. (Un)watch already worked but wasn't documented. diff --git a/MANIFEST b/MANIFEST index 1267d4c..4179f60 100644 --- a/MANIFEST +++ b/MANIFEST @@ -9,4 +9,5 @@ t/10-api.t t/98-pod-coverage.t t/99-pod.t t/testimage.png -META.yml Module meta-data (added by MakeMaker) +META.yml Module YAML meta-data (added by MakeMaker) +META.json Module JSON meta-data (added by MakeMaker) diff --git a/META.json b/META.json new file mode 100644 index 0000000..ca5f324 --- /dev/null +++ b/META.json @@ -0,0 +1,45 @@ +{ + "abstract" : "Provides a Perl interface to the MediaWiki API (http://www.mediawiki.org/wiki/API)", + "author" : [ + "Jools Wills <[email protected]>" + ], + "dynamic_config" : 1, + "generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.142060", + "license" : [ + "unknown" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "MediaWiki-API", + "no_index" : { + "directory" : [ + "t", + "inc" + ] + }, + "prereqs" : { + "build" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "runtime" : { + "requires" : { + "Carp" : "0", + "Encode" : "0", + "JSON" : "0", + "LWP::UserAgent" : "0", + "Test::More" : "0.98" + } + } + }, + "release_status" : "stable", + "version" : "0.40" +} diff --git a/META.yml b/META.yml index 8e6c995..6b55dd7 100644 --- a/META.yml +++ b/META.yml @@ -1,26 +1,26 @@ ---- #YAML:1.0 -name: MediaWiki-API -version: 0.39 -abstract: Provides a Perl interface to the MediaWiki API (http://www.mediawiki.org/wiki/API) +--- +abstract: 'Provides a Perl interface to the MediaWiki API (http://www.mediawiki.org/wiki/API)' author: - - Jools Wills <[email protected]> -license: GPL-3+ -distribution_type: module -configure_requires: - ExtUtils::MakeMaker: 0 + - 'Jools Wills <[email protected]>' build_requires: - ExtUtils::MakeMaker: 0 -requires: - Carp: 0 - Encode: 0 - JSON: 0 - LWP::UserAgent: 0 - Test::More: 0.98 -no_index: - directory: - - t - - inc -generated_by: ExtUtils::MakeMaker version 6.57_05 + ExtUtils::MakeMaker: '0' +configure_requires: + ExtUtils::MakeMaker: '0' +dynamic_config: 1 +generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.142060' +license: unknown meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: '1.4' +name: MediaWiki-API +no_index: + directory: + - t + - inc +requires: + Carp: '0' + Encode: '0' + JSON: '0' + LWP::UserAgent: '0' + Test::More: '0.98' +version: '0.40' diff --git a/README b/README index c636c80..0b7aca3 100644 --- a/README +++ b/README @@ -4,6 +4,9 @@ This module provides an interface between perl and the MediaWiki API (http://www.mediawiki.org/wiki/API) allowing creation of scripts to automate editing and extraction of data from MediaWiki driven sites like Wikipedia. +The latest source/development version is available at +https://github.com/joolswills/mediawikiapi + STANDARD INSTALLATION This module requires the following perl modules @@ -69,7 +72,7 @@ You can also look for information at: COPYRIGHT AND LICENCE -Copyright (C) 2009 - 2012 Jools Wills +Copyright (C) 2009 - 2014 Jools Wills This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/lib/MediaWiki/API.pm b/lib/MediaWiki/API.pm index 2ec4f6e..609bed3 100644 --- a/lib/MediaWiki/API.pm +++ b/lib/MediaWiki/API.pm @@ -46,7 +46,7 @@ Version 0.39 =cut -our $VERSION = "0.39"; +our $VERSION = "0.40"; =head1 SYNOPSIS @@ -795,7 +795,7 @@ sub download { my $url = @{ $pageref->{imageinfo} }[0]->{url}; - unless ( $url =~ /^http\:\/\// ) { + unless ( $url =~ /^https?\:\/\// ) { return $self->_error(ERR_PARAMS,'The API returned a relative path. You need to configure the url where files are stored in {config}->{files_url}') unless ( defined $self->{config}->{files_url} ); $url = $self->{config}->{files_url} . $url; @@ -862,80 +862,70 @@ sub _make_querystring { # gets a token for a specified parameter and sets it in the query for the call sub _get_set_tokens { my ($self, $query) = @_; - my ($prop, $title, $token); - - my $action = $query->{action}; - - if ( $action eq 'move' ) { - $title = $query->{from}; - } elsif ( $action eq 'upload' ) { - $action = 'edit'; - $title = $query->{filename}; - } elsif ( $action eq 'emailuser' ) { - $action = 'email'; - $title = 'User:' . $query->{target}; - } else { - $title = $query->{title}; - } - # check if we have a cached token. - if ( exists( $self->{config}->{tokens}->{$action} ) ) { - $query->{token} = $self->{config}->{tokens}->{$action}; + # Note that although currently many of the tokens are equivalent, we cache them separately + # in case this was to change. + if ( exists( $self->{config}->{tokens}->{$query->{action}} ) ) { + $query->{token} = $self->{config}->{tokens}->{$query->{action}}; return 1; } - # if we are doing an import, get the edit token using Main_Page as API docs suggest. - if ( $action eq 'import' ) { - # if a title is supplied use that page to get the edit token instead of Main_Page - if ( defined $query->{title} ) { - $title = $query->{title}; - } else { - $title = "Main_Page"; - } + # set the token actions and title depending on edit action + my $tokaction = $query->{action}; + my $title = $query->{title}; + if ( $query->{action} eq 'move' ) { + $title = $query->{from}; + } elsif ( $query->{action} eq 'upload' ) { + $tokaction = 'edit'; + $title = $query->{filename}; + } elsif ( $query->{action} eq 'emailuser' ) { + $tokaction = 'email'; + $title = 'User:' . $query->{target}; + } elsif ( $query->{action} eq 'import' ) { + # if title was not specified get the import token using Main_Page as API docs suggest. + $title = "Main_Page" unless defined $query->{title}; } - # set the properties we want to extract based on the action - if ( $action eq 'rollback' ) { - $prop = 'revisions'; - } else { - $prop = 'info'; + # set the properties and token name we want to extract based on the action + # may merge into above ifdef depending on other token implementations + my $prop = 'info'; + my $token = 'intoken'; + my $tokquery = { action => 'query', prop => $prop, $token => $tokaction, titles => $title }; + if ( $tokaction eq 'rollback' ) { + $prop = 'revisions'; + $token = 'rvtoken'; + } elsif ( $tokaction eq 'patrol' ) { + $tokquery = { action => 'query', list => 'recentchanges', rclimit => '1', rctoken => $tokaction }; } - $token = 'intoken'; - $token = 'rvtoken' if ( $action eq 'rollback' ); - my $ref; - if ( $action eq 'patrol' ) { - $ref = $self->api( { action => 'query', list => 'recentchanges', rclimit => '1', rctoken => $action } ); - } else { - $ref = $self->api( { action => 'query', prop => $prop, $token => $action, titles => $title } ); - } + $ref = $self->api( $tokquery ); return undef unless $ref; my ($pageid, $pageref) = each %{ $ref->{query}->{pages} }; # if the page doesn't exist and we aren't editing/creating a new page then return an error - if ( defined $pageref->{missing} && $action ne 'edit' && $action ne 'import' ) { - return $self->_error( ERR_EDIT, "Unable to $action page '$title'. Page does not exist.") + if ( defined $pageref->{missing} && $tokaction ne 'edit' && $tokaction ne 'import' ) { + return $self->_error( ERR_EDIT, "Unable to $tokaction page '$title'. Page does not exist.") } - if ( $action eq 'rollback' ) { - $query->{token} = @{ $pageref->{revisions} }[0]->{$action.'token'}; + if ( $query->{action} eq 'rollback' ) { + $query->{token} = @{ $pageref->{revisions} }[0]->{$tokaction.'token'}; my $lastuser = @{ $pageref->{revisions} }[0]->{user}; $query->{user} = @{ $pageref->{revisions} }[0]->{user} unless defined $query->{user}; return $self->_error( ERR_EDIT, "Unable to rollback edits from user '$query->{user}' for page '$title'. Last edit was made by user $lastuser" ) if ( $query->{user} ne $lastuser ); - } elsif ( $action eq 'patrol' ) { + } elsif ( $tokaction eq 'patrol' ) { $query->{token} = @{$ref->{query}->{recentchanges}}[0]->{patroltoken}; } else { - $query->{token} = $pageref->{$action.'token'}; + $query->{token} = $pageref->{$tokaction.'token'}; } - return $self->_error( ERR_EDIT, "Unable to get an edit token for action '$action'." ) unless ( defined $query->{token} ); + return $self->_error( ERR_EDIT, "Unable to get an edit token for action '$tokaction'." ) unless ( defined $query->{token} ); # cache the token. rollback tokens are specific for the page name and last edited user so can not be cached. Note that although currently many of the tokens # are equivalent, we cache them separately in case this was to change. - if ( $action ne 'rollback' ) { - $self->{config}->{tokens}->{$action} = $query->{token}; + if ( $query->{action} ne 'rollback' ) { + $self->{config}->{tokens}->{$query->{action}} = $query->{token}; } return 1; -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmediawiki-api-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits
