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 768 rtl clean #881

Open
wants to merge 7 commits into
base: skosmos-2
Choose a base branch
from

Conversation

tfrancart
Copy link
Contributor

Hello Osma

This is a new attempt to have a clean PR for RTL support.
I see however that the PR shows a lot of modified files, that have actually not been modified and that I think come from the merge of master branch in this new clean branch. I would have expected these differences to not be shown in the diffs.

Anyway there only 5 interesting commits that include the necessary modifications : 0f60646 , e3d568a , 48c4cea, c636c6e and f663007 that fixes #880

I don't know how to create a PR that would include only these commits. Can you try to include these modifications ?

Thanks

tfrancart and others added 7 commits July 3, 2019 17:25
* finished jsonld augmentation

* cleaned code and added phpdoc

* Implements CBD solution for blank nodes and adds reification nodes

* refactored duplicate code

* adding a configurable property that enables defining a priority for label fallback languages, related to NatLibFi#688

* improving the fallback language order feature, related to NatLibFi#688

* fixing the missing prefLabel language tag when showing a fallback label, related to NatLibFi#688

* adding a few tests for getLanguageOrder(), related to NatLibFi#688

* using the configurable fallback languages for the concept property value labels as well, related to NatLibFi#688

* using the skosmos:feedbackLanguages for the rest api hierarchy fallback, related to NatLibFi#688

* fixing missing lang parameter from a getLanguageOrder-call, related to NatLibFi#688

* code style cleanup: removing trailing whitespaces

* whoops

* Cleaned for PR and made tests

* add build/ directory to .gitignore

* fixes NatLibFi#690

* using the configurable fallback language for the REST API children function as well

* filtering out hiddenLabels always when the concept has been found earlier, related to NatLibFi#690

* fixes NatLibFi#692

* applying a band aid for the broken mobile screen vocabulary info layout, related to NatLibFi#691

* recoded long URIs as shortened versions as requested

* only querying for concept info when the search has found some results, related to NatLibFi#696

* fix NatLibFi#701 updates embedded json-ld data correctly

* add language ordering to passed through variables to javascript

* fixing wrong translations

* using a more specific selector for the sidebar custom scrollbar

* fixing a bug with displaying language codes for fallback labels

* using the configured languages as fallbacks too

* fixing false language tags sometimes appearing with mapping concepts

* Issue NatLibFi#661 add a copy to clipboard button

* Add Dutch translations by @mrvdries and @ismakutl. Fixes NatLibFi#710

* css for the copy button

* fixes hard crash when collection doesnt return a label

* adding a random fallback for the guessLanguage so the negotiator wont crash when the accept header has not been set

* run Travis tests with newer Fuseki 3.6.0

* define Code Climate variable as global, separating it from matrix vars

* Remove support for obsolete APC caching functions. Fixes NatLibFi#728

* Issue NatLibFi#712: display the concepts of the first letter available

* Default to the first letter of the alphabet when no letter is selected. Fixes NatLibFi#712

* Add Dockerfile and a docker-compose to run SKOSMOS with Fuseki

* Add Dockerfile container_name's

* Add volume binding example in comments for Fuseki

* Rename Skosmos docker-compose created container name to skosmos

* Fixes NatLibFi#638

* fix constructor call due to previously done refactoring(?)

* Run Travis tests also under PHP 7.1 and 7.2

* add checks to prevent sizeof() related warnings in PHP 7.2

* fix PHP 7.1+ build test by changing the name for error raised

* Changed test fuseki port to 13030; upgraded test fuseki to 3.7.0; fixed PHP 7.2+ build test

* allow tests to fail on PHP 7.2 due to JsonLD compatibility problems

* expect different exceptions depending on PHP version (7.0 vs 7.1+)

* adjust build matrix: test fuseki SNAPSHOT only on php 7.1, allow failures on 7.2 & fuseki SNAPSHOT

* further adjust build matrix

* specify PHP versions without quotes

* adjust build matrix: only test fuseki SNAPSHOT on php 7.1

* bump Fuseki version to 3.7.0 also on Travis tests

* move notifications to new NatLibFi Slack instance

* Allow request input to be mocked

* Refactor getQueryParamArray to always return array

* Add additional fields to JSON-LD context for search endpoint

If additional fields are requested using the 'fields' parameter,
add them to the JSON-LD context.

Note: This will break any implementation that relies on the 'skos:'
prefix being part of the keys.

* Add mapping relations to JSON-LD context

* Add unit test for NatLibFi#744 / PR NatLibFi#756. Fixes NatLibFi#744

* Open all hierarchies when a concept is in multiple schemes. Fixes NatLibFi#765

* fix layout issue due to having a <p> element instead of <span> in skosxl display

* Change feedback message headers to use Reply-To and make name and e-mail optional. Fixes NatLibFi#761

* Set the feedback email sender address properly when a vocabulary-specific recipient has been set. Fixes NatLibFi#761

* Add Arabic translation from Transifex. Fixes NatLibFi#767

* Fix Dockerfile by automatically answering yes to apt-get install locales

* Issue NatLibFi#738 replace .inc configuration files by .ttl (turtle) files.

The cache that was created in the Model instance, now was moved to the
GlobalConfig, but is still accessed from Model to add entries looked up.

There is no more need of a separate .ttl file for vocabularies, as it is
now part of the configuration file. Old files were removed.

In order to maintain backward compatibility, most methods of GlobalConfig
and of VocabularyConfig were maintained as-is. With internal changes to
re-route requests to the right RDF objects.

Tests were minor updates in tests, but only to replace .inc by .ttl or fix
coverage annotations.

* Fix scrutinizer issues

* Remove unused graph variable from Model

* Use a list for skosmos:languages

* add skosmos:globalPlugins example which was forgotten in PR NatLibFi#769

* Use RDFS properties for language settings. Fixes NatLibFi#772

* Fix test config for NatLibFi#772

* Replace PHP explode function call by a Turtle list for globalPlugins

* Include unit test for new globalPlugins with list, and update distributed configuration file

* Issue NatLibFi#771 config migrate tool

* Replace exit() by exceptions, and fail earlier if invalid mode

* Leave values not defined as comments

* Fix search with double quotes

* Upgrade Travis config to use newest Fuseki 3.8.0

* Use Fuseki 3.8.0 by default for tests

* fix getVersion when on a branch with no tags available in recent history

* use the dev.finto.fi SPARQL endpoint as default endpoint, to match vocab config

* Disable Travis tests for Fuseki snapshot. There is no longer a Fuseki1 distribution snapshot we could use, after building it was disabled in JENA-1573.

* updated German translations. Credit: Jonas Waeber

* updated French translations. Credit: Thomas Francart

* updated Polish translations. Credit: Łukasz Szeremeta

* update translation files to match latest template; no actual changes in translations

