Created
November 3, 2012 17:32
-
-
Save anazawa/4008041 to your computer and use it in GitHub Desktop.
last_modified plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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