The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

RDF::LinkedData::ProviderRole - Role providing important functionality for Linked Data implementations

VERSION

Version 0.04

SYNOPSIS

From the Mojolicious::Lite example:

    my $ld = RDF::LinkedData->new($config->{store}, $config->{base});

    my $uri = $self->param('uri');
    my $type =  $self->param('type');
    my $node = $ld->my_node($uri);

    if ($ld->count($node) > 0) {
        my $content = $ld->content($node, $type);
        $self->res->headers->header('Vary' => join(", ", qw(Accept)));
        $self->res->headers->content_type($content->{content_type});
        $self->render_text($content->{body});
    } else {
        $self->render_not_found;
    }

METHODS

new ( config => $config, model => $model, base => $base, request => $request, headers_in => $headers_in )

Creates a new handler object based on named parameters, given a config string or model and a base URI. Optionally, you may pass a Apache request object, and you will need to pass a HTTP::Headers object if you plan to call content.

headers_in ( [ $headers ] )

Returns the HTTP::Headers object if it exists or sets it if a HTTP::Headers object is given as parameter.

type

Returns the chosen variant based on acceptable formats.

my_node

A node for the requested relative URI. This node is typically used as the subject to find which statements to return as data. Note that the base URI, set in the constructor or using the base method, is prepended to the argument.

count ( $node)

Returns the number of statements that has the $node as subject

content ( $node, $type)

Will return the a hashref with content for this URI, based on the $node subject, and the type of node, which may be either data or page. In the first case, an RDF document serialized to a format set by content negotiation. In the latter, a simple HTML document will be returned. The returned hashref has two keys: content_type and body. The former is self-explanatory, the latter contains the actual content.

model

Returns or sets the RDF::Trine::Model object.

base

Returns or sets the base URI for this handler.

AUTHOR

Most of the code was written by Gregory Todd Williams <gwilliams@cpan.org> for RDF::LinkedData::Apache, but refactored into this class for use by other modules by Kjetil Kjernsmo, <kjetilk at cpan.org>

BUGS

Please report any bugs or feature requests to bug-rdf-linkeddata at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=RDF-LinkedData. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc RDF::LinkedData

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2010 Gregory Todd Williams and ABC Startsiden AS.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.