diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-05-23 22:53:46 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-05-23 22:53:46 +0800 |
commit | a26d468170bf3e193815b960f9139339e450b762 (patch) | |
tree | 398901693c729ca44656351a844a4c0898c8f269 /blog | |
parent | 3fb9e64c9fc04eb949b7319012a8d92c9af13573 (diff) | |
download | pttbbs-a26d468170bf3e193815b960f9139339e450b762.tar pttbbs-a26d468170bf3e193815b960f9139339e450b762.tar.gz pttbbs-a26d468170bf3e193815b960f9139339e450b762.tar.bz2 pttbbs-a26d468170bf3e193815b960f9139339e450b762.tar.lz pttbbs-a26d468170bf3e193815b960f9139339e450b762.tar.xz pttbbs-a26d468170bf3e193815b960f9139339e450b762.tar.zst pttbbs-a26d468170bf3e193815b960f9139339e450b762.zip |
*** empty log message ***
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@894 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'blog')
-rwxr-xr-x | blog/blog.pl | 72 |
1 files changed, 49 insertions, 23 deletions
diff --git a/blog/blog.pl b/blog/blog.pl index f4875b57..4f177972 100755 --- a/blog/blog.pl +++ b/blog/blog.pl @@ -8,17 +8,19 @@ use Date::Calc qw(:all); use Template; use HTML::Calendar::Simple; +use vars qw/@emonth @cnumber %config %attr %article %th/; + sub main { - my($brdname, $fn, %config, %attr, %article, $y, $m, $d); - my($tmpl, %th); - - my @emonth = ('', 'January', 'February', 'March', 'April', 'May', - 'June', 'July', 'August', 'September', 'October', - 'November', 'December'); - my @cnumber = ('零', '一', '二', '三', '四', '五', '六', - '七', '八', '九', '十', '十一', '十二'); - + my($brdname, $fn, $y, $m, $d); + my($tmpl); + + @emonth = ('', 'January', 'February', 'March', 'April', 'May', + 'June', 'July', 'August', 'September', 'October', + 'November', 'December'); + @cnumber = ('零', '一', '二', '三', '四', '五', '六', + '七', '八', '九', '十', '十一', '十二'); + if( !$ENV{PATH_INFO} ){ print header(-status => 400); return; @@ -43,14 +45,24 @@ sub main # loadBlog --------------------------------------------------------------- tie %article, 'DB_File', "$BLOGDATA/$brdname.db", O_RDONLY, 0666, $DB_HASH; - if( $attr{"$fn.loadBlog"} =~ /month/i ){ + if( $attr{"$fn.loadBlog"} =~ /article/i ){ + AddArticle('blog', $attr{"$fn.loadBlogFields"}, packdate($y, $m, $d)); + } + elsif( $attr{"$fn.loadBlog"} =~ /month/i ){ my($s, $y1, $m1, $d1); for( ($y1, $m1, $d1) = ($y, $m, 32) ; $d1 > 0 ; --$d1 ){ - AddArticle('blog', $y1, $m1, $d1, - \%th, \%article, \@emonth, \@cnumber); + AddArticle('blog', $attr{"$fn.loadBlogFields"}, + packdate($y1, $m1, $d1)); } } + if( $attr{"$fn.loadBlogPrevNext"} ){ + my $s = packdate($y, $m, $d); + AddArticle('next', $attr{"$fn.loadBlogPrevNext"}, + $article{"$s.next"}); + AddArticle('prev', $attr{"$fn.loadBlogPrevNext"}, + $article{"$s.prev"}); + } # loadArchives ----------------------------------------------------------- if( $attr{"$fn.loadArchives"} =~ /^monthly/i ){ # 找尋 +-1 year 內有資料的月份 @@ -119,7 +131,7 @@ sub main } else{ my $link = $attr{"$fn.loadCalendar"}; - $link =~ s/\[\% key \%\]/$t/g; + $link =~ s/\[\% key \%\]/,$t/g; $c .= "<a href=\"$link\">$_</a>"; } @@ -136,6 +148,7 @@ sub main #$th{calendar} = $cal->calendar_month; } + # 用 Template Toolkit 輸出 $tmpl = Template->new({INCLUDE_PATH => '.', ABSOLUTE => 0, RELATIVE => 0, @@ -147,20 +160,33 @@ sub main print "<pre>template error: ". $tmpl->error(); } -sub AddArticle($$$$$$$$) +sub AddArticle($$$) { - my($cl, $y, $m, $d, $th, $article, $emonth, $cnumber) = @_; - my $s = packdate($y, $m, $d); - push @{$th->{$cl}}, {year => $y, + my($cl, $fields, $s) = @_; + my $content = ''; + if( $fields =~ /content/i ){ + $content = $article{"$s.content"}; + if( $config{outputfilter} == 1 ){ + $content =~ s/\n/<br>\n/gs; + } + } + + my($y, $m, $d) = unpackdate($s); + push @{$th{$cl}}, {year => $y, month => $m, - emonth => $emonth->[$m], - cmonth => $cnumber->[$m], + emonth => $emonth[$m], + cmonth => $cnumber[$m], day => $d, key => $s, - title => $article->{"$s.title"}, - body => $article->{"$s.content"}, - author => $article->{"$s.author"}} - if( $article->{"$s.title"} ); + title => (($fields !~ /title/i) ? '' : + $article{"$s.title"}), + content=> $content, + author => (($fields !~ /author/i) ? '' : + $article{"$s.author"}), + short => (($fields !~ /short/i) ? '' : + $article{"$s.short"}), + } + if( $article{"$s.title"} ); } sub parsefn($) |