Index: branches/release-30/lib/MT/Template/ContextHandlers.pm
===================================================================
--- branches/release-30/lib/MT/Template/ContextHandlers.pm (revision 1367)
+++ branches/release-30/lib/MT/Template/ContextHandlers.pm (revision 1379)
@@ -3459,4 +3459,10 @@
     
     my $cfg = $ctx->{config};
+    my $at = $ctx->{current_archive_type} || $ctx->{archive_type};
+    my $archiver = MT->publisher->archiver($at);
+    if ( $archiver && $archiver->archive_group_entries ) {
+        my $entries = $archiver->archive_group_entries->( $ctx, %$args );
+        $ctx->stash( 'entries', $entries );
+    }
     my $entries = $ctx->stash('entries');
     my $blog_id = $ctx->stash('blog_id');
Index: branches/release-30/lib/MT/WeblogPublisher.pm
===================================================================
--- branches/release-30/lib/MT/WeblogPublisher.pm (revision 1372)
+++ branches/release-30/lib/MT/WeblogPublisher.pm (revision 1379)
@@ -1444,8 +1444,7 @@
     {
         if ( $archiver->archive_group_entries ) {
-
-            # TBD: Would it help to use MT::Promise here?
-            my $entries = $archiver->archive_group_entries->($ctx);
-            $ctx->stash( 'entries', $entries );
+            require MT::Promise;
+            my $entries = sub { $archiver->archive_group_entries->($ctx) };
+            $ctx->stash( 'entries', MT::Promise::delay($entries) );
         }
 
@@ -2334,6 +2333,10 @@
 sub yearly_group_entries {
     my ( $ctx, %param ) = @_;
-    date_based_group_entries( $ctx, 'Yearly',
-        %param ? sprintf( "%04d%02d%02d000000", $param{year}, 1, 1 ) : undef );
+    my $ts =
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", $param{year}, 1, 1 )
+        : undef;
+    my $limit = $param{limit};
+    date_based_group_entries( $ctx, 'Yearly', $ts, $limit );
 }
 
@@ -2431,8 +2434,10 @@
 sub monthly_group_entries {
     my ( $ctx, %param ) = @_;
-    date_based_group_entries( $ctx, 'Monthly',
-        %param
-        ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month}, 1 )
-        : undef );
+    my $ts =
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month}, 1 )
+        : undef;
+    my $limit = $param{limit};
+    date_based_group_entries( $ctx, 'Monthly', $ts, $limit );
 }
 
@@ -2520,5 +2525,9 @@
 sub category_group_entries {
     my ( $ctx, %param ) = @_;
-
+    my $limit = $param{limit};
+    if ( $limit eq 'auto' ) {
+        my $blog = $ctx->stash('blog');
+        $limit = $blog->entries_on_index if $blog;
+    }
     my $c = $ctx->stash('archive_category') || $ctx->stash('category');
     require MT::Entry;
@@ -2530,6 +2539,7 @@
                 { category_id => $c->id }, { unqiue => 1 }
             ],
-            'sort' => 'authored_on',
+            'sort'      => 'authored_on',
             'direction' => 'descend',
+            ( $limit ? ( 'limit' => $limit ) : () ),
         }
     );
@@ -2739,11 +2749,11 @@
 sub daily_group_entries {
     my ( $ctx, %param ) = @_;
-    date_based_group_entries(
-        $ctx, 'Daily',
-        %param
-        ? sprintf( "%04d%02d%02d000000",
-            $param{year}, $param{month}, $param{day} )
-        : undef
-    );
+    my $ts =
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month},
+               $param{day} )
+        : undef;
+    my $limit = $param{limit};
+    date_based_group_entries( $ctx, 'Daily', $ts, $limit );
 }
 
@@ -2839,11 +2849,10 @@
 sub weekly_group_entries {
     my ( $ctx, %param ) = @_;
-    date_based_group_entries(
-        $ctx, 'Weekly',
-        %param
-        ? sprintf( "%04d%02d%02d000000",
-            week2ymd( $param{year}, $param{week} ) )
-        : undef
-    );
+    my $ts =
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", week2ymd( $param{year}, $param{week} ) )
+        : undef;
+    my $limit = $param{limit};
+    date_based_group_entries( $ctx, 'Weekly', $ts, $limit );
 }
 
@@ -2898,5 +2907,5 @@
 
 sub date_based_group_entries {
-    my ( $ctx, $at, $ts ) = @_;
+    my ( $ctx, $at, $ts, $limit ) = @_;
     my $blog = $ctx->stash('blog');
     my ( $start, $end );
@@ -2925,4 +2934,5 @@
             'sort' => 'authored_on',
             'direction' => 'descend',
+            ( $limit ? ( 'limit' => $limit ) : () ),
         }
     ) or return $ctx->error("Couldn't get $at archive list");
@@ -3002,4 +3012,9 @@
     my $blog = $ctx->stash('blog');
     my $a = $param{author} || $ctx->stash('author');
+    my $limit = $param{limit};
+    if ( $limit eq 'auto' ) {
+        my $blog = $ctx->stash('blog');
+        $limit = $blog->entries_on_index if $blog;
+    }
     return [] unless $a;
     require MT::Entry;
@@ -3013,4 +3028,5 @@
             'sort'      => 'authored_on',
             'direction' => 'descend',
+            ( $limit ? ( 'limit' => $limit ) : () ),
         }
     );
@@ -3201,9 +3217,10 @@
     my ( $ctx, %param ) = @_;
     my $ts =
