Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #737 sorting concept property values correctly #741

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f8fd1e1
sorting concept property values with natural case sort when sortByNot…
henriyli Mar 20, 2018
de27112
Fixes #638
kouralex Apr 5, 2018
6a3278c
fix constructor call due to previously done refactoring(?)
kouralex Apr 11, 2018
e875530
Run Travis tests also under PHP 7.1 and 7.2
osma Apr 12, 2018
3b492fb
add checks to prevent sizeof() related warnings in PHP 7.2
kouralex Apr 12, 2018
224f8ee
fix PHP 7.1+ build test by changing the name for error raised
kouralex Apr 12, 2018
5d29998
Changed test fuseki port to 13030; upgraded test fuseki to 3.7.0; fix…
kouralex Apr 12, 2018
222a273
Merge branch 'master' of https://github.com/NatLibFi/Skosmos into tra…
osma Apr 12, 2018
d09a54a
allow tests to fail on PHP 7.2 due to JsonLD compatibility problems
osma Apr 12, 2018
c1f32d1
expect different exceptions depending on PHP version (7.0 vs 7.1+)
osma Apr 12, 2018
fe866a1
adjust build matrix: test fuseki SNAPSHOT only on php 7.1, allow fail…
osma Apr 12, 2018
d31b17a
further adjust build matrix
osma Apr 12, 2018
bcee453
specify PHP versions without quotes
osma Apr 12, 2018
22750f1
adjust build matrix: only test fuseki SNAPSHOT on php 7.1
osma Apr 12, 2018
35d74b4
bump Fuseki version to 3.7.0 also on Travis tests
osma Apr 12, 2018
007896e
move notifications to new NatLibFi Slack instance
osma Apr 12, 2018
8d66548
Allow request input to be mocked
danmichaelo Apr 3, 2018
25ce463
Refactor getQueryParamArray to always return array
danmichaelo Apr 3, 2018
ed1c8b2
Add mapping relations to JSON-LD context
danmichaelo Apr 3, 2018
1a5cc6c
Add additional fields to JSON-LD context for search endpoint
danmichaelo Apr 3, 2018
2459de9
Merge branch 'fix-fatal-argumentcaughterror'
osma Apr 13, 2018
5d8424b
Add unit test for #744 / PR #756. Fixes #744
osma Apr 13, 2018
ef8493e
Merge branch 'test-relatedmatch' of https://github.com/danmichaelo/Sk…
osma Apr 13, 2018
6f1807a
Open all hierarchies when a concept is in multiple schemes. Fixes #765
osma May 4, 2018
164acc3
fix layout issue due to having a <p> element instead of <span> in sko…
kouralex May 9, 2018
7b517f1
Change feedback message headers to use Reply-To and make name and e-m…
osma May 23, 2018
c56eec7
Set the feedback email sender address properly when a vocabulary-spec…
osma May 28, 2018
9b11ec9
Add Arabic translation from Transifex. Fixes #767
osma May 30, 2018
aea8e8f
Fix Dockerfile by automatically answering yes to apt-get install locales
kinow Jun 2, 2018
6d28f04
Issue #738 replace .inc configuration files by .ttl (turtle) files.
kinow May 30, 2018
d51c82a
Fix scrutinizer issues
kinow Jun 2, 2018
89cae46
Remove unused graph variable from Model
kinow Jun 4, 2018
8287a16
Use a list for skosmos:languages
kinow Jun 4, 2018
aee8384
add skosmos:globalPlugins example which was forgotten in PR #769
osma Jun 5, 2018
2d28268
Use RDFS properties for language settings. Fixes #772
osma Jun 5, 2018
c68a971
Fix test config for #772
osma Jun 5, 2018
73fd33d
Replace PHP explode function call by a Turtle list for globalPlugins
kinow Jun 7, 2018
b89c916
Include unit test for new globalPlugins with list, and update distrib…
kinow Jun 8, 2018
c03b0c0
Issue #771 config migrate tool
kinow Jul 11, 2018
3cdb1be
Replace exit() by exceptions, and fail earlier if invalid mode
kinow Aug 14, 2018
53c750b
Leave values not defined as comments
kinow Aug 14, 2018
2a8fb6d
Fix search with double quotes
kinow Apr 27, 2018
20f0df1
Upgrade Travis config to use newest Fuseki 3.8.0
osma Aug 22, 2018
06b8b20
Use Fuseki 3.8.0 by default for tests
osma Aug 22, 2018
b9ca601
fix getVersion when on a branch with no tags available in recent history
osma Aug 24, 2018
5f54cc5
Merge branch 'henriyli-notsort-fix-737' of https://github.com/henriyl…
Aug 24, 2018
f82db77
Fixed the variable name notsort for a clearer sort_by_notation
Aug 24, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config.inc
config.ttl
vocabularies.ttl
build
vendor
Expand Down
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ sudo: required
dist: trusty
language: php
php:
- "7.0"
- 7.0
- 7.1
- 7.2
install:
- composer install
cache:
Expand All @@ -23,10 +25,16 @@ env:
global:
- CC_TEST_REPORTER_ID=fb98170a5c7ea9cc2bbab19ff26268335e6a11a4f8267ca935e5e8ff4624886c
matrix:
- FUSEKI_VERSION=3.6.0
- FUSEKI_VERSION=3.8.0
- FUSEKI_VERSION=SNAPSHOT
matrix:
exclude:
- php: 7.0
env: FUSEKI_VERSION=SNAPSHOT
- php: 7.2
env: FUSEKI_VERSION=SNAPSHOT
allow_failures:
- php: 7.2
- env: FUSEKI_VERSION=SNAPSHOT
notifications:
slack: finto:5rO9Lp4Tstn6y34grtFBpjJ0
slack: kansalliskirjasto:9mOKu3Vws1CIddF5jqWgXbli
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM php:7.0-apache

RUN apt-get update

RUN apt-get install locales
RUN apt-get -y install locales
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
RUN echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen
RUN echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen
Expand Down
68 changes: 0 additions & 68 deletions config.inc.dist

This file was deleted.

128 changes: 128 additions & 0 deletions config.ttl.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
@prefix void: <http://rdfs.org/ns/void#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dc: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix wv: <http://vocab.org/waiver/terms/norms> .
@prefix sd: <http://www.w3.org/ns/sparql-service-description#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix skosmos: <http://purl.org/net/skosmos#> .
@prefix isothes: <http://purl.org/iso25964/skos-thes#> .
@prefix mdrtype: <http://publications.europa.eu/resource/authority/dataset-type/> .
@prefix : <#> .

# Skosmos main configuration

:config a skosmos:Configuration ;
# SPARQL endpoint
# a local Fuseki server is usually on localhost:3030
skosmos:sparqlEndpoint "http://localhost:3030/ds/sparql" ;
# sparql-query extension, or "Generic" for plain SPARQL 1.1
# set to "JenaText" instead if you use Fuseki with jena-text index
skosmos:sparqlDialect "Generic" ;
# whether to enable collation in sparql queries
skosmos:sparqlCollationEnabled false ;
# HTTP client configuration
skosmos:sparqlTimeout 20 ;
skosmos:httpTimeout 5 ;
# customize the service name
skosmos:serviceName "Skosmos" ;
# customize the base element. Set this if the automatic base url detection doesn't work. For example setups behind a proxy.
# skosmos:baseHref "http://localhost/Skosmos/" ;
# interface languages available, and the corresponding system locales
skosmos:languages (
[ rdfs:label "fi" ; rdf:value "fi_FI.utf8" ]
[ rdfs:label "sv" ; rdf:value "sv_SE.utf8" ]
[ rdfs:label "en" ; rdf:value "en_GB.utf8" ]
) ;
# how many results (maximum) to load at a time on the search results page
skosmos:searchResultsSize 20 ;
# how many items (maximum) to retrieve in transitive property queries
skosmos:transitiveLimit 1000 ;
# whether or not to log caught exceptions
skosmos:logCaughtExceptions false ;
# set to TRUE to enable logging into browser console
skosmos:logBrowserConsole false ;
# set to a logfile path to enable logging into log file
# skosmos:logFileName "" ;
# a default location for Twig template rendering
skosmos:templateCache "/tmp/skosmos-template-cache" ;
# customize the css by adding your own stylesheet
skosmos:customCss "resource/css/stylesheet.css" ;
# default email address where to send the feedback
skosmos:feedbackAddress "" ;
# email address to set as the sender for feedback messages
skosmos:feedbackSender "" ;
# email address to set as the envelope sender for feedback messages
skosmos:feedbackEnvelopeSender "" ;
# whether to display the ui language selection as a dropdown (useful for cases where there are more than 3 languages)
skosmos:uiLanguageDropdown false ;
# whether to enable the spam honey pot or not, enabled by default
skosmos:uiHoneypotEnabled true ;
# default time a user must wait before submitting a form
skosmos:uiHoneypotTime 5 ;
# plugins to activate for the whole installation (including all vocabularies)
skosmos:globalPlugins () .

# Skosmos vocabularies

:ysa a skosmos:Vocabulary, void:Dataset ;
dc:title "YSA - Yleinen suomalainen asiasanasto"@fi,
"YSA - Allmän tesaurus på finska"@sv,
"YSA - General Finnish thesaurus"@en ;
dc:subject :cat_general ;
dc:type mdrtype:THESAURUS ;
void:uriSpace "http://www.yso.fi/onto/ysa/";
skosmos:groupClass skos:Collection;
skosmos:language "fi";
skosmos:shortName "YSA";
skosmos:feedbackRecipient "vesa-posti@helsinki.fi" ;
skosmos:showChangeList "true" ;
void:dataDump <http://api.finto.fi/download/ysa/ysa-skos.ttl> ;
void:sparqlEndpoint <http://api.dev.finto.fi/sparql> ;
skosmos:sparqlGraph <http://www.yso.fi/onto/ysa/>
.

:yso a skosmos:Vocabulary, void:Dataset ;
dc:title "YSO - Yleinen suomalainen ontologia"@fi,
"ALLFO - Allmän finländsk ontologi"@sv,
"YSO - General Finnish ontology"@en ;
dc:subject :cat_general ;
dc:type mdrtype:ONTOLOGY ;
void:uriSpace "http://www.yso.fi/onto/yso/";
skosmos:language "fi", "sv", "en";
skosmos:defaultLanguage "fi";
skosmos:showTopConcepts "true";
skosmos:showStatistics "false";
skosmos:loadExternalResources "false";
skosmos:shortName "YSO",
"ALLFO"@sv;
skosmos:groupClass isothes:ConceptGroup ;
skosmos:arrayClass isothes:ThesaurusArray ;
void:dataDump <http://api.finto.fi/download/yso/yso-skos.ttl> ;
void:sparqlEndpoint <http://api.dev.finto.fi/sparql> ;
skosmos:sparqlGraph <http://www.yso.fi/onto/yso/> ;
skosmos:mainConceptScheme <http://www.yso.fi/onto/yso/>
.

:categories a skos:ConceptScheme;
skos:prefLabel "Skosmos Vocabulary Categories"@en
.

:cat_general a skos:Concept ;
skos:topConceptOf :categories ;
skos:inScheme :categories ;
skos:prefLabel "Yleiskäsitteet"@fi,
"Allmänna begrepp"@sv,
"General concepts"@en
.

mdrtype:THESAURUS a skos:Concept ;
skos:prefLabel "Тезаурус"@bg, "Tezaurus"@cs, "Tesaurus"@da, "Thesaurus"@de, "Θησαυρός"@el, "Thesaurus"@en, "Tesaurus"@et, "Tesaurus"@fi, "Thésaurus"@fr, "Pojmovnik"@hr, "Tezaurusz"@hu, "Tesauro"@it, "Tēzaurs"@lv, "Tezauras"@lt, "Teżawru"@mt, "Thesaurus"@nl, "Tesaurus"@no, "Tezaurus"@pl, "Tesauro"@pt, "Tezaur"@ro, "Synonymický slovník"@sk, "Tezaver"@sl, "Tesauro"@es, "Tesaurus"@sv
.

mdrtype:ONTOLOGY a skos:Concept ;
skos:prefLabel "Онтология"@bg, "Ontologie"@cs, "Ontologi"@da, "Ontologie"@de, "Οντολογία"@el, "Ontology"@en, "Ontoloogia"@et, "Ontologia"@fi, "Ontologie"@fr, "Ontologija"@hr, "Ontológia"@hu, "Ontologia"@it, "Ontoloģija"@lv, "Ontologija"@lt, "Ontoloġija"@mt, "Ontologie"@nl, "Ontologi"@no, "Struktura pojęciowa"@pl, "Ontologia"@pt, "Ontologie"@ro, "Ontológia"@sk, "Ontologija"@sl, "Ontología"@es, "Ontologi"@sv
.
53 changes: 37 additions & 16 deletions controller/RestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,27 +112,43 @@ private function constructSearchParameters($request)
return $parameters;
}

private function transformSearchResults($request, $results)
private function transformSearchResults($request, $results, $parameters)
{
// before serializing to JSON, get rid of the Vocabulary object that came with each resource
foreach ($results as &$res) {
unset($res['voc']);
}
$ret = array(
'@context' => array(
'skos' => 'http://www.w3.org/2004/02/skos/core#',
'isothes' => 'http://purl.org/iso25964/skos-thes#',
'onki' => 'http://schema.onki.fi/onki#',
'uri' => '@id',
'type' => '@type',
'results' => array(
'@id' => 'onki:results',
'@container' => '@list',
),
'prefLabel' => 'skos:prefLabel',
'altLabel' => 'skos:altLabel',
'hiddenLabel' => 'skos:hiddenLabel',

$context = array(
'skos' => 'http://www.w3.org/2004/02/skos/core#',
'isothes' => 'http://purl.org/iso25964/skos-thes#',
'onki' => 'http://schema.onki.fi/onki#',
'uri' => '@id',
'type' => '@type',
'results' => array(
'@id' => 'onki:results',
'@container' => '@list',
),
'prefLabel' => 'skos:prefLabel',
'altLabel' => 'skos:altLabel',
'hiddenLabel' => 'skos:hiddenLabel',
);
foreach ($parameters->getAdditionalFields() as $field) {

// Quick-and-dirty compactification
$context[$field] = 'skos:' . $field;
foreach ($results as &$result) {
foreach ($result as $k => $v) {
if ($k == 'skos:' . $field) {
$result[$field] = $v;
unset($result['skos:' . $field]);
}
}
}
}

$ret = array(
'@context' => $context,
'uri' => '',
'results' => $results,
);
Expand Down Expand Up @@ -171,7 +187,7 @@ public function search($request)

$parameters = $this->constructSearchParameters($request);
$results = $this->model->searchConcepts($parameters);
$ret = $this->transformSearchResults($request, $results);
$ret = $this->transformSearchResults($request, $results, $parameters);

return $this->returnJson($ret);
}
Expand Down Expand Up @@ -561,6 +577,11 @@ private function returnDataResults($results, $format) {
'narrower' => 'skos:narrower',
'related' => 'skos:related',
'inScheme' => 'skos:inScheme',
'exactMatch' => 'skos:exactMatch',
'closeMatch' => 'skos:closeMatch',
'broadMatch' => 'skos:broadMatch',
'narrowMatch' => 'skos:narrowMatch',
'relatedMatch' => 'skos:relatedMatch',
);
$compactJsonLD = \ML\JsonLD\JsonLD::compact($results, json_encode($context));
$results = \ML\JsonLD\JsonLD::toString($compactJsonLD);
Expand Down
25 changes: 18 additions & 7 deletions controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,19 @@ public function invokeFeedbackForm($request)
));
}

private function createFeedbackHeaders($fromName, $fromEmail, $toMail)
private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender)
{
$headers = "MIME-Version: 1.0″ . '\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
if ($toMail) {
if (!empty($toMail)) {
$headers .= "Cc: " . $this->model->getConfig()->getFeedbackAddress() . "\r\n";
}
if (!empty($fromEmail)) {
$headers .= "Reply-To: $fromName <$fromEmail>\r\n";
}

$headers .= "From: $fromName <$fromEmail>" . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$service = $this->model->getConfig()->getServiceName();
$headers .= "From: $fromName via $service <$sender>";
return $headers;
}

Expand All @@ -299,16 +303,23 @@ public function sendFeedback($request, $message, $fromName = null, $fromEmail =
$message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message;
}

$subject = SERVICE_NAME . " feedback";
$headers = $this->createFeedbackHeaders($fromName, $fromEmail, $toMail);
$envelopeSender = FEEDBACK_ENVELOPE_SENDER;
$envelopeSender = $this->model->getConfig()->getFeedbackEnvelopeSender();
$subject = $this->model->getConfig()->getServiceName() . " feedback";
// determine the sender address of the message
$sender = $this->model->getConfig()->getFeedbackSender();
if (empty($sender)) $sender = $envelopeSender;
if (empty($sender)) $sender = $this->model->getConfig()->getFeedbackAddress();

// determine sender name - default to "anonymous user" if not given by user
if (empty($fromName)) $fromName = "anonymous user";

$headers = $this->createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender);
$params = empty($envelopeSender) ? '' : "-f $envelopeSender";

// adding some information about the user for debugging purposes.
$message = $message . "<br /><br /> Debugging information:"
. "<br />Timestamp: " . date(DATE_RFC2822)
. "<br />User agent: " . $request->getServerConstant('HTTP_USER_AGENT')
. "<br />IP address: " . $request->getServerConstant('REMOTE_ADDR')
. "<br />Referer: " . $request->getServerConstant('HTTP_REFERER');

try {
Expand Down
Loading