-
Notifications
You must be signed in to change notification settings - Fork 1
/
one_year_ago
82 lines (57 loc) · 1.52 KB
/
one_year_ago
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Blosxom Plugin: one_year_ago
# Author(s): Kyo Nagashima <[email protected]>
# Version: 2004-07-26
# Blosxom Home/Docs/Licensing: http://www.blosxom.com/
package one_year_ago;
use strict;
use vars qw($list);
# --- Configurable variables -----------
my $prefix = <<"_HTML_";
<div class="story">
<h3>One year ago...</h3>
_HTML_
my $postfix = <<"_HTML_";
</div>
_HTML_
# --- Plug-in package variables --------
my %entries;
# --------------------------------------
use HTTP::Date;
use FileHandle;
my $fh = new FileHandle;
sub start {
return 0 unless $blosxom::path_info =~ /\./;
return 1;
}
sub filter {
my($pkg, $files_ref) = @_;
%entries = %$files_ref;
return 1;
}
sub date {
my($pkg, $path, $date_ref, $mtime, $dw, $mo, $mo_num, $da, $ti, $yr) = @_;
$yr = $yr - 1;
my $from = str2time("$dw, $da $mo $yr 00:00:00 +0900");
my $to = str2time("$dw, $da $mo $yr 23:59:59 +0900");
foreach my $file (keys %entries) {
if ($entries{$file} >= $from and $entries{$file} <= $to) {
my($url, $title) = &getinfo($file);
$list .= qq!<li><a href="$url" title="$title">$title</a></li>\n!;
}
}
chomp($list = "$prefix<ul>\n$list</ul>\n$postfix") if ($list);
return 1;
}
sub getinfo {
my $file = shift;
my($path, $fn) = $file =~ m!^$blosxom::datadir/(?:(.*)/)?(.*)\.$blosxom::file_extension!;
my $url = "$blosxom::url/$path/$fn.$blosxom::flavour";
my $title = '';
if (-f $file and $fh->open("< $file")) {
chomp($title = <$fh>);
$fh->close;
}
return($url, $title);
}
1;
# vim:ft=perl