# Blosxom Plugin: entries_index # Author(s): Rael Dornfest # Version: 2003-03-23 # Documentation: See the bottom of this file or type: perldoc entries_index package entries_index; # --- Configurable variables ----- # -------------------------------- use File::stat; use File::Find; use Data::Dumper; use CGI qw/:standard/; sub start { 1; } sub entries { return sub { my(%files, %indexes); if ( open ENTRIES, "$blosxom::plugin_state_dir/.entries_index.index" ) { my $index = join '', ; close ENTRIES; $index =~ /\$VAR1 = \{/ and eval($index) and !$@ and %files = %$VAR1; } my $reindex = 0; for my $file (keys %files) { -f $file or do { $reindex++; delete $files{$file} }; } find( sub { my $d; my $curr_depth = $File::Find::dir =~ tr[/][]; if ( $blosxom::depth and $curr_depth > $blosxom::depth ) { $files{$File::Find::name} and delete $files{$File::Find::name}; return; } $File::Find::name =~ m!^$blosxom::datadir/(?:(.*)/)?(.+)\.$blosxom::file_extension$! and $2 ne 'index' and $2 !~ /^\./ and (-r $File::Find::name) # to show or not to show future entries and ( $blosxom::show_future_entries or stat($File::Find::name)->mtime <= time ) and ( $files{$File::Find::name} || ++$reindex ) and ( $files{$File::Find::name} = $files{$File::Find::name} || stat($File::Find::name)->mtime ) # Static and ( param('-all') or !-f "$blosxom::static_dir/$1/index." . $blosxom::static_flavours[0] or stat("$blosxom::static_dir/$1/index." . $blosxom::static_flavours[0])->mtime < stat($File::Find::name)->mtime ) and $indexes{$1} = 1 and $d = join('/', (blosxom::nice_date($files{$File::Find::name}))[5,2,3]) and $indexes{$d} = $d and $blosxom::static_entries and $indexes{ ($1 ? "$1/" : '') . "$2.$blosxom::file_extension" } = 1; }, $blosxom::datadir ); if ( $reindex ) { if ( open ENTRIES, "> $blosxom::plugin_state_dir/.entries_index.index" ) { print ENTRIES Dumper \%files; close ENTRIES; } else { warn "couldn't > $blosxom::plugin_state_dir/.entries_index.index: $!\n"; } } return (\%files, \%indexes); }; } 1; __END__ =head1 NAME Blosxom Plug-in: entries_index =head1 SYNOPSIS Purpose: Preserves original creation timestamp on weblog entries, allowing for editing of entries without altering the original creation time. Maintains an index ($blosxom::plugin_state_dir/.entries_index.index) of filenames and their creation times. Adds new entries to the index the first time Blosxom encounters them (read: is run after their creation). Replaces the default $blosxom::entries subroutine =head1 VERSION 2003-03-23 Version number coincides with the version of Blosxom with which the current version was first bundled. =head1 AUTHOR Rael Dornfest , http://www.raelity.org/ This plugin is now maintained by the Blosxom Sourceforge Team, . =head1 SEE ALSO Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/ Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html =head1 BUGS None known; please send bug reports and feedback to the Blosxom development mailing list . =head1 LICENSE Blosxom and this Blosxom Plug-in Copyright 2003, Rael Dornfest Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.