[Bast-commits] r6049 - ironman/plagger/lib/Plagger/Plugin/Publish
castaway at dev.catalyst.perl.org
castaway at dev.catalyst.perl.org
Thu Apr 30 15:35:45 GMT 2009
Author: castaway
Date: 2009-04-30 16:35:45 +0100 (Thu, 30 Apr 2009)
New Revision: 6049
Modified:
ironman/plagger/lib/Plagger/Plugin/Publish/PagedPlanet.pm
Log:
Penfold's bugfixes
Modified: ironman/plagger/lib/Plagger/Plugin/Publish/PagedPlanet.pm
===================================================================
--- ironman/plagger/lib/Plagger/Plugin/Publish/PagedPlanet.pm 2009-04-30 14:59:51 UTC (rev 6048)
+++ ironman/plagger/lib/Plagger/Plugin/Publish/PagedPlanet.pm 2009-04-30 15:35:45 UTC (rev 6049)
@@ -7,12 +7,20 @@
our $VERSION = '0.01';
+sub register {
+ my($self, $context) = @_;
+ $context->register_hook(
+ $self,
+ 'publish.feed' => \&add_feed,
+ );
+}
+
sub add_feed {
my($self, $context, $args) = @_;
my $feed = $args->{feed};
if ($feed->id ne 'smartfeed:all') {
- $context->error("Publish::Planet requires SmartFeed::All to run.");
+ $context->error("Publish::PagedPlanet requires SmartFeed::All to run.");
}
my $theme = $self->conf->{theme} || $self->conf->{skin} || 'default'; # 'skin' as backward compatible
@@ -28,12 +36,12 @@
feed => $feed,
members => [ $context->subscription->feeds ],
};
-
my $start = 0;
my $page = 1;
while ($start < scalar @$entries) {
my $end = $start + $pagesize - 1;
- my @entries = @{$entries->[$start..$end]};
+ $end = ($end >= @$entries) ? @$entries - 1 : $end;
+ my @entries = @{$entries}[$start..$end];
my $filename = ($page == 1) ? 'index.html' : "index_$page.html";
# passing these into template is enough to allow us to build |<- <- 1 2 3 4 5 -> ->| style nav
@@ -56,3 +64,12 @@
$start += $pagesize;
}
}
+
+
+sub is_http {
+ my $uri = URI->new(shift);
+ my $scheme = $uri->scheme or return;
+ $scheme eq 'http' or $scheme eq 'https';
+}
+
+1;
More information about the Bast-commits
mailing list