From 1880cc2f73e5094ee203416552493f783ed24258 Mon Sep 17 00:00:00 2001 From: in2 Date: Sat, 5 Jul 2003 05:19:18 +0000 Subject: gb support git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1022 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- staticweb/article.html | 8 ++++---- staticweb/dir.html | 20 ++++++++++---------- staticweb/header.html | 8 ++++---- staticweb/index.html | 10 +++++----- staticweb/index.pl | 16 +++++++++++++--- staticweb/man.pl | 33 +++++++++++++++++++++++++-------- 6 files changed, 61 insertions(+), 34 deletions(-) (limited to 'staticweb') diff --git a/staticweb/article.html b/staticweb/article.html index 706626a0..0d7d3e57 100644 --- a/staticweb/article.html +++ b/staticweb/article.html @@ -1,7 +1,7 @@ [% INCLUDE header.html %]
-狾: [% brdname %]
-
+[% IF gb %]看板[% ELSE %]狾[% END %]: [% brdname %]
+[% IF gb %]回上页[% ELSE %][% END %]

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

-
-у金金龟穨 (PttWeb) +[% IF gb %]回上页[% ELSE %][% END %]
+[% IF gb %]批踢踢实业坊[% ELSE %]у金金龟穨[% END %] (PttWeb)
diff --git a/staticweb/dir.html b/staticweb/dir.html index a70d9a04..6b626a93 100644 --- a/staticweb/dir.html +++ b/staticweb/dir.html @@ -4,39 +4,39 @@ -呼弘地跋 -[% brdname %]弘地跋 -у金金场辅 +[% IF gb %]网页版精华区首页[% ELSE %]呼弘地跋[% END %] +[% brdname %][% IF gb %]精华区首页[% ELSE %]弘地跋[% END %] +[% IF gb %]批踢踢部落格(big5 only)[% ELSE %]у金金场辅[% END %]
-狾嘿: [% brdname %] +[% IF gb %]看板名称[% ELSE %]狾嘿[% END %]: [% brdname %]
[% IF !isroot %] -糷
+[% IF gb %]返回上一层[% ELSE %]糷[% END %]
[% END %] [% FOREACH x=dat %] - + [% x.title %]
[% END %]
-硂弘地跋ず陆 +[% IF gb %]在这个精华区内翻弄[% ELSE %]硂弘地跋ず陆[% END %] - +

-у金金龟穨 (PttWeb) +[% IF gb %]批踢踢实业坊[% ELSE %]у金金龟穨[% END %] (PttWeb) diff --git a/staticweb/header.html b/staticweb/header.html index 465e9ff7..7f33ab66 100644 --- a/staticweb/header.html +++ b/staticweb/header.html @@ -1,13 +1,13 @@ - + + xml:lang="[% lang %]" lang="[% lang %]"> - у金金龟穨 + [% IF gb %]批踢踢实业坊[% ELSE %]у金金龟穨[% END %] + content="text/html; charset=[% charset %]"> diff --git a/staticweb/index.html b/staticweb/index.html index d0722654..a9f37606 100644 --- a/staticweb/index.html +++ b/staticweb/index.html @@ -4,22 +4,22 @@ -у金金龟穨ぇ弘地跋(experimental)
-ヘ玡矗ㄑ弘地跋戈:
+[% IF gb %]批踢踢实业坊之精华区[% ELSE %]у金金龟穨ぇ弘地跋[% END %](experimental)
+[% IF gb %]目前提供下列精华区资料[% ELSE %]ヘ玡矗ㄑ弘地跋戈[% END %]:

[% FOREACH x=dat %] -[% x.brdname %]
+[% x.brdname %]
[% END %]
-у金金龟穨 (PttWeb) +[% IF gb %]批踢踢实业坊[% ELSE %]у金金龟穨[% END %] (PttWeb) diff --git a/staticweb/index.pl b/staticweb/index.pl index 2fcd7e30..71ad6117 100755 --- a/staticweb/index.pl +++ b/staticweb/index.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: index.pl,v 1.2 2003/07/04 05:59:05 in2 Exp $ +# $Id: index.pl,v 1.3 2003/07/05 05:19:18 in2 Exp $ use lib qw/./; use LocalVars; use CGI qw/:standard/; @@ -10,8 +10,18 @@ sub main { my($tmpl, %rh); - print redirect("/man.pl/$1/") - if( $ENV{REDIRECT_REQUEST_URI} =~ m|/\?(.*)| ); + if( param('gb') ){ + $rh{gb} = 1; + $rh{encoding} = 'gb2312'; + $rh{lang} = 'zh_CN'; + $rh{charset} = 'gb2312'; } + else{ + print redirect("/man.pl/$1/") + if( $ENV{REDIRECT_REQUEST_URI} =~ m|/\?(.*)| ); + $rh{encoding} = 'Big5'; + $rh{lang} = 'zh_TW'; + $rh{charset} = 'big5'; + } charset(''); print header(); diff --git a/staticweb/man.pl b/staticweb/man.pl index 28d21ae0..0baa69be 100755 --- a/staticweb/man.pl +++ b/staticweb/man.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: man.pl,v 1.4 2003/07/04 05:58:45 in2 Exp $ +# $Id: man.pl,v 1.5 2003/07/05 05:19:18 in2 Exp $ use CGI qw/:standard/; use lib qw/./; use LocalVars; @@ -11,7 +11,8 @@ use Template; use HTML::Calendar::Simple; use OurNet::FuzzyIndex; use Data::Serializer; -use vars qw/%db $brdname $fpath/; +use Encode; +use vars qw/%db $brdname $fpath $isgb/; sub main { @@ -26,6 +27,7 @@ sub main return; } + $isgb = (param('gb') ? 1 : 0); charset(''); print header(); @@ -41,21 +43,34 @@ sub main RELATIVE => 0, RECURSION => 0, EVAL_PERL => 0, - COMPILE_EXT => '.tmpl', - COMPILE_DIR => $MANCACHE}); +# COMPILE_EXT => '.tmpl', +# COMPILE_DIR => $MANCACHE, + }); + if( $rh->{gb} = $isgb ){ + $rh->{encoding} = 'gb2312'; + $rh->{lang} = 'zh_CN'; + $rh->{charset} = 'gb2312'; + } + else{ + $rh->{encoding} = 'Big5'; + $rh->{lang} = 'zh_TW'; + $rh->{charset} = 'big5'; + } $tmpl->process($rh->{tmpl}, $rh); } sub dirmode { - my(%th); + my(%th, $isdir); my $serial = Data::Serializer->new(serializer => 'Storable', digester => 'MD5', compress => 0, ); foreach( @{$serial->deserialize($db{$fpath})} ){ - push @{$th{dat}}, {isdir => (($_->[0] =~ m|/$|) ? 1 : 0), - fn => "/man.pl/$brdname$_->[0]", + Encode::from_to($_->[1], 'big5', 'gb2312') if( $isgb ); + $isdir = (($_->[0] =~ m|/$|) ? 1 : 0); + push @{$th{dat}}, {isdir => $isdir, + fn => "man.pl/$brdname$_->[0]", title => $_->[1]}; } @@ -71,7 +86,7 @@ sub articlemode $th{content} = $db{$fpath}; $th{content} =~ s/\033\[.*?m//g; - $th{content} =~ s|(http://[\w\-\.\:\/\,@]+)|$1|gs; + $th{content} =~ s|(http://[\w\-\.\:\/\,@\?=]+)|$1|gs; $th{content} =~ s|(ftp://[\w\-\.\:\/\,@]+)|$1|gs; $th{content} =~ s|у金金ㄟ|у金金ㄟ|gs; @@ -81,6 +96,8 @@ sub articlemode s|ptt\.csie\.ntu\.edu\.tw|ptt.csie.ntu.edu.tw|gs; $th{content} =~ s|ptt\.twbbs\.org|ptt.twbbs.org|gs; + + Encode::from_to($th{content}, 'big5', 'gb2312') if( $isgb ); return \%th; } -- cgit v1.2.3