#use wml::std::tags #use wml::debian::openrecode use Cwd; use Encode; # Very similar to get_recent_list except it looks for the .wml files # inside subdirectories of the given directory, and if it finds less than # 10, falls back to last year's news for the rest. sub get_weeklynews_list { my ($year, $eng_dir, $match, $noyear, $count, $stopat, $reccount, $trans_dir) = @_; # trans_dir should point to dir above the year dir if ($noyear) { $trans_dir ||= '..'; } else { $trans_dir ||= '.'; } my $cwd = getcwd(); if ($count || ($cwd =~ m,/\d+$, && $cwd !~ m,/$year$,)) { $dirprefix = "../" . $year . "/"; } my $str=""; open(CURRENT, "CURRENT-ISSUE-IS") or open(CURRENT, "$eng_dir/CURRENT-ISSUE-IS") or return ''; my $currentissue=;# chomp $currentissue; my ($currentyear)=$currentissue=~m:^(\d+)/:; # Handle main index before the 1st issue of the year if ($year > $currentyear){ $year = $currentyear; $currentissue = '99'; } $currentissue=~s:^\d+/::; close CURRENT; opendir(DIR, "$eng_dir/$year") or return ''; @files = grep { /^$match$/ && -f "$eng_dir/$year/$_/index.wml" } readdir(DIR); closedir DIR; foreach (sort {$b <=> $a} @files) { next if $year == $currentyear && $_ > $currentissue; # skip issues in preparation. $_="$_/index.wml"; $trans_title = $_; $trans_title =~ s/wml/title/; ($base)=m:(.*/):; my $fh = openrecode("$trans_dir/$year/$_", "$trans_dir/$year/$trans_title", "$eng_dir/$year/$_"); $title = ''; $summary = ''; $line=Encode::decode_utf8(<$fh>); $line=Encode::decode_utf8(<$fh>) if $line =~ m/use wml::debian::translation-check/; if ($line =~ /PUBDATE="(.*?)"/) { $title=newsdate(Encode::encode_utf8($1)); } if ($line =~ /SUMMARY="(.*?)"/) { $summary=Encode::encode_utf8($1); } if ($title) { $str.="$title $summary
\n"; } close $fh; $count++; last if ($stopat ne '' && $count >= $stopat); } close DIR; # Get more if necessary. if (!$noyear && $count < 10 && $reccount < 3 ) { $str.=get_weeklynews_list($year - 1, $eng_dir, $match, $noyear, $count, 10, $reccount++); } return $str; }