[Libreoffice-commits] help.git: upload-wiki.pl

2015-07-07 Thread Dennis Roczek
 upload-wiki.pl |   51 +--
 1 file changed, 41 insertions(+), 10 deletions(-)

New commits:
commit f36f2883973e4ba6d59ee8d0d9b3e98273aa1c44
Author: Dennis Roczek dennisroc...@libreoffice.org
Date:   Tue Jun 9 03:54:20 2015 +0200

improving upload script

Change-Id: I8f7bc5973f988af29b0a07ad3ac066f93bebe5e6
Reviewed-on: https://gerrit.libreoffice.org/16198
Reviewed-by: Adolfo Jayme Barrientos fit...@ubuntu.com
Tested-by: Adolfo Jayme Barrientos fit...@ubuntu.com

diff --git a/upload-wiki.pl b/upload-wiki.pl
index a42d809..f49c739 100755
--- a/upload-wiki.pl
+++ b/upload-wiki.pl
@@ -11,6 +11,7 @@ use MediaWiki::API;
 use File::Find();
 use File::Slurp;
 use Getopt::Std;
+use Digest::SHA1 qw(sha1 sha1_hex sha1_base64);
 
 # help
 sub usage {
@@ -153,9 +154,12 @@ File::Find::find( {wanted = \upload_article}, 'wiki/' );
 # upload the images
 if ( $upload_images ) {
 open( IN, images.txt ) || usage();
+my $imagename = '';
+my $imageuploadmsg = '';
+my $image = '';
 while ( my $line = IN ) {
 chomp( $line );
-$fname = images/$line;
+my $fname = images/$line;
 if ( ! -f $fname ) {
 print Image '$fname' not found, skipped.\n;
 next;
@@ -163,19 +167,46 @@ if ( $upload_images ) {
 if ( ! $fname =~ /\.(png|gif|jpg|jpeg)$/ ) {
 print Image '$line' ignored, not a jpg/png/gif.\n;
 next;
-}
-
-my $imagename = $line;
+}
+
+$imagename = $line;
 if ( $line =~ /\/([^\/]*)$/ ) {
 $imagename = $1;
 }
-my $image = read_file( $fname );
-
-print Uploading image '$imagename'\n;
-$mw-upload( {
-title = $imagename,
-summary = 'Initial upload.',
+sub upload_file_to_mw {
+$mw-upload( {
+title = 'File:'.$imagename,
+summary = $imageuploadmsg,
 data = $image } ) || die $mw-{error}-{code} . ': ' . 
$mw-{error}-{details};
+}
+
+$image = read_file( $fname );
+
+# don't reupload an image if it is already present - otherwise it only 
bloats the wiki
+my $imagesha1 = sha1_hex($image);
+# get the sha1 request directly from the wiki
+my $mwquery = $mw-api( {
+action = 'query',
+prop = 'imageinfo',
+iiprop = 'sha1',
+titles = 'File:'.$imagename } );
+my $mwimagesha1 = ;
+#FIXME: bad style, this foreach should konsist only ONE imageid -- do 
that nicelier
+foreach my $imageid (keys $mwquery-{'query'}{'pages'}) {
+$mwimagesha1 = 
$mwquery-{'query'}{'pages'}{$imageid}{'imageinfo'}-[0]-{'sha1'};
+}
+
+if (($imagesha1 ne $mwimagesha1) and ($mwimagesha1 ne '')) {
+print Updating image '$imagename', sha1 is different from already 
uploaded image.\n;
+$imageuploadmsg = 'Updating image.';
+upload_file_to_mw();
+} elsif ($mwimagesha1 eq '') {
+print Initial upload of  image '$imagename'\n;
+$imageuploadmsg = 'Initial upload.';
+upload_file_to_mw();
+} else {
+print Skipping image '$imagename', sha1 identially to already 
uploaded image.\n;
+}
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] help.git: upload-wiki.pl

2014-02-20 Thread Andras Timar
 upload-wiki.pl |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit db935b234688a7d4690246e48530c3d3f99b5fe3
Author: Andras Timar andras.ti...@collabora.com
Date:   Thu Feb 20 14:33:45 2014 +0100

use 'unless' instead of 'if'

Change-Id: Ie40681e6f7097a1d9b2935e238cfb0ecfb840db4

diff --git a/upload-wiki.pl b/upload-wiki.pl
index 58de4fb..a42d809 100755
--- a/upload-wiki.pl
+++ b/upload-wiki.pl
@@ -136,7 +136,7 @@ sub upload_article {
 
 RETRY:
 print Uploading page '$pagename'\n;
-if ( $mw-edit( {
+unless ( $mw-edit( {
 action = 'edit',
 title = $pagename,
 text = $text }, { skip_encoding = 1 } ) )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] help.git: upload-wiki.pl

2013-05-07 Thread Andras Timar
 upload-wiki.pl |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 87300967302507220e9a33e1f48d73779c584791
Author: Andras Timar ati...@suse.com
Date:   Tue May 7 14:00:57 2013 +0200

do not verify hostname when using SSL

Change-Id: I9f89e0b185661a92c63937853c53afecea0d57fc

diff --git a/upload-wiki.pl b/upload-wiki.pl
index 1337900..94eb4cd 100755
--- a/upload-wiki.pl
+++ b/upload-wiki.pl
@@ -105,6 +105,8 @@ if ( $upload_images ) {
 }
 }
 
+$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
+
 # initialize the wiki
 my $mw = MediaWiki::API-new();
 $mw-{config}-{api_url} = $url;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits