summaryrefslogtreecommitdiff
path: root/lib/Multi
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Multi')
-rw-r--r--lib/Multi/Feed.pm44
-rw-r--r--lib/Multi/IRC.pm3
-rw-r--r--lib/Multi/RG.pm13
3 files changed, 29 insertions, 31 deletions
diff --git a/lib/Multi/Feed.pm b/lib/Multi/Feed.pm
index c97d87d8..12631497 100644
--- a/lib/Multi/Feed.pm
+++ b/lib/Multi/Feed.pm
@@ -8,7 +8,7 @@ package Multi::Feed;
use strict;
use warnings;
use POE;
-use XML::Writer;
+use TUWF::XML;
use POSIX 'strftime';
use Time::HiRes 'time';
use VNDBUtil 'bb2html';
@@ -104,33 +104,33 @@ sub write_atom { # num, res, feed, time
}
my $data;
- my $x = XML::Writer->new(OUTPUT => \$data, DATA_MODE => 1, DATA_INDENT => 2);
- $x->xmlDecl('UTF-8');
- $x->startTag(feed => xmlns => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en', 'xml:base' => $VNDB::S{url}.'/');
- $x->dataElement(title => $VNDB::S{atom_feeds}{$feed}[1]);
- $x->dataElement(updated => datetime($updated));
- $x->dataElement(id => $VNDB::S{url}.$VNDB::S{atom_feeds}{$feed}[2]);
- $x->emptyTag(link => rel => 'self', type => 'application/atom+xml', href => "$VNDB::S{url}/feeds/$feed.atom");
- $x->emptyTag(link => rel => 'alternate', type => 'text/html', href => $VNDB::S{atom_feeds}{$feed}[2]);
+ my $x = TUWF::XML->new(write => sub { $data .= shift }, pretty => 2);
+ $x->xml();
+ $x->tag(feed => xmlns => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en', 'xml:base' => $VNDB::S{url}.'/');
+ $x->tag(title => $VNDB::S{atom_feeds}{$feed}[1]);
+ $x->tag(updated => datetime($updated));
+ $x->tag(id => $VNDB::S{url}.$VNDB::S{atom_feeds}{$feed}[2]);
+ $x->tag(link => rel => 'self', type => 'application/atom+xml', href => "$VNDB::S{url}/feeds/$feed.atom", undef);
+ $x->tag(link => rel => 'alternate', type => 'text/html', href => $VNDB::S{atom_feeds}{$feed}[2], undef);
for(@$r) {
- $x->startTag('entry');
- $x->dataElement(id => $VNDB::S{url}.$_->{id});
- $x->dataElement(title => $_->{title});
- $x->dataElement(updated => $_->{updated}?datetime($_->{updated}):datetime($_->{published}));
- $x->dataElement(published => datetime($_->{published})) if $_->{published};
+ $x->tag('entry');
+ $x->tag(id => $VNDB::S{url}.$_->{id});
+ $x->tag(title => $_->{title});
+ $x->tag(updated => $_->{updated}?datetime($_->{updated}):datetime($_->{published}));
+ $x->tag(published => datetime($_->{published})) if $_->{published};
if($_->{username}) {
- $x->startTag('author');
- $x->dataElement(name => $_->{username});
- $x->dataElement(uri => '/u'.$_->{uid}) if $_->{uid};
- $x->endTag('author');
+ $x->tag('author');
+ $x->tag(name => $_->{username});
+ $x->tag(uri => '/u'.$_->{uid}) if $_->{uid};
+ $x->end;
}
- $x->emptyTag(link => rel => 'alternate', type => 'text/html', href => $_->{id});
- $x->dataElement(summary => bb2html($_->{summary}, 200), type => 'html') if $_->{summary};
- $x->endTag('entry');
+ $x->tag(link => rel => 'alternate', type => 'text/html', href => $_->{id}, undef);
+ $x->tag('summary', type => 'html', bb2html($_->{summary}, 200)) if $_->{summary};
+ $x->end('entry');
}
- $x->endTag('feed');
+ $x->end('feed');
open my $f, '>:utf8', "$VNDB::ROOT/www/feeds/$feed.atom" || die $!;
print $f $data;
diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm
index 22e4021b..2967724c 100644
--- a/lib/Multi/IRC.pm
+++ b/lib/Multi/IRC.pm
@@ -15,7 +15,8 @@ use POE qw|
|;
use POE::Component::IRC::Common ':ALL';
use Time::HiRes 'time';
-use VNDBUtil 'normalize_query', 'uri_escape';
+use VNDBUtil 'normalize_query';
+use TUWF::Misc 'uri_escape';
use constant {
diff --git a/lib/Multi/RG.pm b/lib/Multi/RG.pm
index a04ae062..e8ef52ee 100644
--- a/lib/Multi/RG.pm
+++ b/lib/Multi/RG.pm
@@ -10,7 +10,7 @@ use warnings;
use POE 'Wheel::Run', 'Filter::Stream';
use Encode 'encode_utf8';
use XML::Parser;
-use XML::Writer;
+use TUWF::XML;
use Time::HiRes 'time';
@@ -147,7 +147,7 @@ sub savegraph {
# - Remove first <polygon> element (emulates the background color)
# - Replace stroke and fill attributes with classes (so that coloring is done in CSS)
my $svg = '';
- my $w = XML::Writer->new(OUTPUT => \$svg);
+ my $w = TUWF::XML->new(write => sub { $svg .= shift });
my $p = XML::Parser->new;
$p->setHandlers(
Start => sub {
@@ -160,24 +160,21 @@ sub savegraph {
delete @attr{qw|stroke fill xmlns xmlns:xlink|};
delete $attr{id} if $attr{id} && $attr{id} !~ /^node_[vp]\d+$/;
- $el eq 'path' || $el eq 'polygon'
- ? $w->emptyTag("svg:$el", %attr)
- : $w->startTag("svg:$el", %attr);
+ $w->tag("svg:$el", %attr, $el eq 'path' || $el eq 'polygon' ? undef : ());
},
End => sub {
my($expat, $el) = @_;
return if $el eq 'title' || $expat->in_element('title');
return if $el eq 'polygon' && $expat->depth == 2;
- $w->endTag("svg:$el") if $el ne 'path' && $el ne 'polygon';
+ $w->end("svg:$el") if $el ne 'path' && $el ne 'polygon';
},
Char => sub {
my($expat, $str) = @_;
return if $expat->in_element('title');
- $w->characters($str) if $str !~ /^[\s\t\r\n]*$/s;
+ $w->txt($str) if $str !~ /^[\s\t\r\n]*$/s;
}
);
$p->parsestring($_[HEAP]{svg});
- $w->end();
# save the processed SVG in the database and fetch graph ID
$_[KERNEL]->post(pg => query => 'INSERT INTO relgraphs (svg) VALUES (?) RETURNING id', [ $svg ], 'finish');