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