#use wml::debian::common_tags #use wml::debian::openrecode # this file is a modified version from recent_list.wml for use with users/ # get_users_list($eng_dir, $rel_path, $format, $match) # # get_users_list grabs title of all files from directory $rel_path. # # The format parameter specifies the type of output: numbered, definition # and bulleted list, a table, or a RDF file (rdf, rdflong, or rfsseq). # RDF output is currently only supported for DSAs. # # The match parameter is a regexp used to determine if the file should be # parsed. use Encode; my $listhead = ''; my $elemhead = '
  • '; my $elemfoot = '
  • ';
    sub get_users_list { my ($eng_dir, $rel_path, $match) = @_; opendir DIR, "$eng_dir/$rel_path/" or do { warn "couldn't open dir $eng_dir/$rel_path: $!\n"; return; }; my @files = grep { /^$match.wml$/ && -f "$eng_dir/$rel_path/$_" } readdir(DIR); closedir DIR; @files = sort {lc($a) cmp lc($b)} @files; #warn "files: " . join " ", @files; warn "\n"; #warn "eng_dir=$eng_dir rel_path=$rel_path match=$match\n"; my $str = grab_titles($eng_dir, $rel_path, $match , @files); $str = "$listhead$str$listfoot"; #warn "$str\n"; return $str; } # grab_titles is an auxiliary function to get_users_list, which actually # does the real work. sub grab_titles { my ($eng_dir, $rel_path, $match, @files) = @_; my $str = ""; foreach $file (@files) { (my $trans_title = $file) =~ s/wml$/title/; my $base = $1 if ($file =~ m|^([[:alpha:]./]*(\d{4})?/(?:$match)).wml|); #warn "$file -> $base\n"; # read file in my $fh = openrecode("$rel_path/$file", "$rel_path/$trans_title", "$eng_dir/$rel_path/$file") or die "couldn't open $eng_dir/$rel_path/$file: $!\n"; my $content; { local $/; $content = Encode::decode_utf8(<$fh>); } close $fh; my ($title, $webpage); if ($content =~ /^\s*(.*?)\s*<\/define-tag>/ms) { $title = Encode::encode_utf8(qq/$1/); } if ($content =~ /^\s*(.*?)\s*<\/define-tag>/ms) { $webpage = Encode::encode_utf8(qq/$1/); } my ($shortfile) = $file =~ /^(?:.*\/)?(.*)\.wml$/; #$eng_dir =~ /^(?:.*\/)?(.*)$/; $str .= "$elemhead$title$elemfoot\n"; } # for each file return $str; }
    # # vim:ts=8:sw=4: #