-      %param
-      ? sprintf( "%04d%02d%02d000000", $param{year}, 1, 1 )
-      : $ctx->stash('current_timestamp');
-    my $author = %param ? $param{author} : $ctx->stash('author');
-    date_based_author_entries( $ctx, 'Author-Yearly', $author, $ts );
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", $param{year}, 1, 1 )
+        : $ctx->stash('current_timestamp');
+    my $author = $param{author} || $ctx->stash('author');
+    my $limit = $param{limit};
+    date_based_author_entries( $ctx, 'Author-Yearly', $author, $ts, $limit );
 }
 
@@ -3384,9 +3401,10 @@
     my ( $ctx, %param ) = @_;
     my $ts =
-      %param
-      ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month}, 1 )
-      : $ctx->stash('current_timestamp');
-    my $author = %param ? $param{author} : $ctx->stash('author');
-    date_based_author_entries( $ctx, 'Author-Monthly', $author, $ts );
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month}, 1 )
+        : $ctx->stash('current_timestamp');
+    my $author = $param{author} || $ctx->stash('author');
+    my $limit = $param{limit};
+    date_based_author_entries( $ctx, 'Author-Monthly', $author, $ts, $limit );
 }
 
@@ -3565,9 +3583,10 @@
     my ( $ctx, %param ) = @_;
     my $ts =
-      %param
-      ? sprintf( "%04d%02d%02d000000", week2ymd( $param{year}, $param{week} ) )
-      : $ctx->stash('current_timestamp');
-    my $author = %param ? $param{author} : $ctx->stash('author');
-    date_based_author_entries( $ctx, 'Author-Weekly', $author, $ts );
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", week2ymd( $param{year}, $param{week} ) )
+        : $ctx->stash('current_timestamp');
+    my $author = $param{author} || $ctx->stash('author');
+    my $limit = $param{limit};
+    date_based_author_entries( $ctx, 'Author-Weekly', $author, $ts, $limit );
 }
 
@@ -3754,10 +3773,11 @@
     my ( $ctx, %param ) = @_;
     my $ts =
-      %param
-      ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month},
-        $param{day} )
-      : $ctx->stash('current_timestamp');
-    my $author = %param ? $param{author} : $ctx->stash('author');
-    date_based_author_entries( $ctx, 'Author-Daily', $author, $ts );
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month},
+               $param{day} )
+        : $ctx->stash('current_timestamp');
+    my $author = $param{author} || $ctx->stash('author');
+    my $limit = $param{limit};
+    date_based_author_entries( $ctx, 'Author-Daily', $author, $ts, $limit );
 }
 
@@ -3956,12 +3976,11 @@
 sub cat_yearly_group_entries {
     my ( $ctx, %param ) = @_;
-
     my $ts =
-      %param
-      ? sprintf( "%04d%02d%02d000000", $param{year}, 1, 1 )
-      : $ctx->stash('current_timestamp');
-    my $cat = %param ? $param{category} : $ctx->stash('archive_category');
-
-    date_based_category_entries( $ctx, 'Category-Yearly', $cat, $ts );
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", $param{year}, 1, 1 )
+        : $ctx->stash('current_timestamp');
+    my $cat = $param{category} || $ctx->stash('archive_category');
+    my $limit = $param{limit};
+    date_based_category_entries( $ctx, 'Category-Yearly', $cat, $ts, $limit );
 }
 
@@ -4124,12 +4143,11 @@
 sub cat_monthly_group_entries {
     my ( $ctx, %param ) = @_;
-
     my $ts =
-      %param
-      ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month}, 1 )
-      : $ctx->stash('current_timestamp');
-    my $cat = %param ? $param{category} : $ctx->stash('archive_category');
-
-    date_based_category_entries( $ctx, 'Category-Monthly', $cat, $ts );
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month}, 1 )
+        : $ctx->stash('current_timestamp');
+    my $cat = $param{category} || $ctx->stash('archive_category');
+    my $limit = $param{limit};
+    date_based_category_entries( $ctx, 'Category-Monthly', $cat, $ts, $limit );
 }
 
@@ -4297,13 +4315,12 @@
 sub cat_daily_group_entries {
     my ( $ctx, %param ) = @_;
-
     my $ts =
-      %param
-      ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month},
-        $param{day} )
-      : $ctx->stash('current_timestamp');
-    my $cat = %param ? $param{category} : $ctx->stash('archive_category');
-
-    date_based_category_entries( $ctx, 'Category-Daily', $cat, $ts );
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", $param{year}, $param{month},
+               $param{day} )
+        : $ctx->stash('current_timestamp');
+    my $cat = $param{category} || $ctx->stash('archive_category');
+    my $limit = $param{limit};
+    date_based_category_entries( $ctx, 'Category-Daily', $cat, $ts, $limit );
 }
 
@@ -4464,10 +4481,10 @@
     my ( $ctx, %param ) = @_;
     my $ts =
-      %param
-      ? sprintf( "%04d%02d%02d000000", week2ymd( $param{year}, $param{week} ) )
-      : $ctx->stash('current_timestamp');
-    my $cat = %param ? $param{category} : $ctx->stash('archive_category');
-
-    date_based_category_entries( $ctx, 'Category-Weekly', $cat, $ts );
+        $param{year}
+    ? sprintf( "%04d%02d%02d000000", week2ymd( $param{year}, $param{week} ) )
+        : $ctx->stash('current_timestamp');
+    my $cat = $param{category} || $ctx->stash('archive_category');
+    my $limit = $param{limit};
+    date_based_category_entries( $ctx, 'Category-Weekly', $cat, $ts, $limit );
 }
 
