From 455ad22bfea540a4f7493c0126eb0d5032412050 Mon Sep 17 00:00:00 2001 From: in2 Date: Fri, 23 May 2003 10:18:15 +0000 Subject: calendar support, XHTML valid git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@892 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- blog/blog.pl | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/blog/blog.pl b/blog/blog.pl index 30577d14..f4875b57 100755 --- a/blog/blog.pl +++ b/blog/blog.pl @@ -6,6 +6,7 @@ use strict; use Data::Dumper; use Date::Calc qw(:all); use Template; +use HTML::Calendar::Simple; sub main { @@ -84,7 +85,57 @@ sub main } } - # output + # Calendar --------------------------------------------------------------- + if( $attr{"$fn.loadCalendar"} ){ + # 沒有合適的 module , 自己寫一個 |||b + my($c, $week, $day, $t, $link); + $c = ("\n". + "\n". + "\n"); + $c .= ("\n") + foreach( ['Sunday', 'Sun'], ['Monday', 'Mon'], + ['Tuesday', 'Tue'], ['Wednesday', 'Wed'], + ['Thursday', 'Thu'], ['Friday', 'Fri'], + ['Saturday', 'Sat'] ); + + $week = Day_of_Week($y, $m, 1); + $c .= "\n\n"; + + if( $week == 7 ){ + $week = 0; + } + else{ + $c .= ("\n") + foreach( 1..$week ); + } + foreach( 1..31 ){ + $c .= "\n"; + if( ++$week == 7 ){ + $c .= "\n\n\n"; + $week = 0; + } + } + + $c .= "\n
$emonth[$m] $y
[0]\" align=\"center\">". + "$_->[1]
". + " "; + + $t = packdate($y, $m, $_); + if( !$article{"$t.title"} ){ + $c .= "$_"; + } + else{ + my $link = $attr{"$fn.loadCalendar"}; + $link =~ s/\[\% key \%\]/$t/g; + $c .= "$_"; + } + + $c .= "
\n"; + $th{calendar} = $c; + #my $cal = HTML::Calendar::Simple->new({month => $m, year => $y}); + #$th{calendar} = $cal->calendar_month; + } + $tmpl = Template->new({INCLUDE_PATH => '.', ABSOLUTE => 0, RELATIVE => 0, -- cgit v1.2.3