RDF::LinkedData - A Linked Data server implementation
Version 0.21_1
A simple Plack server illustrates the usage nicely:
use RDF::LinkedData; use Plack::Request; use RDF::Trine; my $parser = RDF::Trine::Parser->new( 'turtle' ); my $model = RDF::Trine::Model->temporary_model; my $base_uri = 'http://localhost:5000'; $parser->parse_file_into_model( $base_uri, 't/data/basic.ttl', $model ); my $ld = RDF::LinkedData->new(model => $model, base_uri=>$base_uri); my $linked_data = sub { my $env = shift; my $req = Plack::Request->new($env); my $uri = $req->path_info; if ($req->path_info =~ m!^(.+?)/?(page|data)$!) { $uri = $1; $ld->type($2); } $ld->headers_in($req->headers); return $ld->response($uri)->finalize; }
This class provides a server implementation for serving Linked Data from the host it is configured for. Its main feature is that it can take an RDF model optionally read from file(s) or from a SPARQL endpoint and serve the URIs of those resources according to Linked Data best practices. It will do content negotation, supports many seralizations, and it will do 303 redirects as needed.
For example, say you control a host lod.example.org and wish to use it to serve Linked Data. On file, you have a bit of RDF that you want to serve, like:
lod.example.org
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . <http://lod.example.org/foo> rdfs:label "DAHUT" ; rdfs:seeAlso <http://lod.example.org/bar> . <http://lod.example.org/bar> rdfs:label "More here" .
Then configuring this server to use the above file will make http://lod.example.org/foo and http://lod.example.org/bar dereferenceable with no further effort. The server will also return an appropriate 303 redirect to either a data or page suffix depending on the client's Accept header and return a representation of the data.
http://lod.example.org/foo
http://lod.example.org/bar
data
page
Accept
This module simply uses the default implementation in RDF::LinkedData::ProviderRole, and does nothing on its own. However, there is a quirk which is only relevant to a developer of this package.
I had to redefine Moose::Role's with due to a conflict with Error described in the documentation of the latter. Users will never see this.
This module was started by by Gregory Todd Williams <gwilliams@cpan.org> for RDF::LinkedData::Apache, but heavily refactored and rewritten by Kjetil Kjernsmo, <kjetilk@cpan.org>
<gwilliams@cpan.org>
<kjetilk@cpan.org>
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.
bug-rdf-linkeddata at rt.cpan.org
Do not rely in the current API unless you are planning to keep track of the development of this module. It is still very much in flux, and may change without warning!
You can find documentation for this module with the perldoc command.
perldoc RDF::LinkedData
The perlrdf mailing list is the right place to seek help and discuss this module:
http://lists.perlrdf.org/listinfo/dev
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=RDF-LinkedData
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/RDF-LinkedData
CPAN Ratings
http://cpanratings.perl.org/d/RDF-LinkedData
Search CPAN
http://search.cpan.org/dist/RDF-LinkedData
Copyright 2010-2011 Kjetil Kjernsmo, 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.
To install RDF::LinkedData, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RDF::LinkedData
CPAN shell
perl -MCPAN -e shell install RDF::LinkedData
For more information on module installation, please visit the detailed CPAN module installation guide.