#!/usr/bin/perl
#
# display translation status.
#

use CGI;

$kauthorsent="build/doc/ko_KR.eucKR/books/handbook/kauthors.ent";
%anames=();
%aemail=();

$drophead="doc/ko_KR.eucKR/";

# read author entry.
open (KAUTHORS, $kauthorsent);
while (<KAUTHORS>)
{
  next unless /^<!ENTITY ([a-z\.]+) \"(.+)\s<email>(.*)<\/email>\">/;

  if ($1 ne "") {
#    print "$1 $2 $3\n";
    $anames{$1}=$2;
    $aemail{$1}=$3;
  }
}
close KAUTHORS;

@handbook=split(/[\s\n]/, `find build/doc/ko_KR.eucKR/books/handbook -type f \\( -name '*.sgml' -o -name '*.ent' \\)`);

use CGI;

$q = new CGI;


print $q->header(-type=>"text/html", -charset=>"euc-kr");

cat_file("/kfug/www/htdocs/prefix/header-cgi.html");

cat_file("/kfug/www/htdocs/projects/doc-kr/menu.shtml");

print "<h2 align=\"center\"><font color=\"#000080\">¹ø¿ª »óÈ²Ç¥</font></h2>

¾Æ·¡ Ç¥´Â doc-kr ÇÁ·ÎÁ§Æ®ÀÇ ´ë»óÀÌ µÇ´Â ¿©·¯ ¹®¼­ ÆÄÀÏÀÇ ¹ø¿ª ¿©ºÎ¿Í
¹ø¿ªÀÚ, ±×¸®°í ¹ø¿ªÁßÀÎ ¿ø¹®ÀÇ ¹öÀüÀ» ³ªÅ¸³À´Ï´Ù. °¢ ¸µÅ©¸¦ Å¬¸¯ÇÏ¸é
ÇØ´ç ÆÄÀÏÀ» º¼ ¼ö ÀÖ½À´Ï´Ù.<p>\n";
print "<center><table border width=100%>
<tr bgcolor=#ddddff>
  <th>ÆÄÀÏ¸í</th>
  <th>¹ø¿ªÀÚ</th>
  <th>¿ø¹® ¹öÀü</th>
  <th>»óÈ²</th>
</tr>\n";
 
$afound=0;
$astat="¹ø¿ª¾ÈµÊ";
foreach $f (@handbook)
{
  print "<tr>\n";

  $sf=$f;
  $sf=~s/^build\/$drophead//g;
  print "<td><a href=\"http://www.kr.freebsd.org/cgi-bin/cvsweb.cgi/$drophead\/$sf?cvsroot=kfug\">$sf</a></td>\n";
  
  print "<td>";
  open(DOCFILE, $f);
  while(<DOCFILE>)
  {
     if (/\$FreeBSD.*,v\s([0-9\.]+)/){
       $over=$1;
     }
     if (/\$Id.*,v\s([0-9\.]+)/){
       $tver=$1;
     }
     if (/&(a\.kr\.[a-z]+)/){
       print "<a href=\"mailto:$aemail{$1}.no-spam\">$anames{$1}</a> ";
       $afound=1;
       $astat="¹ø¿ªÁß";
       last;
     }
  }
  close($f);
  if ($afound == 0){
    print "¾øÀ½";
  }
  $afound=0;
  print "</td>";

  $of=$f;
  $of=~s/^build\///g;
  $of=~s/ko_KR\.eucKR/en_US\.ISO_8859-1/;
  print "<td>$over [<a href=\"http://www.kr.freebsd.org/cgi-bin/cvsweb.cgi/$of?rev=$over&content-type=text/x-cvsweb-markup\">¿ø¹®º¸±â</a>]</td>";

  # status should be improved...
  print "<td>$astat</td>\n";
  $astat="¹ø¿ª¾ÈµÊ";

  print "</tr>";
}
print "</table></center>";

cat_file("/kfug/www/htdocs/prefix/tailer-cgi.html");

sub cat_file
{
  my $path=$_[0];

  open(CAT_PATH, $path);
  while(<CAT_PATH>){
    print $_;
  }
  close(CAT_PATH);
}
