From 1d75440f9719b9f2de57f6250f574b427939ea50 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 14 Nov 2011 04:26:15 +0000 Subject: Use htaccess for conneg instead of PHP. --- doc/htaccess.in | 24 +++++++++++++++++++++++ doc/index.php | 60 --------------------------------------------------------- 2 files changed, 24 insertions(+), 60 deletions(-) create mode 100644 doc/htaccess.in delete mode 100644 doc/index.php (limited to 'doc') diff --git a/doc/htaccess.in b/doc/htaccess.in new file mode 100644 index 0000000..43c3002 --- /dev/null +++ b/doc/htaccess.in @@ -0,0 +1,24 @@ +# Turn off MultiViews +Options -MultiViews + +# Ensure *.ttl files are served as appropriate content type +AddType text/turtle .ttl + +# Rewrite engine setup +RewriteEngine On +RewriteBase @BASE@ + +# Rewrite rule to serve HTML content from the vocabulary URI if requested +RewriteCond %{HTTP_ACCEPT} !application/rdf\+xml.*(text/html|application/xhtml\+xml) +RewriteCond %{HTTP_ACCEPT} text/html [OR] +RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml [OR] +RewriteCond %{HTTP_USER_AGENT} ^Mozilla/.* +RewriteRule ^$ @NAME@.html [L] + +# Rewrite rule to serve Turtle content from the vocabulary URI if requested +RewriteCond %{HTTP_ACCEPT} text/turtle [OR] +RewriteCond %{HTTP_ACCEPT} application/x-turtle +RewriteRule ^$ @NAME@.ttl [L] + +# Serve HTML page by default +RewriteRule ^$ @NAME@.html [L] diff --git a/doc/index.php b/doc/index.php deleted file mode 100644 index e6cdd10..0000000 --- a/doc/index.php +++ /dev/null @@ -1,60 +0,0 @@ -/
This document is content-negotiated. If you request it with Accept: application\/x-turtle<\/code> you will get the description in Turtle. Also supported: application\/rdf+xml<\/code>, application\/json<\/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; - } -} - -?> -- cgit v1.2.1