From 6586626ac878e99b9e3f5f15ac5ec37cd7484831 Mon Sep 17 00:00:00 2001 From: in2 Date: Tue, 16 Dec 2003 06:51:38 +0000 Subject: better big5=>gb2312 implementation git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1415 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- staticweb/article.html | 8 ++++---- staticweb/banner.html | 6 +++--- staticweb/dir.html | 18 +++++++++--------- staticweb/header.html | 2 +- staticweb/index.html | 4 ++-- staticweb/index.pl | 21 +++++++++++++-------- staticweb/man.pl | 16 +++++++++++----- 7 files changed, 43 insertions(+), 32 deletions(-) diff --git a/staticweb/article.html b/staticweb/article.html index 0d7d3e57..1386c3d6 100644 --- a/staticweb/article.html +++ b/staticweb/article.html @@ -1,7 +1,7 @@ [% INCLUDE header.html %]
-[% IF gb %]看板[% ELSE %]狾[% END %]: [% brdname %]
-[% IF gb %]回上页[% ELSE %][% END %]
+狾: [% brdname %]
+

@@ -9,8 +9,8 @@
 

-[% IF gb %]回上页[% ELSE %][% END %]
-[% IF gb %]批踢踢实业坊[% ELSE %]у金金龟穨[% END %] (PttWeb) +
+у金金龟穨 (PttWeb)
diff --git a/staticweb/banner.html b/staticweb/banner.html index 4a8d0678..c6b9688b 100644 --- a/staticweb/banner.html +++ b/staticweb/banner.html @@ -1,10 +1,10 @@ diff --git a/staticweb/dir.html b/staticweb/dir.html index 50f5ef63..2a40ae72 100644 --- a/staticweb/dir.html +++ b/staticweb/dir.html @@ -5,17 +5,17 @@ -[% IF gb %]网页版精华区首页[% ELSE %]呼弘地跋[% END %] -[% brdname %][% IF gb %]精华区首页[% ELSE %]弘地跋[% END %] -[% IF gb %]批踢踢部落格(big5 only)[% ELSE %]у金金场辅[% END %] +呼弘地跋 +[% brdname %]弘地跋 +у金金场辅(big5 only)
-[% IF gb %]看板名称[% ELSE %]狾嘿[% END %]: [% brdname %] +狾嘿: [% brdname %]
[% IF !isroot %] -[% IF gb %]返回上一层[% ELSE %]糷[% END %]
+糷
[% END %] [% FOREACH x=dat %] @@ -28,14 +28,14 @@ [% IF !gb %]
-[% IF gb %]在这个精华区内翻弄[% ELSE %]硂弘地跋ず陆[% END %] +硂弘地跋ず陆 - +
[% END %]
-[% IF gb %]制作时间[% ELSE %]籹丁[% END %]: [% buildtime %]
-[% IF gb %]批踢踢实业坊[% ELSE %]у金金龟穨[% END %] (PttWeb) +籹丁: [% buildtime %]
+у金金龟穨 (PttWeb) diff --git a/staticweb/header.html b/staticweb/header.html index 9683178b..5dc7161b 100644 --- a/staticweb/header.html +++ b/staticweb/header.html @@ -5,7 +5,7 @@ - [% IF gb %]批踢踢实业坊[% ELSE %]у金金龟穨[% END %][% IF exttitle %] - [% exttitle %][% END %] + у金金龟穨[% IF exttitle %] - [% exttitle %][% END %] diff --git a/staticweb/index.html b/staticweb/index.html index 6ad6e831..e13f7d2d 100644 --- a/staticweb/index.html +++ b/staticweb/index.html @@ -5,7 +5,7 @@ -[% IF gb %]批踢踢实业坊之精华区[% ELSE %]у金金龟穨ぇ弘地跋[% END %] +у金金龟穨ぇ弘地跋 [% FOREACH x=class %] »[% x.title %] [% END %] @@ -40,7 +40,7 @@
-[% IF gb %]批踢踢实业坊[% ELSE %]у金金龟穨[% END %] (PttWeb) +у金金龟穨 (PttWeb) diff --git a/staticweb/index.pl b/staticweb/index.pl index d4c9e14c..87c9b5f5 100755 --- a/staticweb/index.pl +++ b/staticweb/index.pl @@ -42,21 +42,17 @@ sub main foreach( @{$brd{$bid}} ){ next if( $_->[0] == -1 && ! -e "$MANDATA/$_->[1].db" ); - b2g::big5togb($_->[2]) if( $rh{gb} ); push @{$rh{dat}}, $_; } my $path = ''; foreach( $ENV{PATH_INFO} =~ m|(\w+)|g ){ - my $t = $brd{"$_.title"}; - b2g::big5togb($t) if( $rh{gb} ); push @{$rh{class}}, {path => "$path/$_/", - title => $t}; + title => $brd{"$_.title"}}; $path .= "/$_"; } $rh{exttitle} = ($rh{class} ? - $rh{class}[ $#{@{$rh{class}}} ]{title} : - ($rh{gb} ? '首页' : '')); + $rh{class}[ $#{@{$rh{class}}} ]{title} : ''); $tmpl = Template->new({INCLUDE_PATH => '.', ABSOLUTE => 0, @@ -64,8 +60,17 @@ sub main RECURSION => 0, EVAL_PERL => 0, COMPILE_EXT => '.tmpl', - COMPILE_DIR => $MANCACHE}); - $tmpl->process('index.html', \%rh); + COMPILE_DIR => $MANCACHE, + }); + if( !$rh{gb} ){ + $tmpl->process('index.html', \%rh); + } + else{ + my $output; + $tmpl->process('index.html', \%rh, \$output); + b2g::big5togb($output); + print $output; + } } main(); diff --git a/staticweb/man.pl b/staticweb/man.pl index 6afb7410..003f7ebf 100755 --- a/staticweb/man.pl +++ b/staticweb/man.pl @@ -59,7 +59,17 @@ sub main $rh->{lang} = 'zh_TW'; $rh->{charset} = 'big5'; } - $tmpl->process($rh->{tmpl}, $rh); + + if( !$rh->{gb} ){ + $tmpl->process($rh->{tmpl}, $rh); + } + else{ + my $output; + $tmpl->process($rh->{tmpl}, $rh, \$output); + b2g::big5togb($output); + print $output; + } + untie %db; } @@ -71,8 +81,6 @@ sub dirmode compress => 0, ); foreach( @{$serial->deserialize($db{$fpath}) || []} ){ - $_->[1] =~ s/([\xA1-\xF9].)/$b2g{$1}/eg if( $isgb ); - #Encode::from_to($_->[1], 'big5', 'gbk') if( $isgb ); $isdir = (($_->[0] =~ m|/$|) ? 1 : 0); push @{$th{dat}}, {isdir => $isdir, fn => "man.pl/$brdname$_->[0]", @@ -108,8 +116,6 @@ sub articlemode $th{content} =~ s|ptt\.twbbs\.org|ptt.twbbs.org|gs; - $th{content} =~ s/([\xA1-\xF9].)/$b2g{$1}/eg if( $isgb ); - #Encode::from_to($th{content}, 'big5', 'gbk') if( $isgb ); return \%th; } -- cgit v1.2.3