[Debian-l10n-commits] r2584 - in /ddtss/trunk: DDTSS.pm ddts_lib.pm ddtss-cgi ddtss-clean ddtss-process ddtss-setup test.pl

bubulle at users.alioth.debian.org bubulle at users.alioth.debian.org
Sun Apr 3 05:49:30 UTC 2011


Author: bubulle
Date: Sun Apr  3 05:49:23 2011
New Revision: 2584

URL: http://svn.debian.org/wsvn/?sc=1&rev=2584
Log:
Pending changes on churro

Modified:
    ddtss/trunk/DDTSS.pm
    ddtss/trunk/ddts_lib.pm
    ddtss/trunk/ddtss-cgi
    ddtss/trunk/ddtss-clean
    ddtss/trunk/ddtss-process
    ddtss/trunk/ddtss-setup
    ddtss/trunk/test.pl

Modified: ddtss/trunk/DDTSS.pm
URL: http://svn.debian.org/wsvn/ddtss/trunk/DDTSS.pm?rev=2584&op=diff
==============================================================================
--- ddtss/trunk/DDTSS.pm (original)
+++ ddtss/trunk/DDTSS.pm Sun Apr  3 05:49:23 2011
@@ -1,4 +1,4 @@
-use strict;
+#use strict;
 use POSIX qw(strftime);
 use DB_File::Lock;
 use Text::Iconv;
@@ -59,6 +59,39 @@
   }
 }
   
+# Get list of suggestions packages
+sub DDTSS_Get_Suggestions
+{
+  my $db = shift;
+  my $lang = shift;
+  
+  my @suggestions;
+  
+  @suggestions=get_suggestions($lang);
+  # $id, $package, $md5, $importer, $importtime
+  return [ map { 
+      my $refuse = "";
+      $db->get("suggestion/$_->[0]/refuse", $refuse);
+      [ $_->[0], $_->[1], $_->[2], $_->[3], $_->[4], $refuse ] } sort { $b->[0] <=> $a->[0] } @suggestions ];
+  #return [@suggestions];
+}
+
+# Get list of suggestions packages
+sub DDTSS_Get_Suggestion_Infos
+{
+  my $db = shift;
+  my $suggestion_id = shift;
+
+  my %suggestion=get_suggestion_infos($suggestion_id);
+
+  my $refuse = "";
+  $db->get("suggestion/$suggestion_id/refuse", $refuse);
+
+  $suggestion{'refuse'}=$refuse;
+  
+  return %suggestion;
+}
+
 # Get list of untranslated packages
 sub DDTSS_Get_Untranslated
 {
@@ -279,6 +312,28 @@
   return $wordlist;
 }
 
+sub DDTSS_Get_Team
+{
+  my $db = shift;
+  my $lang = shift;
+
+  my @team;  
+  ddtss_match( $db, "aliases/", sub {
+    my ($key, $value) = @_;
+    return if $value !~ m,^$lang$,;
+    return if $key !~ m,aliases/(.*)/lastlanguage$,;
+    my $user = $1;
+    my $trans = 0;
+    $db->get("aliases/$user/counttranslations", $trans);
+    my $review = 0;
+    $db->get("aliases/$user/countreviews", $review);
+
+    push @team, [ $user, $trans, $review ];
+  } );
+
+  return \@team;  
+}
+
 sub DDTSS_Get_Translated
 {
   my $db = shift;
@@ -295,8 +350,8 @@
   # Should be ordered by time ascending
   @trans = reverse @trans;   # Now descending
   
-  if( scalar(@trans) > 10 )
-  { splice @trans, 10 }   # Keep only the last 10
+  if( scalar(@trans) > 20 )
+  { splice @trans, 20 }   # Keep only the last 10
 
 #  use Data::Dumper;
 #  print Dumper(\@trans);
@@ -572,6 +627,21 @@
   }
 }
 
+sub submit_one_suggestion
+{
+  my($package,$version,$description_md5,$translation,$language,$importer);
+
+  $package =  shift(@_);
+  $version =  shift(@_);
+  $description_md5 =  shift(@_);
+  $translation =  shift(@_);
+  $language =  shift(@_);
+  $importer =  shift(@_);
+
+  return add_suggestion_to_db($package,$version,$description_md5,$translation,$language,$importer);
+
+}
+
 sub submit_one_package
 {
   my($lang,$package);
@@ -640,6 +710,7 @@
     $db->del("$lang/packages/$package/owner");
     $db->del("$lang/packages/$package/long");
     $db->del("$lang/packages/$package/data");
+    $db->del("$lang/packages/$package/age");
     $db->del("$lang/packages/$package/reviewers");
     $db->del("$lang/packages/$package/timestamp");
     $db->del("$lang/packages/$package/oldshort");
@@ -875,6 +946,7 @@
   DDTSS_Kill_Oldest_Request($db,$lang);
   
   $db->put("$lang/packages/$package/data", $data);
+  $db->put("$lang/packages/$package/age", time() );
   $db->put("$lang/packages/$package", "untranslated,$prio" );
   $db->put("descrmatch/$descr",$package);
   $db->del($key);
@@ -907,6 +979,15 @@
   return $sender;
 }
 
+sub DDTSS_Get_commonpackages
+{
+  #my $db = shift;
+  my $text = shift;
+
+  my @commonpackages=get_commonpackages_by_text($text);
+
+  return @commonpackages;
+}
 
 1;
 

Modified: ddtss/trunk/ddts_lib.pm
URL: http://svn.debian.org/wsvn/ddtss/trunk/ddts_lib.pm?rev=2584&op=diff
==============================================================================
--- ddtss/trunk/ddts_lib.pm (original)
+++ ddtss/trunk/ddts_lib.pm Sun Apr  3 05:49:23 2011
@@ -1,6 +1,6 @@
 use lib '/org/ddtp.debian.net/ddts/bin/';
-use diagnostics;
-use strict;
+#use diagnostics;
+#use strict;
 use ddts_config;
 use ddts_common;
 
@@ -11,7 +11,7 @@
 use MIME::Entity;
 use Text::Iconv;
 
-my $start= shift(@ARGV);
+#my $start= shift(@ARGV);
 
 my @DSN = ("DBI:Pg:dbname=ddtp", "", "");
 
@@ -38,22 +38,24 @@
 my $mADDRwithUserName = qr/([ "\<\>\(\)\w+\.\@-]+)/;
 
 # Number of days before we ignore the owner when sending descriptions to translate
-my $OWNER_EXPIRE = 0;
+# Must be greater than zero, otherwise we'll keep fetching the same description over and over
+my $OWNER_EXPIRE = 15;
 
 # This is _copied_ from /org/ddtp.debian.net/ddts.cgi
 sub get_versions ($) {
-        my $desc_id = shift;
-
-        my @versions=();
-
-        my $sth = $dbh->prepare("SELECT version FROM version_tb WHERE description_id=?");
-        $sth->execute($desc_id);
-
-        my $version;
-        while(($version) = $sth->fetchrow_array) {
-                push @versions,$version;
-        }
-        return (@versions);
+	my $desc_id = shift;
+
+	my @versions=();
+
+	my $sth = $dbh->prepare("SELECT package,version FROM package_version_tb WHERE description_id=?");
+	$sth->execute($desc_id);
+
+	my $package;
+	my $version;
+	while(($package,$version) = $sth->fetchrow_array) {
+		push @versions,"$package ($version)";
+	}
+	return (@versions);
 }
 
 # This is _copied_ from /org/ddtp.debian.net/ddts/bin/mailparser.pl
@@ -303,7 +305,7 @@
 	  }
 	  else
 	  {
-	    $sth = $dbh->prepare("SELECT description_id FROM description_tb ".
+	    $sth = $dbh->prepare("SELECT description_id FROM package_version_tb ".
 	                         "WHERE description_id in (SELECT description_id FROM active_tb) and package=?");
 	    $sth->execute($package);
 	  }
@@ -322,10 +324,12 @@
 	my $description_id;
 	my $found = 0;
 	my $locked = 0;
+	my @all_descr;
 
 	while(($description_id) = $sth->fetchrow_array) {
 	  # If not in force mode we need to check that this isn't translated
 	  print STDERR "Found description ID $description_id\n";
+	  push @all_descr, $description_id;
 	  $found++;
 	  if( not $force )
 	  {
@@ -360,7 +364,7 @@
 		die "All descriptions for package $package already fetched by others\n";
 	} else {
 		status "WARNING: All found descriptions skipped (force=$force)";
-		die "All descriptions for package $package already translated\n";
+		die "All descriptions for package $package already translated (checked ".join(",", at all_descr).")\n";
 	}
 	return ($body);
 }
@@ -459,4 +463,214 @@
 	return $body;
 }
 
+
+sub add_suggestion_to_db
+{
+	my $package= shift(@_);
+	my $version= shift(@_);
+	my $description_md5= shift(@_);
+	my $translation= shift(@_);
+	my $language= shift(@_);
+	my $importer= shift(@_);
+	
+	my $oldtranslation;
+
+	# get the description_id
+	my $d_id;
+	my $sth = $dbh->prepare("SELECT description_id FROM description_tb WHERE description_md5=?");
+	$sth->execute($description_md5);
+	($d_id) = $sth->fetchrow_array;
+
+	# get the translation
+	$sth = $dbh->prepare("SELECT translation FROM translation_tb WHERE description_id=? and language=?");
+	$sth->execute($d_id,$language);
+	($oldtranslation) = $sth->fetchrow_array;
+
+	if ((defined($oldtranslation) and ($importer eq "rosetta"))) {
+		my $fh;
+        	open ($fh, ">>/tmp/ddts.log") or return undef;
+		print $fh "           md5: $description_md5\n";
+		print $fh "       package: $package\n";
+		print $fh "   translation: $translation\n";
+		print $fh "oldtranslation: $oldtranslation\n";
+		print $fh "Translation is already translated\n\n";
+		print $fh "\n\n";
+		close $fh;
+		return "Translation is translated";
+	}
+
+	my $body = get_untrans_file_from_db($language,"",$d_id);
+	if (not (defined($oldtranslation))) {
+                ($oldtranslation) = ($body =~ /^Description-[^:]+: (.*\n(?: .*\n)+)/m);
+	}
+
+	if ( $oldtranslation !~ /^Description/ ) {
+		$oldtranslation="Description-$language: ".$oldtranslation;	
+	}
+	if ( $translation !~ /^Description/ ) {
+		$translation="Description-$language: ".$translation;	
+	}
+
+	my $fh;
+        open ($fh, ">>/tmp/ddts.log") or return undef;
+	print $fh "           md5: $description_md5\n";
+	print $fh "       package: $package\n";
+	print $fh "   translation: $translation\n";
+	print $fh "oldtranslation: $oldtranslation\n";
+	print $fh "\n\n";
+	close $fh;
+
+	if ($oldtranslation eq $translation) {
+		return "Translation don't have any changes";
+	} else {
+		eval {
+			$dbh->do("INSERT INTO suggestion_tb (package, version, description_md5, translation, language, importer, importtime) VALUES (?,?,?,?,?,?,CURRENT_DATE);", undef, $package,$version,$description_md5,$translation,$language,$importer);
+			$dbh->commit;   # commit the changes if we get this far
+		};
+	}
+
+	return undef;
+
+}
+
+sub get_suggestions
+{
+	my $language= shift(@_);
+	
+        my @suggestions=();
+
+        my $sth = $dbh->prepare("SELECT suggestion_id,package,description_md5,importer,importtime FROM suggestion_tb WHERE language=?");
+        $sth->execute($language);
+
+        my ($id,$package,$md5,$importer,$importtime);
+        while(($id,$package,$md5,$importer,$importtime) = $sth->fetchrow_array) {
+                push @suggestions, [$id, $package, $md5, $importer, $importtime];
+        }
+        return (@suggestions);
+
+}
+
+sub get_suggestion_infos
+{
+	my $suggestion_id= shift(@_);
+
+	my %suggestion;
+
+        my $sth = $dbh->prepare("SELECT package,version,description_md5,translation,language,importer,importtime FROM suggestion_tb WHERE suggestion_id=?");
+        $sth->execute($suggestion_id);
+
+	my ($package,$version,$description_md5,$translation,$language,$importer,$importtime);
+        while(($package,$version,$description_md5,$translation,$language,$importer,$importtime) = $sth->fetchrow_array) {
+
+		$suggestion{'package'}=$package;
+		$suggestion{'version'}=$version;
+		$suggestion{'description_md5'}=$description_md5;
+		$suggestion{'suggestion'}=$translation."\n";
+		$suggestion{'language'}=$language;
+		$suggestion{'importer'}=$importer;
+		$suggestion{'importtime'}=$importtime;
+        }
+
+	# get more....
+
+	# get the description
+	$sth = $dbh->prepare("SELECT description_id,description,prioritize,package,source FROM description_tb WHERE description_md5=?");
+	$sth->execute($suggestion{'description_md5'});
+	($suggestion{'description_id'},$suggestion{'description'},$suggestion{'prioritize'},$suggestion{'packages'},$suggestion{'source'}) = $sth->fetchrow_array;
+
+	my @versions=get_versions($suggestion{'description_id'});
+	$suggestion{'versions'}= join(", ", at versions);
+
+	# get the translation
+	$sth = $dbh->prepare("SELECT translation FROM translation_tb WHERE description_id=? and language=?");
+	$sth->execute($suggestion{'description_id'},$suggestion{'language'});
+	($suggestion{'translation'}) = $sth->fetchrow_array;
+
+	my $body = get_untrans_file_from_db($suggestion{'language'},"",$suggestion{'description_id'});
+	if (not (defined($suggestion{'translation'}))) {
+                ($suggestion{'translation'}) = ($body =~ /^Description-[^:]+: (.*\n(?: .*\n)+)/m);
+	}
+
+
+	if ( $suggestion{'description'} !~ /^Description: / ) {
+		$suggestion{'description'}='Description: '.$suggestion{'description'};	
+	}
+	if ( $suggestion{'translation'} !~ /^Description/ ) {
+		$suggestion{'translation'}="Description-$suggestion{'language'}: ".$suggestion{'translation'};	
+	}
+	if ( $suggestion{'suggestion'} !~ /^Description/ ) {
+		$suggestion{'suggestion'}="Description-$suggestion{'language'}: ".$suggestion{'suggestion'};	
+	}
+
+	
+        return (%suggestion);
+}
+
+sub get_translation_by_md5
+{
+	my $description_md5= shift(@_);
+	my $language= shift(@_);
+
+	my $translation;
+
+	# get the description_id
+	my $d_id;
+	my $sth = $dbh->prepare("SELECT description_id FROM description_tb WHERE description_md5=?");
+	$sth->execute($description_md5);
+	($d_id) = $sth->fetchrow_array;
+
+	# get the translation
+	$sth = $dbh->prepare("SELECT translation FROM translation_tb WHERE description_id=? and language=?");
+	$sth->execute($d_id,$language);
+	($translation) = $sth->fetchrow_array;
+
+	return $translation;
+}
+
+sub get_commonpackages_by_text
+{
+	my @commonpackages;
+
+	my $description=shift;
+
+	sub get_description_id {
+		my $md5sum= shift(@_);
+
+		my $description_id;
+
+		my $sth = $dbh->prepare("SELECT description_id FROM description_tb WHERE description_md5=?");
+		$sth->execute($md5sum);
+		($description_id) = $sth->fetchrow_array;
+		return $description_id;
+	}
+
+	my $md5sum_description=md5_hex($description);
+	my $description_id=get_description_id($md5sum_description);
+
+	my @parts = desc_to_parts($description);
+	my $count=0;
+	foreach (@parts) {
+		my $sth = $dbh->prepare("SELECT description_id FROM part_description_tb WHERE part_md5=?");
+		$sth->execute(md5_hex($_));
+
+		my $desc_id;
+		my $count_common=0;
+		my $commonpackage=" $count : ";
+		while(($desc_id) = $sth->fetchrow_array) {
+			next if ($desc_id eq $description_id) ;
+			my @versions=get_versions($desc_id);
+			$count_common++;
+			$commonpackage.=join(", ", at versions) . "; ";
+		}
+                push @suggestions, [$id, $package, $md5, $importer, $importtime];
+		if ($commonpackage eq " $count : ") {
+			$commonpackage.=" no other package description; ";
+		}
+                push @commonpackages, [$count_common, $commonpackage];
+		$count++;
+	}
+
+	return (@commonpackages);
+}
+
 1;

Modified: ddtss/trunk/ddtss-cgi
URL: http://svn.debian.org/wsvn/ddtss/trunk/ddtss-cgi?rev=2584&op=diff
==============================================================================
--- ddtss/trunk/ddtss-cgi (original)
+++ ddtss/trunk/ddtss-cgi Sun Apr  3 05:49:23 2011
@@ -45,7 +45,6 @@
 my $path = $ENV{PATH_INFO} || '/';
 # Later $self is overwritten for the per language page, so keep a copy of the real thing
 my $self = $ENV{SCRIPT_NAME} || 'local';
-my $http_host = $ENV{HTTP_HOST} || 'local';
 
 if( defined $q->param("_charset_") and uc($q->param("_charset_")) ne "UTF-8" )
 {
@@ -100,10 +99,6 @@
   {
     main_display();
   }
-  elsif( $path =~ m,^/forexternalreview/([-\w+.]+)$, )
-  {
-    forexternalreview_display($1);
-  }
   elsif( $path =~ m,^/translate/([-\w+.]+)$, )
   {
     translate_display($1,$2);
@@ -192,7 +187,8 @@
         $q->start_html( -title => "DDTSS", @html_headers ),
         $q->h1("DDTSS"),
         $q->p("The DDTSS (DDTS Satellite or Debian Distributed Translation Server Satellite) is a web frontend to the DDTS email server. It provides facilities to request translations, enter a translation and review other peoples translations. Afterwards the updated translation can be sent via email to the DDTS server."),
-        $q->p("The DDTSS was created by Martijn van Oosterhout &lt;kleptog\@svana.org&gt;.\n"),
+        $q->p({-style => 'color: #ff0000'}, "Scheduled downtime: around 13:00 UTC on the 29th of August."),
+        $q->p("The DDTSS was created by Martijn van Oosterhout &lt;kleptog (at) svana.org&gt;.\n"),
         $q->p("More information about the DDTP and the DDTSS can be found ", $q->a({-href => 'http://www.debian.org/international/l10n/ddtp'},"here")."." );
   print $q->h1("Select a language:"),
         $q->p("Note: These stats only count what is done via the DDTSS. Anything sent directly to the email server is not counted.",
@@ -253,16 +249,10 @@
   DDTSS_Close($db);
   
   print $q->header( -type =>'text/html', -charset => "UTF-8", -refresh => "240; url=$self", -expires => '+10s', -cookie => $usercookie ),
-        $q->start_html( -title => "DDTSS ($lang)", @html_headers, -xbase => "http://$http_host$self/" );
+        $q->start_html( -title => "DDTSS ($lang)", @html_headers, -xbase => $q->url(-base=>1)."$self/" );
 
   print $q->h1("DDTSS for $lang");
   print $q->p("<div style='color: #ff0000'>The DDTSS has moved to a new system. Please report any issues to the <a href='mailto:debian-i18n\@lists.debian.org'>mailing list</a></div>");
-  if( not $logged_in ) 
-  { 
-    print $q->p($q->b("Please login... Only with a login, you can use all features! Go to " . 
-             $q->a({-href => "$realself/login"}, "Login")
-	     ));
-  };
   print $q->p("The DDTSS is a queue-based system. New translations are automatically fetched only when there are only a few pending translation. Translations will only be sent off after they have received a certain amount of review. New translations will be fetched in priority order, so the goal is to get your priority numbers as low as possible!");
   print $q->p("The rate of getting new descriptions to translate is not automatic. If you find you keep running low on things to translate, ask me to increase it.");
   print $q->p( $q->a({-href => 'http://www.debian.org/international/l10n/ddtp#rules'}, "Common translation rules") );
@@ -411,9 +401,6 @@
     $msg = submit_translation( $db, $package, $key, $q->param("short"), $q->param("long") );
     if( not defined $msg )
     {
-      my $count=0;
-      $db->get("aliases/$user/counttranslations", $count );
-      $db->put("aliases/$user/counttranslations", ++$count );
       DDTSS_Unlock( $db, "$lang/packages/$package", $user );
       DDTSS_Close($db);
 #      print STDERR "line 383\n";
@@ -465,105 +452,6 @@
       help("Abandon returns the description to the untranslated list\nSubmit puts translation forreview"),
       $short, $long );
 }  
-
-# Display the screen that reviewers see
-sub forexternalreview_display
-{
-  my $package = shift;
-    
-  $q->charset("UTF-8");
-
-  my $db = DDTSS_Open_Write();
-
-  if( not DDTSS_Check_Valid_Language($db,$lang) )
-  {
-    DDTSS_Close($db);
-    display_langlist(); 
-    return;
-  }
-  
-  my $requirelogin = 0;
-
-  my($owner, $short, $long, $data, $reviewers, $timestamp );
-  
-  my $msg = '';
-
-  # Description adjusted, submit new version ... (mailing list etc)
-  if( defined $q->param("submit") )
-  {
-    $msg = submit_externalreview( $db, $package, $q->param("short"), $q->param("long"), $q->param("comment").$q->param("NameEMail") );
-    if( not defined $msg )
-    {
-      DDTSS_Close($db);
-      goto_main_display("Changes and comments for $package send to the team, thanks for your contribution");
-      exit;
-    }
-  }
- 
-  eval {
-    $data = get_untrans( $lang, "", $package, "1" );
-  };
-  
-  # Any error/warning procuded, display it
-  if( $@ )
-  {
-    display_error($@);
-  }
-  if( not defined $data )
-  {
-    display_error("Couldn't fetch an untranslated description: $lang, $package");
-  }
-
-  if( not defined $data or $data !~ /Description:/ or $data !~ /Description-[a-z_A-Z]+:/)
-  {
-    display_error("Couldn't fetch package description");
-  }
-
-  if( $data !~ /^# Package[^:]*: ([\w.+-]+)/m )
-  { display_error( "Fetched description didn't contain package name" ) }
-  
-  eval {
-    my $str = Encode::decode_utf8($data, Encode::FB_CROAK);
-  };
-  if($@)
-  {
-    print STDERR "Encoding error ($@)\n";
-    print STDERR "Data: [$data]\n";
-    display_error("Encoding error retreiving data for package $package");
-  }
-  $data =~ s,^# patch http*,#  patch http,m; # don't show patch-box
-
-  ($short, $long) = ($data =~ /^Description-$lang: (.*)\n((?: .*\n)+)/m);
-
-  my($oldshort,$oldlong,$diffshort,$difflong);
-  
-  if( defined $oldshort and $short ne $oldshort )
-  {
-    $diffshort = make_colour_diff( $oldshort, $short );
-  }
-  
-  if( defined $oldlong and $long ne $oldlong )
-  {
-    $difflong = make_colour_diff( $oldlong, $long );
-  }
-  
-  my $trailer = $q->h5("Name and EMail-Address" ).
-		$q->ul(
-                  $q->input( { -type => 'text', -size => 52, -name => 'NameEMail' } ),
-                  $q->br(),
-		  ("With a email-Address the translator team can contact you, if they have questions.")
-		).
-                $q->br().
-                $q->submit(-name => "submit",  -label => "Send to team").
-                $q->br().
-                ("'Send to team' send the changes and the comments to the translator team.");
-
-  my $comment = "";
-  DDTSS_Close($db);
-
-  display_translate_screen( $data, "External Reviewing $package", $msg, $comment, $trailer,
-       $short, $long, $diffshort, $difflong );
-}
 
 # Display the screen that reviewers see
 sub forreview_display
@@ -628,20 +516,15 @@
         if( scalar( grep { $_ eq $user } @a ) == 0 )
         {
           $db->put("$lang/packages/$package/reviewers", $reviewers.",".$user);
-          my $count=0;
-          $db->get("aliases/$user/countreviews", $count );
-          $db->put("aliases/$user/countreviews", ++$count );
           DDTSS_Log( $db, "$lang/packages/$package/log", time()." reviewed by $user" );
         }
       }
       else
       {
         $db->put("$lang/packages/$package/reviewers",$user);
-        my $count=0;
-        $db->get("aliases/$user/countreviews", $count );
-        $db->put("aliases/$user/countreviews", ++$count );
         DDTSS_Log( $db, "$lang/packages/$package/log", time()." reviewed by $user" );
       }
+      $db->put( "aliases/$user/lastlanguage", $lang );
     }
     DDTSS_Close($db);
     process_reviewed($lang);
@@ -698,8 +581,6 @@
       { $trailer .= $q->br.$q->b("Note: You have already reviewed this decription") }
     }
   } 
-
-  $trailer .= $q->br("Note: the owner is: ".$q->b("$owner").", reviewer are: ".$q->b("$reviewers")) ;
 
   my $comment = "";
   $db->get("$lang/packages/$package/comment", $comment);
@@ -833,9 +714,9 @@
 }
 
 
-sub submit_externalreview
-{
-  my( $db, $package, $short, $long, $comment ) = @_;
+sub submit_translation
+{
+  my( $db, $package, $key, $short, $long ) = @_;
   
   $short =~ s/^\s+//;
   $short =~ s/\s+$//;
@@ -846,135 +727,6 @@
   $long =~ s/[ \t]+$//mg;
   $long =~ s/^/ /mg; # Insert leading space
 
-  eval {
-    my $shortx = Encode::decode_utf8($short, Encode::FB_CROAK);
-    my $longx = Encode::decode_utf8($long, Encode::FB_CROAK);
-    
-    if( length($shortx) > 80 or $longx =~ /^.{80}/m )
-    {
-      return "Translation contains line longer than 80 characters";
-    }
-  };
-  if( $@ )
-  {
-    print STDERR "Encoding failure: charset=[".$q->param("_charset_")."], browser=[$ENV{HTTP_USER_AGENT}], err=[$@]\n";
-    print STDERR "short=[$short]\n";
-    print STDERR "long=[$long]\n";
-    return "Entered data was not validly encoded. Please check your translation contains no invalid characters. If this error persists, contact me at <kleptog\@svana.org>";
-  }
-  
-  my $data;
-  my ($oldshort,$oldlong);
-  eval {
-    $data = get_untrans( $lang, "", $package, "1" );
-  };
-  
-  # Any error/warning procuded, display it
-  if( $@ )
-  {
-    return ($@);
-  }
-  if( not defined $data )
-  {
-    return("Couldn't fetch an untranslated description: $lang, $package");
-  }
-
-  if( not defined $data or $data !~ /Description:/ or $data !~ /Description-[a-z_A-Z]+:/)
-  {
-    return("Couldn't fetch package description");
-  }
-
-  if( $data !~ /^# Package[^:]*: ([\w.+-]+)/m )
-  { return( "Fetched description didn't contain package name" ) }
-  
-  eval {
-    my $str = Encode::decode_utf8($data, Encode::FB_CROAK);
-  };
-  if($@)
-  {
-    print STDERR "Encoding error ($@)\n";
-    print STDERR "Data: [$data]\n";
-    display_error("Encoding error retreiving data for package $package");
-  }
-  $data =~ s,^# patch http*,#  patch http,m; # don't show patch-box
-
-  ($oldshort, $oldlong) = ($data =~ /^Description-$lang: (.*)\n((?: .*\n)+)/m);
- 
-  my $str1 = $oldshort . "\n" . $oldlong;
-  my $str2 = $short . "\n" . $long;
-  
-  my $words = 1;
-  if( $lang eq "ja" )
-  { $words = 0 }
-  
-  my $diff = DDTSS_CreateDiff( $str1, $str2, $words );
-  my $res = "";
-  for my $hunk (@$diff)
-  {
-    my($type,$str) = @$hunk;
-    $str = $q->escapeHTML($str);
-    
-    if( $type eq "" )
-    {
-      $res .= $str;
-    }
-    elsif( $type eq "-" )
-    {
-      $res .= "-(".$str.")";
-    }
-    elsif( $type eq "+" )
-    {
-      $res .= "+(".$str.")";
-    }
-  }
-  $diff=$res;
-
-  my $sender = setup_email_connection($db);
-  
-  DDTSS_Close($db);
-
-  my $email='grisu at debian.org, debian-i18n at lists.debian.org';
-  
-  $sender->MailMsg({to => $email, 
-	       	    from => 'debian-i18n at lists.debian.org',
-                    subject => "(test)External Description Review from '$package', lang '$lang'", 
-	       	    charset => 'UTF-8',
-                    msg => "Hi\n\n".
-		           "Somebody has made a review of the $lang-translation of package '$package'.\n\n".
-			   "The data in the database is:\n".
-			   $data.
-			   "\n\n".
-			   "The external reviewer has proposed the following change:\n\n".
-			   "Description-$lang: $short\n".
-			   $long.
-			   "\n\n".
-			   "The diff of the change:\n\n".
-			   $diff.
-			   "\n\n".
-			   "The reviewer made the following comment:\n\n".
-			   $comment.
-			   "\n\n".
-			   "To apply this change http://ddtp.debian.net/ddtss/index.cgi/$lang/fetch?package=$package&force=1 or \nsend an email to pdesc\@ddtp.debian.net\n\n".
-			   "Thanks"
-		   });
- 
-  return undef;
-}
-
-
-sub submit_translation
-{
-  my( $db, $package, $key, $short, $long ) = @_;
-  
-  $short =~ s/^\s+//;
-  $short =~ s/\s+$//;
-  $short =~ s/\s+/ /g;
-  $long =~ s/\s+$//;   # Trailing newlines
-  $long =~ s/\r\n?/\n/g;   # Fix line endings
-  $long =~ s/^[ \t]*$/./mg;  # Don't use \s because that matches \n
-  $long =~ s/[ \t]+$//mg;
-  $long =~ s/^/ /mg; # Insert leading space
-
   if( $short =~ /<trans>/ or $long =~ /<trans>/ )
   {
     return "Translation not complete, still <trans>";
@@ -1028,6 +780,7 @@
   $db->del( "$lang/packages/$package/reviewers");
  
   $db->put( "aliases/$user/timestamp", time() );
+  $db->put( "aliases/$user/lastlanguage", $lang );
  
   DDTSS_Log( $db, "$lang/packages/$package/log", time()." updated text by $user ($cs$cl)" );
   
@@ -1281,6 +1034,7 @@
     $db->put( "aliases/$alias", $email );
     $db->put( "aliases/$alias/password", $password );
     $db->put( "aliases/$alias/timestamp", time() );
+    $db->put( "aliases/$alias/lastlanguage", $lang );
     $db->put( "aliases/$alias/realname", $realname );
     $db->put( "aliases/$alias/active", 0 );
     $db->put( "aliases/$alias/key", $key );
@@ -1293,7 +1047,7 @@
     $sender->MailMsg({to => $email, 
                       subject => 'Confirm DDTSS account', 
                       msg => "To confirm you account ($alias) on the DDTSS, please follow this link\n".
-                             "http://$http_host$self/verifylogin?a=$alias&k=$key\n\n".
+                             $q->url(-base=>1)."$self/verifylogin?a=$alias&k=$key\n\n".
                              "If you did not create an account, please ignore this email.\n".
                              "DDTSS (Debian Distributed Translation Server Satelite)\n"});
     
@@ -1425,7 +1179,6 @@
         
   print $q->p("A login on the DDTSS is only used so you can keep the status
               of what you've reviewed between machines."),
-	$q->p("(To create a account go to " . $q->a({-href => "$realself/createlogin"}, "Create Login") .  ")"),
         $q->start_form( -method => 'post' ),
         $q->start_table( -id => 'login' ),
         $q->TR( $q->td( $q->label( { -for => 'alias' }, "Alias:" ) ), 

Modified: ddtss/trunk/ddtss-clean
URL: http://svn.debian.org/wsvn/ddtss/trunk/ddtss-clean?rev=2584&op=diff
==============================================================================
--- ddtss/trunk/ddtss-clean (original)
+++ ddtss/trunk/ddtss-clean Sun Apr  3 05:49:23 2011
@@ -21,14 +21,15 @@
   or die "Cannot tie $db_hash ($!)\n";
 
 my @dependancies = (
-   [ qr,^(\w+)/packages/([\w.+-]+)$, => '$1/packages/$2/data' ],
+   [ qr,^(\w+)/packages/([\w.+-]+)$, => '$1/packages/$2' ],
    [ qr,^(\w+)/, => 'root/$1' ],
-   [ qr,^(\w+)/packages/([\w.+-]+)/\w+, => '$1/packages/$2/data' ],
+   [ qr,^(\w+)/packages/([\w.+-]+)/\w+, => '$1/packages/$2' ],
    [ qr,^lock/(.*)$,   => '$1'],
    [ qr,^users/(.*)$, =>  'aliases/$hash{$key}'],
    [ qr,^aliases/(\w+)$, => 'users/$hash{$key}'],
    [ qr,^aliases/(\w+)/\w+$, => 'aliases/$1'],
    [ qr,^todo/.*, => 'root/todo'],
+   [ qr,^suggestion/.*, => 'root/suggestion'],
 );
 
 ### Missing TODO!!!
@@ -77,7 +78,7 @@
 }
 foreach my $key (@archive)
 {
-  print "Archiving: $key\n";
+#  print "Archiving: $key\n";
 }
 
 untie %hash;

Modified: ddtss/trunk/ddtss-process
URL: http://svn.debian.org/wsvn/ddtss/trunk/ddtss-process?rev=2584&op=diff
==============================================================================
--- ddtss/trunk/ddtss-process (original)
+++ ddtss/trunk/ddtss-process Sun Apr  3 05:49:23 2011
@@ -8,7 +8,7 @@
 # that and so eventually this program will completely disappear.
 
 use strict;
-use warnings;
+#use warnings;
 
 BEGIN { 
   exit if( scalar grep { $_ > 10 } split / *, */, qx(uptime |sed "s/.*average: //") );

Modified: ddtss/trunk/ddtss-setup
URL: http://svn.debian.org/wsvn/ddtss/trunk/ddtss-setup?rev=2584&op=diff
==============================================================================
--- ddtss/trunk/ddtss-setup (original)
+++ ddtss/trunk/ddtss-setup Sun Apr  3 05:49:23 2011
@@ -5,8 +5,8 @@
 
 use strict;
 
-my @langs = qw(da de es fi fr hu it ja km_KH nl pl sv zh_CN pt pt_BR eo zh_TW ca cs uk vi ml ru sk);
-my @disabled_langs = qw(ko go);
+my @langs = qw(da de es fi fr hu id it ja km_KH ko nb nl pl sv zh_CN pt pt_BR eo zh_TW ca cs uk vi ml ru sk);
+my @disabled_langs = qw(go);
 
 use DB_File::Lock;
 my %hash;
@@ -41,10 +41,11 @@
 $hash{'ja/config/minuntranslated'} = '1';
 $hash{'km_KH/config/minuntranslated'} = '1';
 $hash{'fr/config/minuntranslated'} = '4';
+$hash{'fr/config/numreviewers'} = '2';
 $hash{'es/config/minuntranslated'} = '50';
 $hash{'es/config/numreviewers'} = '2';
 $hash{'pl/config/minuntranslated'} = '2';
-$hash{'it/config/minuntranslated'} = '2';
+$hash{'it/config/minuntranslated'} = '3';
 $hash{'fi/config/minuntranslated'} = '2';
 $hash{'pt_PT/config/minuntranslated'} = '3';
 $hash{'pt_PT/config/numreviewers'} = '2';
@@ -57,7 +58,9 @@
 $hash{'cs/config/numreviewers'} = '2';
 $hash{'zh_CN/config/minuntranslated'} = 2;
 $hash{'vi/config/requirelogin'} = '1';
+$hash{'vi/config/numreviewers'} = '1';
 $hash{'ru/config/numreviewers'} = '2';
+$hash{'sk/config/numreviewers'} = '1';
 
 # Email address of DDTS
 $hash{'config/serveremail'} = '<pdesc at ddtp.debian.net>';

Modified: ddtss/trunk/test.pl
URL: http://svn.debian.org/wsvn/ddtss/trunk/test.pl?rev=2584&op=diff
==============================================================================
--- ddtss/trunk/test.pl (original)
+++ ddtss/trunk/test.pl Sun Apr  3 05:49:23 2011
@@ -16,7 +16,17 @@
 {
 #  if( $key =~ m,^../requests/, )
 #  { push @todo, $key }
+#  next unless $key =~ m,^([^/]+)/logs/(\d+)/(.+),;
+#  next if $2 < 1220047200;
+  
+  next unless $key =~ /^it/;
+
   print "Key: $key: $hash{$key}\n";
+#  print "Key: $key\n";
+  
+#  $key = "$1/done/$3";
+  
+#  print "Key: $key: $hash{$key}\n";
   
   eval {
     my $str = Encode::decode("utf8", $hash{$key}, Encode::FB_CROAK);
@@ -41,6 +51,8 @@
 #{
 #  delete $hash{$key};
 #}
+exit;
+
 foreach my $key (keys %hash)
 {
   if( $key =~ m,pt_PT/, )




More information about the Debian-l10n-commits mailing list