* Add translations for Farsi, by Omid Ghiasvand and Reza Ghiasvand. Still missing true RTL support (NatLibFi#768)

* fixes NatLibFi#714

* sorting concept property values with natural case sort when sortByNotation is true, fixes NatLibFi#737

* Fixed the variable name notsort for a clearer sort_by_notation

* Avoid double encoding of search query string. Fixes NatLibFi#763

* fix issue regarding updating the json-ld data

* Specify skosmos:defaultEndpoint as a resource, not literal. Fixes NatLibFi#786

* updated German translations for 100% coverage. Credit: Jonas Waeber

* Fix PHP syntax when calling a method

* Set a value for variable when declaring it

* Avoid type coercion in JS when comparing values

* Avoid declaring a variable twice

* Remove unused variable

* Remove duplicated semicolon

* Add Vagrantfile and Ansible Playbook setup for deploying and running Skosmos in virtual environment

* Add .vagrant and .DS_Store to .gitignore

* Remove unnecessary installation of Python 2.7 and configure to use python3

* Removed old config files and added references to eclipse project file to .gitignore

* Remove Fuseki deployment

* Fix apt not installing php-mbstring by updating cache before apt install

* Turn off verbose/debug mode for Ansible provisioner

* Delete .DS_Store

* Delete second .DS_Store

* Remove unnecessary, duplicate configuration file

* Add Vagrantfile and Ansible Playbook setup for deploying and running Skosmos in virtual environment

* Add .vagrant and .DS_Store to .gitignore

* Remove unnecessary installation of Python 2.7 and configure to use python3

* Removed old config files and added references to eclipse project file to .gitignore

* Remove Fuseki deployment

* Fix apt not installing php-mbstring by updating cache before apt install

* Turn off verbose/debug mode for Ansible provisioner

* Delete .DS_Store

* Delete second .DS_Store

* Remove unnecessary, duplicate configuration file

* reorder .gitignore

* Use correct value when retrieving settings

* Add tests for GlobalConfig

* Add more tests for VoacabularyConfig

* Use array in the test for GlobalConfig::getGlobalPlugins

* Fix parameter order for jena-text queries - MAX_N setting was being ignored. Fixes NatLibFi#794

* Loosen the check for port numbers in guessBaseHref. Fixes NatLibFi#796

* removed references to old configuration files

* Choose feedback recipient based on selection on feedback form, not the URL from which the feedback page was invoked. Fixes NatLibFi#808

* Fix unit test that broke after the fix to NatLibFi#808

(cherry picked from commit 1a55e8b)

* Fix fragile unit test (may break if /tmp/skosmos-template-cache exists but is owned by another user)

* Fix config migration of LOG_FILE_NAME=null

Fixes NatLibFi#801

* fixes NatLibFi#804

* fix some css; addresses issue NatLibFi#799

* Added a check for empty arrays to avoid the situation in NatLibFi#813

* #fixes NatLibFi#791; also update fuseki to 3.9.0

* Reenable Fuseki snapshot builds on Travis; use Fuseki2 3.9.0 on Travis instead of 3.8.0

* Don't allow Travis builds with PHP 7.2 to fail; run Fuseki snapshot builds with PHP 7.2. Related to NatLibFi#758

* check which locales are installed in Travis environment

* Try to break unit tests by setting LANGUAGE=fr. Part of NatLibFi#816

* Always set LANGUAGE environment variable when setting LC_ALL. Fixes NatLibFi#816

* update gitignore to match Fuseki2 directory naming (NatLibFi#791)

* Update fi, sv UI translations for skos:relatedMatch. Fixes NatLibFi#707

* support for MARC sources in REST controller

* fix updated, unit tests passed

* Display concept types for search

* Adapt code from concepts page

* Added the new icon and updated tooltip translations

* refactor: rename function for clarity, and make it private since it's only needed internally

* Rewrite concept group handling to take into account multiple hierarchical groups. Fixes NatLibFi#811

* Fix display of array property values

* Use test-specific template cache dir to avoid permission problems. Fixes NatLibFi#821

* updated translations for Finnish, Swedish and German

* Fix case when a concept property value is from another vocabulary. Fixes NatLibFi#819

* Fix concept group display also in search result list. Related to NatLibFi#811

* mark the start of 2.2 development

* Switch from FILTER NOT EXISTS to MINUS to avoid Jena 3.8+ performance issue. Fixes NatLibFi#829

* Also move the VALUES block to avoid Jena 3.8+ performance issues. Fixes NatLibFi#829

* Add phpdocs type hints

* Don't perform label and subPropertyOf lookups for well-known properties. Part of NatLibFi#836

* Support last modified header

* Fix type hints in Model

* Be more lenient with mixed types from EasyRDF

* Add unit test for VocabularyConfig

* Add unit test for Vocabulary

* Add unit test for Concept

* Make unit tests work on both command line and IDE

* Add test data for HTTP 304 RDF tests

* Add unit test for Controller (and include a function to encapsulate header)

* Report coverage for controllers

* Move php built-in functions to other functions, so that we can mock and test everything

* Add unit test for Controller where the 304 response is sent successfully

* Add unit test for WebController

* Update controller/Controller.php

Co-Authored-By: kinow <kinow@users.noreply.github.com>

* Fixed function calls for getLiteral with property and lang

* Added redirection to vocab main page for vocab uri

* Prevent error when the system is configured to use dc:modified, but neither concept nor scheme have dates

* Remove duplicated array index

* Added text to the feedback form in fi, en & sv

* Add REST endpoint for mappings

* Mappings endpoint: Return 404 if concept not found

* Mappings endpoint: Handle case when no label is found

* Mappings endpoint: Fix routing

* Mappings endpoint: Make querying external endpoints optional

* Avoid second unnecessary getProperties call in search result list. Part of NatLibFi#836

* Changed SPARQL query in Count Lang Concepts

Better performance when counting the languages for all concepts by optimizing the SPARQL query

* Avoid unnecessary properties when calling getMappingProperties from search result page. Part of NatLibFi#836

* clean up formatValuesFilterAndBind method

* further simplify generation of languageStatistics query

* Add a cache to avoid computing language order many times during a request

* Added the correct parameters for a constructor call

* Update of Fira Sans embedded fonts with newer version from https://github.com/mozilla/Fira/tree/4.202
- related to bug NatLibFi#855

* Fix methods calls following pull request about concept property mappings

* Get git modified date

* Get config.ttl modified date

* Rename test for getConceptModifiedDate

* Return the most recent date, or null if no date found/retrieved

* Fix data provider name

* Use Model::getConfig() instead of accessing private Model::

* Use a constant of 10 minutes to read configuration for last-modified headers

* Update mocks to expect getConfig called

* Store result of filemtime in GlobalConfig, and re-use in WebController

* Rename constant used only by Git now, and amend comment

* Return a DateTime instead of int in Controller:getIfModifiedSince

* Add missing return statement (used in an empty() function in another part of the code)

* Remove unnecessary variable (it is instantiated in each try/catch block)

* Add missing throws docstring

* Use !== for comparison

* Add missing return statement (returning false as in the other function)

* Turn off mouse events on the dropdown menu

* Rename docker-compose created container from "web" to "skosmos"

There was a note in the Docker installation documentation about renaming it. I'd agree it makes more sense, so prepared this PR.

* Remove playbook.retry file and prevent Ansible from creating one

* Add Fuseki installation and configurations for locally-hosted example data

* Add new line to end of Fuseki config file

* Add config file for using locally-hosted data

* Use a default vocabulary ID when guessing vocabulary, to save lookups. Part of NatLibFi#836

* fix operator that got reverted to != when resolving merge conflict

* Make guessVocabularyFromURI more careful and avoid calling it unless absolutely necessary. Fixes NatLibFi#868

* more elegant way of checking whether a ConceptPropertyValue has a label

* Update README.md

Updated to match current development (delete mention of technologies no longer used)

* upgrading phpunit to 7.5.10 and fixing one test broken by the upgrade

* updating the phpunit configuration file
@tfrancart
Copy link
Contributor Author

After all, after fixing a one-line conflict, the PR seem consistent. Hope you can review the modifications and include them in Skosmos !
Let us know

@Experiencis-Aurelien

@osma osma mentioned this pull request Aug 9, 2019
@osma
Copy link
Member

osma commented Aug 9, 2019

Thanks @tfrancart and @Experiencis-Aurelien! This PR indeed looks clean, with the diff only showing the intended changes and nothing more. I will review it shortly.

My initial reaction is that this PR introduces a surprisingly large amount of extra CSS that then has to be maintained. I'm wondering if there would be a way to reduce that maintenance cost, for example by using a tool like RTLCSS to generate the RTL CSS rules instead of maintaining them manually.

Copy link
Member

@osma osma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've commented on some specific issues in the implementation which I think can be worked out rather easily.

But the big problem I see in this PR is the 700 line CSS file (rtl.css). Adding it to the Skosmos codebase would create a significant extra maintenance burden. When editing the current CSS file, it would be not be obvious that also rtl.css must be changed accordingly. So it would be very likely that future changes to HTML templates or CSS rules would cause unintended breakage for RTL languages. I think a better solution is needed.

RTLCSS seems to provide such a solution, by automatically generating a RTL version of a CSS file. Would it be possible for you to try it out and see whether it could be used to autogenerate a RTL CSS file starting from the current (LTR) Skosmos CSS file? If that approach worked, it would eliminate a lot of the maintenance burden.

If RTLCSS turns out to be problematic for some reason, there are other similar tools such as CSSJanus and rtl-css-js.

use \Punic\Language;
use \Punic\Misc;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Misc import seems to be unused?

@@ -76,6 +78,13 @@ public function __construct($model)
$this->honeypot->disable();
}
$this->twig->addGlobal('honeypot', $this->honeypot);

$direction_test = new Twig_Function('direction_test', function($locale=''){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the direction_test function should be given a more descriptive name, for example locale_direction


$direction_test = new Twig_Function('direction_test', function($locale=''){
$data = Data::get('layout', $locale);
return $data['characterOrder'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to convert the characterOrder value to either ltr or rtl before returning. It would make using the function from within Twig templates easier.

@@ -35,7 +35,8 @@ public function getLang()
return $this->getEnvLang();
}

public function getLabel($lang = '', $fallback = 'uri')
public function getLabel($lang = '', $fallbackToUri = 'uri')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of this change? Is it related to the RTL support at all?

@@ -69,7 +70,7 @@ public function getLabel($lang = '', $fallback = 'uri')
return $this->resource->getLiteral('rdf:value');
}

if ($fallback == 'uri') {
if ($fallbackToUri == 'uri') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of this change? Is it related to the RTL support at all?

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html dir="ltr" lang="{{ request.lang }}">
<html{% if request.lang == 'ar' %} dir="rtl" {% else %} dir="ltr"{% endif %} lang="{{ request.lang }}">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should use the direction_test (or locale_direction if renamed) function, instead of checking only for Arabic.

{% endif %}
{% if vocab.config.showChangeList %}
<li id="changes"><a href="{{ request.vocabid }}/{{ request.lang }}/new{% if request.contentLang != request.lang %}?clang={{ request.contentLang }}{% endif %}">{% trans "Changes-nav" %}</a></li>
{% if direction_test(request.lang) == 'right-to-left' %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right to me. You shouldn't need to define the elements of the list separately for LTR and RTL languages. Doing it this way causes a lot of repetition and maintenance headaches.

In my understanding it should be possible to reverse the visual list order using either the dir attribute or CSS.

{% endif %}
</ul>
</div>
{% if letters %}
{% if letters and direction_test(request.lang) == 'right-to-left' %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding an extra direction_test clause breaks the logic. It appears to me that if letters is false but the language is LTR, then the list will be displayed even if it shouldn't be.

I'd suggest defining an additional variable which is either a copy of letters (for LTR locales), or letters in reverse order (for RTL). Then the same template code applies for both cases.

<li id="hierarchy{% if not vocab.config.showHierarchy %}-disabled{% endif %}"{% if active_tab == 'hierarchy' %} class="active"{% endif %}><a href="#" id="hier-trigger"{% if not vocab.config.showHierarchy %} title="{% trans 'hierarchy-disabled-help' %}"{% endif %}>{% trans "Hier-nav" %}</a></li>
{% if vocab.config.groupClassURI %}
<li id="groups"><a href="{{ request.vocabid }}/{{ request.lang }}/groups{% if request.contentLang != request.lang %}?clang={{ request.contentLang }}{% endif %}">{% trans "Group-nav" %}</a></li>
{% endif %}
{% if vocab.config.showChangeList %}
<li id="changes"><a href="{{ request.vocabid }}/{{ request.lang }}/new{% if request.contentLang != request.lang %}?clang={{ request.contentLang }}{% endif %}">{% trans "Changes-nav" %}</a></li>
{% endif %}
{% if request.vocab.config.showAlphabeticalIndex %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this block moved?

@Experiencis-Aurelien
Copy link

Experiencis-Aurelien commented Aug 13, 2019 via email

@osma
Copy link
Member

osma commented Feb 5, 2020

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 7
           

See the complete overview on Codacy

@@ -76,6 +78,13 @@ public function __construct($model)
$this->honeypot->disable();
}
$this->twig->addGlobal('honeypot', $this->honeypot);

$direction_test = new Twig_Function('direction_test', function($locale=''){
$data = Data::get('layout', $locale);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/* scrollbars
****************************/
html[dir="rtl"] .mCSB_container {
margin-left: 15px !important;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Use of !important

@media (min-width: 1260px) {
html[dir="rtl"] #service-name {
right: 0 !important;
left: initial !important;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Use of !important

left:initial;
  }

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@media (min-width: 1260px) {
html[dir="rtl"] #service-name {
right: 0 !important;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Use of !important

html[dir="rtl"] .right-box {
right: 0;
left:initial;
  }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/* typeahead.js
***********************************/
html[dir="rtl"] .tt-dropdown-menu {
left: 0 !important;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Use of !important

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In ConceptPropertyValue.getLabel(), the $fallback parameter should have another name
3 participants