diff options
author | Eric Wong <e@80x24.org> | 2016-12-17 04:27:52 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-12-17 05:41:49 +0000 |
commit | f084e94a4774b95eb45f55fc9f0dfda678522e54 (patch) | |
tree | 9606587e01b4e57b650d1f805b5046611110fbb3 /lib/PublicInbox/Inbox.pm | |
parent | 464048b28be5063a3151742feaaa170c9d9e3b19 (diff) | |
download | public-inbox-f084e94a4774b95eb45f55fc9f0dfda678522e54.tar.gz |
feed: support publicinbox.<name>.feedmax
This allows users to customize by using smaller or larger Atom feeds than the default value of 25 entries.
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r-- | lib/PublicInbox/Inbox.pm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 8c639082..5503980f 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -29,11 +29,22 @@ sub _weaken_later ($) { $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; } |