-
Notifications
You must be signed in to change notification settings - Fork 3
/
archives-v0i5
60 lines (44 loc) · 1.78 KB
/
archives-v0i5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl -w
# Blosxom Plugin: archives
# Author: Brian Akins (bakins@web.turner.com)
# Version: 0+5i
# Blosxom Home/Docs/Licensing: http://www.raelity.org/blosxom
package archives;
# --- Configurable Variables ---
# Do you want the list sorted in reverse chronological order?
my $reversechron=0;
# Set to whatever you want your HTML to be indented with. Leave blank for nothing.
my $indent="\t";
# Customize your month names here if you want to.
my @monthname=('January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December');
# ------------------------------
$archives = '';
sub start {
return 1;
}
sub filter {
my ($pkg, $files) = @_;
my %archive;
foreach (keys %{$files}) {
my @date = localtime($files->{$_});
my $month = $date[4];
my $year = $date[5] + 1900;
$archive{$year}{'count'}++;
$archive{$year}{$month}{'count'}++;
}
my $results = qq{<ul class="archives">\n};
foreach my $year(sort {$reversechron?$b<=>$a:$a<=>$b} keys(%archive)) {
$results .= qq{$indent<li><a href="$blosxom::url/$year/">$year</a> ($archive{$year}{'count'})\n$indent$indent<ul>\n};
delete $archive{$year}{'count'};
# loop for each month found; one LI per month.
foreach my $month(sort {$reversechron?$b<=>$a:$a<=>$b} keys(%{$archive{$year}})) {
my $mnum = sprintf("%02d", $month+1);
$results .= qq{$indent$indent$indent<li><a href="$blosxom::url/$year/$mnum/index.$blosxom::flavour">$monthname[$month]</a> ($archive{$year}{$month}{'count'})</li>\n};
}
$results .= "$indent$indent</ul>\n$indent</li>\n";
}
$results .= "</ul>\n";
$archives = $results;
}
1;