aboutsummaryrefslogtreecommitdiffstats
path: root/english/template/debian/release.wml
blob: fea04ceaf7662924a469ce2045147edccec70b5f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#use wml::std::tags
#use wml::debian::languages

<define-tag name_for_arch whitespace=delete>
# given a manual name and an architecture, join them
# if you need to reorder the two, use "%2$s ... %1$s", cf. printf(3)
  <gettext><void id="doc_for_arch" />%s for %s</gettext>
</define-tag>

#<define-tag installationguide whitespace=delete>
## the non-generic name of the document that contains the installation manual
#  <gettext>Installation Guide</gettext>
#</define-tag>
#<define-tag releasenotes whitespace=delete>
## the non-generic name of the document that contains the release notes
#  <gettext>Release Notes</gettext>
#</define-tag>

<perl>
#
# emits a bunch of li (list items)
#   assumes %arches, @arches and $indirect_object_conjoiner
#
sub permute_as_list {
    my($file, $name, @noarches) = @_;
    my($print, $arch, $noarch);

#    if ($name eq 'Release Notes') {
#      $name = q{<releasenotes>};
#    elsif ($name eq 'Installation Guide') {
#      $name = q{<installationguide>};
#    }

    @arches || die "@arches is not set\n";

    foreach $arch (@arches) {
      $print = 1;
      if ( $#noarches != -1 ) {
	foreach $noarch (@noarches) {
	  $print = 0 if ( $arch eq $noarch );
	}
      }
      if ( $print == 1 ) {
	print "<li> <a href=\"$arch/$file\">";
	printf q{<name_for_arch>}, $name, $arches{$arch};
	print "</a>";
	print "\n";
      }
    }
}

#
# emits an HTML table matrix:
#   | arch | format | lang1, lang2, lang3 |
#   assumes %arches, @arches and %formats
#
sub permute_as_matrix {
    my($file, @langs) = @_;
    my($ext, $arch, $lang, $l10nlang, @cur_dir, $release);
    # my $altcolor = 'white';
    my $ctr = 0;
    my $check_if_file_exists = 0;

    @cur_dir = split('/', '$(WML_SRC_DIRNAME)');
    $release = pop @cur_dir;

    @arches || die "@arches is not set\n";
    %formats || die "%formats is not set\n";

    if ($file =~ /release-notes/) {
      # these two releases had installmanual.*.pdf but no release-notes.*.pdf
      if ($release eq 'slink' or $release eq 'potato') {
        delete $formats{'pdf'};
      };
    };

    my %sorted_langs = ();
    foreach (@langs) {
      $sorted_langs{$trans{$(CUR_ISO_LANG)}{$_}} = $_;
    }
    foreach $arch (@arches) {
	$ctr++;
	my $first = 1;

	foreach $ext (keys %formats) {
	    if ($check_if_file_exists && 
                ! -f "$(HTMLDIR)/releases/$release/$arch/$file.en.$ext") {
	        next;
	    }
	    # alternate the row color
	    if ( $ctr % 2 ) {
		print "\n<tr class=\"even\">\n";
	    } else {
		print "\n<tr class=\"odd\">\n";
	    }
	    # only print the arch name on the first row
	    if ( $first == 1 ) {
		if ($file =~ /release-notes/) {
		    print "  <td align=\"left\"><a href=\"$arch/$file/\">" . $arches{$arch} . "</a></td>\n";
		} else {
		    print "  <td align=\"left\"><a href=\"$arch/$file\">" . $arches{$arch} . "</a></td>\n";
		}
		$first = 0;
	    } else {
		print "  <td>&nbsp;</td>\n";
	    }
	    print "  <td align=\"left\">" . $formats{$ext} . "</td>\n";
	    # permute over languages
	    print "  <td>";
	    foreach $l10nlang (sort langcmp keys %sorted_langs) {
	        $lang = $sorted_langs{$l10nlang};
	        next if ($ext eq "pdf" && $lang eq "japanese");
	        next if ($ext eq "pdf" && $lang eq "russian");
	        $file_version = "$arch/$file." . $langsinstall{$lang} . ".$ext";
	        if ( $file =~ /release-notes/ && $ext eq "html" ) {
		   # convert languages with sublangs (zh_TW -> zh-tw)
		   (my $html_lang = $langsrelnotes{$lang}) =~ s/(\w\w)_(\w\w)/"$1-".lc($2)/e;
	           $file_version = "$arch/$file/index." . $html_lang . ".$ext";
	        }
		elsif ( $file =~ /release-notes/ && (($ext eq "txt") || ($ext eq "pdf"))) {
		   $file_version = "$arch/$file." . $langsrelnotes{$lang} . ".$ext";
		}
	        if (! $check_if_file_exists || 
                    -f "$(HTMLDIR)/releases/$release/$file_version") {
	            # all languages should be defined in %trans. Add missing entries 
	            # in English if this is not the case
		    print "<strong>" if $lang eq lc($CUR_LANG);
	            print "<a href=\"$file_version\">" . $trans{$CUR_ISO_LANG}{$lang} . "</a>";
		    print "</strong>" if $lang eq lc($CUR_LANG);
		    print " \n";
	        }
	    }
	    print "  </td>";
	    print "</tr>\n";
	    
	}
    }
}

sub permute_as_matrix_new {
    my %options = @_;
    my $file = $options{file}
        or die "permute_as_matrix: file argument is required";
    my $html_file = $options{html_file} || $file;
    my %langs = %{$options{langs}}
        or die "permute_as_matrix: langs argument is required";
    my @arches = @{$options{arches}}
        or die "permute_as_matrix: arches argument is required";
    my %formats = %{$options{formats}}
        or die "permute_as_matrix: formats argument is required";
    my %missing = map { $_ => 1 } @{$options{missing}};

    # my $altcolor = $options{altcolor} || 'white';
    my $namingscheme = $options{namingscheme}
        || sub { join('.',@_);
    }; # name, lang, ext
    my $dirmode = $options{dirmode};
    my $check_if_file_exists = exists $options{checkfiles} ?
	$options{checkfiles} : 1;

    my ($ext, $arch, $lang, $l10nlang, @cur_dir, $release);
    @cur_dir = split('/', '$(WML_SRC_DIRNAME)');
    $release = pop @cur_dir;

    my $ctr = 0;
    my $targetdir = "$(HTMLDIR)/releases/$release";

    my %sorted_langs = ();
    foreach (keys %langs) {
      $sorted_langs{$trans{$(CUR_ISO_LANG)}{$_}} = $_;
    }
    foreach $arch (@arches) {
	$ctr++;
	my $first = 1;

	foreach $ext (sort keys %formats) {
	    my $targetfile = "$arch/".(($ext eq 'html') ? $html_file : $file);
	    if ($check_if_file_exists && 
                ! -f &$namingscheme( "$targetdir/$targetfile", 'en', $ext ) ) {
	        next;
	    }
	    # alternate the row color
	    if ( $ctr % 2 ) {
		print "\n<tr class=\"even\">\n";
	    } else {
		print "\n<tr class=\"odd\">\n";
	    }
	    # only print the arch name on the first row
	    if ( $first == 1 ) {
		print "  <td align=\"left\"><a href=\"$arch/$html_file\">" . $arches{$arch} . "</a></td>\n";
		$first = 0;
	    } else {
		print "  <td>&nbsp;</td>\n";
	    }
	    print "  <td align=\"left\">" . $formats{$ext} . "</td>\n";
	    # permute over languages
	    print "  <td>";
	    foreach $l10nlang (sort langcmp keys %sorted_langs) {
	        $lang = $sorted_langs{$l10nlang};
	        next if exists $missing{"$lang:$ext"};
	        $file_version = &$namingscheme( $targetfile,
						$langs{$lang}, $ext );
		# convert languages with sublangs (zh_TW -> zh-tw)
		(my $lang_alt = $langs{$lang}) =~ s/(\w\w)_(\w\w)/"$1-".lc($2)/e;
	        my $file_version_alt = &$namingscheme( $targetfile,
						       $lang_alt, $ext );
		if( $check_if_file_exists &&
		    ! -f "$targetdir/$file_version" &&
		    -f "$targetdir/$file_version_alt" ) {
		    $file_version = $file_version_alt;
		}
	        if (! $check_if_file_exists || 
                    -f "$targetdir/$file_version") {
	            # all languages should be defined in %trans. Add missing entries 
	            # in English if this is not the case
		    print "<strong>" if $lang eq lc($CUR_LANG);
	            print "<a href=\"$file_version\">" . $trans{$CUR_ISO_LANG}{$lang} . "</a>";
		    print "</strong>" if $lang eq lc($CUR_LANG);
		    print " \n";
	        }
	    }
	    print "  </td>";
	    print "</tr>\n";
	    
	}
    }
}


</perl>

© 2014-2024 Faster IT GmbH | imprint | privacy policy