forked from bentglasstube/blosxom-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwriteback_sort-v1i0
60 lines (42 loc) · 1.15 KB
/
writeback_sort-v1i0
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
# Blosxom Plugin: writeback_sort
# Author(s): Randall Hand
# Version: 1.0
# Documentation: See below.
package writeback_sort;
use File::stat;
# --- Configurable variables -----
# -- Set to the directory of your writeback files
# In the writeback plugin, it's $writeback_dir
$writeback_dir = "$blosxom::plugin_state_dir/writeback";
# -- Set to your writeback extension
# In the writeback plugin, it's $file_extension
$writeback_extension = "wb";
# --------------------------------
sub start {
1;
}
sub sort {
return sub {
my($files_ref) = @_;
return sort {
my $time_a;
my $time_b;
$time_a = $files_ref->{$a};
$time_b = $files_ref->{$b};
$file = $a;
$file =~ s/$blosxom::datadir/$writeback_dir/;
$file =~ s/txt$/$writeback_extension/;
if (-e $file) {
$time_a = stat($file)->mtime;
}
$file = $b;
$file =~ s/$blosxom::datadir/$writeback_dir/;
$file =~ s/txt$/$writeback_extension/;
if (-e $file) {
$time_b = stat($file)->mtime;
}
$time_b <=> $time_a;
} keys %$files_ref;
};
}
1;