Created
August 18, 2010 15:54
-
-
Save phillipadsmith/535221 to your computer and use it in GitHub Desktop.
This file contains 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
<%init>; | |
my $offset = $burner->notes('last_offset') || 0; | |
my $cat = $burner->get_cat->get_uri; | |
$cat = undef if $cat eq '/archive/'; | |
my @sorted; | |
if ($burner->notes('story_list')) { | |
@sorted = @{$burner->notes('story_list')}; | |
} else { | |
my $all_stories = $m->comp( | |
'/util/archive_list.mc', | |
limit => 0, | |
category => $cat, | |
order => $order, | |
sort => $sort, | |
element => "directory_listing", | |
); | |
@sorted = | |
map { $_->[0] } | |
sort { $a->[1] cmp $b->[1] } | |
map { [ $_, ($_->get_element->get_value('enhanced') ? 'A' : 'B').$_->get_title ] } | |
@$all_stories; | |
} | |
my $stories = []; | |
for (my $i=$offset; $i < ($offset+$limit); $i++) { | |
push(@$stories, $sorted[$i]) if ($sorted[$i]); | |
} | |
my $prev = $burner->prev_page_file; | |
my $next; | |
if (@$stories >= $limit) { | |
# Set it up to burn another page. | |
$burner->notes(last_offset => $offset + $limit); | |
$burner->notes(story_list => \@sorted); | |
$burner->set_burn_again(1); | |
$next = $burner->next_page_file; | |
} else { | |
# Reset the offset so that any other archives published by the same | |
# request won't be broken. | |
$burner->notes(last_offset => 0); | |
$burner->notes(story_list => undef); | |
} | |
</%init> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment