1 # Blosxom Plugin: Recent Entries
2 # Author(s): Gregory Bair - http://mypage.iu.edu/~gbair/
3 # Gavin Carr - http://www.openfusion.net/
5 # Blosxom Home: http://blosxom.sourceforge.net/
6 # Use: insert $recententries::recententries in one of the flavour templates.
13 #-------------- Configurable Options ----------------
15 # How many titles do you want to show?
18 # What comes before each title? below adds a line between each title - good for long titles.
19 my $title_before = qq!<div style="border-bottom:1px solid #369;">!;
22 my $title_after = qq!</div>!;
24 #----------------------------------------------------
26 use vars qw($recententries);
31 my ($pkg, $files_ref) = @_;
34 # Put each file name (the key of %$files_ref) into an array, but sort
35 # them by modification time (value) first
36 my @files = sort { $$files_ref{$b} <=> $$files_ref{$a} } keys %$files_ref;
38 foreach my $file (@files)
40 last if $tn >= $title_num;
42 open (STORY, $file) || die "Cannot open file $file : $!";
46 # The title is always the first line in an entry. Get that.
47 my $storytitle = $story[0];
52 # Use permalink if it's available
53 if (defined $permalink::root_format) {
55 $rel_file =~ s/^$blosxom::datadir//;
56 $rel_file =~ s/\.$blosxom::file_extension$//;
57 $link = permalink::get_link( $rel_file );
61 my ($volume, $directory, $filename) = File::Spec->splitpath($file);
62 $filename =~ s/\.$blosxom::file_extension$//;
64 #Change the file into a URL we can use.
65 my $newvol = File::Spec->catfile($volume, $directory, '');
66 $newvol =~ s/$blosxom::datadir/$blosxom::url/g;
68 $link = "$newvol#$filename";
71 # Create our variable.
72 $recententries .= sprintf qq(%s<a href="%s">%s</a>%s\n),
73 $title_before, $link, $storytitle, $title_after;
89 Blosxom Plugin: recententries
93 Purpose: Populates $recententries::recententries with a list of the most
94 recent entries. The number is specified by a configuration variable.
98 Gregory Bair gregindy@softhome.net, http://mypage.iu.edu/~gbair/
99 Gavin Carr gavin@openfusion.net, http://www.openfusion.net/
103 0.2 used qq!! instead of "" in configs
105 0.3 simplified the sorting algorithm at the suggestion of Todd Larason.
107 0.4 fixed File::Spec problems on OSes without volumes, and added L<permalink> support.