/usr/share/perl5/HTML/Microformats/Format/hNews.pm is in libhtml-microformats-perl 0.105-2+deb8u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | =head1 NAME
HTML::Microformats::Format::hNews - the hNews microformat
=head1 SYNOPSIS
use HTML::Microformats::DocumentContext;
use HTML::Microformats::Format::hNews;
my $context = HTML::Microformats::DocumentContext->new($dom, $uri);
my @objects = HTML::Microformats::Format::hNews->extract_all(
$dom->documentElement, $context);
foreach my $article (@objects)
{
printf("%s %s\n", $article->get_link, $article->get_dateline);
}
=head1 DESCRIPTION
HTML::Microformats::Format::hNews inherits from HTML::Microformats::Format. See the
base class definition for a description of property getter/setter methods,
constructors, etc.
=cut
package HTML::Microformats::Format::hNews;
use base qw(HTML::Microformats::Format::hEntry);
use strict qw(subs vars); no warnings;
use 5.010;
use HTML::Microformats::Utilities qw(searchClass);
use HTML::Microformats::Format::hCard;
use Object::AUTHORITY;
BEGIN {
$HTML::Microformats::Format::hNews::AUTHORITY = 'cpan:TOBYINK';
$HTML::Microformats::Format::hNews::VERSION = '0.105';
}
sub new
{
my ($class, $element, $context) = @_;
my $cache = $context->cache;
return $cache->get($context, $element, $class)
if defined $cache && $cache->get($context, $element, $class);
my $self = {
'element' => $element ,
'context' => $context ,
'cache' => $cache ,
'id' => $context->make_bnode($element) ,
};
bless $self, $class;
my $clone = $self->_hentry_parse;
# hNews has a source-org which is probably an hCard.
$self->_source_org_fallback($clone);
$self->{'DATA'}->{'class'} = 'hnews';
$cache->set($context, $element, $class, $self)
if defined $cache;
return $self;
}
sub _source_org_fallback
{
my ($self, $clone) = @_;
unless (@{ $self->{'DATA'}->{'source-org'} })
{
##TODO: Should really only use the nearest-in-parent. post-0.001
my @so_elements = searchClass('source-org', $self->context->document->documentElement);
foreach my $so (@so_elements)
{
next unless $so->getAttribute('class') =~ /\b(vcard)\b/;
push @{ $self->{'DATA'}->{'source-org'} }, HTML::Microformats::Format::hCard->new($so, $self->context);
}
}
}
sub format_signature
{
my $rv = HTML::Microformats::Format::hEntry->format_signature;
$rv->{'root'} = 'hnews';
push @{ $rv->{'classes'} }, (
['source-org', 'm?', {embedded=>'hCard'}],
['dateline', 'M?', {embedded=>'hCard adr'}],
['geo', 'm*', {embedded=>'geo'}],
['item-license', 'ur*'],
['principles', 'ur*'],
);
my $hnews = 'http://ontologi.es/hnews#';
my $iana = 'http://www.iana.org/assignments/relation/';
# $rv->{'rdf:property'}->{'source-org'}->{'resource'} = ["${hnews}source-org"];
# $rv->{'rdf:property'}->{'dateline'}->{'resource'} = ["${hnews}dateline"];
$rv->{'rdf:property'}->{'dateline'}->{'literal'} = ["${hnews}dateline-literal"];
# $rv->{'rdf:property'}->{'geo'}->{'resource'} = ["${hnews}geo"];
$rv->{'rdf:property'}->{'item-license'}->{'resource'} = ["${iana}license", "http://creativecommons.org/ns#license"];
$rv->{'rdf:property'}->{'principles'}->{'resource'} = ["${hnews}principles"];
return $rv;
}
sub add_to_model
{
my $self = shift;
my $model = shift;
my $hnews = 'http://ontologi.es/hnews#';
$self->SUPER::add_to_model($model);
if ($self->_isa($self->data->{'source-org'}, 'HTML::Microformats::Format::hCard'))
{
$model->add_statement(RDF::Trine::Statement->new(
$self->id(1),
RDF::Trine::Node::Resource->new("${hnews}source-org"),
$self->data->{'source-org'}->id(1, 'holder'),
));
}
if ($self->_isa($self->data->{'dateline'}, 'HTML::Microformats::Format::hCard'))
{
$model->add_statement(RDF::Trine::Statement->new(
$self->id(1),
RDF::Trine::Node::Resource->new("${hnews}dateline"),
$self->data->{'source-org'}->id(1, 'holder'),
));
}
foreach my $geo (@{ $self->data->{'geo'} })
{
if ($self->_isa($geo, 'HTML::Microformats::Format::geo'))
{
$model->add_statement(RDF::Trine::Statement->new(
$self->id(1),
RDF::Trine::Node::Resource->new("${hnews}geo"),
$geo->id(1, 'location'),
));
}
}
return $self;
}
sub profiles
{
my $class = shift;
return qw(http://purl.org/uF/hNews/0.1/);
}
1;
=head1 MICROFORMAT
HTML::Microformats::Format::hNews supports hNews as described at
L<http://microformats.org/wiki/hNews>.
=head1 RDF OUTPUT
hNews is an extension of hAtom; data is returned using the same vocabularies as hAtom,
with additional news-specific terms from L<http://ontologi.es/hnews#>.
=head1 BUGS
Please report any bugs to L<http://rt.cpan.org/>.
=head1 SEE ALSO
L<HTML::Microformats::Format>,
L<HTML::Microformats>,
L<HTML::Microformats::Format::hAtom>,
L<HTML::Microformats::Format::hEntry>.
=head1 AUTHOR
Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
=head1 COPYRIGHT AND LICENCE
Copyright 2008-2012 Toby Inkster
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
=cut
|