Index: head/ja_JP.eucJP/htdocs/ports/portindex =================================================================== --- head/ja_JP.eucJP/htdocs/ports/portindex (revision 49769) +++ head/ja_JP.eucJP/htdocs/ports/portindex (revision 49770) @@ -1,406 +1,392 @@ #!/usr/bin/perl # convert a ports INDEX file to XML files # # by John Fieber # Mon May 13 10:31:58 EST 1996 # $FreeBSD$ # The FreeBSD Japanese Documentation Project -# Original revision: 1.57 +# Original revision: r47265 ############################################################ use strict; use POSIX; use IO::File; my $base = ""; my $baseHTTP = ""; my $urlcgi = ""; my $packagesURL = ""; my $today = getdate(); my %p = (); # Load local config file. You can override in portindex.conf # the variables for the default web and the ftp server. This # make it easy to maintain a local web mirror and let the # URL point to yourself and not to the standard FreeBSD FTP server. my $config = $0 . '.' . 'conf'; do $config if -f $config; # This is the base of where we ftp stuff from my $ftpserver; if ($ENV{'MASTER_FTP_SERVER'}) { $ftpserver = $ENV{'MASTER_FTP_SERVER'}; } else { $ftpserver = 'ftp://ftp.FreeBSD.org' if !$ftpserver; } -$baseHTTP = $base if !$baseHTTP; my $baseFTP = "$ftpserver/pub/FreeBSD/ports/ports"; -my $baseCVSWEB = 'http://www.FreeBSD.org/cgi/cvsweb.cgi/'; -$urlcgi = 'http://www.FreeBSD.org/cgi/url.cgi' if !$urlcgi; +my $baseSVNWEB = 'https://svnweb.FreeBSD.org/ports/head/'; $packagesURL = "$ftpserver/pub/FreeBSD/ports/i386/packages-stable/All/" if !$packagesURL; # support tar on the fly or gzip'ed tar on the fly my $ftparchive = ''; $ftparchive = '.tar' if !defined $ftparchive; -# ports download sources script -my $pds = 'http://www.FreeBSD.org/cgi/pds.cgi'; - -# better layout and link to the sources -if ($urlcgi) { - $baseHTTP = $urlcgi . '?' . $baseHTTP; -} - my %packages = (); my %category_description = (); my @category_groups = (); my %category_groups = (); packages_exist('packages.exists'); category_description(($ARGV[1] || '.') . '/categories' ); category_groups(($ARGV[1] || '.') . '/categories.descriptions' ); main(); sub getdate { # return ": $year 年 $mon 月 $mday 日"; return POSIX::strftime("%d-%B-%Y", localtime); } sub header { my $fh = shift; my $htext = shift; #local($fh, $htext) = @_; print $fh < %ports.ent; %statistics.ent; ]> $htext x x x $today x x x &searchform;
EOF } sub footer { my $fh = shift; my $ftext = shift; #local ($fh, $ftext) = @_; print $fh < EOF } sub packages_exist { my $file=shift; my %p; #local($file, *p) = @_; open(P, $file) || do { warn "open $file: $!\n"; warn "Cannot create packages links\n"; return 1; }; while(

) { chop; $packages{$_} = 1; } close P; } sub category_description { my $file = shift; open(P, $file) || do { warn "open $file: $!\n"; warn "Cannot find category description\n"; return 1; }; while(

) { # ignore comments next if /^\s*#/; if (/^\s*([^,]+),\s*"([^"]+)",\s*([A-Z]+)/) { $category_description{$1}{desc}=$2; $category_description{$1}{group}=$3; } } close P; } sub category_groups { my $file = shift; open(P, $file) || do { warn "open $file: $!\n"; warn "Cannot find category groups\n"; return 1; }; while(

) { # ignore comments next if /^\s*#/; if (/^\s*([^,]+),\s*(.+)/) { $category_groups{$1}=$2; push(@category_groups,$1); } } close P; } sub main { my @master=(); my %stats; my %catkey; my %data; my %descLANG; my $portnumber = 0; my $sep = ":"; my $moutf = new IO::File; my $outf = new IO::File; my $mindex = new IO::File; my $statistics = new IO::File; my $lloc; # 'COMMENT' translation database if (open(COMF, "comments.ja")) { while () { ($a, $b) = split('\|'); next if !defined($b); chop($b); $b =~ s/&/&/g; $b =~ s//>/g; $descLANG{$a} = $b; } } open(INDEX, $ARGV[0]); $portnumber = "0"; while () { chop; s/&/&/g; s//>/g; # Read a record my ($name, $loc, $prefix, $desc, $ldesc, $owner, $cats, $bdep, $rdep, $www) = split('\|'); # Check for double hyphens in the name (--). $name =~ s/--/-/g; # Split the categories into an array my @cat = split("[ \t]+", $cats); $catkey{$name} = $cat[0]; - my $sourcepath = $loc; - $sourcepath =~ s%/usr/%%; - # desc translation ($lloc = $loc) =~ s@^/usr/ports/@@; $desc = $descLANG{$lloc} if ($descLANG{$lloc} ne ''); foreach my $i (sort(@cat)) { $stats{$i}++; # figure out the FTP url - $loc =~ s/\/usr\//$baseCVSWEB/; - $ldesc =~ s/\/usr\//$baseHTTP/; + $loc =~ s%/usr/ports/%$baseSVNWEB%; + $ldesc =~ s%/usr/ports/%$baseSVNWEB%; + $ldesc .= '?revision=HEAD'; # The name description and maintainer $name =~ s/,.*//g; $name =~ s/\++//g; $data{$i} .= "

$name
"; $data{$i} .= "
$desc
詳しい説明"; if ($packages{"$name.tbz"}) { $data{$i} .= qq{ | パッケージ}; } elsif ($packages{"$name.tgz"}) { $data{$i} .= qq{ | パッケージ}; } - $data{$i} .= qq{ | ソース}; + $data{$i} .= qq{ | 変更点}; if ($www ne "") { - $data{$i} .= qq{ | Main Web Site}; + $data{$i} .= qq{ | メインウェブサイト}; } my $ownerurl = $owner; $ownerurl =~ s/<//g; $data{$i} .= "
保守担当者: $owner"; # If there are any dependencies, list them if ($bdep ne "" || $rdep ne "") { $data{$i} .= "
必要なもの: "; my @dep = split(/ /, "$bdep $rdep"); my $last = ''; foreach my $j (sort @dep) { next if $j eq $last; $last = $j; $data{$i} .= " $j,"; } # remove the trailing comma chop $data{$i}; } # If the port is listed in more than one category, throw # in some cross references if ($#cat > 0) { $data{$i} .= "
ここにも含まれています: "; foreach my $j (@cat) { if ($j ne $i) { if ($j eq $cat[0]) { $data{$i} .= " \u$j,"; } else { $data{$i} .= " \u$j,"; } } } # remove the trailing comma chop($data{$i}); } $data{$i} .= "

\n" } # Add an entry to the master index - # workaround for XML syntax, `--' is not allowed in comments + # workaround XML syntax, `--' is not allowed in comments my $sname = $name; $sname =~ s/--/-=/g; $master[$portnumber] = "$name " . " -- $desc
\n"; $portnumber++; } # create categories-grouped.xml and .xml $moutf->open(">categories-grouped.xml"); header($moutf, "FreeBSD Ports -- グループによる分類"); print $moutf < EOF if ($portnumber eq '0') { print $moutf "

none found

\n"; } else { foreach my $cg (@category_groups) { print $moutf "

",$category_groups{$cg},"

\n"; print $moutf "
    \n"; foreach my $key (sort(keys(%stats))) { next if ($category_description{$key}{group} ne $cg); # For the master file... print $moutf "
  • \u$key ($stats{$key})"; if ($category_description{$key}{desc}) { print $moutf " -- " . $category_description{$key}{desc}; } + # Someone forgot to add a category to the description file # or there is a typo in the category field. else { warn "No description found for category: ``$key''!\n"; warn "Please fix me or send an E-Mail to doc\@FreeBSD.org\a\n"; sleep(3); } print $moutf "
  • \n"; - # Create the category file $outf->open(">$key.xml"); header($outf, "FreeBSD Ports: \u$key"); if ($category_description{$key}{desc}) { print $outf "

    ", $category_description{$key}{desc}, "

    \n"; } print $outf "
    \n"; my $d = join("\n", sort(split(/\n/, $data{$key}))); $d =~ s/##([^#]*)##/$catkey{$1}/g; print $outf $d; print $outf "
    \n"; footer($outf, "

    top" . " -- Index"); $outf->close; } print $moutf "
\n"; } } footer($moutf, ""); $moutf->close; # create categories-alpha.xml $moutf->open(">categories-alpha.xml"); header($moutf, "FreeBSD Ports -- アルファベット順"); print $moutf < EOF if ($portnumber eq '0') { print $moutf "

none found

\n"; } else { print $moutf "
    \n"; foreach my $key (sort(keys(%stats))) { print $moutf - "
  • \u$key ($stats{$key})\n"; + "
  • \u$key ($stats{$key})"; if ($category_description{$key}{desc}) { print $moutf " -- " . $category_description{$key}{desc}; } print $moutf "
  • \n"; } print $moutf "
\n"; } footer($moutf, ""); $moutf->close; # Create master-index.xml $mindex->open(">master-index.xml"); header($mindex, "FreeBSD Ports Collection 一覧"); print $mindex "

\n"; print $mindex sort @master; print $mindex "

"; footer($mindex, "top"); $mindex->close; # Create statistics.ent - $statistics->open(">statistics.ent"); - print $statistics "\n"; - $statistics->close; + close(INDEX); }