Default: none
+=item publicinbox.<name>.feedmax
+
+The size of an Atom feed for the inbox. If specified more than
+once, only the last value is used. Invalid values (<= 0) will
+be treated as the default value.
+
+Default: 25
+
=back
=head1 ENVIRONMENT
my $rv = {};
foreach my $k (qw(mainrepo address filter url newsgroup
- infourl watch watchheader httpbackendmax)) {
+ infourl watch watchheader httpbackendmax
+ feedmax)) {
my $v = $self->{"$pfx.$k"};
$rv->{$k} = $v if defined $v;
}
use Email::MIME;
use PublicInbox::View;
use PublicInbox::WwwAtomStream;
-use constant {
- MAX_PER_PAGE => 25, # this needs to be tunable
-};
# main function
sub generate {
sub each_recent_blob {
my ($ctx, $cb) = @_;
- my $max = $ctx->{max} || MAX_PER_PAGE;
+ my $max = $ctx->{-inbox}->{feedmax};
my $hex = '[a-f0-9]';
my $addmsg = qr!^:000000 100644 \S+ \S+ A\t(${hex}{2}/${hex}{38})$!;
my $delmsg = qr!^:100644 000000 \S+ \S+ D\t(${hex}{2}/${hex}{38})$!;
$WEAKEN->{"$self"} = $self;
}
+sub _set_uint ($$$) {
+ my ($opts, $field, $default) = @_;
+ my $val = $opts->{$field};
+ if (defined $val) {
+ $val = $val->[-1] if ref($val) eq 'ARRAY';
+ $val = undef if $val !~ /\A\d+\z/;
+ }
+ $opts->{$field} = $val || $default;
+}
+
sub new {
my ($class, $opts) = @_;
my $v = $opts->{address} ||= 'public-inbox@example.com';
my $p = $opts->{-primary_address} = ref($v) eq 'ARRAY' ? $v->[0] : $v;
$opts->{domain} = ($p =~ /\@(\S+)\z/) ? $1 : 'localhost';
+ _set_uint($opts, 'feedmax', 25);
weaken($opts->{-pi_config});
bless $opts, $class;
}
'url' => 'http://example.com/meta',
-primary_address => 'meta@public-inbox.org',
'name' => 'meta',
+ feedmax => 100,
-pi_config => $cfg,
}, "lookup matches expected output");
'mainrepo' => '/home/pi/test-main.git',
'domain' => 'public-inbox.org',
'name' => 'test',
+ feedmax => 100,
'url' => 'http://example.com/test',
-pi_config => $cfg,
}, "lookup matches expected output for test");
name => 'testbox',
mainrepo => $git_dir,
url => 'http://example.com/test',
+ feedmax => 3,
});
my $git = $ibx->git;
my $im = PublicInbox::Import->new($git, $ibx->{name}, 'test@example');
{
# check initial feed
{
- my $feed = string_feed({
- -inbox => $ibx,
- max => 3
- });
+ my $feed = string_feed({ -inbox => $ibx });
SKIP: {
skip 'XML::Feed missing', 2 unless $have_xml_feed;
my $p = XML::Feed->parse(\$feed);
# check spam shows up
{
- my $spammy_feed = string_feed({
- -inbox => $ibx,
- max => 3
- });
+ my $spammy_feed = string_feed({ -inbox => $ibx });
SKIP: {
skip 'XML::Feed missing', 2 unless $have_xml_feed;
my $p = XML::Feed->parse(\$spammy_feed);
# spam no longer shows up
{
- my $feed = string_feed({ -inbox => $ibx, max => 3 });
+ my $feed = string_feed({ -inbox => $ibx });
SKIP: {
skip 'XML::Feed missing', 2 unless $have_xml_feed;
my $p = XML::Feed->parse(\$feed);