r35599 - in /trunk/libmediawiki-api-perl: Changes LICENSE MANIFEST META.yml Makefile.PL README debian/changelog lib/MediaWiki/API.pm

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Sun May 17 20:51:11 UTC 2009


Author: ryan52-guest
Date: Sun May 17 20:51:06 2009
New Revision: 35599

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=35599
Log:
New upstream release

Added:
    trunk/libmediawiki-api-perl/LICENSE
      - copied unchanged from r35598, branches/upstream/libmediawiki-api-perl/current/LICENSE
Modified:
    trunk/libmediawiki-api-perl/Changes
    trunk/libmediawiki-api-perl/MANIFEST
    trunk/libmediawiki-api-perl/META.yml
    trunk/libmediawiki-api-perl/Makefile.PL
    trunk/libmediawiki-api-perl/README
    trunk/libmediawiki-api-perl/debian/changelog
    trunk/libmediawiki-api-perl/lib/MediaWiki/API.pm

Modified: trunk/libmediawiki-api-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmediawiki-api-perl/Changes?rev=35599&op=diff
==============================================================================
--- trunk/libmediawiki-api-perl/Changes (original)
+++ trunk/libmediawiki-api-perl/Changes Sun May 17 20:51:06 2009
@@ -1,4 +1,14 @@
 Revision history for MediaWiki-API
+
+0.27    2009-05-14
+        Updated README installation instructions including some notes for building debian packages and dependencies.
+        Fixed old reference to JSON::XS
+
+0.26    2009-05-12
+        A new configuration option $mw->{config}->{use_http_get} to tell the module to use http GET requests for
+        those API calls that allow it. By default the module will use POST for all API requests. Fixes bug #45974.
+        Switched the module to ask for the JSON module and not specifically JSON::XS. If JSON::XS is available the
+        JSON module will use it by default, but if not it will fallback to a pure perl JSON parser.
 
 0.25    2009-03-19
         Support the skip_encoding option in the list and edit calls. Thanks to Brent Garber for

Modified: trunk/libmediawiki-api-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmediawiki-api-perl/MANIFEST?rev=35599&op=diff
==============================================================================
--- trunk/libmediawiki-api-perl/MANIFEST (original)
+++ trunk/libmediawiki-api-perl/MANIFEST Sun May 17 20:51:06 2009
@@ -1,4 +1,5 @@
 Changes
+LICENSE
 MANIFEST
 Makefile.PL
 README

Modified: trunk/libmediawiki-api-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmediawiki-api-perl/META.yml?rev=35599&op=diff
==============================================================================
--- trunk/libmediawiki-api-perl/META.yml (original)
+++ trunk/libmediawiki-api-perl/META.yml Sun May 17 20:51:06 2009
@@ -1,8 +1,8 @@
 --- #YAML:1.0
 name:                MediaWiki-API
-version:             0.25
+version:             0.27
 abstract:            Provides a Perl interface to the MediaWiki API (http://www.mediawiki.org/wiki/API)
-license:             ~
+license:             GPL-3+
 author:              
     - Jools Smyth <buzz at exotica.org.uk>
 generated_by:        ExtUtils::MakeMaker version 6.42
@@ -10,7 +10,7 @@
 requires:     
     Carp:                          0
     Encode:                        0
-    JSON::XS:                      0
+    JSON:                          0
     LWP::UserAgent:                0
     Test::More:                    0
 meta-spec:

Modified: trunk/libmediawiki-api-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmediawiki-api-perl/Makefile.PL?rev=35599&op=diff
==============================================================================
--- trunk/libmediawiki-api-perl/Makefile.PL (original)
+++ trunk/libmediawiki-api-perl/Makefile.PL Sun May 17 20:51:06 2009
@@ -7,10 +7,11 @@
     AUTHOR              => 'Jools Smyth <buzz at exotica.org.uk>',
     VERSION_FROM        => 'lib/MediaWiki/API.pm',
     ABSTRACT_FROM       => 'lib/MediaWiki/API.pm',
+    LICENSE             => 'GPL-3+',
     PL_FILES            => {},
     PREREQ_PM => {
         'Test::More'     => 0,
-        'JSON::XS'       => 0,
+        'JSON'           => 0,
         'LWP::UserAgent' => 0,
         'Encode'         => 0,
         'Carp'           => 0

Modified: trunk/libmediawiki-api-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmediawiki-api-perl/README?rev=35599&op=diff
==============================================================================
--- trunk/libmediawiki-api-perl/README (original)
+++ trunk/libmediawiki-api-perl/README Sun May 17 20:51:06 2009
@@ -4,14 +4,39 @@
 (http://www.mediawiki.org/wiki/API) allowing creation of scripts to automate
 editing and extraction of data from MediaWiki driven sites like Wikipedia.
 
-INSTALLATION
+STANDARD INSTALLATION
+
+This module requires the following perl modules
+
+    LWP::UserAgent
+    URI::Escape
+    JSON
+    Encode
+    Carp
+
+and optionally JSON::XS for faster JSON decoding.
 
 To install this module, run the following commands:
 
-	perl Makefile.PL
-	make
-	make test
-	make install
+    perl Makefile.PL
+    make
+    make test
+    make install
+
+CREATING DEBIAN PACKAGE / INSTALLING ON DEBIAN
+
+Note that this module requires the packages libwww-perl, libjson-perl, and
+optionally libjson-xs-perl for faster JSON decoding.
+
+On a debian system, you can easily generate a debian package to install. To
+do this make sure you have the package "dh-make-perl" installed. Unpack the
+MediaWiki-API-x.xx.tar.gz and run
+
+dh-make-perl
+dpkg-buildpackage
+
+If everything works successfully you should have a deb file created in the
+parent folder.
 
 SUPPORT AND DOCUMENTATION
 
@@ -34,17 +59,16 @@
     Search CPAN
         http://search.cpan.org/dist/MediaWiki-API
 
-
 COPYRIGHT AND LICENCE
 
-Copyright (C) 2008 Jools Smyth
+Copyright (C) 2009 Jools Wills
 
-This library is free software; you can redistribute it and/or modify
+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
-the Free Software Foundation; either version 3 of the License, or
+the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
-This library is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

Modified: trunk/libmediawiki-api-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmediawiki-api-perl/debian/changelog?rev=35599&op=diff
==============================================================================
--- trunk/libmediawiki-api-perl/debian/changelog (original)
+++ trunk/libmediawiki-api-perl/debian/changelog Sun May 17 20:51:06 2009
@@ -1,3 +1,9 @@
+libmediawiki-api-perl (0.27-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Ryan Niebur <ryanryan52 at gmail.com>  Sun, 17 May 2009 13:50:31 -0700
+
 libmediawiki-api-perl (0.25-1) unstable; urgency=low
 
   * Initial Release. (Closes: #527536)

Modified: trunk/libmediawiki-api-perl/lib/MediaWiki/API.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmediawiki-api-perl/lib/MediaWiki/API.pm?rev=35599&op=diff
==============================================================================
--- trunk/libmediawiki-api-perl/lib/MediaWiki/API.pm (original)
+++ trunk/libmediawiki-api-perl/lib/MediaWiki/API.pm Sun May 17 20:51:06 2009
@@ -6,11 +6,12 @@
 # our required modules
 
 use LWP::UserAgent;
-use JSON::XS;
+use URI::Escape;
+use JSON;
 use Encode;
 use Carp;
 
-#use Data::Dumper;
+# use Data::Dumper;
 
 use constant {
   ERR_NO_ERROR => 0,
@@ -28,7 +29,9 @@
 
   DEF_MAX_LAG => undef,
   DEF_MAX_LAG_RETRIES => 4,
-  DEF_MAX_LAG_DELAY => 5
+  DEF_MAX_LAG_DELAY => 5,
+
+  USE_HTTP_GET => 0
 };
 
 =head1 NAME
@@ -37,11 +40,11 @@
 
 =head1 VERSION
 
-Version 0.25
-
-=cut
-
-our $VERSION  = "0.25";
+Version 0.27
+
+=cut
+
+our $VERSION  = "0.27";
 
 =head1 SYNOPSIS
 
@@ -97,6 +100,8 @@
 
 =item * on_error = Function reference to call if an error occurs in the module.
 
+=item * use_http_get = Boolean 0 or 1 (defaults to 0). If set to 1, the perl module will use http GET method for accessing the api. By default it uses the POST method. Note that the module will still use POST for the api calls that require POST no matter what the value of this configuration option. Currently the following actions will work with GET: query, logout, purge, paraminfo.
+
 =item * retries = Integer value; The number of retries to send an API request if an http error or JSON decoding error occurs. Defaults to 0 (try only once - don't retry). If max_retries is set to 4, and the wiki is down, the error won't be reported until after the 5th connection attempt. 
 
 =item * retry_delay = Integer value in seconds; The amount of time to wait before retrying a request if an HTTP error or JSON decoding error occurs.
@@ -170,7 +175,7 @@
 
   $self->{ua} = $ua;
 
-  my $json = JSON::XS->new->utf8()->max_depth(10) ;
+  my $json = JSON->new->utf8()->max_depth(10) ;
   $self->{json} = $json;
 
   # initialise some defaults
@@ -184,6 +189,8 @@
   $self->{config}->{max_lag} = DEF_MAX_LAG;
   $self->{config}->{max_lag_retries} = DEF_MAX_LAG_RETRIES;
   $self->{config}->{max_lag_delay} = DEF_MAX_LAG_DELAY;
+  
+  $self->{config}->{use_http_get} = USE_HTTP_GET;
 
   bless ($self, $class);
   return $self;
@@ -251,6 +258,13 @@
 sub api {
   my ($self, $query, $options) = @_;
 
+  my $get_actions = {
+    'query' => 1,
+    'logout' => 1,
+    'purge' => 1,
+    'paraminfo' => 1
+  };
+
   unless ( $options->{skip_encoding} ) {
     $self->_encode_hashref_utf8($query);
   }
@@ -276,7 +290,15 @@
         sleep $self->{config}->{retry_delay};
       }
 
-      my $response = $self->{ua}->post( $self->{config}->{api_url}, $query );
+      # if the config is set to use GET we need to contruct the querystring. some actions are "POST" only -
+      # edit, move, action = rollback, action = undelete, action = 
+      my $response;
+      if ( $self->{config}->{use_http_get} && defined $get_actions->{$query->{action}} ) {
+        my $qs = _make_querystring( $query );
+        $response = $self->{ua}->get( $self->{config}->{api_url} . $qs );
+      } else {
+        $response = $self->{ua}->post( $self->{config}->{api_url}, $query );
+      }
       $self->{response} = $response;
       
       # if the request was successful then check the returned content and decode.
@@ -683,6 +705,17 @@
   }
 }
 
+# creates a querystring from a hashref
+sub _make_querystring {
+  my ($ref) = @_;
+  my @qs = ();
+  for my $key ( keys %{$ref} ) {
+    my $keyval = uri_escape($key) . '=' . uri_escape($ref->{$key});
+    push(@qs, $keyval);
+  }
+  return '?' . join('&', at qs);
+}
+
 # gets a token for a specified parameter and sets it in the query for the call
 sub _get_set_tokens {
   my ($self, $query) = @_;
@@ -754,7 +787,7 @@
 
 =head1 AUTHOR
 
-Jools 'BuZz' Smyth, C<< <buzz [at] exotica.org.uk> >>
+Jools 'BuZz' Wills, C<< <buzz [at] exotica.org.uk> >>
 
 =head1 BUGS
 
@@ -811,14 +844,14 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2008 Jools Smyth, all rights reserved.
-
-This library is free software; you can redistribute it and/or modify
+Copyright 2008 Jools Wills, all rights reserved.
+
+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
-the Free Software Foundation; either version 3 of the License, or
+the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
-This library is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.




More information about the Pkg-perl-cvs-commits mailing list