summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-11-27 11:13:25 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-11-27 11:13:25 +0000
commit72a436f5866cf02defaad890523d214a94fc185c (patch)
tree70ab34491ea68efc8dfadbd69cacc6a9ccf7c45b
parentf40a1bb3705baa606ef8de423af106ea450516f8 (diff)
restructure get_archives(), get rid of 'no strict "refs"'
-rwxr-xr-xindex.cgi23
1 files changed, 11 insertions, 12 deletions
diff --git a/index.cgi b/index.cgi
index 786847b..6241434 100755
--- a/index.cgi
+++ b/index.cgi
@@ -275,6 +275,7 @@ sub get_archives {
my %history;
my @archives;
my @archives_compressed;
+ my @year_loop;
my $current_year = $args{'year'} || ((localtime)[5] + 1900);
my $current_month = $args{'month'} || ((localtime)[4] + 1);
my %months = (
@@ -301,7 +302,7 @@ sub get_archives {
($result->{'year'}, $result->{'month'}) = ($1, $2);
if (($result->{'year'} eq $current_year) && ($result->{'month'} eq $current_month) && $result->{'uri'}) {
- push(@{$history{$result->{'year'}}{$result->{'month'}}->{'uri_loop'}},
+ push(@{$history{$result->{'year'}}->{'uri_loop'}},
{
year => $result->{'year'},
month => $result->{'month'},
@@ -310,27 +311,25 @@ sub get_archives {
uri => $result->{'uri'},
}
);
- } else {
- $history{$result->{'year'}}->{$result->{'month'}}->{'count'}++;
}
+ $history{$result->{'year'}}->{'month_count'}->{$result->{'month'}}++;
$history{$result->{'year'}}->{'count'}++;
-
}
for my $year (sort {$b <=> $a} keys %history) {
- no strict "refs";
- for my $month (sort {$b <=> $a} keys %{$history{$year}}) {
+ for my $month (sort {$b <=> $a} keys %{$history{$year}->{'month_count'}}) {
my $m = {
'year' => $year,
'month' => $month,
'month_name' => $months{$month},
- 'count' => $history{$year}->{$month}->{'count'},
+ 'count' => $history{$year}->{'month_count'}->{$month},
};
# check to see if uri_loop exists first
- if ($history{$year}->{$month}->{'uri_loop'}) {
- $m->{'uri_loop'} = $history{$year}->{$month}->{'uri_loop'};
+ if (($month eq $current_month) && $history{$year}->{'uri_loop'}) {
+ delete $m->{'count'};
+ $m->{'uri_loop'} = $history{$year}->{'uri_loop'};
}
- push(@{$history{$year}->{'month_loop'}}, $m) unless ($month eq 'count');
+ push(@{$history{$year}->{'month_loop'}}, $m);
}
my $y = {
'year' => $year,
@@ -340,10 +339,10 @@ sub get_archives {
if (($year eq $current_year) && $history{$year}->{'month_loop'}) {
$y->{'month_loop'} = $history{$year}->{'month_loop'};
}
- push(@{$history{'year_loop'}}, $y) unless ($year eq 'count');
+ push(@year_loop, $y);
}
- return \@{$history{'year_loop'}};
+ return \@year_loop;
}
sub format_tags {