.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "HTTP::LRDD 3pm" .TH HTTP::LRDD 3pm "2012-12-12" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" HTTP::LRDD \- link\-based resource descriptor discovery .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use HTTP::LRDD; \& \& my $lrdd = HTTP::LRDD\->new; \& my @descriptors = $lrdd\->discover($resource); \& foreach my $descriptor (@descriptors) \& { \& my $description = $lrdd\->parse($descriptor); \& # $description is an RDF::Trine::Model \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Note: the \s-1LRDD\s0 specification has ceased to be, with some parts being merged into the host-meta Internet Draft. This \s-1CPAN\s0 module will go in its own direction, bundling up best-practice techniques for discovering links and descriptors for a given \s-1URI\s0. .SS "Import Routine" .IX Subsection "Import Routine" .ie n .IP """use HTTP::LRDD (@predicates)""" 4 .el .IP "\f(CWuse HTTP::LRDD (@predicates)\fR" 4 .IX Item "use HTTP::LRDD (@predicates)" When importing \s-1HTTP::LRDD\s0, you can optionally provide a list of predicate URIs (i.e. the URIs which rel values expand to). This may also include IANA-registered link types, which are short tokens rather than full URIs. If you do not provide a list of predicate URIs, then a sensible default set is used. .Sp Because this configuration is global in nature, it is not recommended. It is better to supply a list of predicates to the constructor instead, or rely on the defaults. This feature should be regarded as deprecated. .SS "Constructors" .IX Subsection "Constructors" .ie n .IP """HTTP::LRDD\->new(@predicates)""" 4 .el .IP "\f(CWHTTP::LRDD\->new(@predicates)\fR" 4 .IX Item "HTTP::LRDD->new(@predicates)" Create a new \s-1LRDD\s0 discovery object using the given predicate URIs. If \f(CW@predicates\fR is omitted, then the predicates passed to the import routine are used instead. .ie n .IP """HTTP::LRDD\->new_strict""" 4 .el .IP "\f(CWHTTP::LRDD\->new_strict\fR" 4 .IX Item "HTTP::LRDD->new_strict" Create a new \s-1LRDD\s0 discovery object using the 'describedby' and \&'lrdd' IANA-registered predicates. .ie n .IP """HTTP::LRDD\->new_default""" 4 .el .IP "\f(CWHTTP::LRDD\->new_default\fR" 4 .IX Item "HTTP::LRDD->new_default" Create a new \s-1LRDD\s0 discovery object using the default set of predicates ('describedby', 'lrdd', 'wdrs:describedby', 'xhv:meta' and 'rdfs:seeAlso'). .SS "Public Methods" .IX Subsection "Public Methods" .ie n .IP """$lrdd\->discover($resource_uri)""" 4 .el .IP "\f(CW$lrdd\->discover($resource_uri)\fR" 4 .IX Item "$lrdd->discover($resource_uri)" Discovers a descriptor for the given resource; or if called in a list context, a list of descriptors. .Sp A descriptor is a resource that provides a description for something. So, if the given resource \s-1URI\s0 was the web address for an image, then the descriptor might be the web address for a metadata file about the image. If the given \s-1URI\s0 was an e\-mail address, then the descriptor might be a profile document for the person to whom the address belongs. .Sp The following sources are checked (in order) to find links to descriptors. .RS 4 .IP "\(bu" 4 \&\s-1HTTP\s0 response headers (\*(L"Link\*(R" header; \*(L"303 See Other\*(R" status) .IP "\(bu" 4 \&\s-1HTTP\s0 response message (\s-1RDF\s0 or RDFa) .IP "\(bu" 4 https://HOSTNAME/.well\-known/host\-meta .IP "\(bu" 4 http://HOSTNAME/.well\-known/host\-meta .RE .RS 4 .Sp If none of the above is able to yield a link to a descriptor, then the resource \s-1URI\s0 itself may be returned if it is in a self-describing format (e.g. \s-1RDF\s0). .Sp There is no guaranteed file format for the descriptor, but it is usually \s-1RDF\s0, \s-1POWDER\s0 \s-1XML\s0 or \s-1XRD\s0. .Sp This method can also be called without an object (as a class method) in which case, a temporary object is created automatically using \&\f(CW\*(C`new\*(C'\fR. .RE .ie n .IP """$lrdd\->parse($descriptor_uri)""" 4 .el .IP "\f(CW$lrdd\->parse($descriptor_uri)\fR" 4 .IX Item "$lrdd->parse($descriptor_uri)" Parses a descriptor in \s-1XRD\s0 or \s-1RDF\s0 (\s-1RDF/XML\s0, RDFa, Turtle, etc). .Sp Returns an RDF::Trine::Model or undef if unable to process. .Sp This method can also be called without an object (as a class method) in which case, a temporary object is created automatically using \&\f(CW\*(C`new\*(C'\fR. .ie n .IP """$lrdd\->process($resource_uri)""" 4 .el .IP "\f(CW$lrdd\->process($resource_uri)\fR" 4 .IX Item "$lrdd->process($resource_uri)" Performs the equivalent of \f(CW\*(C`discover\*(C'\fR and \f(CW\*(C`parse\*(C'\fR in one easy step. .Sp Calls \f(CW\*(C`discover\*(C'\fR in a non-list context, so only the first descriptor is used. .ie n .IP """$lrdd\->process_all($resource_uri)""" 4 .el .IP "\f(CW$lrdd\->process_all($resource_uri)\fR" 4 .IX Item "$lrdd->process_all($resource_uri)" Performs the equivalent of \f(CW\*(C`discover\*(C'\fR and \f(CW\*(C`parse\*(C'\fR in one easy step. .Sp Calls \f(CW\*(C`discover\*(C'\fR in a list context, so multiple descriptors are combined into the resulting graph. .SH "EXAMPLES" .IX Header "EXAMPLES" Discover the hub address (PubSubHubub) for a feed: .PP .Vb 2 \& my $lrdd = HTTP::LRDD\->new(\*(Aqhub\*(Aq); \& my $hub = $lrdd\->discover(\*(Aqhttp://example.net/feed.atom\*(Aq); .Ve .PP Discover an author link (rel=\*(L"author\*(R") from an \s-1HTML\s0 page: .PP .Vb 2 \& my $lrdd = HTTP::LRDD\->new(\*(Aqauthor\*(Aq); \& my $author = $lrdd\->discover(\*(Aqhttp://example.com/page.html\*(Aq); .Ve .PP (For \s-1RDF\s0 people, you should note that rel=\*(L"author\*(R" is not semantically equivalent to the \*(L"foaf:maker\*(R" property but closer to the \&\*(L"foaf:maker/foaf:homepage\*(R" \s-1SPARQL\s0 1.1 property path \- i.e. the rel=\*(L"author\*(R" link destination is not a \s-1URI\s0 for the author themselves, but a page about the author.) .PP If that author resource is in a machine-readable format (e.g. \s-1RDF\s0), then parse the data: .PP .Vb 1 \& my $author_data = $lrdd\->parse($author); .Ve .PP Or, you can combine \f(CW\*(C`discover\*(C'\fR and \f(CW\*(C`parse\*(C'\fR: .PP .Vb 2 \& my $lrdd = HTTP::LRDD\->new(\*(Aqauthor\*(Aq); \& my $author_data = $lrdd\->process(\*(Aqhttp://example.com/page.html\*(Aq); .Ve .PP Get metadata for an image: .PP .Vb 2 \& my $lrdd = HTTP::LRDD\->new; \& my $data = $lrdd\->process_all(\*(Aqhttp://example.org/flower.jpeg\*(Aq); .Ve .PP As we're not passing any arguments to the constructor, we can use a shortcut: .PP .Vb 1 \& my $data = HTTP::LRDD\->process_all(\*(Aqhttp://example.org/flower.jpeg\*(Aq); .Ve .PP Find the title of the image: .PP .Vb 1 \& use RDF::QueryX::Lazy; \& \& my $image = q; \& my $results = RDF::QueryX::Lazy \& \-> new("SELECT * WHERE { <$image> dc:title ?t }") \& \-> execute( HTTP::LRDD\->process_all($image) ); .Ve .SH "BUGS" .IX Header "BUGS" Please report any bugs to . .PP \&\fBNote\fR: many problems can stem from servers that send incorrect \&\f(CW\*(C`Content\-Type\*(C'\fR headers. If you send an \s-1XRD\s0 file as \*(L"text/html\*(R", then this module will not guess what you're doing \- it will assume the file is really \s-1HTML\s0, and inspect it for RDFa. For host-meta files, this module is slightly more relaxed, as there's a strong assumption that they are \s-1XRD\s0... but \s-1YOU\s0 \s-1SHOULD\s0 \s-1NOT\s0 \s-1RELY\s0 \s-1ON\s0 \s-1THIS\s0. If you're running a server, use the correct media type. .SH "SEE ALSO" .IX Header "SEE ALSO" HTTP::Link::Parser, XRD::Parser, XML::Atom::OWL WWW::Finger. .PP . .SH "AUTHOR" .IX Header "AUTHOR" Toby Inkster . .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" Copyright 2010\-2012 Toby Inkster .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "DISCLAIMER OF WARRANTIES" .IX Header "DISCLAIMER OF WARRANTIES" \&\s-1THIS\s0 \s-1PACKAGE\s0 \s-1IS\s0 \s-1PROVIDED\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R" \s-1AND\s0 \s-1WITHOUT\s0 \s-1ANY\s0 \s-1EXPRESS\s0 \s-1OR\s0 \s-1IMPLIED\s0 \&\s-1WARRANTIES\s0, \s-1INCLUDING\s0, \s-1WITHOUT\s0 \s-1LIMITATION\s0, \s-1THE\s0 \s-1IMPLIED\s0 \s-1WARRANTIES\s0 \s-1OF\s0 \&\s-1MERCHANTIBILITY\s0 \s-1AND\s0 \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0.