Skip to content
Snippets Groups Projects
Commit 0797ab48 authored by alvaro's avatar alvaro
Browse files

Fixing rdfs:Resource template

Adding better content-type based on file extension for static module.
parent 393e0ab0
No related branches found
No related tags found
No related merge requests found
...@@ -25,8 +25,9 @@ class StaticModule extends abstractModule{ ...@@ -25,8 +25,9 @@ class StaticModule extends abstractModule{
global $acceptContentType; global $acceptContentType;
global $endpoints; global $endpoints;
global $lodspk; global $lodspk;
$extension = array_pop(explode(".", $file));
header("Content-type: "); $ct = $this->getContentType($extension);
header("Content-type: ".$ct);
$uri = $localUri; $uri = $localUri;
if($conf['debug']){ if($conf['debug']){
echo "\n-------------------------------------------------\nIn ".$conf['static']['directory']."\n"; echo "\n-------------------------------------------------\nIn ".$conf['static']['directory']."\n";
...@@ -55,6 +56,33 @@ class StaticModule extends abstractModule{ ...@@ -55,6 +56,33 @@ class StaticModule extends abstractModule{
} }
} }
private function getContentType($e){
$contentTypes = array('html' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'nt' => 'text/plain',
'ttl' => 'text/turtle',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'pdf' => 'application/pdf',
'zip' => 'application/zip',
'gz' => 'application/gzip'
);
//Add new/override existing mime types defined by user
foreach($conf['static']['mimetypes'] as $k => $v){
$contentTypes[$k] = $v;
}
if(isset($contentTypes[$e])){
return $contentTypes[$e];
}
return ""; //empty string seems to work fine with browsers
}
} }
......
...@@ -83,8 +83,6 @@ ...@@ -83,8 +83,6 @@
<td> <td>
{%if row.o.uri == 1%} {%if row.o.uri == 1%}
<a rel='{{row.p.value}}' href='{{row.o.value}}'>{{row.o.curie}}</a> <a rel='{{row.p.value}}' href='{{row.o.value}}'>{{row.o.curie}}</a>
{%elif row.o.blank == 1%}
<a rel='{{row.p.value}}' href='{{row.o.value}}'>{{row.o.curie}}</a>
{%else%} {%else%}
<span property='{{row.p.value}}'>{{row.o.value}}</span> <span property='{{row.p.value}}'>{{row.o.value}}</span>
{%endif%} {%endif%}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment