——=head1 NAME
HTML::Microformats::Format::RelEnclosure - the rel-enclosure microformat
=head1 SYNOPSIS
my @enclosures = HTML::Microformats::Format::RelEnclosure->extract_all(
$doc->documentElement, $context);
foreach my $e (@enclosures)
{
my $type = $l->get_type || 'unknown';
printf("%s (%s)\n"), $l->get_href, $type);
}
=head1 DESCRIPTION
HTML::Microformats::Format::RelEnclosure inherits from HTML::Microformats::Format_Rel. See the
base class definition for a description of property getter/setter methods,
constructors, etc.
=head2 Additional Method
=over 4
=item C<< $relenc->get_type() >>
Returns the media type (Content-Type) of the resource being linked to. This
is taken from the HTML 'type' attribute, so if that's not present, returns undef.
=back
=cut
use
common::sense;
use
5.008;
our
$VERSION
=
'0.100'
;
sub
new
{
my
$class
=
shift
;
my
$self
=
$class
->SUPER::new(
@_
);
$self
->{
'DATA'
}->{
'type'
} =
$self
->{
'element'
}->getAttribute(
'type'
)
if
$self
->{
'element'
}->hasAttribute(
'type'
);
return
$self
;
}
sub
format_signature
{
return
{
'rel'
=>
'enclosure'
,
'classes'
=> [
[
'type'
,
'?#'
] ,
[
'href'
,
'1#'
] ,
[
'label'
,
'1#'
] ,
[
'title'
,
'1#'
] ,
] ,
'rdf:type'
=> [] ,
'rdf:property'
=> {} ,
}
}
sub
profiles
{
}
sub
add_to_model
{
my
$self
=
shift
;
my
$model
=
shift
;
$model
->add_statement(RDF::Trine::Statement->new(
RDF::Trine::Node::Resource->new(
$self
->context->document_uri),
RDF::Trine::Node::Resource->new(
"${enc}enclosure"
),
RDF::Trine::Node::Resource->new(
$self
->data->{
'href'
}),
));
$model
->add_statement(RDF::Trine::Statement->new(
RDF::Trine::Node::Resource->new(
$self
->data->{
'href'
}),
RDF::Trine::Node::Resource->new(
"${enc}Enclosure"
),
));
$model
->add_statement(RDF::Trine::Statement->new(
RDF::Trine::Node::Resource->new(
$self
->data->{
'href'
}),
RDF::Trine::Node::Resource->new(
"${enc}type"
),
RDF::Trine::Node::Literal->new(
''
.
$self
->data->{
'type'
}),
))
if
defined
$self
->data->{
'type'
};
$model
->add_statement(RDF::Trine::Statement->new(
RDF::Trine::Node::Resource->new(
$self
->data->{
'href'
}),
$self
->_make_literal(
$self
->data->{
'label'
}),
));
$model
->add_statement(RDF::Trine::Statement->new(
RDF::Trine::Node::Resource->new(
$self
->data->{
'href'
}),
$self
->_make_literal(
$self
->data->{
'title'
}),
));
return
$self
;
}
1;
=head1 MICROFORMAT
HTML::Microformats::Format::RelEnclosure supports rel-enclosure as described at
The "title" attribute on the link, and the linked text are taken to be significant.
=head1 RDF OUTPUT
Data is returned using the RSS Enclosures vocabulary
(L<http://purl.oclc.org/net/rss_2.0/enc#>) and occasional other terms.
=head1 BUGS
Please report any bugs to L<http://rt.cpan.org/>.
=head1 SEE ALSO
L<HTML::Microformats::Format_Rel>,
L<HTML::Microformats>,
L<HTML::Microformats::Format::hAtom>.
=head1 AUTHOR
Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
=head1 COPYRIGHT
Copyright 2008-2010 Toby Inkster
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut