Make translation status more verbose use 'use strict' in perl stuff.
Peter Palfrader

Peter Palfrader commited on 2005-10-08 14:16:45
Zeige 13 geänderte Dateien mit 80 Einfügungen und 37 Löschungen.

... ...
@@ -10,7 +10,7 @@
10 10
   <div class="bottom" id="bottom">
11 11
      <i><a href="mailto:tor-webmaster@freehaven.net" class="smalllink">Webmaster</a></i> -
12 12
 #     Id: developers.html,v 1.41 2005/08/31 20:19:16 thomass Exp 
13
-      Letzte &auml;nderung: <: @stat = stat($(LANG).'/'.$WML_SRC_FILENAME); print scalar localtime($stat[9]); :>
13
+      Letzte &auml;nderung: <: my @stat = stat($(LANG).'/'.$WML_SRC_FILENAME); print scalar localtime($stat[9]); :>
14 14
       -
15 15
       Zuletzt kompiliert: <: print scalar localtime(); :>
16 16
 
... ...
@@ -5,7 +5,7 @@
5 5
 # Last-Translator: jens@kubieziel.de
6 6
 
7 7
 <:
8
-	@navigation = (
8
+	my @navigation = (
9 9
 		'index'			, 'Startseite',
10 10
 		'overview'		, '�bersicht',
11 11
 		'download'		, 'Download',
... ...
@@ -9,7 +9,7 @@
9 9
   <div class="bottom" id="bottom">
10 10
      <i><a href="mailto:tor-webmaster@freehaven.net" class="smalllink">Webmaster</a></i> -
11 11
 #     Id: developers.html,v 1.41 2005/08/31 20:19:16 thomass Exp 
12
-      Last modified: <: @stat = stat($(LANG).'/'.$WML_SRC_FILENAME); print scalar localtime($stat[9]); :>
12
+      Last modified: <: my @stat = stat($(LANG).'/'.$WML_SRC_FILENAME); print scalar localtime($stat[9]); :>
13 13
       -
14 14
       Last compiled: <: print scalar localtime(); :>
15 15
 
... ...
@@ -4,7 +4,7 @@
4 4
 # Revision: $Revision$
5 5
 
6 6
 <:
7
-	@navigation = (
7
+	my @navigation = (
8 8
 		'index'			, 'Home',
9 9
 		'overview'		, 'Overview',
10 10
 		'download'		, 'Download',
... ...
@@ -6,7 +6,7 @@
6 6
 <div class="main-column">
7 7
 
8 8
 <:
9
-	$man = `man2html -M '' $(TORCVSHEAD)/doc/tor.1.in`;
9
+	my $man = `man2html -M '' $(TORCVSHEAD)/doc/tor.1.in`;
10 10
 	die "No manpage" unless $man;
11 11
 
12 12
 	$man =~ s,.*<body>,,is;
... ...
@@ -6,7 +6,7 @@
6 6
 <div class="main-column">
7 7
 
8 8
 <:
9
-	$man = `man2html -M '' $(TORCVSSTABLE)/doc/tor.1.in`;
9
+	my $man = `man2html -M '' $(TORCVSSTABLE)/doc/tor.1.in`;
10 10
 	die "No manpage" unless $man;
11 11
 
12 12
 	$man =~ s,.*<body>,,is;
... ...
@@ -10,16 +10,18 @@
10 10
 
11 11
 <:
12 12
 	my %files;
13
+	my @warnings;
13 14
 	for my $lang (@LANGUAGES) {
14 15
 		opendir(DIR, $lang) or die ("Cannot opendir $lang: $!\n");
15 16
 		my @files = grep { $_ ne '.' && $_ ne '..' && $_ =~ m/^[^.]/ && -f $lang.'/'.$_} readdir(DIR);
16 17
 		closedir DIR;
17 18
 
18 19
 		for my $file (@files) {
20
+			$files{$lang}->{$file}->{'all'} = getMetadata($lang.'/'.$file);
19 21
 			if ($lang eq 'en') {
20
-				$files{$lang}->{$file} = translation_get_masterrevision_file($file);
22
+				$files{$lang}->{$file}->{'rev'} = translation_get_masterrevision_file($file);
21 23
 			} else {
22
-				$files{$lang}->{$file} = translation_get_basedonrevision_langfile($lang, $file);
24
+				$files{$lang}->{$file}->{'based'} = translation_get_basedonrevision_langfile($lang, $file);
23 25
 			};
24 26
 		};
25 27
 	};
... ...
@@ -27,25 +29,56 @@
27 29
 	print "<table border=1>\n";
28 30
 	print "<tr>\n";
29 31
 	print "<th>File</th>\n";
30
-	printf("<th>%s</th>\n", $LANGUAGES{$_}) for (@LANGUAGES);
32
+	printf("<th>%s (%s)</th>\n", $_, $LANGUAGES{$_}) for (@LANGUAGES);
31 33
 	print "</tr>\n";
32 34
 	for my $file (sort {$a cmp $b} keys %{$files{'en'}}) {
33 35
 		my $obs = file_is_obsolete('en', $file);
34 36
 		print "<tr>";
35 37
 		printf "<th>%s</th>", $file;
36
-		printf "<td%s>%s%s</td>", ($obs ? ' bgcolor="grey"' : ''), $files{'en'}->{$file}, ($obs ? ' (obsolete)' :'');
38
+		printf '<td%s>Revision %s%s<br>
39
+		        <a href="http://cvs.seul.org/viewcvs/viewcvs.cgi/website/en/%s?root=tor&view=markup">HEAD</a></td>',
40
+			($obs ? ' bgcolor="lightgrey"' : ''),
41
+			$files{'en'}->{$file}->{'rev'},
42
+			($obs ? ' (obsolete)' :''),
43
+			$file;
37 44
 		for my $lang (@LANGUAGES) {
38 45
 			next if $lang eq 'en';
46
+			my $color;
47
+			my $status;
39 48
 			if (exists $files{$lang}->{$file}) {
40
-				if ($files{$lang}->{$file}  eq  $files{'en'}->{$file}) {
41
-					printf '<td bgcolor="lightgreen">current</td>';
49
+				my $all_info = '';
50
+				for my $key (sort {$a cmp $b} keys %{$files{$lang}->{$file}->{'all'}}) {
51
+					$all_info .= sprintf "%s: %s<br>", $key, $files{$lang}->{$file}->{'all'}->{$key};
52
+				};
53
+
54
+				my $difflink;
55
+				if ($files{$lang}->{$file}->{'based'}  eq  $files{'en'}->{$file}->{'rev'}) {
56
+					$color='lightgreen';
57
+					$status='current';
58
+					$difflink='';
42 59
 				} else {
43
-					printf '<td bgcolor="yellow">%s</td>', $files{$lang}->{$file};
60
+					$color='yellow';
61
+					$status='not current';
62
+					if ($files{$lang}->{$file} ne 'unknown') {
63
+						$difflink=sprintf '<br><a href="http://cvs.seul.org/viewcvs/viewcvs.cgi/website/en/%s?root=tor&r1=%s&r2=%s">changes in original</a>',
64
+							$file, $files{$lang}->{$file}->{'based'}, $files{'en'}->{$file}->{'rev'};
44 65
 					};
45
-				delete $files{$lang}->{$file};
66
+				};
67
+				printf '<td bgcolor="%s">%s<br>
68
+					<a href="http://cvs.seul.org/viewcvs/viewcvs.cgi/website/%s/%s?root=tor&view=markup">HEAD</a><br>
69
+					%s
70
+					%s</td>',
71
+					$color,
72
+					$status,
73
+					$lang, $file,
74
+					$all_info,
75
+					$difflink;
46 76
 			} else {
47
-				printf '<td bgcolor="%s">missing</td>', ($obs ? 'lightgreen' : 'red')
77
+				$color=($obs ? 'lightgreen' : 'red');
78
+				$status='missing';
79
+				printf '<td bgcolor="%s">%s</td>', $color, $status;
48 80
 			};
81
+			delete $files{$lang}->{$file};
49 82
 		};
50 83
 		print "</tr>";
51 84
 	};
... ...
@@ -54,7 +87,8 @@
54 87
 	for my $lang (@LANGUAGES) {
55 88
 		next if $lang eq 'en';
56 89
 		if (keys %{$files{$lang}} > 0) {
57
-			printf "<h2>Additional files in %s</h2>\n", $LANGUAGES{$lang};
90
+			print "<p>";
91
+			printf "<h2>Additional files in %s (%s)</h2>\n", $lang, $LANGUAGES{$lang};
58 92
 
59 93
 			print "<table border=1>\n";
60 94
 			print "<tr>\n";
... ...
@@ -63,8 +97,11 @@
63 97
 			print "</tr>\n";
64 98
 			for my $file (sort {$a cmp $b} keys %{$files{$lang}}) {
65 99
 				print "<tr>";
66
-				printf "<th>%s</th>", $file;
67
-				printf "<td>%s</td>", $files{$lang}->{$file};
100
+				printf "<th>%s</th><td>", $file;
101
+				for my $key (sort {$a cmp $b} keys %{$files{$lang}->{$file}->{'all'}}) {
102
+					printf "%s: %s<br>", $key, $files{$lang}->{$file}->{'all'}->{$key};
103
+				};
104
+				printf "</td>";
68 105
 				delete $files{$lang}->{$file};
69 106
 			};
70 107
 			print "</table>\n";
... ...
@@ -5,6 +5,8 @@
5 5
 sub getMetadata($) {
6 6
 	my ($file) = @_;
7 7
 
8
+	die ("File $file is not a regular file") unless (-f $file);
9
+
8 10
 	open(F, "$file") or die ("Cannot open $file: $!\n");
9 11
 	my $found_metadata = 0;
10 12
 	while (<F>) {
... ...
@@ -24,16 +26,16 @@ sub getMetadata($) {
24 26
 			last;
25 27
 		};
26 28
 	};
27
-	return %data;
29
+	return \%data;
28 30
 };
29 31
 
30 32
 sub translation_get_masterrevision_file($) {
31 33
 	my ($page) = @_;
32
-	%master = getMetadata("en/$page");
34
+	my $master = getMetadata("en/$page");
33 35
 
34
-	die ("Cannot find 'Revision' header in master's translation metadata of en/$page") unless exists $master{'Revision'};
36
+	die ("Cannot find 'Revision' header in master's translation metadata of en/$page") unless exists $master->{'Revision'};
35 37
 
36
-	my ($rev) = $master{'Revision'} =~ m/([0-9.]+)/;
38
+	my ($rev) = $master->{'Revision'} =~ m/([0-9.]+)/;
37 39
 	if ($rev eq '') { $rev = '(Revision not a valid number)'; };
38 40
 
39 41
 	return $rev;
... ...
@@ -44,17 +46,17 @@ sub translation_get_masterrevision() {
44 46
 
45 47
 sub translation_get_basedonrevision_langfile($$) {
46 48
 	my ($lang, $page) = @_;
47
-	%translation = getMetadata("$lang/$page");
49
+	my $translation = getMetadata("$lang/$page");
48 50
 
49
-	die ("Cannot find 'Based-On-Revision' header in translations's translation metadata of $lang/$page") unless exists $translation{'Based-On-Revision'};
51
+	die ("Cannot find 'Based-On-Revision' header in translations's translation metadata of $lang/$page") unless exists $translation->{'Based-On-Revision'};
50 52
 
51
-	my ($rev) = $translation{'Based-On-Revision'};
53
+	my ($rev) = $translation->{'Based-On-Revision'};
52 54
 	if ($rev eq '') { $rev = '(unknown)'; };
53 55
 
54 56
 	return $rev
55 57
 };
56 58
 sub translation_get_basedonrevision() {
57
-	translation_get_basedonrevision_langfile($(LANG), $WML_SRC_FILENAME);
59
+	translation_get_basedonrevision_langfile("$(LANG)", $WML_SRC_FILENAME);
58 60
 };
59 61
 
60 62
 
... ...
@@ -64,8 +66,8 @@ sub translation_current() {
64 66
 
65 67
 sub file_is_obsolete($$) {
66 68
 	my ($lang, $page) = @_;
67
-	%translation = getMetadata("$lang/$page");
68
-	return (exists $translation{'Status'} && ($translation{'Status'} eq 'obsolete'))
69
+	my $translation = getMetadata("$lang/$page");
70
+	return (exists $translation->{'Status'} && ($translation->{'Status'} eq 'obsolete'))
69 71
 };
70 72
 
71 73
 :>
... ...
@@ -1,4 +1,5 @@
1 1
 #! /usr/bin/wml
2
+<: use strict; :>
2 3
 #include "perl-globals.wmi"
3 4
 #include "links.wmi"
4 5
 #include "versions.wmi"
... ...
@@ -23,15 +24,17 @@
23 24
         <td class="banner-left"></td>
24 25
         <td class="banner-middle">
25 26
 	<:
27
+	    my %navigation;
28
+	    my @keys;
26 29
 	    while (@navigation) {
27
-	      $key = shift @navigation;
28
-	      $val = shift @navigation;
30
+	      my $key = shift @navigation;
31
+	      my $val = shift @navigation;
29 32
 	      push @keys, $key;
30 33
 	      $navigation{$key} = $val;
31 34
 	    }
32 35
 
33
-	    for $key (@keys) {
34
-	      $page = $WML_SRC_FILENAME;
36
+	    for my $key (@keys) {
37
+	      my $page = $WML_SRC_FILENAME;
35 38
 	      $page =~ s/\.wml//;
36 39
 	      if ($page ne $key) {
37 40
 	        printf '<a href="%s.html.$(LANG)">%s</a>'."\n", $key, $navigation{$key};
... ...
@@ -43,7 +46,7 @@
43 46
         </td>
44 47
         <td class="banner-right">
45 48
 	<:
46
-	  $page = $WML_SRC_FILENAME;
49
+	  my $page = $WML_SRC_FILENAME;
47 50
 	  $page =~ s/\.wml//;
48 51
 	  for my $dir (sort {$LANGUAGES{$a} cmp $LANGUAGES{$b}} @LANGUAGES) {
49 52
 	    next if $dir eq '$(LANG)';
... ...
@@ -6,8 +6,8 @@
6 6
 #  Xinclude "langlocallinks.$(LANG).wmi"
7 7
 
8 8
 <define-tag page whitespace=delete><:
9
-	$page="%0";
10
-	$lang="$(LANG)";
9
+	my $page="%0";
10
+	my $lang="$(LANG)";
11 11
 	if (-e "$lang/$page.wml") {
12 12
 		print "%0.html.$lang";
13 13
 	} elsif (-e "en/$page.wml") {
... ...
@@ -6,4 +6,5 @@
6 6
 		'de' => "Deutsch",
7 7
 		'it' => "Italiano"
8 8
 		);
9
+	our $WML_SRC_FILENAME;
9 10
 :>
... ...
@@ -10,7 +10,7 @@
10 10
   <div class="bottom" id="bottom">
11 11
      <i><a href="mailto:tor-webmaster@freehaven.net" class="smalllink">Webmaster</a></i> -
12 12
 #     Id: developers.html,v 1.41 2005/08/31 20:19:16 thomass Exp 
13
-      Last modified: <: @stat = stat($(LANG).'/'.$WML_SRC_FILENAME); print scalar localtime($stat[9]); :>
13
+      Last modified: <: my @stat = stat($(LANG).'/'.$WML_SRC_FILENAME); print scalar localtime($stat[9]); :>
14 14
       -
15 15
       Last compiled: <: print scalar localtime(); :>
16 16
 
... ...
@@ -5,7 +5,7 @@
5 5
 # Last-Translator: unknown
6 6
 
7 7
 <:
8
-	@navigation = (
8
+	my @navigation = (
9 9
 		'index'			, 'Home',
10 10
 		'howitworks'		, 'Come Funziona',
11 11
 		'download'		, 'Scarica',
12 12