Remove polymorphic-port extension (obsoleted by atom extension).
[lv2.git] / doc / index.php
blobe6cdd10e64905b7c32dbb30a3d373ae03dd06949
1 <?php
2 # Content-type negotiation for LV2 specification bundles
4 $rdfxml = accepts("application\/rdf\+xml");
5 $turtle = accepts("application\/turtle");
6 $x_turtle = accepts("application\/x-turtle");
7 $text_turtle = accepts("text\/turtle");
8 $json = accepts("application\/json");
9 $html = accepts("text\/html");
10 $xhtml = accepts("application\/xhtml\+xml");
11 $text_plain = accepts("text\/plain");
13 $name = basename($_SERVER['REQUEST_URI']);
15 # Return Turtle ontology
16 if ($turtle or $x_turtle or $text_turtle) {
17 header("Content-Type: application/x-turtle");
18 passthru("cat ./$name.ttl");
20 # Return ontology translated into rdf+xml
21 } else if ($rdfxml) {
22 header("Content-Type: application/rdf+xml");
23 passthru("~/bin/rapper -q -i turtle -o rdfxml-abbrev ./$name.ttl");
25 } else if ($json) {
26 header("Content-Type: application/json");
27 passthru("~/bin/rapper -q -i turtle -o json ./$name.ttl");
29 # Return HTML documentation
30 } else if ($html or $xhtml) {
31 if ($html) {
32 header("Content-Type: text/html");
33 } else {
34 header("Content-Type: application/xhtml+xml");
36 $name = basename($_SERVER['REQUEST_URI']);
37 passthru("cat ./$name.html | sed '
38 s/<\/body>/<div style=\"font-size: smaller; color: gray; text-align: right; margin: 1ex;\">This document is content-negotiated. If you request it with <code>Accept: application\/x-turtle<\/code> you will get the description in Turtle. Also supported: <code>application\/rdf+xml<\/code>, <code>application\/json<\/code>, <code>text\/plain<\/code><\/div><\/body>/'");
40 # Return NTriples (text/plain)
41 } else if ($text_plain) {
42 header("Content-Type: text/plain");
43 passthru("~/bin/rapper -q -i turtle -o ntriples ./$name.ttl");
45 # Return Turtle ontology by default
46 } else {
47 header("Content-Type: application/x-turtle");
48 passthru("cat ./$name.ttl");
51 function accepts($type) {
52 global $_SERVER;
53 if (preg_match("/$type(;q=(\d+\.\d+))?/i", $_SERVER['HTTP_ACCEPT'], $matches)) {
54 return isset($matches[2]) ? $matches[2] : 1;
55 } else {
56 return 0;