line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
313
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
351
|
use Plack::App::RDF::LinkedData; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use RDF::LinkedData; |
7
|
|
|
|
|
|
|
use Plack::Request; |
8
|
|
|
|
|
|
|
use Plack::Builder; |
9
|
|
|
|
|
|
|
use Config::ZOMG; |
10
|
|
|
|
|
|
|
use Carp qw(confess); |
11
|
|
|
|
|
|
|
use Module::Load::Conditional qw[can_load]; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
linked_data.psgi - A simple Plack server for RDF as linked data |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 INSTRUCTIONS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
See L<Plack::App::RDF::LinkedData> for instructions on how to use this. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $config; |
26
|
|
|
|
|
|
|
BEGIN { |
27
|
|
|
|
|
|
|
unless ($config = Config::ZOMG->open( |
28
|
|
|
|
|
|
|
name => "RDF::LinkedData" |
29
|
|
|
|
|
|
|
)) { |
30
|
|
|
|
|
|
|
if ($ENV{'PERLRDF_STORE'}) { |
31
|
|
|
|
|
|
|
$config->{store} = $ENV{'PERLRDF_STORE'}; |
32
|
|
|
|
|
|
|
$config->{base_uri} = 'http://localhost:5000'; |
33
|
|
|
|
|
|
|
} else { |
34
|
|
|
|
|
|
|
confess "Couldn't find config"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $linkeddata = Plack::App::RDF::LinkedData->new(); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$linkeddata->configure($config); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $rdf_linkeddata = $linkeddata->to_app; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
builder { |
46
|
|
|
|
|
|
|
enable "Head"; |
47
|
|
|
|
|
|
|
enable "ContentLength"; |
48
|
|
|
|
|
|
|
enable "ConditionalGET"; |
49
|
|
|
|
|
|
|
if (defined($config->{expires}) && (can_load( modules => { 'Plack::Middleware::Expires' => 0 }))) { |
50
|
|
|
|
|
|
|
enable 'Expires', |
51
|
|
|
|
|
|
|
content_type => qr//, |
52
|
|
|
|
|
|
|
expires => $config->{expires} |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
if (can_load( modules => { 'Plack::Middleware::CrossOrigin' => 0 })) { enable 'CrossOrigin' => %{$config->{cors}}}; |
55
|
|
|
|
|
|
|
$rdf_linkeddata; |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AUTHOR |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Kjetil Kjernsmo C<< <kjetilk@cpan.org> >> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 COPYRIGHT |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Copyright (c) 2010 ABC Startsiden AS and Gregory Todd Williams and |
69
|
|
|
|
|
|
|
2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kjetil Kjernsmo. This program is |
70
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same |
71
|
|
|
|
|
|
|
terms as Perl itself. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |