NAME
Plack::App::RDF::Files - Serve RDF data from static files
VERSION
version 0.01
DESCRIPTION
This Plack application serves RDF from static files. In short, each RDF resource to be served corresponds to a directory in the file system, located in a common based directory base_dir
. All RDF resources must share a common base URI, which is either taken from the PSGI request or configured with base_uri
.
EXAMPLE
Let's assume you have a base directory /var/rdf/
with some subdirectories foo
, bar
, and doz
. Given a base URI, such as <http://example.org/>, an instance of Plack::App::RDF::Files will serve RDF data for the following URIs:
http://example.org/
http://example.org/foo
http://example.org/bar
http://example.org/doz
The actual RDF data is collected and combined from RDF files (*.nt
, *.ttl
, *.rdfxml
...) in each directory. There is no need to set up a triple store, just create and modify directories and RDF files.
METHODS
negotiate( $env )
This internal methods selects an RDF serializer based on the PSGI environment variable negotiate.format
(see Plack::Middleware::Negotiate) or the negotiate
method of RDF::Trine::Serializer. Returns first a RDF::Trine::Serializer on success or undef
on error) and second a (possibly empty) list of HTTP response headers.
CONFIGURATION
- base_dir
-
Mandatory base directory that all resource directories are located in.
- base_uri
-
The base URI of all resources.
- path_map
-
Optional code reference that maps a local part of an URI to a relative directory. Set to the identity mapping by default.
- file_types
-
An array of RDF file types (extensions) to look for. Set to
['rdfxml','nt','ttl']
by default. - include_index
-
By default a HTTP 404 error is returned if one tries to access the base directory. Enable this option to also serve RDF data from this location.
- index_property
-
RDF property to use for listing all resources connected to the base URI (if <include_index> is enabled). Set to
rdfs:seeAlso
by default. Can be disabled by setting a false value. - namespaces
-
Optional namespaces for serialization, passed to RDF::Trine::Serializer.
PSGI environment variables
The following PSGI environment variables are relevant:
- rdf.uri
-
The requested URI
- rdf.iterator
-
The RDF::Trine::Iterator that will be used for serializing, if
psgi.streaming
is set. One can use this variable to catch the RDF data in another post-processing middleware. - rdf.files
-
An hash of source filenames, each with the number of triples (on success) as property
size
, an error message aserror
if parsing failed, and the timestamp of last modification asmtime
.size
anderror
may not be given before parsing, ifrdf.iterator
is set. - rdf.files.mtime
-
Maximum value of all last modification times (this may be removed!).
LIMITATIONS
This module is an early developer release. Be warned!
All resource URIs to be served must have a common URI prefix (such as http://example.org/
above) and a local part that may be restricted to a limited set of characters. For instance the character sequence ../
is not allowed.
NOTES
If an existing resource does not contain triples, the axiomatic triple ?uri rdf:type rdfs:Resource
is returned.
To update the files, add a middleware that catches 404 and 202 responses.
TODO
VoID descriptions could be added, possibly with RDF::Generator::Void.
SEE ALSO
Use Plack::Middleware::Negotiate to add content negotiation based on an URL parameter and/or suffix.
See RDF::LinkedData for a different module to serve RDF as linked data. See also RDF::Flow and RDF::Lazy for processing RDF data.
See http://foafpress.org/ for a similar approach in PHP.
AUTHOR
Jakob Voß <voss@gbv.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Jakob Voß.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 349:
Non-ASCII character seen before =encoding in 'Voß'. Assuming UTF-8