# category_list.pl - category listup plugin for sns # # usage: {{category_list("days")}} # wiki style {{category_list}} # html style <%= category_list %> sub category_list { my $max = shift; my (%category); my $buf; my $diary; if ($max eq "") { $max = 365; } my @list = $sns->load_diary({rows=>$max}); foreach my $diary (@list){ my @sections = $diary->parse(); foreach my $section (@sections){ my $sec_title = $section->{TITLE}; if ($sec_title =~ s/\[(.*?)\] (.*)/"[$1<\/a>]"/eg) { $category{$sec_title}++; } } } $buf .= "\n"; return $buf; }