aboutsummaryrefslogtreecommitdiffstats
path: root/doc/index.php
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-10-04 18:21:08 +0000
committerDavid Robillard <d@drobilla.net>2010-10-04 18:21:08 +0000
commitcef9811dac46a9d54dab0f0d82ce5c3ae032fc7c (patch)
tree632b911da25fc24b6b3d331d7ceffc22606b8e5b /doc/index.php
parent61842745ab15454ee66be54a6f3bcc148a75406f (diff)
downloadlv2-cef9811dac46a9d54dab0f0d82ce5c3ae032fc7c.tar.xz
Initial import of lv2plug.in universe.
Diffstat (limited to 'doc/index.php')
-rw-r--r--doc/index.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/doc/index.php b/doc/index.php
new file mode 100644
index 0000000..e6cdd10
--- /dev/null
+++ b/doc/index.php
@@ -0,0 +1,60 @@
+<?php
+# Content-type negotiation for LV2 specification bundles
+
+$rdfxml = accepts("application\/rdf\+xml");
+$turtle = accepts("application\/turtle");
+$x_turtle = accepts("application\/x-turtle");
+$text_turtle = accepts("text\/turtle");
+$json = accepts("application\/json");
+$html = accepts("text\/html");
+$xhtml = accepts("application\/xhtml\+xml");
+$text_plain = accepts("text\/plain");
+
+$name = basename($_SERVER['REQUEST_URI']);
+
+# Return Turtle ontology
+if ($turtle or $x_turtle or $text_turtle) {
+ header("Content-Type: application/x-turtle");
+ passthru("cat ./$name.ttl");
+
+# Return ontology translated into rdf+xml
+} else if ($rdfxml) {
+ header("Content-Type: application/rdf+xml");
+ passthru("~/bin/rapper -q -i turtle -o rdfxml-abbrev ./$name.ttl");
+
+} else if ($json) {
+ header("Content-Type: application/json");
+ passthru("~/bin/rapper -q -i turtle -o json ./$name.ttl");
+
+# Return HTML documentation
+} else if ($html or $xhtml) {
+ if ($html) {
+ header("Content-Type: text/html");
+ } else {
+ header("Content-Type: application/xhtml+xml");
+ }
+ $name = basename($_SERVER['REQUEST_URI']);
+ passthru("cat ./$name.html | sed '
+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>/'");
+
+# Return NTriples (text/plain)
+} else if ($text_plain) {
+ header("Content-Type: text/plain");
+ passthru("~/bin/rapper -q -i turtle -o ntriples ./$name.ttl");
+
+# Return Turtle ontology by default
+} else {
+ header("Content-Type: application/x-turtle");
+ passthru("cat ./$name.ttl");
+}
+
+function accepts($type) {
+ global $_SERVER;
+ if (preg_match("/$type(;q=(\d+\.\d+))?/i", $_SERVER['HTTP_ACCEPT'], $matches)) {
+ return isset($matches[2]) ? $matches[2] : 1;
+ } else {
+ return 0;
+ }
+}
+
+?>