diff --git a/README b/README index d12a4d6669b21a9c97b43ac3c8da7f0ba5bb5d8b..839586ed59575909b8256ad9877a3b04df93a6a8 100644 --- a/README +++ b/README @@ -1,11 +1,11 @@ lodspeakr - Linked Open Data Simple Publishing Kit author: Alvaro Graves (alvaro@graves.cl) -version: 20120223 +version: 20120411 Simplest Installation --------------------- -Just run +Simply go to your web server root directory (e.g., /var/www), create a new folder, cd into it and run bash < <(curl -sL http://lodspeakr.org/install) diff --git a/classes/AbstractSpecialFunction.php b/classes/AbstractSpecialFunction.php deleted file mode 100644 index 1865981a5ce7a0b57fd94037e6c5288db74bb26b..0000000000000000000000000000000000000000 --- a/classes/AbstractSpecialFunction.php +++ /dev/null @@ -1,10 +0,0 @@ -<? - -abstract class AbstractSpecialFunction{ - abstract protected function getFunction($uri); - abstract protected function getParams($uri); - abstract public function execute($uri, $context); - -} - -?> diff --git a/classes/BasicSpecialFunction.php b/classes/BasicSpecialFunction.php deleted file mode 100644 index 3a4f2977bb5240796af156f3629d5c8720f48e50..0000000000000000000000000000000000000000 --- a/classes/BasicSpecialFunction.php +++ /dev/null @@ -1,119 +0,0 @@ -<? - -include_once('AbstractSpecialFunction.php'); - -class SpecialFunction extends AbstractSpecialFunction{ - protected function getFunction($uri){ - global $conf; - $count = 1; - $prefixUri = $conf['basedir']; - $aux = str_replace($prefixUri, '', $uri, $count); - $functionAndParams = explode('/', $aux); - return $functionAndParams[0]; - } - - protected function getParams($uri){ - global $conf; - $count = 1; - $prefixUri = $conf['basedir']; - $functionAndParams = explode('/', str_replace($prefixUri, '', $uri, $count)); - if(sizeof($functionAndParams) > 1){ - array_shift($functionAndParams); - return $functionAndParams; - }else{ - return array(null); - } - } - - public function execute($uri, $context){ - global $conf; - global $lodspk; - global $results; - global $rRoot; - $f = $this->getFunction($uri); - $params = array(); - $params = $this->getParams($uri); - //$params[] = $context; - $acceptContentType = Utils::getBestContentType($_SERVER['HTTP_ACCEPT']); - $extension = Utils::getExtension($acceptContentType); - $args = array(); - try{ - $viewFile = $conf['service']['prefix'].$f."/".$extension.".template"; - $modelFile = $conf['service']['prefix'].$f."/".$extension.".queries"; - if(!(is_dir($conf['model']['directory'].$modelFile) || is_file($conf['model']['directory'].$modelFile))){ - $msg = '<h1>Method does not exist!</h1><br/>This means that <tt>'.$modelFile."</tt> doesn't exist.<br/>Please refer to this tutorial to create one.<br/>"; - throw new Exception($msg); - } - if(!is_file($conf['view']['directory'].$viewFile)){ - $msg='<h1>Method does not exist!</h1><br/>This means that <tt>'.$conf['view']['directory'].$viewFile."</tt> doesn't exist.<br/>Please refer to this tutorial to create one.<br/>"; - throw new Exception($msg); - } - $endpoints = $context['endpoints']; - //array_pop($params); - //array_shift($params); - - $prefixHeader = array(); - - for($i=0;$i<sizeof($params);$i++){ - if($conf['mirror_external_uris']){ - $altUri = Utils::curie2uri($params[$i]); - $altUri = preg_replace("|^".$conf['basedir']."|", $conf['ns']['local'], $altUri); - $params[$i] = Utils::uri2curie($altUri); - } - } - - for($i=0;$i<sizeof($params);$i++){ - $auxPrefix = Utils::getPrefix($params[$i]); - if($auxPrefix['ns'] != NULL){ - $prefixHeader[] = $auxPrefix; - } - $args["arg".$i]=$params[$i]; - } - $results['params'] = $params; - $lodspk = $conf['view']['standard']; - $lodspk['type'] = $modelFile; - $lodspk['root'] = $conf['root']; - $lodspk['home'] = $conf['basedir']; - $lodspk['this']['value'] = $uri; - $lodspk['this']['curie'] = Utils::uri2curie($uri); - $lodspk['this']['contentType'] = $acceptContentType; - $lodspk['model']['directory'] = $conf['model']['directory']; - $lodspk['view']['directory'] = $conf['view']['directory']; - $lodspk['ns'] = $conf['ns']; - $lodspk['endpoint'] = $conf['endpoint']; - $lodspk['type'] = $modelFile; - $lodspk['header'] = $prefixHeader; - $lodspk['args'] = $args; - $lodspk['module'] = 'service'; - $lodspk['add_mirrored_uris'] = false; - $lodspk['baseUrl'] = $conf['basedir']; - $lodspk['this']['value'] = $uri; - $lodspk['this']['contentType'] = $acceptContentType; - $lodspk['view']['directory'] = $conf['home'].$conf['view']['directory'].$conf['service']['prefix'].$f.'/'; - $lodspk['model']['directory'] = $conf['home'].$conf['model']['directory']; - chdir($conf['model']['directory']); - $first = array(); - Utils::queryFile($modelFile, $endpoints['local'], $results, $first); - chdir($conf['home']); - $results = Utils::internalize($results); - - if(is_array($results)){ - $results = Convert::array_to_object($results); - } - - //Need to redefine viewFile as 'local' i.e., inside service.foo/ so I can load files with the relative path correctly - $viewFile = $extension.".template"; - Utils::processDocument($viewFile, $lodspk, $results); - - }catch (Exception $ex){ - echo $ex->getMessage(); - trigger_error($ex->getMessage(), E_ERROR); - Utils::send500($uri); - } - - } - -} - -?> - diff --git a/classes/Endpoint.php b/classes/Endpoint.php index c4bb2db6dda330ebcf0e0e6d3d70be3d8c81c8f4..f31dd3e8156bfd151bd09026fa6f7996a0d780c2 100644 --- a/classes/Endpoint.php +++ b/classes/Endpoint.php @@ -31,6 +31,7 @@ class Endpoint{ $url = $this->sparqlUrl.'?'.http_build_query($params, '', '&'); curl_setopt($c, CURLOPT_URL, $url); curl_setopt($c, CURLOPT_HTTPHEADER, $context); + curl_setopt($c, CURLOPT_USERAGENT, "LODSPeaKr version ".$conf['version']); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $aux = curl_exec($c); // execute the curl command if($conf['debug']){ diff --git a/classes/HTTPStatus.php b/classes/HTTPStatus.php new file mode 100644 index 0000000000000000000000000000000000000000..e062430684083149b82073019892bfb509eba988 --- /dev/null +++ b/classes/HTTPStatus.php @@ -0,0 +1,35 @@ +<? + +class HTTPStatus{ + + public static function send303($uri, $ext){ + header("HTTP/1.0 303 See Other"); + header("Location: ".$uri); + header("Content-type: ".$ext); + echo $uri."\n\n"; + exit(0); + } + + public static function send404($uri){ + header("HTTP/1.0 404 Not Found"); + echo "LODSPeaKr could not find ".$uri." or information about it.\nNo URIs in the triple store, or services configured with that URI\n"; + exit(0); + } + + public static function send406($uri){ + header("HTTP/1.0 406 Not Acceptable"); + echo "LODSPeaKr can't find a representation suitable for the content type you accept\n\n"; + exit(0); + } + + public static function send500($msg = null){ + header("HTTP/1.0 500 Internal Server Error"); + echo "An internal error ocurred. Please try later\n\n"; + if($msg != null){ + echo $msg; + } + exit(0); + } +} + +?> diff --git a/classes/Importer.php b/classes/Importer.php index 43931d962875d5791a90e9dd2407160495672388..9acba3df52c70b02d7ebd797991e4d2a872125ca 100644 --- a/classes/Importer.php +++ b/classes/Importer.php @@ -37,7 +37,7 @@ class Importer{ }elseif(isset($_POST['importtext'])){ $parser->parse(RDF, $_POST['importtext']); }else{ - Utils::send500(); + HTTPStatus::send500(); exit(0); } $triples = $parser->getTriples(); diff --git a/classes/Utils.php b/classes/Utils.php index 005f875e3cd23cd5bef1414e385fdabc418f6dcd..29028d5f8b4fd61d4ad7745bdfc46a2db9047ba1 100644 --- a/classes/Utils.php +++ b/classes/Utils.php @@ -1,36 +1,7 @@ <? class Utils{ - - public static function send303($uri, $ext){ - header("HTTP/1.0 303 See Other"); - header("Location: ".$uri); - header("Content-type: ".$ext); - echo $uri."\n\n"; - exit(0); - } - - public static function send404($uri){ - header("HTTP/1.0 404 Not Found"); - echo "LODSPeaKr could not find ".$uri." or information about it.\nNo URIs in the triple store, or services configured with that URI\n"; - exit(0); - } - - public static function send406($uri){ - header("HTTP/1.0 406 Not Acceptable"); - echo "LODSPeaKr can't find a representation suitable for the content type you accept\n\n"; - exit(0); - } - - public static function send500($msg = null){ - header("HTTP/1.0 500 Internal Server Error"); - echo "An internal error ocurred. Please try later\n\n"; - if($msg != null){ - echo $msg; - } - exit(0); - } - + public static function uri2curie($uri){ global $conf; $ns = $conf['ns']; @@ -116,7 +87,15 @@ class Utils{ $row[$k]['uri'] = 1; }elseif($v['type'] == 'bnode'){ $row[$k]['curie'] = 'blankNode'; - } + }else{ + if($v['datatype']){ + $row[$k]['type'] = $v['datatype']; + } + if($v['xml:lang']){ + $row[$k]['lang'] = $v['xml:lang']; + } + + } } /*if(sizeof($aux) == 1){ $obj = $row; @@ -268,7 +247,7 @@ class Utils{ }elseif(preg_match("/construct/i", $query)){ return $conf['output']['describe']; }else{ - Utils::send500(null); + HTTPStatus::send500(null); } } @@ -367,7 +346,7 @@ class Utils{ $vars = compact('uri', 'lodspk', 'models', 'first'); $q = file_get_contents($modelFile); if($q == false){ - Utils::send500("I can't load ".$modelFile." in ".getcwd()); + HTTPStatus::send500("I can't load ".$modelFile." in ".getcwd()); } $fnc = Haanga::compile($q); $query = $fnc($vars, TRUE); @@ -433,13 +412,13 @@ class Utils{ //For now, assuming variables are in the GRAPH ?g $query = "CONSTRUCT {?g ?x ?y} WHERE{GRAPH ?g{?g ?x ?y}}"; }else{ - Utils::send500(); + HTTPStatus::send500(); } }else{ $query = preg_replace('/select\n?.*\n?where/i', 'CONSTRUCT {'.$construct.'} WHERE', $query); } }else { - Utils::send500("invalid query: " . $parser->getErrors()); + HTTPStatus::send500("invalid query: " . $parser->getErrors()); } } if($conf['debug']){ @@ -457,9 +436,6 @@ class Utils{ if(Utils::getResultsType($query) == $conf['output']['select']){ $rPointer[$strippedModelFile] = Utils::sparqlResult2Obj($aux); $fPointer[$strippedModelFile] = $rPointer[$strippedModelFile][0]; - /*if(sizeof($rPointer)>0){ - $rPointer[$modelFile]['firstResults'] = $rPointer[$modelFile][0]; - }*/ }else{ $lodspk['resultRdf'] = true; $rPointer[$strippedModelFile] = $aux; @@ -468,9 +444,6 @@ class Utils{ if(Utils::getResultsType($query) == $conf['output']['select']){ $rPointer = Utils::sparqlResult2Obj($aux); $fPointer[$strippedModelFile] = $rPointer[0]; - /*if(sizeof($rPointer)>0){ - $rPointer['firstResults'] = $rPointer[0]; - }*/ }else{ $lodspk['resultRdf'] = true; $rPointer = $aux; @@ -512,7 +485,7 @@ class Utils{ }elseif(is_string($conf['mirror_external_uris'])){ $value['value'] = preg_replace("|^".$conf['mirror_external_uris']."|", $conf['basedir'], $value['value']); }else{ - Utils::send500("Error in mirroring configuration"); + HTTPStatus::send500("Error in mirroring configuration"); exit(1); } } diff --git a/classes/modules/serviceModule.php b/classes/modules/serviceModule.php index fc6879c471e61e08dba5ce71dda8492b44c38460..99aa3147403bc59288e91b3413a28616a583d8a2 100644 --- a/classes/modules/serviceModule.php +++ b/classes/modules/serviceModule.php @@ -20,7 +20,7 @@ class ServiceModule extends abstractModule{ if(isset($aux[1])){ $contentTypes = $conf['http_accept'][$aux[1]]; if($contentTypes == null){ - Utils::send406("Content type not acceptable\n"); + HTTPStatus::send406("Content type not acceptable\n"); } $acceptContentType = $contentTypes[0]; } @@ -31,6 +31,7 @@ class ServiceModule extends abstractModule{ $viewFile = null; $lodspk['model'] = $conf['model']['directory'].'/'.$conf['service']['prefix'].'/'.$qArr[0].'/'; $lodspk['view'] = $conf['view']['directory'].'/'.$conf['service']['prefix'].'/'.$qArr[0].'/'.$extension.'.template'; + $lodspk['serviceName'] = $qArr[0]; $modelFile = $lodspk['model'].$extension.'.queries'; if(file_exists($lodspk['model'].$extension.'.queries')){ if(!file_exists($lodspk['view'])){ @@ -49,7 +50,7 @@ class ServiceModule extends abstractModule{ } return array($modelFile, $viewFile); }elseif(file_exists($lodspk['model'])){ - Utils::send406($uri); + HTTPStatus::send406($uri); exit(0); } return FALSE; @@ -66,8 +67,6 @@ class ServiceModule extends abstractModule{ $context = array(); $context['contentType'] = $acceptContentType; $context['endpoints'] = $endpoints; - //$sp = new SpecialFunction(); - //$sp->execute($localUri, $context); $f = $this->getFunction($localUri); $params = array(); $params = $this->getParams($localUri); @@ -151,7 +150,7 @@ class ServiceModule extends abstractModule{ }catch (Exception $ex){ echo $ex->getMessage(); trigger_error($ex->getMessage(), E_ERROR); - Utils::send500($uri); + HTTPStatus::send500($uri); } exit(0); } diff --git a/classes/modules/staticModule.php b/classes/modules/staticModule.php index 6f59daa99f936161d35499aaedb63ad200b1abba..c1c24130c186943bc2290d97a0883045ec041e9c 100644 --- a/classes/modules/staticModule.php +++ b/classes/modules/staticModule.php @@ -23,10 +23,37 @@ class StaticModule extends abstractModule{ global $uri; global $acceptContentType; global $endpoints; - global $lodspk; + global $lodspk; + header("Content-type: "); - echo file_get_contents($conf['static']['directory'].$file); + $uri = $localUri; + if($conf['debug']){ + echo "\n-------------------------------------------------\nIn ".$conf['static']['directory']."\n"; + echo "Static file $file\n-------------------------------------------------\n\n"; + } + if($conf['static']['haanga']){ + $lodspk['home'] = $conf['basedir']; + $lodspk['baseUrl'] = $conf['basedir']; + $lodspk['module'] = 'static'; + $lodspk['root'] = $conf['root']; + $lodspk['contentType'] = $acceptContentType; + $lodspk['ns'] = $conf['ns']; + $lodspk['this']['value'] = $localUri; + $lodspk['this']['curie'] = Utils::uri2curie($localUri); + $lodspk['this']['local'] = $localUri; + $lodspk['contentType'] = $acceptContentType; + $lodspk['endpoint'] = $conf['endpoint']; + $lodspk['type'] = $modelFile; + $lodspk['header'] = $prefixHeader; + $lodspk['baseUrl'] = $conf['basedir']; + + Utils::processDocument($conf['static']['directory'].$file, $lodspk, null); + }else{ + echo file_get_contents($conf['static']['directory'].$file); + } } + + } ?> diff --git a/classes/modules/typeModule.php b/classes/modules/typeModule.php index b745db20e01524d961f7185fae1839153cd26d59..5bf22e26b1df316b790293e9bd89f7c278785dfb 100644 --- a/classes/modules/typeModule.php +++ b/classes/modules/typeModule.php @@ -20,12 +20,12 @@ class TypeModule extends abstractModule{ if(Queries::uriExist($uri, $endpoints['local'])){ $page = Queries::createPage($uri, $localUri, $acceptContentType, $metaDb); if($page == NULL){ - Utils::send500("Can't write sqlite database."); + HTTPStatus::send500("Can't write sqlite database."); } - Utils::send303($page, $acceptContentType); + HTTPStatus::send303($page, $acceptContentType); exit(0); }else{ - return false; //Utils::send404($uri); + return false; } } return $pair; @@ -43,7 +43,7 @@ class TypeModule extends abstractModule{ list($res, $page, $format) = $pair; //If resource is not the page, send a 303 to the document if($res == $localUri){ - Utils::send303($page, $acceptContentType); + HTTPStatus::send303($page, $acceptContentType); } $uri = $res; diff --git a/classes/modules/uriModule.php b/classes/modules/uriModule.php index 182c9aab7ac6e63589fb6b2af2a9bda691e6ee9a..c52f8ee160113dbb573a089dad464ed5c4903707 100644 --- a/classes/modules/uriModule.php +++ b/classes/modules/uriModule.php @@ -21,12 +21,12 @@ class UriModule extends abstractModule{ if(Queries::uriExist($uri, $endpoints['local'])){ $page = Queries::createPage($uri, $localUri, $acceptContentType, $metaDb); if($page == NULL){ - Utils::send500("Can't write sqlite database."); + HTTPStatus::send500("Can't write sqlite database."); } - Utils::send303($page, $acceptContentType); + HTTPStatus::send303($page, $acceptContentType); exit(0); }else{ - return false; //Utils::send404($uri); + return false; } } $extension = Utils::getExtension($pair[2]); @@ -63,7 +63,7 @@ class UriModule extends abstractModule{ //If resource is not the page, send a 303 to the document if($res == $localUri){ - Utils::send303($page, $acceptContentType); + HTTPStatus::send303($page, $acceptContentType); } $uri = $res; diff --git a/common.inc.php b/common.inc.php index db9883368320353dc71f4e10a0b937a4c66247ab..7618f5ff912bd7c3cfd96f624d7f2232c727a2b1 100644 --- a/common.inc.php +++ b/common.inc.php @@ -1,5 +1,5 @@ <? - +$conf['version'] = '20120411'; $conf['output']['select'] = 'json'; $conf['output']['describe'] = 'rdf'; $conf['endpointParams']['config']['show_inline'] = 0; @@ -21,6 +21,7 @@ $conf['view']['extension'] = '.view'; $conf['view']['default'] = 'rdfs:Resource'; $conf['static']['directory'] = 'static/'; #include trailing slash! +$conf['static']['haanga'] = false; //Should static files be processed by Haanga? $conf['resource']['url_delimiter'] = "%u"; @@ -33,7 +34,6 @@ $conf['http_accept']['nt'] = array('text/plain'); $conf['service']['prefix'] = 'services'; -$conf['service']['class'] = 'classes/BasicSpecialFunction.php'; $conf['type']['prefix'] = 'types'; $conf['uri']['prefix'] = 'uris'; diff --git a/doc/examples/components/services/people/html.template b/doc/examples/components/services/people/html.template index 43c17e2cad4fd64a360c78d67f8b9d6bb93f83a9..f072a11adbc9b118fcc8e92705c29044eb6989d4 100644 --- a/doc/examples/components/services/people/html.template +++ b/doc/examples/components/services/people/html.template @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}" +<html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in lodspk.ns %}xmlns:{{i}}="{{ns}}" {%endfor%}version="XHTML+RDFa 1.0" xml:lang="en"> <head> <title>TWC People directory</title> diff --git a/doc/examples/components/services/peopleByName/html.template b/doc/examples/components/services/peopleByName/html.template index 982cdd8d7e34a5bacc05729c665bddec9e314aba..15462828d4dfa96b37a24866b3b2d18001b0b24b 100644 --- a/doc/examples/components/services/peopleByName/html.template +++ b/doc/examples/components/services/peopleByName/html.template @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}" +<html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in lodspk.ns %}xmlns:{{i}}="{{ns}}" {%endfor%}version="XHTML+RDFa 1.0" xml:lang="en"> <head> <title>TWC People directory</title> diff --git a/doc/examples/originalComponents/services/instances/html.template b/doc/examples/originalComponents/services/instances/html.template index 1dc603e143d3c06eb8b431ed15b784cb342f57dc..d9bf5b429fc01622699f35a82949e368d8a856a9 100644 --- a/doc/examples/originalComponents/services/instances/html.template +++ b/doc/examples/originalComponents/services/instances/html.template @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}" + <html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in lodspk.ns %}xmlns:{{i}}="{{ns}}" {%endfor%}version="XHTML+RDFa 1.0" xml:lang="en"> <head> <title>Instances of {{lodspk.args.arg0}}</title> diff --git a/doc/examples/originalComponents/services/namedGraphs/html.template b/doc/examples/originalComponents/services/namedGraphs/html.template index e6109aef46e74c43bb6ff9c3ba2aa78c92c27881..f1c287312a104708130948cd3c0f6832a5b23efe 100644 --- a/doc/examples/originalComponents/services/namedGraphs/html.template +++ b/doc/examples/originalComponents/services/namedGraphs/html.template @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}" + <html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in lodspk.ns %}xmlns:{{i}}="{{ns}}" {%endfor%}version="XHTML+RDFa 1.0" xml:lang="en"> <head> <title>Named Graphs</title> diff --git a/index.php b/index.php index 07cce5f9cf717c66df037b7efb6fbd128285f9e1..66082fd73037ff2d2661d96c292c08c2f67c478b 100755 --- a/index.php +++ b/index.php @@ -22,6 +22,7 @@ if($conf['debug']){ error_reporting(E_ERROR); } +include_once('classes/HTTPStatus.php'); include_once('classes/Utils.php'); include_once('classes/Queries.php'); include_once('classes/Endpoint.php'); @@ -37,7 +38,7 @@ $extension = Utils::getExtension($acceptContentType); //Check content type is supported by LODSPeaKr if($acceptContentType == NULL){ - Utils::send406($uri); + HTTPStatus::send406($uri); } //Export @@ -67,7 +68,7 @@ if(isset($conf['mirror_external_uris']) && $conf['mirror_external_uris'] != fals }elseif(is_string($conf['mirror_external_uris'])){ $uri = $conf['mirror_external_uris'].$_GET['q']; }else{ - Utils::send500("Error in mirroring configuration"); + HTTPStatus::send500("Error in mirroring configuration"); exit(1); } @@ -79,7 +80,7 @@ foreach($conf['modules']['available'] as $i){ $className = $i.'Module'; $currentModule = $conf['modules']['directory'].$className.'.php'; if(!is_file($currentModule)){ - Utils::send500("<br/>Can't load or error in module <tt>".$currentModule."</tt>" ); + HTTPStatus::send500("<br/>Can't load or error in module <tt>".$currentModule."</tt>" ); exit(1); } require_once($currentModule); @@ -91,5 +92,5 @@ foreach($conf['modules']['available'] as $i){ } } -Utils::send404($uri); +HTTPStatus::send404($uri); ?> diff --git a/install.sh b/install.sh index 46426a307a3220a8f33b44be59d31976a7883dbf..90a7bd64bc968d8f85097737673b1d6ff1146e0b 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash # - root_htaccess="root.htaccess" parent_htaccess="../.htaccess" settings_file="settings.inc.php" diff --git a/lib/Haanga/lib/Haanga/Extension/Filter/Explode.php b/lib/Haanga/lib/Haanga/Extension/Filter/Explode.php new file mode 100644 index 0000000000000000000000000000000000000000..7e6deae3c607a0bf519281e00e71abd01867bc9c --- /dev/null +++ b/lib/Haanga/lib/Haanga/Extension/Filter/Explode.php @@ -0,0 +1,13 @@ +<?php + +class Haanga_Extension_Filter_Explode +{ + static function generator($compiler, $args) + { + if (count($args) != 2) { + $compiler->Error("Explode only needs two parameter"); + } + + return hexec('explode', $args[1], $args[0]); + } +} diff --git a/lib/Haanga/lib/Haanga/Extension/Filter/Length.php b/lib/Haanga/lib/Haanga/Extension/Filter/Length.php index d0fb526222eff1a0a67b739bfb575686a093a222..952f377c66ac47f9d330b95cdb92584421c00171 100644 --- a/lib/Haanga/lib/Haanga/Extension/Filter/Length.php +++ b/lib/Haanga/lib/Haanga/Extension/Filter/Length.php @@ -7,6 +7,7 @@ class Haanga_Extension_Filter_Length { $count = hexec('count', $args[0]); $strlen = hexec('strlen', $args[0]); + $vars = hexec('count', hexec('get_object_vars', $args[0])); $guess = hexpr_cond(hexec('is_array', $args[0]), hexec('count', $args[0]), hexec('strlen', $args[0])); @@ -18,8 +19,10 @@ class Haanga_Extension_Filter_Length return $count; } else if (is_string($value)) { return $strlen; + } else if (is_object($value)) { + return $vars; } else { - return $guess; + return $gess; } } diff --git a/lib/Haanga/lib/Haanga/Extension/Filter/Pop.php b/lib/Haanga/lib/Haanga/Extension/Filter/Pop.php new file mode 100644 index 0000000000000000000000000000000000000000..5d3914a415d0ed10eded2a564030ccb15d786581 --- /dev/null +++ b/lib/Haanga/lib/Haanga/Extension/Filter/Pop.php @@ -0,0 +1,13 @@ +<?php + +class Haanga_Extension_Filter_Pop +{ + static function generator($compiler, $args) + { + if (count($args) != 1) { + $compiler->Error("Pop only needs two parameter"); + } + + return hexec('array_pop', $args[0]); + } +} diff --git a/lib/Haanga/lib/Haanga/Extension/Filter/Urifragment.php b/lib/Haanga/lib/Haanga/Extension/Filter/Urifragment.php index 72e5ffb13bb6db8a02ac086fa9bef2b43fcea8d9..d84b3f152cbfc1cff040ccdc6fcaca9f65800c82 100644 --- a/lib/Haanga/lib/Haanga/Extension/Filter/Urifragment.php +++ b/lib/Haanga/lib/Haanga/Extension/Filter/Urifragment.php @@ -2,12 +2,8 @@ class Haanga_Extension_Filter_Urifragment { - static function generator($compiler, $args) + static function generator($cmp, $args) { - if (count($args) != 1) { - $compiler->Error("URIFragment only needs one parameter"); - } - - return hexec('array_pop', hexec('split', '#', $args[0])); + return hexec('parse_url', $args[0], hconst('PHP_URL_FRAGMENT')); } } diff --git a/lib/Haanga/lib/Haanga/Extension/Filter/Uripath.php b/lib/Haanga/lib/Haanga/Extension/Filter/Uripath.php new file mode 100644 index 0000000000000000000000000000000000000000..1de855ab2bc46ae82f823d72f14c89826de9c9f3 --- /dev/null +++ b/lib/Haanga/lib/Haanga/Extension/Filter/Uripath.php @@ -0,0 +1,9 @@ +<?php + +class Haanga_Extension_Filter_Uripath +{ + static function generator($cmp, $args) + { + return hexec('parse_url', $args[0], hconst('PHP_URL_PATH')); + } +} diff --git a/lib/Haanga/lib/Haanga/Extension/Filter/Urischeme.php b/lib/Haanga/lib/Haanga/Extension/Filter/Urischeme.php new file mode 100644 index 0000000000000000000000000000000000000000..2fc5457f344c1fd4d065de4a9d183989af397c43 --- /dev/null +++ b/lib/Haanga/lib/Haanga/Extension/Filter/Urischeme.php @@ -0,0 +1,9 @@ +<?php + +class Haanga_Extension_Filter_Urischeme +{ + static function generator($cmp, $args) + { + return hexec('parse_url', $args[0], hconst('PHP_URL_SCHEME')); + } +} diff --git a/utils/lodspk.sh b/utils/lodspk.sh index 10600ef2c309cbf7a979647e09b377b2b3037cb3..3d64011929446ea00125f3de2b43615434a6f2c8 100755 --- a/utils/lodspk.sh +++ b/utils/lodspk.sh @@ -9,6 +9,7 @@ USAGE=$USAGE" Switch to standard view/models temporaly:\t\t$0 disable on|off\n" USAGE=$USAGE" Backup current installation:\t\t\t\t$0 backup\n" USAGE=$USAGE" Restore previous installation:\t\t\t\t$0 restore\n" USAGE=$USAGE" Clear cache:\t\t\t\t\t\t$0 cache clear\n" +USAGE=$USAGE" Version:\t\t\t\t\t\t$0 version\n" USAGEDEBUG="Usage: $0 debug on|off" if [[ $# -eq 0 || "$1" == "--help" ]]; then echo -e $USAGE @@ -16,7 +17,7 @@ if [[ $# -eq 0 || "$1" == "--help" ]]; then fi DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -operations=( create delete debug backup restore disable cache ) +operations=( create delete debug backup restore disable cache version ) currentOperation= if [[ ${operations[@]} =~ $1 ]]; then @@ -119,3 +120,8 @@ if [[ $currentOperation == "cache" ]]; then $DIR/modules/cache.sh $2 exit fi + +## Version +if [[ $currentOperation == "version" ]]; then + $DIR/modules/version.sh +fi diff --git a/utils/modules/create-service.sh b/utils/modules/create-service.sh index a1d43c872c65536d230cd3c1e980c3916d830e6a..fbcbc581a49a90a0a7a283e9abbff4e18c6f64ea 100755 --- a/utils/modules/create-service.sh +++ b/utils/modules/create-service.sh @@ -13,21 +13,23 @@ SELECT DISTINCT ?resource WHERE { [] a ?resource . } } +LIMIT 10 QUERY` viewHtml=`cat <<VIEW <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" - "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}" - {%endfor%}version="XHTML+RDFa 1.0" xml:lang="en"> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in lodspk.ns %}xmlns:{{i}}="{{ns}}" {%endfor%} + version="XHTML+RDFa 1.0" xml:lang="en"> <head> - <title>My new Service</title> + <title>$1</title> <link href="{{lodspk.baseUrl}}css/basic.css" rel="stylesheet" type="text/css" media="screen" /> + <style type="text/css"> + </style> </head> <body> - <h1>Classes available</h1> - <ul> + <h1>$1</h1> + <ul> {% for row in models.main %} <li><a href="{{lodspk.baseUrl}}special/instances/{{ row.resource.curie }}">{{row.resource.curie}}</a></li> {% endfor %} diff --git a/utils/modules/version.sh b/utils/modules/version.sh new file mode 100755 index 0000000000000000000000000000000000000000..7f36515bfe525d7f0e226af7faea03cf33a6695c --- /dev/null +++ b/utils/modules/version.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +FILE=README +cd $DIR/../.. +grep -E "^version" $FILE |head -1 |sed -e 's/version: //'