r22762 - in /trunk/libxml-rss-perl: Changes META.yml debian/changelog lib/XML/RSS.pm lib/XML/RSS/Private/Output/Base.pm t/items-are-0.t
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Sat Jul 5 10:45:04 UTC 2008
Author: gregoa
Date: Sat Jul 5 10:45:03 2008
New Revision: 22762
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=22762
Log:
New upstream release.
Modified:
trunk/libxml-rss-perl/Changes
trunk/libxml-rss-perl/META.yml
trunk/libxml-rss-perl/debian/changelog
trunk/libxml-rss-perl/lib/XML/RSS.pm
trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/Base.pm
trunk/libxml-rss-perl/t/items-are-0.t
Modified: trunk/libxml-rss-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/Changes?rev=22762&op=diff
==============================================================================
--- trunk/libxml-rss-perl/Changes (original)
+++ trunk/libxml-rss-perl/Changes Sat Jul 5 10:45:03 2008
@@ -1,4 +1,9 @@
Revision history for Perl module XML::RSS
+
+1.33 - June 8, 2008
+ - Allowed the end-user to customise the _encode() routine in
+ XML::RSS::Private::Output::Base from XML::RSS using the
+ encode_cb key.
1.32 - February 8, 2008
- Fixed http://rt.cpan.org/Public/Bug/Display.html?id=25336 :
Modified: trunk/libxml-rss-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/META.yml?rev=22762&op=diff
==============================================================================
--- trunk/libxml-rss-perl/META.yml (original)
+++ trunk/libxml-rss-perl/META.yml Sat Jul 5 10:45:03 2008
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: XML-RSS
-version: 1.32
+version: 1.33
abstract: ~
license: ~
generated_by: ExtUtils::MakeMaker version 6.36
Modified: trunk/libxml-rss-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/debian/changelog?rev=22762&op=diff
==============================================================================
--- trunk/libxml-rss-perl/debian/changelog (original)
+++ trunk/libxml-rss-perl/debian/changelog Sat Jul 5 10:45:03 2008
@@ -1,3 +1,9 @@
+libxml-rss-perl (1.33-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- gregor herrmann <gregoa at debian.org> Sat, 05 Jul 2008 12:43:57 +0200
+
libxml-rss-perl (1.32-1) unstable; urgency=low
[ gregor herrmann ]
Modified: trunk/libxml-rss-perl/lib/XML/RSS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/lib/XML/RSS.pm?rev=22762&op=diff
==============================================================================
--- trunk/libxml-rss-perl/lib/XML/RSS.pm (original)
+++ trunk/libxml-rss-perl/lib/XML/RSS.pm Sat Jul 5 10:45:03 2008
@@ -14,7 +14,7 @@
use vars qw($VERSION $AUTOLOAD @ISA $AUTO_ADD);
-$VERSION = '1.32';
+$VERSION = '1.33';
$AUTO_ADD = 0;
@@ -305,6 +305,7 @@
{key => "encode_output", default => 1,},
{key => "output", default => "",},
{key => "encoding", default => "UTF-8",},
+ {key => "encode_cb", default => undef(),},
];
}
@@ -453,6 +454,17 @@
}
}
+sub _get_encode_cb_params
+{
+ my $self = shift;
+
+ return
+ defined($self->{encode_cb}) ?
+ ("encode_cb" => $self->{encode_cb}) :
+ ()
+ ;
+}
+
sub _get_rendering_obj {
my ($self, $ver) = @_;
@@ -460,6 +472,7 @@
{
main => $self,
version => $ver,
+ $self->_get_encode_cb_params(),
}
);
}
@@ -1355,6 +1368,17 @@
output an C<<< <?xsl-stylesheet ... ?> >>> meta-tag in the header that will
allow some browsers to render the RSS file as HTML.
+You can also set C<encode_cb> to a reference to a subroutine that will
+encode the output in a custom way. This subroutine accepts two parameters:
+a reference to the C<XML::RSS::Private::Output::Base>-derived object (which
+should normally not concern you) and the text to encode. It should return
+the text to encode. If not set, then the module will encode using its
+custom encoding routine.
+
+Note that in order to encode properly, you need to handle "CDATA" sections
+properly. Look at L<XML::RSS::Private::Output::Base>'s C<_default_encode()>
+method for how to do it properly.
+
=item add_item (title=>$title, link=>$link, description=>$desc, mode=>$mode)
Adds an item to the XML::RSS object. B<mode> and B<description> are optional.
Modified: trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/Base.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/Base.pm?rev=22762&op=diff
==============================================================================
--- trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/Base.pm (original)
+++ trunk/libxml-rss-perl/lib/XML/RSS/Private/Output/Base.pm Sat Jul 5 10:45:03 2008
@@ -31,6 +31,16 @@
}
return $self->{_main};
+}
+
+sub _encode_cb {
+ my $self = shift;
+
+ if (@_) {
+ $self->{_encode_cb} = shift;
+ }
+
+ return $self->{_encode_cb};
}
sub _initialize {
@@ -41,6 +51,12 @@
$self->_main($args->{main});
# TODO : Remove once we have inheritance proper.
$self->_rss_out_version($args->{version});
+ if (defined($args->{encode_cb})) {
+ $self->_encode_cb($args->{encode_cb});
+ }
+ else {
+ $self->_encode_cb(\&_default_encode);
+ }
return 0;
}
@@ -55,6 +71,11 @@
}
sub _encode {
+ my ($self, $text) = @_;
+ return $self->_encode_cb()->($self, $text);
+}
+
+sub _default_encode {
my ($self, $text) = @_;
if (!defined($text)) {
Modified: trunk/libxml-rss-perl/t/items-are-0.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-rss-perl/t/items-are-0.t?rev=22762&op=diff
==============================================================================
--- trunk/libxml-rss-perl/t/items-are-0.t (original)
+++ trunk/libxml-rss-perl/t/items-are-0.t Sat Jul 5 10:45:03 2008
@@ -3,9 +3,10 @@
use strict;
use warnings;
-use Test::More tests => 167;
+use Test::More tests => 168;
use XML::RSS;
+use HTML::Entities qw(encode_entities);
sub contains
{
@@ -2092,6 +2093,41 @@
);
}
+sub named_encode
+{
+ my ($self, $text) = @_;
+
+ if (!defined($text)) {
+ require Carp;
+ Carp::confess "\$text is undefined in XML::RSS::_encode(). We don't know how " . "to handle it!";
+ }
+
+ my $encoded_text = '';
+
+ while ($text =~ s/(.*?)(\<\!\[CDATA\[.*?\]\]\>)//s) {
+ # we use &named; entities here because it's HTML
+ $encoded_text .= encode_entities($1) . $2;
+ }
+
+ # we use numeric entities here because it's XML
+ $encoded_text .= encode_entities($text);
+
+ return $encoded_text;
+}
+
+{
+ my $version = "0.91";
+ my $rss = create_rss_1({
+ version => $version,
+ image_link => "Hello <there&Yes>",
+ rss_args => ["encode_cb" => \&named_encode],
+ });
+ # TEST
+ contains($rss,
+ "<image>\n<title>freshmeat.net</title>\n<url>0</url>\n<link>Hello <there&Yes></link>\n</image>\n",
+ "Testing encode_cb with named encodings",
+ );
+}
{
my $rss = create_channel_rss({
version => "0.91",
More information about the Pkg-perl-cvs-commits
mailing list