Skip to content

Instantly share code, notes, and snippets.

@anazawa
Created November 3, 2012 17:32
Show Gist options
  • Select an option

  • Save anazawa/4008041 to your computer and use it in GitHub Desktop.

Select an option

Save anazawa/4008041 to your computer and use it in GitHub Desktop.
last_modified plugin
package last_modified;
use strict;
use warnings;
use parent 'Blosxom::Plugin';
use CGI::Header;
use HTTP::Date;
use List::Util qw/max/;
__PACKAGE__->mk_accessors(
last_modified => sub { [] },
header => sub { CGI::Header->new($blosxom::header) },
);
sub start { !$blosxom::static_entries }
sub date {
my ( $self, $mtime ) = @_[0, 3];
push @{ $self->last_modified }, $mtime;
}
sub last {
my $self = shift;
my $last_modified = max @{ $self->last_modified };
$self->header->set( 'Last-Modified' => time2str $last_modified );
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment