diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-03-29 11:48:13 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-03-29 11:48:13 +0800 |
commit | 6dfdfa5f38690608af3c892f231d98c6bc6df2d4 (patch) | |
tree | 0fa1e86f1921adef2ca72246018aea1751439fc1 | |
parent | 5bf761730f13f5e967e76a4fc729fb93406cf06e (diff) | |
download | pttbbs-6dfdfa5f38690608af3c892f231d98c6bc6df2d4.tar pttbbs-6dfdfa5f38690608af3c892f231d98c6bc6df2d4.tar.gz pttbbs-6dfdfa5f38690608af3c892f231d98c6bc6df2d4.tar.bz2 pttbbs-6dfdfa5f38690608af3c892f231d98c6bc6df2d4.tar.lz pttbbs-6dfdfa5f38690608af3c892f231d98c6bc6df2d4.tar.xz pttbbs-6dfdfa5f38690608af3c892f231d98c6bc6df2d4.tar.zst pttbbs-6dfdfa5f38690608af3c892f231d98c6bc6df2d4.zip |
wiki like support
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1624 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rwxr-xr-x | blog/blog.pl | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/blog/blog.pl b/blog/blog.pl index 8126bc6f..3f851d3b 100755 --- a/blog/blog.pl +++ b/blog/blog.pl @@ -15,6 +15,7 @@ use POSIX; use MD5; use Mail::Sender; use Data::Serializer; +use Encode; use vars qw/@emonth @cnumber %config %attr %article %th $dbh $brdname/; @@ -322,13 +323,14 @@ $comment compress => 0, ); open FH, '<'.$attr{"$fn.loadSerialized"}; - FH->read($str, 104857600); + FH->read($str, -s $attr{"$fn.loadSerialized"}); close FH; %h = %{$obj->deserialize($str)}; $th{$_} = $h{$_} foreach( keys %h ); } # ¥Î Template Toolkit ¿é¥X + $th{LANG} =~ s/zh_TW/zh-TW/; mkdir "$BLOGCACHE/$brdname"; $tmpl = Template->new({INCLUDE_PATH => '.', ABSOLUTE => 0, @@ -349,6 +351,17 @@ $comment undef $tmpl; } +sub utf8dump($;$) +{ + my($str, $prefix) = @_; + my $ret = $prefix || ''; + my $ostr = $str; + Encode::from_to($str, 'big5', 'utf-8'); + $ret .= '%'. sprintf('%x', ord($_)) + foreach( split(//, $str) ); + return "<a href=\"$ret\">$ostr</a>"; +} + sub AddArticle($$$;$) { my($cl, $fields, $s, $score) = @_; @@ -400,7 +413,7 @@ sub applyfilter($$) $c =~ s/\>/>/gs; $c =~ s/\"/"/gs; $c =~ s/\'/'/gs; - $c =~ s/ / /gs; +# $c =~ s/ / /gs; } elsif( /^ubb$/i ){ $c =~ s|\[url\](.*?)\[/url\]|<a href="$1">$1</a>|gsi; @@ -410,6 +423,14 @@ sub applyfilter($$) $c =~ s|\[i\](.*?)\[/i\]|<i>$1</i>|gsi; $c =~ s|\[img\](.*?)\[/img\]|<img src="$1" alt="(null)" style="border:0;" />|gsi; } + elsif( /^wiki$/i ){ + my $t; + $c =~ s|\[(http://\S+) (.*?)\]|\[ <a href=\"$1\">$2</a> \]|gi; + $c =~ s|([^\>\"])(http://\S+\.(:?jpg\|gif\|png\|bmp))|$1<a href=\"$2\"><img src=\"$2\" alt="$2" style="border:0;"></a>|gsi; + $c =~ s|([^\>\"])(http://\S+)|$1<a href=\"$2\">$2</a>|gsi; + $c =~ s|\(\((.*?)\)\)|utf8dump($1, $th{wikibase})|gsie; + $c =~ s|^\-{4,}$|<hr />|gm; + } } return $c; } |