| 1 | # Copyright 2010, 2011, 2012, 2013, 2014, 2015 Kevin Ryde | ||
| 2 | # | ||
| 3 | # This file is part of RSS2Leafnode. | ||
| 4 | # | ||
| 5 | # RSS2Leafnode is free software; you can redistribute it and/or modify it | ||
| 6 | # under the terms of the GNU General Public License as published by the Free | ||
| 7 | # Software Foundation; either version 3, or (at your option) any later | ||
| 8 | # version. | ||
| 9 | # | ||
| 10 | # RSS2Leafnode is distributed in the hope that it will be useful, but | ||
| 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
| 12 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 13 | # for more details. | ||
| 14 | # | ||
| 15 | # You should have received a copy of the GNU General Public License along | ||
| 16 | # with RSS2Leafnode. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | |||
| 18 | package App::RSS2Leafnode::Conf; | ||
| 19 | use 5.010; | ||
| 20 | use strict; | ||
| 21 | use warnings; | ||
| 22 | |||
| 23 | our $VERSION = 79; | ||
| 24 | |||
| 25 | { | ||
| 26 | package App::RSS2Leafnode::Conf::Tie; | ||
| 27 | use Carp; | ||
| 28 | sub TIESCALAR { | ||
| 29 | my ($class, $field) = @_; | ||
| 30 | return bless { field => $field }, $class; | ||
| 31 | } | ||
| 32 | sub FETCH { | ||
| 33 | my ($self) = @_; | ||
| 34 | my $r2l = $App::RSS2Leafnode::Conf::r2l | ||
| 35 | || croak "Oops, \$App::RSS2Leafnode::Conf::r2l not set"; | ||
| 36 | return $r2l->{$self->{'field'}}; | ||
| 37 | } | ||
| 38 | sub STORE { | ||
| 39 | my ($self, $value) = @_; | ||
| 40 | my $r2l = $App::RSS2Leafnode::Conf::r2l | ||
| 41 | || croak "Oops, \$App::RSS2Leafnode::Conf::r2l not set"; | ||
| 42 | return $r2l->{$self->{'field'}} = $value; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | # config variables | ||
| 47 | |||
| 48 | our $r2l; | ||
| 49 | foreach my $field ('verbose', | ||
| 50 | 'render', | ||
| 51 | 'render_width', | ||
| 52 | 'rss_get_links', | ||
| 53 | 'rss_get_comments', | ||
| 54 | 'rss_newest_only', | ||
| 55 | 'rss_charset_override', | ||
| 56 | 'get_icon', | ||
| 57 | 'html_charset_from_content', | ||
| 58 | 'html_extract_main', | ||
| 59 | 'user_agent', | ||
| 60 | |||
| 61 | # secret variables | ||
| 62 | 'msgidextra', | ||
| 63 | 'status_filename', | ||
| 64 | ) { | ||
| 65 | my $fullvar = __PACKAGE__."::$field"; | ||
| 66 | no strict 'refs'; | ||
| 67 | tie ${$fullvar}, 'App::RSS2Leafnode::Conf::Tie', $field; | ||
| 68 | } | ||
| 69 | |||
| 70 | sub fetch_html { | ||
| 71 | $r2l->fetch_html(@_); | ||
| 72 | } | ||
| 73 | sub fetch_rss { | ||
| 74 | $r2l->fetch_rss(@_); | ||
| 75 | } | ||
| 76 | |||
| 77 | 1; | ||
| 78 | __END__ |