#!/usr/bin/perl -w # Created by Ben Okopnik on Thu Jan 14 21:55:46 EST 2010 use strict; use Mail::MboxParser; use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; use CGI qw/:standard/; $|++; my $fname = "test"; my $mb = Mail::MboxParser->new( $fname, parseropts => { enable_cache => 1, # enable_grep => 1, cache_file_name => '/tmp/cache' . substr(rand(), 1, 10) } ); my($self) = $0 =~ m{([^/]+)$}; my $count = $mb->nmsgs - 1; binmode STDOUT, ':encoding(UTF-8)'; # Set up utf-8 output print header(-charset => 'utf-8'), start_html( -encoding => 'utf-8', -title => 'Origami Archive'); if (!param('msg')){ my $end; my $incr = 50; my $start = param('start') || 0; my $div; # $start is always going to be $incr * $_ for 0 .. int($count / $incr) # If we're more than $incr posts from the start (i.e., $start is $incr or more), # show the "Previous" link if ($start > 0){ my $bottom = $start - $incr; print a({-href=>"$self?start=$bottom"}, "Previous $incr"); $div = " | "; } # If we're >= $incr posts from the end, show the 'Next' link if ($count - $start >= $incr){ my $top = $start + $incr; print $div if $div; print a({-href=>"$self?start=$top"}, "Next $incr"); $end = $top - 1; } else { $end = $count; } print hr; # print "Start: $start End: $end"; # Subscripting one message after the other print "