# Blosxom Plugin: archives # Author: Brian Akins # Version: 0+5i # Blosxom Home/Docs/Licensing: http://www.blosxom.com/ # modified 2006/11/10 by iso tank package archives; use strict; use vars qw/$archives $url $count $year $month/; # ----- 変数の設定 ----- # 初期化 $archives = ''; # 月の並び順の設定 # 0: 古い方が上 # 1: 新しい方が上 my $reverse = 1; # 現在のカテゴリ内のみのリストにする my $catelist = 1; # 月の表示に使う文字列 my @monthname = ( "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" ); # -------------------------------------- sub start { return 1; } sub filter { my ($pkg, $files) = @_; my (%archive, $path, @date, $sub_mo, $sub_yr); $path = $blosxom::path_info; $path =~ s!(.*)/\w+\.\w+$!$1!; $path &&= "/$path"; foreach(grep{$catelist ? /$blosxom::datadir$path/ : /./} keys %{$files}){ @date = localtime($files->{$_}); $sub_mo = $date[4]; $sub_yr = $date[5] + 1900; $archive{$sub_yr}{'count'}++; $archive{$sub_yr}{$sub_mo}{'count'}++; } # 出力 while () { last if (/^__END__$/); my ($flavour, $comp, $text) = split(' ', $_, 3); $text =~ s/\\n/\n/g; $blosxom::template{$flavour}{$comp} = $text; } my $results = &$blosxom::template($path, 'head', 'archives'); foreach my $for_yr (sort {$reverse?$b<=>$a:$a<=>$b} keys(%archive)) { $url = "$path/$for_yr/"; $count = $archive{$for_yr}{'count'}; $year = $for_yr; $results .= &$blosxom::template($path, 'year', 'archives'); $results =~ s/\$archives::url/$url/g; $results =~ s/\$archives::year/$year/g; $results =~ s/\$archives::count/$count/g; delete $archive{$for_yr}{'count'}; foreach my $for_mo (sort {$reverse?$b<=>$a:$a<=>$b} keys(%{$archive{$for_yr}})) { my $mnum = sprintf("%02d", $for_mo + 1); $url = "$path/$for_yr/$mnum/"; $count = $archive{$for_yr}{$for_mo}{'count'}; $month = $monthname[$for_mo]; $results .= &$blosxom::template($path, 'mon', 'archives'); $results =~ s/\$archives::url/$url/g; $results =~ s/\$archives::year/$year/g; $results =~ s/\$archives::count/$count/g; $results =~ s/\$archives::month/$month/g; } $results .= &$blosxom::template($path, 'mon_end', 'archives'); } $results .= &$blosxom::template($path, 'foot', 'archives'); $archives = $results; 1; } 1; __DATA__ archives head
archives year
$archives::year年 ($archives::count)
\n
archives mon $archives::month ($archives::count) archives mon_end
archives foot
__END__