summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-12-16 11:05:49 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-12-16 11:05:49 +0800
commit16c3a9991961588f43d6d280cc93317d29d242dc (patch)
tree02c74c7053cca01ce2b723198c6116961e413e17
parentecd00f1452bbfe0305ff6ce46e1436ba4b9f2bd8 (diff)
downloadpttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar
pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar.gz
pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar.bz2
pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar.lz
pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar.xz
pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.tar.zst
pttbbs-16c3a9991961588f43d6d280cc93317d29d242dc.zip
use Compress::Zlib to save disk space
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1413 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rwxr-xr-xstaticweb/man.pl10
-rwxr-xr-xstaticweb/manbuilder.pl13
2 files changed, 18 insertions, 5 deletions
diff --git a/staticweb/man.pl b/staticweb/man.pl
index 4e9c2ed3..6afb7410 100755
--- a/staticweb/man.pl
+++ b/staticweb/man.pl
@@ -12,6 +12,7 @@ use Data::Serializer;
use Time::HiRes qw/gettimeofday tv_interval/;
use b2g;
use POSIX;
+use Compress::Zlib;
use vars qw/%db $brdname $fpath $isgb %b2g/;
@@ -88,7 +89,12 @@ sub articlemode
{
my(%th);
$th{tmpl} = 'article.html';
+
+ # ㄓ unzip, 璶ぃ礛穦年奔 :p
$th{content} = $db{$fpath};
+ $th{content} = Compress::Zlib::memGunzip($th{content})
+ if( $db{_gzip} );
+
$th{content} =~ s/\033\[.*?m//g;
$th{content} =~ s|(http://[\w\-\.\:\/\,@\?=~]+)|<a href="$1">$1</a>|gs;
@@ -98,9 +104,9 @@ sub articlemode
$th{content} =~
s|祇獺: у金金龟穨|祇獺: <a href="http://blog.ptt.cc">у金金龟穨</a>|gs;
$th{content} =~
- s|ptt\.csie\.ntu\.edu\.tw|<a href="telnet://ptt.csie.ntu.edu.tw">ptt.csie.ntu.edu.tw</a>|gs;
+ s|ptt\.cc|<a href="telnet://ptt.cc">ptt.cc</a>|gs;
$th{content} =~
- s|ptt\.twbbs\.org|<a href="telnet://ptt.csie.ntu.edu.tw">ptt.twbbs.org</a>|gs;
+ s|ptt\.twbbs\.org|<a href="telnet://ptt.cc">ptt.twbbs.org</a>|gs;
$th{content} =~ s/([\xA1-\xF9].)/$b2g{$1}/eg if( $isgb );
#Encode::from_to($th{content}, 'big5', 'gbk') if( $isgb );
diff --git a/staticweb/manbuilder.pl b/staticweb/manbuilder.pl
index f3b18cf4..3b992a98 100755
--- a/staticweb/manbuilder.pl
+++ b/staticweb/manbuilder.pl
@@ -7,12 +7,13 @@ use Getopt::Std;
use DB_File;
use BBSFileHeader;
use Data::Serializer;
+use Compress::Zlib;
my(%db, $idx, $serial);
sub main
{
- die usage() unless( getopts('n') || !@ARGV );
+ die usage() unless( getopts('nz') || !@ARGV );
$serial = Data::Serializer->new(serializer => 'Storable',
digester => 'MD5',
@@ -34,6 +35,7 @@ sub main
if( !$Getopt::Std::opt_n );
build("/home/bbs/man/boards/".substr($_, 0, 1)."/$_", '');
$db{_buildtime} = time();
+ $db{_gzip} = 1 if( $Getopt::Std::opt_z );
untie %db;
}
}
@@ -41,9 +43,13 @@ sub main
sub buildidx
{
+ my $gzipped = $db{_gzip};
foreach( keys %db ){
next if( /^title/ || /\/$/ ); # 琌 title ┪ヘ魁常铬筁
- $idx->insert($_, $db{"title-$_"}. "\n". $db{$_});
+ $idx->insert($_,
+ ($db{"title-$_"}. "\n".
+ ($gzipped ? Compress::Zlib::memGunzip($db{$_}) :
+ $db{$_})));
}
}
@@ -69,7 +75,8 @@ sub build($$)
my $c = $bfh{"$_.content"};
$idx->insert("$doffset/$fn", $bfh{"$_.title"}. "\n$c")
if( !$Getopt::Std::opt_n );
- $db{"$doffset/$fn"} = $c;
+ $db{"$doffset/$fn"} = ($Getopt::Std::opt_z ?
+ Compress::Zlib::memGzip($c) : $c);
}
}
$db{"$doffset/"} = $serial->serialize(\@tdir);