had to backrev
This commit is contained in:
parent
a06b6dbb00
commit
9076619517
1 changed files with 5 additions and 22 deletions
|
|
@ -25,7 +25,6 @@ use WebGUI::Session;
|
||||||
use WebGUI::Wobject;
|
use WebGUI::Wobject;
|
||||||
use XML::RSSLite;
|
use XML::RSSLite;
|
||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
use WebGUI::ErrorHandler;
|
|
||||||
|
|
||||||
our @ISA = qw(WebGUI::Wobject);
|
our @ISA = qw(WebGUI::Wobject);
|
||||||
|
|
||||||
|
|
@ -45,8 +44,7 @@ sub new {
|
||||||
rssUrl=>{},
|
rssUrl=>{},
|
||||||
maxHeadlines=>{},
|
maxHeadlines=>{},
|
||||||
},
|
},
|
||||||
-useTemplate=>1,
|
-useTemplate=>1
|
||||||
-useMetaData=>1
|
|
||||||
);
|
);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
}
|
}
|
||||||
|
|
@ -183,25 +181,11 @@ sub _get_rss_data {
|
||||||
my $ua = LWP::UserAgent->new(timeout => 5);
|
my $ua = LWP::UserAgent->new(timeout => 5);
|
||||||
my $response = $ua->get($url);
|
my $response = $ua->get($url);
|
||||||
if (!$response->is_success()) {
|
if (!$response->is_success()) {
|
||||||
WebGUI::ErrorHandler::warn("Error retrieving url '$url': " .
|
warn("Error retrieving url '$url': " .
|
||||||
$response->status_line());
|
$response->status_line());
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
my $xml = $response->content();
|
my $xml = $response->content();
|
||||||
|
|
||||||
# Convert encoding if needed / Perl 5.8.0 or up required.
|
|
||||||
if ($] >= 5.008) {
|
|
||||||
$xml =~ /<\?xml.*?encoding=['"](\S+)['"]/i;
|
|
||||||
my $xmlEncoding = $1;
|
|
||||||
my $encoding = WebGUI::International::getLanguage($session{page}{languageId},"charset");
|
|
||||||
if (lc($xmlEncoding) ne lc($encoding)) {
|
|
||||||
use Encode qw(from_to);
|
|
||||||
eval { from_to($xml, $xmlEncoding, $encoding) };
|
|
||||||
WebGUI::ErrorHandler::warn($@) if ($@);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# there is no encode_entities_numeric that I can find, so I am
|
# there is no encode_entities_numeric that I can find, so I am
|
||||||
# commenting this out. -hal
|
# commenting this out. -hal
|
||||||
|
|
@ -213,7 +197,7 @@ sub _get_rss_data {
|
||||||
XML::RSSLite::parseXML($rss_lite, \$xml);
|
XML::RSSLite::parseXML($rss_lite, \$xml);
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
WebGUI::ErrorHandler::warn("error parsing rss for url $url");
|
warn("error parsing rss for url $url");
|
||||||
}
|
}
|
||||||
|
|
||||||
# make sure that the {channel} points to the channel
|
# make sure that the {channel} points to the channel
|
||||||
|
|
@ -224,10 +208,10 @@ sub _get_rss_data {
|
||||||
$rss_lite = {channel => $rss_lite};
|
$rss_lite = {channel => $rss_lite};
|
||||||
if (!($rss->{channel} =
|
if (!($rss->{channel} =
|
||||||
_find_record($rss_lite, qr/^channel$/))) {
|
_find_record($rss_lite, qr/^channel$/))) {
|
||||||
WebGUI::ErrorHandler::warn("unable to find channel info for url $url");
|
warn("unable to find channel info for url $url");
|
||||||
}
|
}
|
||||||
if (!($rss->{items} = _find_record($rss_lite, qr/^items?$/))) {
|
if (!($rss->{items} = _find_record($rss_lite, qr/^items?$/))) {
|
||||||
WebGUI::ErrorHandler::warn("unable to find item info for url $url");
|
warn("unable to find item info for url $url");
|
||||||
$rss->{items} = [];
|
$rss->{items} = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,7 +329,6 @@ sub _view_single_feed {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub www_view {
|
sub www_view {
|
||||||
$_[0]->logView() if ($session{setting}{passiveProfilingEnabled});
|
|
||||||
my $maxHeadlines = $_[0]->get("maxHeadlines") || 1000000;
|
my $maxHeadlines = $_[0]->get("maxHeadlines") || 1000000;
|
||||||
|
|
||||||
my @urls = split(/\s+/,$_[0]->get("rssUrl"));
|
my @urls = split(/\s+/,$_[0]->get("rssUrl"));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue