# HG changeset patch # User ymh # Date 1477920263 -3600 # Node ID c731ab9b934d4a8f73a2ef3d28f493e2a19f56bc # Parent f8200c5482ec9d51b0c41451708cb3bae3703234 implement first version of sparql client interface diff -r f8200c5482ec -r c731ab9b934d .hgignore --- a/.hgignore Sun Oct 23 01:07:09 2016 +0200 +++ b/.hgignore Mon Oct 31 14:24:23 2016 +0100 @@ -33,7 +33,7 @@ ^server/src/storage/framework/views/ ^server/node_modules ^server/src/public/css -^server/src/public/js/vendor +^server/src/public/js ^server/src/public/fonts ^server/src/public/corpus-app ^server/bo_client/.dir-locals.el$ diff -r f8200c5482ec -r c731ab9b934d build/build.sh --- a/build/build.sh Sun Oct 23 01:07:09 2016 +0200 +++ b/build/build.sh Mon Oct 31 14:24:23 2016 +0100 @@ -92,8 +92,14 @@ [[ -z "$environment" ]] && environment='production' case $environment in - development) build_option='--dev' ;; - *) build_option='--prod' ;; + development) + build_option='--dev' + build_option_back='--development' + ;; + *) + build_option='--prod' + build_option_back='--production' + ;; esac echo "environment: $environment" @@ -113,7 +119,7 @@ pushd ../server/src version=$(sed -n "s/[[:space:]]*\'version\'[[:space:]]*=>[[:space:]]*\'\([\.0-9]*\)\'/\1/p" config/version.php) version=${version:-0.0.0} -./node_modules/.bin/gulp copy-build ${build_option} +./node_modules/.bin/gulp copy-build ${build_option_back} popd echoblue "---> buiding back done" diff -r f8200c5482ec -r c731ab9b934d server/src/app/Facades/RdfHelperFacade.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/app/Facades/RdfHelperFacade.php Mon Oct 31 14:24:23 2016 +0100 @@ -0,0 +1,12 @@ +prefixes; + } + + /** + * Keep track of the prefixes used while serialising + * @ignore + */ + public function addPrefix($qname) + { + list ($prefix) = explode(':', $qname); + $this->prefixes[$prefix] = true; + return $prefix; + } + + + /** + * Given a IRI string, escape and enclose in angle brackets. + * + * @param string $resourceIri + * + * @return string + */ + public function escapeIri($resourceIri) { + $escapedIri = str_replace('>', '\\>', $resourceIri); + return "<".htmlentities($escapedIri).">"; + } + + /** + * Insprired by EasyRdf\Serialiser\Turtle::serialiseLiteral + * Given a string, enclose in quotes and escape any quotes in the string. + * Strings containing tabs, linefeeds or carriage returns will be + * enclosed in three double quotes ("""). + * + * @param string $value + * + * @return string + */ + public function serialiseLiteral($literal) + { + $value = strval($literal); + $quoted = Turtle::quotedString($value); + + if ($datatype = $literal->getDatatypeUri()) { + if ($datatype == 'http://www.w3.org/2001/XMLSchema#integer') { + return sprintf('%d', $value); + } elseif ($datatype == 'http://www.w3.org/2001/XMLSchema#decimal') { + return sprintf('%s', $value); + } elseif ($datatype == 'http://www.w3.org/2001/XMLSchema#double') { + return sprintf('%e', $value); + } elseif ($datatype == 'http://www.w3.org/2001/XMLSchema#boolean') { + return sprintf('%s', $value); + } else { + $escaped = $this->serialiseResource($datatype, false); + return sprintf('%s^^%s', $quoted, $escaped); + } + } elseif ($lang = $literal->getLang()) { + return sprintf('%s@%s',$quoted, $lang); + } else { + return "$quoted"; + } + } + + /** + * Given a an EasyRdf\Resource or URI, convert it into a string, suitable to + * be written to a Turtle document. URIs will be shortened into CURIES + * where possible. + * + * @param Resource|string $resource The resource to convert to a Turtle string + * @param boolean $createNamespace If true, a new namespace may be created + * + * @return string + */ + public function serialiseResource($resource, $createNamespace = false) + { + if (is_object($resource)) { + if ($resource->isBNode()) { + $uri = preg_replace("/^_\:/", "", $resource->getUri(), 1); + return "_:".htmlentities($uri).""; + } + + $resource = $resource->getUri(); + } + + $short = RdfNamespace::shorten($resource, $createNamespace); + + if ($short) { + $prefix = $this->addPrefix($short); + $shortVal = substr($short, strlen($prefix)+1); + $namespaceVal = RdfNamespace::namespaces()[$prefix]; + + return "$prefix:".htmlentities($shortVal).""; + } + + return $this->escapeIri($resource); + } + + + public function serialiseValue($val) { + + if($val instanceof Resource) { + return $this->serialiseResource($val, false); + } elseif($val instanceof Literal) { + return $this->serialiseLiteral($val); + } else { + throw new \InvalidArgumentException( + "serialiseObject() requires \$object to be ". + 'of type EasyRdf\Resource or EasyRdf\Literal' + ); + } + + } + +} diff -r f8200c5482ec -r c731ab9b934d server/src/app/Http/Controllers/Sparql/SparqlClientController.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/app/Http/Controllers/Sparql/SparqlClientController.php Mon Oct 31 14:24:23 2016 +0100 @@ -0,0 +1,215 @@ + "text/csv", + "SPARQL/JSON" => "application/sparql-results+json", + "SPARQL/XML" => "application/sparql-results+xml", + "SPARQL/TSV" => "text/tab-separated-values", + "BINARY" => "application/x-binary-rdf-results-table" + ]; + + const GRAPH_RESULT_FORMAT = [ + "N-Triples" => "application/n-triples", + "RDF/XML" => "application/rdf+xml", + "Turtle" => "text/turtle", + "N3" => "text/n3", + "RDF/JSON" => "application/rdf+json", + "TriG" => "application/trig", + "N-Quads" => "application/n-quads", + "BinaryRDF" => "application/x-binary-rdf", + "TriX" => "application/trix", + "JSON-LD" => "application/ld+json" + ]; + + + private $sparqlClient; + private $httpClient; + + public function __construct(SparqlClient $sparqlClient, Client $httpClient) { + $this->sparqlClient = $sparqlClient; + $this->httpClient = $httpClient; + } + + // display form + public function index() { + return view('sparql/sparqlClientForm'); + } + + private function querySelect(Request $request, $query, $analyser) { + $countResult = $this->sparqlClient->query($analyser->getCountQuery()); + $countField = $countResult->getFields()[0]; + $count = $countResult->current()->$countField; + $docs = $this->sparqlClient->query($query); + $fields = $docs->getFields(); + $results = []; + foreach($docs as $row) { + $results[] = array_reduce($fields, function($res, $field) use ($row) { + if(isset($row->$field)) { + $res[$field] = RdfHelper::serialiseValue($row->$field); + } else { + $res[$field] = " "; + } + return $res; + }, []); + } + $namespaces = array_reduce(array_keys(RdfHelper::getPrefixes()), function($res, $p) { + $res[$p] = RdfNamespace::namespaces()[$p]; + return $res; + }, []); + $data = [ + 'query' => $query, + 'count' => $count, + 'fields' => $fields, + 'fieldPrefix' => "?", + 'results' => $results, + 'namespaces' => $namespaces, + 'downloadFormats' => self::SELECT_RESULT_FORMAT + ]; + $view = 'sparql/sparqlClientResultList'; + return [$view, $data]; + } + + private function queryGraph(Request $request, $query, $analyser) { + + $docs = $this->sparqlClient->query($query); + $fields = ["subject", "predicate", "object"]; + $results = []; + foreach ($docs->resources() as $resource ) { + foreach ($resource->propertyUris() as $property) { + $propertyResource = $docs->resource($property); + foreach ($resource->all($propertyResource) as $value) { + $results[] = [ + 'subject' => RdfHelper::serialiseValue($resource), + 'predicate'=> RdfHelper::serialiseValue($propertyResource), + 'object'=> RdfHelper::serialiseValue($value) + ]; + } + } + } + $namespaces = array_reduce(array_keys(RdfHelper::getPrefixes()), function($res, $p) { + $res[$p] = RdfNamespace::namespaces()[$p]; + return $res; + }, []); + + + $data = [ + 'query' => $query, + 'count' => count($results), + 'fields' => $fields, + 'fieldPrefix' => "", + 'results' => $results, + 'namespaces' => $namespaces, + 'downloadFormats' => self::GRAPH_RESULT_FORMAT + ]; + $view = 'sparql/sparqlClientResultList'; + + return [$view, $data]; + } + + private function queryAsk(Request $request, $query, $analyser) { + $data = [ + 'results' => $this->sparqlClient->query($query), + 'namespaces' => $analyser->getPrefixes() + ]; + + $view = 'sparql/sparqlClientResultBoolean'; + return [$view, $data]; + } + + private function showHtml(Request $request) { + + $query = $request->input('query'); + + $analyser = new SparqlQueryAnalyser($query); + + $queryType = $analyser->getQueryType(); + + $namespaces = $analyser->getPrefixes(); + + foreach($namespaces as $prefix => $nUri) { + RdfNamespace::set($prefix,$nUri); + } + + if($queryType === SparqlQueryAnalyser::SELECT_QUERY) { + list($view, $data) = $this->querySelect($request, $query, $analyser); + } elseif($queryType === SparqlQueryAnalyser::GRAPH_QUERY) { + list($view, $data) = $this->queryGraph($request, $query, $analyser); + } elseif($queryType === SparqlQueryAnalyser::ASK_QUERY) { + list($view, $data) = $this->queryAsk($request, $query, $analyser); + } else { + //return 500 + abort(500, "Serialization format unknown"); + } + + return view($view, $data); + + } + + + private function proxyQuery(Request $request, $format=null) { + $query = $request->input('query'); + $headers = []; + foreach (self::HEADERS_FORWARDED as $h) { + $headerValue = $request->header($h); + if($headerValue) { + $headers[$h] = $headerValue; + } + } + + if(!empty($format)){ + $headers['Accept'] = $format; + } + + $sesameResp = $this->httpClient->get(config('corpusparole.sesame_query_url'), ['query' => $request->all(), 'headers' => $headers]); + + $resp = response((string)$sesameResp->getBody(), $sesameResp->getStatusCode()); + foreach ($sesameResp->getHeaders() as $name => $values) { + if($name != 'Transfer-Encoding') { + $resp->header($name, $values); + } + } + + return $resp; + } + + // display result + public function show(Request $request) { + + $format = $request->input('format'); + + if($format === 'text/html') { + return $this->showHtml($request); + } else { + return $this->proxyQuery($request, $format); + } + + } + + // do the query + public function query(Request $request) { + return $this->proxyQuery($request); + } + +} diff -r f8200c5482ec -r c731ab9b934d server/src/app/Libraries/Sparql/SparqlQueryAnalyser.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/app/Libraries/Sparql/SparqlQueryAnalyser.php Mon Oct 31 14:24:23 2016 +0100 @@ -0,0 +1,126 @@ +)\s*'; + + const SPARQL_SELECT_QUERY_REGEXP = '^(?:\s*(?:'.self::SPARQL_PREFIX_BASE_REGEXP.')*select)'; + const SPARQL_ASK_QUERY_REGEXP = '^(?:\s*(?:'.self::SPARQL_PREFIX_BASE_REGEXP.')*ask)'; + const SPARQL_GRAPH_QUERY_REGEXP = '^(?:\s*(?:'.self::SPARQL_PREFIX_BASE_REGEXP.')*(?:(?:construct)|(?:describe)))'; + + const SPARQL_LIMIT_OFFSET_QUERY_REGEXP = '(?:(?:(limit\s+(\d+))|(offset\s+(\d+)))\s*)+\s*$'; + + const UNKNOWN_QUERY = 0; + const SELECT_QUERY = 1; + const GRAPH_QUERY = 2; + const ASK_QUERY = 2; + + private $query; + private $queryType = false; + private $rawPrefixes = false; + private $prefixes = false; + private $limit = false; + private $offset = false; + private $rawQuery = false; + private $countVar = false; + + public function __construct($query) { + $this->query = $query; + } + + public function getQueryType() { + + if($this->queryType === false) { + if(preg_match("%".self::SPARQL_SELECT_QUERY_REGEXP."%iu", $this->query) === 1) { + $this->queryType = self::SELECT_QUERY; + } elseif(preg_match("%".self::SPARQL_GRAPH_QUERY_REGEXP."%iu", $this->query) === 1) { + $this->queryType = self::GRAPH_QUERY; + } elseif(preg_match("%".self::SPARQL_ASK_QUERY_REGEXP."%iu", $this->query) === 1) { + $this->queryType = self::ASK_QUERY; + } else { + $this->queryType = self::UNKNOWN_QUERY; + } + } + return $this->queryType; + } + + private function extractPrefix() { + $prefixes = []; + $rawPrefixes = []; + $res = preg_replace_callback("%".self::SPARQL_PREFIX_BASE_REGEXP."%iu", function($m) use (&$prefixes, &$rawPrefixes) { + $rawPrefixes[] = trim($m[0]); + $prefixes[$m[3]?$m[3]:""] = $m[4]; + return ""; + }, $this->query); + + return [$rawPrefixes, $prefixes, trim($res)]; + } + + public function getRawPrefixes() { + if($this->rawPrefixes === false) { + list($this->rawPrefixes, $this->prefixes, $this->rawQuery) = $this->extractPrefix(); + } + return $this->rawPrefixes; + } + + public function getPrefixes() { + if($this->prefixes === false) { + list($this->rawPrefixes, $this->prefixes, $this->rawQuery) = $this->extractPrefix(); + } + return $this->prefixes; + } + + public function getRawQuery() { + if($this->rawQuery === false) { + list($this->rawPrefixes, $this->prefixes, $this->rawQuery) = $this->extractPrefix(); + } + return $this->rawQuery; + } + + public function getCountVar() { + if($this->countVar === false) { + $this->countVar = "?count_cp_".hash('md5', $this->query); + } + return $this->countVar; + } + + public function getCountQuery() { + return implode(" ", $this->getRawPrefixes())." select (count(*) as ".$this->getCountVar().") { ".$this->getRawQuery()." }"; + } + + private function setLimitOffset() { + if(preg_match("%".self::SPARQL_LIMIT_OFFSET_QUERY_REGEXP."%iu", $this->query, $m) === 1) { + for($i=0;$i<(count($m)-1)/2;$i++) { + if(Utils::startsWith(strtolower($m[2*$i+1]), "limit")) { + $this->limit = intval($m[$i*2+2]); + } elseif (Utils::startsWith(strtolower($m[2*$i+1]), "offset")) { + $this->offset = intval($m[$i*2+2]); + } + } + } + if($this->limit === false) { + $this->limit = null; + } + if($this->offset === false) { + $this->offset = null; + } + } + + public function getLimit() { + if($this->limit === false) { + $this->setLimitOffset(); + } + return $this->limit; + } + + public function getOffset() { + if($this->offset === false) { + $this->setLimitOffset(); + } + return $this->offset; + } + +} diff -r f8200c5482ec -r c731ab9b934d server/src/app/Libraries/Utils.php --- a/server/src/app/Libraries/Utils.php Sun Oct 23 01:07:09 2016 +0200 +++ b/server/src/app/Libraries/Utils.php Mon Oct 31 14:24:23 2016 +0100 @@ -11,6 +11,7 @@ */ class Utils { + /** * convert DateIntervals to milliseconds * Months and year calculated by approximation based on average number diff -r f8200c5482ec -r c731ab9b934d server/src/app/Providers/RdfHelperServiceProvider.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/app/Providers/RdfHelperServiceProvider.php Mon Oct 31 14:24:23 2016 +0100 @@ -0,0 +1,24 @@ +app->singleton('RdfHelper', function() { + return new RdfHelper(); + }); + } +} diff -r f8200c5482ec -r c731ab9b934d server/src/bower.json --- a/server/src/bower.json Sun Oct 23 01:07:09 2016 +0200 +++ b/server/src/bower.json Mon Oct 31 14:24:23 2016 +0100 @@ -20,6 +20,8 @@ "dependencies": { "bootstrap-sass": "bootstrap-sass-official#~3.3.5", "bourbon": "~4.2.4", - "font-awesome": "~4.4.0" + "font-awesome": "~4.4.0", + "yasqe": "yasgui-yasqe#^2.11.4", + "yasr": "yasgui-yasr#^2.9.0" } } diff -r f8200c5482ec -r c731ab9b934d server/src/config/app.php --- a/server/src/config/app.php Sun Oct 23 01:07:09 2016 +0200 +++ b/server/src/config/app.php Mon Oct 31 14:24:23 2016 +0100 @@ -160,7 +160,7 @@ 'CorpusParole\Providers\GeonamesServiceProvider', 'CorpusParole\Providers\VersionServiceProvider', 'CorpusParole\Providers\PaginationServiceProvider', - + 'CorpusParole\Providers\RdfHelperServiceProvider', ], /* @@ -212,6 +212,7 @@ 'Html' => 'Collective\Html\HtmlFacade', 'Form' => 'Collective\Html\FormFacade', 'Guzzle' => 'CorpusParole\Facades\GuzzleFacade', + 'RdfHelper' => 'CorpusParole\Facades\RdfHelperFacade', ], ]; diff -r f8200c5482ec -r c731ab9b934d server/src/gulpfile.js --- a/server/src/gulpfile.js Sun Oct 23 01:07:09 2016 +0200 +++ b/server/src/gulpfile.js Mon Oct 31 14:24:23 2016 +0100 @@ -9,9 +9,9 @@ var options = minimist(process.argv.slice(2)); var buildOption = "--prod"; -if(options.prod) { +if(options.production) { buildOption = "--prod"; -} else if(options.dev) { +} else if(options.development) { buildOption = "--dev"; } @@ -52,9 +52,15 @@ elixir(function(mix) { mix.sass('app.scss', 'public/css/app.css', {includePaths: [paths['bootstrap']+'stylesheets/']}) + .scripts(['sparqlclient.js'], 'public/js/sparqlclient.js') + .copy('resources/assets/sass/img', 'public/css/img') .copy(paths.bootstrap + 'fonts/bootstrap', 'public/fonts') .copy(paths.bootstrap + 'javascripts/bootstrap.js', 'public/js/vendor/bootstrap.js') + .copy(paths.bower_base_path + 'yasqe/dist/yasqe.bundled.min.js', 'public/js/vendor/yasqe.bundled.min.js') + .copy(paths.bower_base_path + 'yasr/dist/yasr.bundled.min.js', 'public/js/vendor/yasr.bundled.min.js') .copy(paths.bower_base_path + 'jquery/dist/jquery.min.js', 'public/js/vendor/jquery.js') + .copy(paths.bower_base_path + 'yasqe/dist/yasqe.min.css', 'public/css/vendor/yasqe.min.css') + .copy(paths.bower_base_path + 'yasr/dist/yasr.min.css', 'public/css/vendor/yasr.min.css') .copy(paths.bower_base_path + 'font-awesome/css/font-awesome.min.css', 'public/css/vendor/font-awesome.css') .task('build-ember') .task('copy-bo-ember'); diff -r f8200c5482ec -r c731ab9b934d server/src/public/css/app.css --- a/server/src/public/css/app.css Sun Oct 23 01:07:09 2016 +0200 +++ b/server/src/public/css/app.css Mon Oct 31 14:24:23 2016 +0100 @@ -1131,43 +1131,165 @@ cursor: pointer; } h1, h2, h3, h4, h5, h6, -.h1, .h2, .h3, .doc_details_title, .h4, .content-main-title, .data-audio-title, .h5, .content-title, .h6 { +.h1, .h2, .h3, .doc_details_title, .corpus-rdf-boolean, .h4, .content-main-title, .data-audio-title, .h5, .content-title, .h6 { font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; } h1 small, - h1 .small, h2 small, - h2 .small, h3 small, - h3 .small, h4 small, - h4 .small, h5 small, - h5 .small, h6 small, + h1 .small, + h1 .corpus-rdf-literal-type-separator, + h1 + .corpus-rdf-literal-type, + h1 .corpus-rdf-literal-lang, + h1 + .corpus-rdf-literal-lang-separator, h2 small, + h2 .small, + h2 .corpus-rdf-literal-type-separator, + h2 + .corpus-rdf-literal-type, + h2 .corpus-rdf-literal-lang, + h2 + .corpus-rdf-literal-lang-separator, h3 small, + h3 .small, + h3 .corpus-rdf-literal-type-separator, + h3 + .corpus-rdf-literal-type, + h3 .corpus-rdf-literal-lang, + h3 + .corpus-rdf-literal-lang-separator, h4 small, + h4 .small, + h4 .corpus-rdf-literal-type-separator, + h4 + .corpus-rdf-literal-type, + h4 .corpus-rdf-literal-lang, + h4 + .corpus-rdf-literal-lang-separator, h5 small, + h5 .small, + h5 .corpus-rdf-literal-type-separator, + h5 + .corpus-rdf-literal-type, + h5 .corpus-rdf-literal-lang, + h5 + .corpus-rdf-literal-lang-separator, h6 small, h6 .small, + h6 .corpus-rdf-literal-type-separator, + h6 + .corpus-rdf-literal-type, + h6 .corpus-rdf-literal-lang, + h6 + .corpus-rdf-literal-lang-separator, .h1 small, - .h1 .small, .h2 small, - .h2 .small, .h3 small, .doc_details_title small, - .h3 .small, .doc_details_title .small, .h4 small, .content-main-title small, .data-audio-title small, - .h4 .small, .content-main-title .small, .data-audio-title .small, .h5 small, .content-title small, - .h5 .small, .content-title .small, .h6 small, - .h6 .small { + .h1 .small, + .h1 .corpus-rdf-literal-type-separator, + .h1 + .corpus-rdf-literal-type, + .h1 .corpus-rdf-literal-lang, + .h1 + .corpus-rdf-literal-lang-separator, .h2 small, + .h2 .small, + .h2 .corpus-rdf-literal-type-separator, + .h2 + .corpus-rdf-literal-type, + .h2 .corpus-rdf-literal-lang, + .h2 + .corpus-rdf-literal-lang-separator, .h3 small, .doc_details_title small, .corpus-rdf-boolean small, + .h3 .small, .doc_details_title .small, .corpus-rdf-boolean .small, + .h3 .corpus-rdf-literal-type-separator, .doc_details_title .corpus-rdf-literal-type-separator, .corpus-rdf-boolean .corpus-rdf-literal-type-separator, + .h3 + .corpus-rdf-literal-type, .doc_details_title + .corpus-rdf-literal-type, .corpus-rdf-boolean + .corpus-rdf-literal-type, + .h3 .corpus-rdf-literal-lang, .doc_details_title .corpus-rdf-literal-lang, .corpus-rdf-boolean .corpus-rdf-literal-lang, + .h3 + .corpus-rdf-literal-lang-separator, .doc_details_title + .corpus-rdf-literal-lang-separator, .corpus-rdf-boolean + .corpus-rdf-literal-lang-separator, .h4 small, .content-main-title small, .data-audio-title small, + .h4 .small, .content-main-title .small, .data-audio-title .small, + .h4 .corpus-rdf-literal-type-separator, .content-main-title .corpus-rdf-literal-type-separator, .data-audio-title .corpus-rdf-literal-type-separator, + .h4 + .corpus-rdf-literal-type, .content-main-title + .corpus-rdf-literal-type, .data-audio-title + .corpus-rdf-literal-type, + .h4 .corpus-rdf-literal-lang, .content-main-title .corpus-rdf-literal-lang, .data-audio-title .corpus-rdf-literal-lang, + .h4 + .corpus-rdf-literal-lang-separator, .content-main-title + .corpus-rdf-literal-lang-separator, .data-audio-title + .corpus-rdf-literal-lang-separator, .h5 small, .content-title small, + .h5 .small, .content-title .small, + .h5 .corpus-rdf-literal-type-separator, .content-title .corpus-rdf-literal-type-separator, + .h5 + .corpus-rdf-literal-type, .content-title + .corpus-rdf-literal-type, + .h5 .corpus-rdf-literal-lang, .content-title .corpus-rdf-literal-lang, + .h5 + .corpus-rdf-literal-lang-separator, .content-title + .corpus-rdf-literal-lang-separator, .h6 small, + .h6 .small, + .h6 .corpus-rdf-literal-type-separator, + .h6 + .corpus-rdf-literal-type, + .h6 .corpus-rdf-literal-lang, + .h6 + .corpus-rdf-literal-lang-separator { font-weight: normal; line-height: 1; color: #777777; } h1, .h1, h2, .h2, -h3, .h3, .doc_details_title { +h3, .h3, .doc_details_title, .corpus-rdf-boolean { margin-top: 20px; margin-bottom: 10px; } h1 small, - h1 .small, .h1 small, + h1 .small, + h1 .corpus-rdf-literal-type-separator, + h1 + .corpus-rdf-literal-type, + h1 .corpus-rdf-literal-lang, + h1 + .corpus-rdf-literal-lang-separator, .h1 small, .h1 .small, + .h1 .corpus-rdf-literal-type-separator, + .h1 + .corpus-rdf-literal-type, + .h1 .corpus-rdf-literal-lang, + .h1 + .corpus-rdf-literal-lang-separator, h2 small, - h2 .small, .h2 small, + h2 .small, + h2 .corpus-rdf-literal-type-separator, + h2 + .corpus-rdf-literal-type, + h2 .corpus-rdf-literal-lang, + h2 + .corpus-rdf-literal-lang-separator, .h2 small, .h2 .small, + .h2 .corpus-rdf-literal-type-separator, + .h2 + .corpus-rdf-literal-type, + .h2 .corpus-rdf-literal-lang, + .h2 + .corpus-rdf-literal-lang-separator, h3 small, - h3 .small, .h3 small, .doc_details_title small, - .h3 .small, .doc_details_title .small { + h3 .small, + h3 .corpus-rdf-literal-type-separator, + h3 + .corpus-rdf-literal-type, + h3 .corpus-rdf-literal-lang, + h3 + .corpus-rdf-literal-lang-separator, .h3 small, .doc_details_title small, .corpus-rdf-boolean small, + .h3 .small, .doc_details_title .small, .corpus-rdf-boolean .small, + .h3 .corpus-rdf-literal-type-separator, .doc_details_title .corpus-rdf-literal-type-separator, .corpus-rdf-boolean .corpus-rdf-literal-type-separator, + .h3 + .corpus-rdf-literal-type, .doc_details_title + .corpus-rdf-literal-type, .corpus-rdf-boolean + .corpus-rdf-literal-type, + .h3 .corpus-rdf-literal-lang, .doc_details_title .corpus-rdf-literal-lang, .corpus-rdf-boolean .corpus-rdf-literal-lang, + .h3 + .corpus-rdf-literal-lang-separator, .doc_details_title + .corpus-rdf-literal-lang-separator, .corpus-rdf-boolean + .corpus-rdf-literal-lang-separator { font-size: 65%; } h4, .h4, .content-main-title, .data-audio-title, @@ -1176,14 +1298,56 @@ margin-top: 10px; margin-bottom: 10px; } h4 small, - h4 .small, .h4 small, .content-main-title small, .data-audio-title small, + h4 .small, + h4 .corpus-rdf-literal-type-separator, + h4 + .corpus-rdf-literal-type, + h4 .corpus-rdf-literal-lang, + h4 + .corpus-rdf-literal-lang-separator, .h4 small, .content-main-title small, .data-audio-title small, .h4 .small, .content-main-title .small, .data-audio-title .small, + .h4 .corpus-rdf-literal-type-separator, .content-main-title .corpus-rdf-literal-type-separator, .data-audio-title .corpus-rdf-literal-type-separator, + .h4 + .corpus-rdf-literal-type, .content-main-title + .corpus-rdf-literal-type, .data-audio-title + .corpus-rdf-literal-type, + .h4 .corpus-rdf-literal-lang, .content-main-title .corpus-rdf-literal-lang, .data-audio-title .corpus-rdf-literal-lang, + .h4 + .corpus-rdf-literal-lang-separator, .content-main-title + .corpus-rdf-literal-lang-separator, .data-audio-title + .corpus-rdf-literal-lang-separator, h5 small, - h5 .small, .h5 small, .content-title small, + h5 .small, + h5 .corpus-rdf-literal-type-separator, + h5 + .corpus-rdf-literal-type, + h5 .corpus-rdf-literal-lang, + h5 + .corpus-rdf-literal-lang-separator, .h5 small, .content-title small, .h5 .small, .content-title .small, + .h5 .corpus-rdf-literal-type-separator, .content-title .corpus-rdf-literal-type-separator, + .h5 + .corpus-rdf-literal-type, .content-title + .corpus-rdf-literal-type, + .h5 .corpus-rdf-literal-lang, .content-title .corpus-rdf-literal-lang, + .h5 + .corpus-rdf-literal-lang-separator, .content-title + .corpus-rdf-literal-lang-separator, h6 small, - h6 .small, .h6 small, - .h6 .small { + h6 .small, + h6 .corpus-rdf-literal-type-separator, + h6 + .corpus-rdf-literal-type, + h6 .corpus-rdf-literal-lang, + h6 + .corpus-rdf-literal-lang-separator, .h6 small, + .h6 .small, + .h6 .corpus-rdf-literal-type-separator, + .h6 + .corpus-rdf-literal-type, + .h6 .corpus-rdf-literal-lang, + .h6 + .corpus-rdf-literal-lang-separator { font-size: 75%; } h1, .h1 { @@ -1192,7 +1356,7 @@ h2, .h2 { font-size: 30px; } -h3, .h3, .doc_details_title { +h3, .h3, .doc_details_title, .corpus-rdf-boolean { font-size: 24px; } h4, .h4, .content-main-title, .data-audio-title { @@ -1217,7 +1381,11 @@ font-size: 21px; } } small, -.small { +.small, +.corpus-rdf-literal-type-separator, +.corpus-rdf-literal-type, +.corpus-rdf-literal-lang, +.corpus-rdf-literal-lang-separator { font-size: 85%; } mark, @@ -1405,14 +1573,26 @@ margin-bottom: 0; } blockquote footer, blockquote small, - blockquote .small { + blockquote .small, + blockquote .corpus-rdf-literal-type-separator, + blockquote + .corpus-rdf-literal-type, + blockquote .corpus-rdf-literal-lang, + blockquote + .corpus-rdf-literal-lang-separator { display: block; font-size: 80%; line-height: 1.42857; color: #777777; } blockquote footer:before, blockquote small:before, - blockquote .small:before { + blockquote .small:before, + blockquote .corpus-rdf-literal-type-separator:before, + blockquote + .corpus-rdf-literal-type:before, + blockquote .corpus-rdf-literal-lang:before, + blockquote + .corpus-rdf-literal-lang-separator:before { content: '\2014 \00A0'; } .blockquote-reverse, @@ -1425,16 +1605,40 @@ .blockquote-reverse footer:before, .blockquote-reverse small:before, .blockquote-reverse .small:before, + .blockquote-reverse .corpus-rdf-literal-type-separator:before, + .blockquote-reverse + .corpus-rdf-literal-type:before, + .blockquote-reverse .corpus-rdf-literal-lang:before, + .blockquote-reverse + .corpus-rdf-literal-lang-separator:before, blockquote.pull-right footer:before, blockquote.pull-right small:before, - blockquote.pull-right .small:before { + blockquote.pull-right .small:before, + blockquote.pull-right .corpus-rdf-literal-type-separator:before, + blockquote.pull-right + .corpus-rdf-literal-type:before, + blockquote.pull-right .corpus-rdf-literal-lang:before, + blockquote.pull-right + .corpus-rdf-literal-lang-separator:before { content: ''; } .blockquote-reverse footer:after, .blockquote-reverse small:after, .blockquote-reverse .small:after, + .blockquote-reverse .corpus-rdf-literal-type-separator:after, + .blockquote-reverse + .corpus-rdf-literal-type:after, + .blockquote-reverse .corpus-rdf-literal-lang:after, + .blockquote-reverse + .corpus-rdf-literal-lang-separator:after, blockquote.pull-right footer:after, blockquote.pull-right small:after, - blockquote.pull-right .small:after { + blockquote.pull-right .small:after, + blockquote.pull-right .corpus-rdf-literal-type-separator:after, + blockquote.pull-right + .corpus-rdf-literal-type:after, + blockquote.pull-right .corpus-rdf-literal-lang:after, + blockquote.pull-right + .corpus-rdf-literal-lang-separator:after { content: '\00A0 \2014'; } address { @@ -2074,10 +2278,10 @@ .table-bordered > thead > tr > td { border-bottom-width: 2px; } -.table-striped > tbody > tr:nth-of-type(odd) { +.table-striped > tbody > tr:nth-of-type(odd), table.resultsTable > tbody > tr:nth-of-type(odd) { background-color: #f9f9f9; } -.table-hover > tbody > tr:hover { +.table-hover > tbody > tr:hover, table.resultsTable > tbody > tr:hover { background-color: #f5f5f5; } table col[class*="col-"] { @@ -2105,11 +2309,11 @@ .table > tfoot > tr.active > th { background-color: #f5f5f5; } -.table-hover > tbody > tr > td.active:hover, -.table-hover > tbody > tr > th.active:hover, -.table-hover > tbody > tr.active:hover > td, -.table-hover > tbody > tr:hover > .active, -.table-hover > tbody > tr.active:hover > th { +.table-hover > tbody > tr > td.active:hover, table.resultsTable > tbody > tr > td.active:hover, +.table-hover > tbody > tr > th.active:hover, table.resultsTable > tbody > tr > th.active:hover, +.table-hover > tbody > tr.active:hover > td, table.resultsTable > tbody > tr.active:hover > td, +.table-hover > tbody > tr:hover > .active, table.resultsTable > tbody > tr:hover > .active, +.table-hover > tbody > tr.active:hover > th, table.resultsTable > tbody > tr.active:hover > th { background-color: #e8e8e8; } .table > thead > tr > td.success, @@ -2126,11 +2330,11 @@ .table > tfoot > tr.success > th { background-color: #dff0d8; } -.table-hover > tbody > tr > td.success:hover, -.table-hover > tbody > tr > th.success:hover, -.table-hover > tbody > tr.success:hover > td, -.table-hover > tbody > tr:hover > .success, -.table-hover > tbody > tr.success:hover > th { +.table-hover > tbody > tr > td.success:hover, table.resultsTable > tbody > tr > td.success:hover, +.table-hover > tbody > tr > th.success:hover, table.resultsTable > tbody > tr > th.success:hover, +.table-hover > tbody > tr.success:hover > td, table.resultsTable > tbody > tr.success:hover > td, +.table-hover > tbody > tr:hover > .success, table.resultsTable > tbody > tr:hover > .success, +.table-hover > tbody > tr.success:hover > th, table.resultsTable > tbody > tr.success:hover > th { background-color: #d0e9c6; } .table > thead > tr > td.info, @@ -2147,11 +2351,11 @@ .table > tfoot > tr.info > th { background-color: #d9edf7; } -.table-hover > tbody > tr > td.info:hover, -.table-hover > tbody > tr > th.info:hover, -.table-hover > tbody > tr.info:hover > td, -.table-hover > tbody > tr:hover > .info, -.table-hover > tbody > tr.info:hover > th { +.table-hover > tbody > tr > td.info:hover, table.resultsTable > tbody > tr > td.info:hover, +.table-hover > tbody > tr > th.info:hover, table.resultsTable > tbody > tr > th.info:hover, +.table-hover > tbody > tr.info:hover > td, table.resultsTable > tbody > tr.info:hover > td, +.table-hover > tbody > tr:hover > .info, table.resultsTable > tbody > tr:hover > .info, +.table-hover > tbody > tr.info:hover > th, table.resultsTable > tbody > tr.info:hover > th { background-color: #c4e3f3; } .table > thead > tr > td.warning, @@ -2168,11 +2372,11 @@ .table > tfoot > tr.warning > th { background-color: #fcf8e3; } -.table-hover > tbody > tr > td.warning:hover, -.table-hover > tbody > tr > th.warning:hover, -.table-hover > tbody > tr.warning:hover > td, -.table-hover > tbody > tr:hover > .warning, -.table-hover > tbody > tr.warning:hover > th { +.table-hover > tbody > tr > td.warning:hover, table.resultsTable > tbody > tr > td.warning:hover, +.table-hover > tbody > tr > th.warning:hover, table.resultsTable > tbody > tr > th.warning:hover, +.table-hover > tbody > tr.warning:hover > td, table.resultsTable > tbody > tr.warning:hover > td, +.table-hover > tbody > tr:hover > .warning, table.resultsTable > tbody > tr:hover > .warning, +.table-hover > tbody > tr.warning:hover > th, table.resultsTable > tbody > tr.warning:hover > th { background-color: #faf2cc; } .table > thead > tr > td.danger, @@ -2189,11 +2393,11 @@ .table > tfoot > tr.danger > th { background-color: #f2dede; } -.table-hover > tbody > tr > td.danger:hover, -.table-hover > tbody > tr > th.danger:hover, -.table-hover > tbody > tr.danger:hover > td, -.table-hover > tbody > tr:hover > .danger, -.table-hover > tbody > tr.danger:hover > th { +.table-hover > tbody > tr > td.danger:hover, table.resultsTable > tbody > tr > td.danger:hover, +.table-hover > tbody > tr > th.danger:hover, table.resultsTable > tbody > tr > th.danger:hover, +.table-hover > tbody > tr.danger:hover > td, table.resultsTable > tbody > tr.danger:hover > td, +.table-hover > tbody > tr:hover > .danger, table.resultsTable > tbody > tr:hover > .danger, +.table-hover > tbody > tr.danger:hover > th, table.resultsTable > tbody > tr.danger:hover > th { background-color: #ebcccc; } .table-responsive { @@ -3903,23 +4107,23 @@ margin-right: 0; } } .navbar-default { - background-color: #f8f8f8; - border-color: #e7e7e7; } + background-color: #0085cb; + border-color: #006faa; } .navbar-default .navbar-brand { - color: #777; } + color: white; } .navbar-default .navbar-brand:hover, .navbar-default .navbar-brand:focus { - color: #5e5e5e; + color: #e6e6e6; background-color: transparent; } .navbar-default .navbar-text { - color: #777; } + color: white; } .navbar-default .navbar-nav > li > a { - color: #777; } + color: white; } .navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus { - color: #333; + color: #e6e6e6; background-color: transparent; } .navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus { color: #555; - background-color: #e7e7e7; } + background-color: #006faa; } .navbar-default .navbar-nav > .disabled > a, .navbar-default .navbar-nav > .disabled > a:hover, .navbar-default .navbar-nav > .disabled > a:focus { color: #ccc; background-color: transparent; } @@ -3931,30 +4135,30 @@ background-color: #888; } .navbar-default .navbar-collapse, .navbar-default .navbar-form { - border-color: #e7e7e7; } + border-color: #006faa; } .navbar-default .navbar-nav > .open > a, .navbar-default .navbar-nav > .open > a:hover, .navbar-default .navbar-nav > .open > a:focus { - background-color: #e7e7e7; + background-color: #006faa; color: #555; } @media (max-width: 767px) { .navbar-default .navbar-nav .open .dropdown-menu > li > a { - color: #777; } + color: white; } .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover, .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus { - color: #333; + color: #e6e6e6; background-color: transparent; } .navbar-default .navbar-nav .open .dropdown-menu > .active > a, .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover, .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus { color: #555; - background-color: #e7e7e7; } + background-color: #006faa; } .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a, .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover, .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus { color: #ccc; background-color: transparent; } } .navbar-default .navbar-link { - color: #777; } + color: white; } .navbar-default .navbar-link:hover { - color: #333; } + color: #e6e6e6; } .navbar-default .btn-link { - color: #777; } + color: white; } .navbar-default .btn-link:hover, .navbar-default .btn-link:focus { - color: #333; } + color: #e6e6e6; } .navbar-default .btn-link[disabled]:hover, .navbar-default .btn-link[disabled]:focus, fieldset[disabled] .navbar-default .btn-link:hover, fieldset[disabled] .navbar-default .btn-link:focus { @@ -4524,11 +4728,29 @@ border-color: #337ab7; } .list-group-item.active .list-group-item-heading, .list-group-item.active .list-group-item-heading > small, - .list-group-item.active .list-group-item-heading > .small, .list-group-item.active:hover .list-group-item-heading, + .list-group-item.active .list-group-item-heading > .small, + .list-group-item.active .list-group-item-heading > .corpus-rdf-literal-type-separator, + .list-group-item.active .list-group-item-heading > + .corpus-rdf-literal-type, + .list-group-item.active .list-group-item-heading > .corpus-rdf-literal-lang, + .list-group-item.active .list-group-item-heading > + .corpus-rdf-literal-lang-separator, .list-group-item.active:hover .list-group-item-heading, .list-group-item.active:hover .list-group-item-heading > small, - .list-group-item.active:hover .list-group-item-heading > .small, .list-group-item.active:focus .list-group-item-heading, + .list-group-item.active:hover .list-group-item-heading > .small, + .list-group-item.active:hover .list-group-item-heading > .corpus-rdf-literal-type-separator, + .list-group-item.active:hover .list-group-item-heading > + .corpus-rdf-literal-type, + .list-group-item.active:hover .list-group-item-heading > .corpus-rdf-literal-lang, + .list-group-item.active:hover .list-group-item-heading > + .corpus-rdf-literal-lang-separator, .list-group-item.active:focus .list-group-item-heading, .list-group-item.active:focus .list-group-item-heading > small, - .list-group-item.active:focus .list-group-item-heading > .small { + .list-group-item.active:focus .list-group-item-heading > .small, + .list-group-item.active:focus .list-group-item-heading > .corpus-rdf-literal-type-separator, + .list-group-item.active:focus .list-group-item-heading > + .corpus-rdf-literal-type, + .list-group-item.active:focus .list-group-item-heading > .corpus-rdf-literal-lang, + .list-group-item.active:focus .list-group-item-heading > + .corpus-rdf-literal-lang-separator { color: inherit; } .list-group-item.active .list-group-item-text, .list-group-item.active:hover .list-group-item-text, .list-group-item.active:focus .list-group-item-text { color: #c7ddef; } @@ -4664,8 +4886,20 @@ .panel-title > a, .panel-title > small, .panel-title > .small, + .panel-title > .corpus-rdf-literal-type-separator, + .panel-title > + .corpus-rdf-literal-type, + .panel-title > .corpus-rdf-literal-lang, + .panel-title > + .corpus-rdf-literal-lang-separator, .panel-title > small > a, - .panel-title > .small > a { + .panel-title > .small > a, + .panel-title > .corpus-rdf-literal-type-separator > a, + .panel-title > + .corpus-rdf-literal-type > a, + .panel-title > .corpus-rdf-literal-lang > a, + .panel-title > + .corpus-rdf-literal-lang-separator > a { color: inherit; } .panel-footer { @@ -5736,4 +5970,95 @@ .doc_details_title { margin-top: 0; } +.navbar-default .navbar-collapse { + background: #0085cb url("img/banner_img_reloaded.jpg") no-repeat 0 -89px; } + +.navbar > .container .navbar-brand { + font-weight: bold; + display: inline-block; + width: 120px; + margin-top: 8px; + margin-left: 0px; + height: auto; } + +.navbar-nav { + font-weight: bold; + color: white; } + +footer { + margin-top: 15px; } + +footer section.partenariat .row > div:nth-child(2) { + text-align: right; + line-height: 50px; } + +footer section.partenariat { + border-radius: 5px; + box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1); + padding: 20px 15px; + background: #fff; } + +section.partenariat label { + font-weight: bold; } + +footer .region-footer #block-menu-menu-footer-menu { + font-size: 90%; + color: #8A8A8A; } + +footer .region-footer #block-menu-menu-footer-menu .row { + padding: 0 15px; } + +footer .region-footer #block-menu-menu-footer-menu .menu li { + display: inline-block; + margin-top: 5px; + margin-bottom: 5px; + border-right: 1px solid #DEDDDD; } + +footer .region-footer #block-menu-menu-footer-menu .menu li a { + padding-top: 4px; + padding-bottom: 4px; + color: #8A8A8A; } + +footer .region-footer #block-menu-menu-footer-menu .menu li:first-child a { + padding-left: 0; } + +footer .region-footer #block-menu-menu-footer-menu div.row div:nth-child(1) { + padding-left: 0; } + +footer .region-footer #block-menu-menu-footer-menu div.row div:nth-child(2) { + padding-right: 0; + text-align: right; + line-height: 39px; } + +#query-form #timeout { + max-width: 150px; } + +.corpus-rdf-resource-prefix, +.result-bindings-namespaces-prefix { + color: #f50; } + +.corpus-rdf-resource-link, .corpus-rdf-resource-delimiter { + color: #085; } + +.corpus-rdf-literal-value, .corpus-rdf-literal-value-str { + color: #a11; } + +.corpus-rdf-literal-type-separator, +.corpus-rdf-literal-type { + color: #777777; } + +.corpus-rdf-literal-lang, +.corpus-rdf-literal-lang-separator { + color: #219; } + +.result-bindings-heading { + margin-top: 0; + margin-bottom: 0; } + +.corpus-rdf-boolean-true { + color: #085; } + +.corpus-rdf-boolean-false { + color: #a11; } + /*# sourceMappingURL=app.css.map */ diff -r f8200c5482ec -r c731ab9b934d server/src/public/img/favicon.ico Binary file server/src/public/img/favicon.ico has changed diff -r f8200c5482ec -r c731ab9b934d server/src/public/img/logoCNRS.jpg Binary file server/src/public/img/logoCNRS.jpg has changed diff -r f8200c5482ec -r c731ab9b934d server/src/public/img/logoIRI.jpg Binary file server/src/public/img/logoIRI.jpg has changed diff -r f8200c5482ec -r c731ab9b934d server/src/public/img/logo_corpus.png Binary file server/src/public/img/logo_corpus.png has changed diff -r f8200c5482ec -r c731ab9b934d server/src/public/img/marianne.jpg Binary file server/src/public/img/marianne.jpg has changed diff -r f8200c5482ec -r c731ab9b934d server/src/resources/assets/js/sparqlclient.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/resources/assets/js/sparqlclient.js Mon Oct 31 14:24:23 2016 +0100 @@ -0,0 +1,103 @@ +// sparql edit function + +// ASK, null +const ASK_RESULT_FORMAT = [ + ["HTML", "text/html"] +]; + +// SELECT +const SELECT_RESULT_FORMAT = [ + ["HTML", "text/html"], + ["SPARQL/CSV", "text/csv"], + ["SPARQL/JSON", "application/sparql-results+json"], + ["SPARQL/XML", "application/sparql-results+xml"], + ["SPARQL/TSV", "text/tab-separated-values"], + ["BINARY", "application/x-binary-rdf-results-table"] +]; + +// DESCRIBE,CONSTRUCT +const GRAPH_RESULT_FORMAT = [ + ["HTML", "text/html"], + ["N-Triples", "application/n-triples"], + ["RDF/XML", "application/rdf+xml"], + ["Turtle", "text/turtle"], + ["N3", "text/n3"], + ["RDF/JSON", "application/rdf+json"], + ["TriG", "application/trig"], + ["N-Quads", "application/n-quads"], + ["BinaryRDF", "application/x-binary-rdf"], + ["TriX", "application/trix"], + ["JSON-LD", "application/ld+json"] +]; + +function setOutputFormatSelect(selectElt, optionsList) { + var keys = $.map(optionsList, function(o) { return o[0];}); + var selectedKey = $(":selected",selectElt).text(); + if(!selectedKey || $.inArray(selectedKey, keys) === -1) { + selectedKey = "HTML"; + } + selectElt.empty(); + var innerHtml = ""; + $.each(optionsList, function(i, o) { + innerHtml += "