From d71e44c7195373a3a3f4d215a2b8b78dc82a02e6 Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Thu, 10 Dec 2020 03:20:32 +0100 Subject: Use wikimedia/less.php instead of leafo/lessphp (#16813) * use wikimedias less php * fix some less related stuff * fix expected test file * updates expected test file --- composer.json | 21 +++-- composer.lock | 102 +++++++++++++-------- .../UIAssetMerger/StylesheetUIAssetMerger.php | 2 +- core/Plugin/ThemeStyles.php | 2 +- .../stylesheets/ExpectedMergeResult.css | 18 ++-- .../UIIntegrationTest_customdirplugin.png | 4 +- 6 files changed, 92 insertions(+), 57 deletions(-) diff --git a/composer.json b/composer.json index 9221c9630c..5f7197fbdf 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,12 @@ "name": "matomo/matomo", "type": "application", "description": "the leading free/libre analytics platform", - "keywords": ["piwik","matomo","web","analytics"], + "keywords": [ + "piwik", + "matomo", + "web", + "analytics" + ], "homepage": "https://matomo.org", "license": "GPL-3.0+", "authors": [ @@ -30,7 +35,6 @@ "composer/semver": "~1.3.0", "davaxi/sparkline": "~1.2", "geoip2/geoip2": "^2.8", - "leafo/lessphp": "dev-php74-compat", "matomo/cache": "~2.0", "matomo/decompress": "~2.0", "matomo/device-detector": "^4.0", @@ -51,7 +55,8 @@ "szymach/c-pchart": "^2.0", "tecnickcom/tcpdf": "~6.0", "tedivm/jshrink": "dev-master#aed09eace9d498e18d48a5b62a7e5a97dfc0e55d", - "twig/twig": "^3.0" + "twig/twig": "^3.0", + "wikimedia/less.php": "^2.0" }, "require-dev": { "lox/xhprof": "dev-master", @@ -67,12 +72,6 @@ "symfony/polyfill-php71": "*", "symfony/polyfill-php72": "*" }, - "repositories": [ - { - "type": "git", - "url": "https://github.com/matomo-org/lessphp.git" - } - ], "scripts": { "pre-update-cmd": [ "Piwik\\Composer\\ScriptHandler::cleanXhprof" @@ -98,7 +97,9 @@ "PEAR_": "libs/", "Archive_": "libs/" }, - "files": ["LegacyAutoloader.php"] + "files": [ + "LegacyAutoloader.php" + ] }, "autoload-dev": { "psr-4": { diff --git a/composer.lock b/composer.lock index 59644bb2d6..071ed6a25e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "436a8ac860535902739aa0c17595a5e9", + "content-hash": "87f49276c9a0487bc83c1f020ee2f4e1", "packages": [ { "name": "composer/ca-bundle", @@ -367,40 +367,6 @@ }, "time": "2020-10-01T18:48:34+00:00" }, - { - "name": "leafo/lessphp", - "version": "dev-php74-compat", - "source": { - "type": "git", - "url": "https://github.com/matomo-org/lessphp.git", - "reference": "1c1bf226f6d394f28cc676a6c2893556a5dcb495" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "lessc.inc.php" - ] - }, - "license": [ - "MIT", - "GPL-3.0" - ], - "authors": [ - { - "name": "Leaf Corcoran", - "email": "leafot@gmail.com", - "homepage": "http://leafo.net" - } - ], - "description": "lessphp is a compiler for LESS written in PHP.", - "homepage": "http://leafo.net/lessphp/", - "time": "2020-06-18T02:38:35+00:00" - }, { "name": "matomo/cache", "version": "2.0.2", @@ -2248,6 +2214,71 @@ } ], "time": "2020-10-27T19:28:23+00:00" + }, + { + "name": "wikimedia/less.php", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/wikimedia/less.php.git", + "reference": "c1affb4d4472c9e100fc80bf456b4334862ace3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wikimedia/less.php/zipball/c1affb4d4472c9e100fc80bf456b4334862ace3c", + "reference": "c1affb4d4472c9e100fc80bf456b4334862ace3c", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "phpunit/phpunit": "7.5.14" + }, + "bin": [ + "bin/lessc" + ], + "type": "library", + "autoload": { + "psr-0": { + "Less": "lib/" + }, + "classmap": [ + "lessc.inc.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Josh Schmidt", + "homepage": "https://github.com/oyejorge" + }, + { + "name": "Matt Agar", + "homepage": "https://github.com/agar" + }, + { + "name": "Martin Jantošovič", + "homepage": "https://github.com/Mordred" + } + ], + "description": "PHP port of the Javascript version of LESS http://lesscss.org (Originally maintained by Josh Schmidt)", + "keywords": [ + "css", + "less", + "less.js", + "lesscss", + "php", + "stylesheet" + ], + "support": { + "issues": "https://github.com/wikimedia/less.php/issues", + "source": "https://github.com/wikimedia/less.php/tree/v2.0.0" + }, + "time": "2020-02-04T22:36:29+00:00" } ], "packages-dev": [ @@ -4012,7 +4043,6 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { - "leafo/lessphp": 20, "tedivm/jshrink": 20, "lox/xhprof": 20 }, diff --git a/core/AssetManager/UIAssetMerger/StylesheetUIAssetMerger.php b/core/AssetManager/UIAssetMerger/StylesheetUIAssetMerger.php index 88db64ec00..c57610a466 100644 --- a/core/AssetManager/UIAssetMerger/StylesheetUIAssetMerger.php +++ b/core/AssetManager/UIAssetMerger/StylesheetUIAssetMerger.php @@ -68,7 +68,7 @@ class StylesheetUIAssetMerger extends UIAssetMerger private function getCssStatementForReplacement($path) { - return '.nonExistingSelectorOnlyForReplacementOfCssFiles { display:"' . $path . '"; }'; + return ".nonExistingSelectorOnlyForReplacementOfCssFiles {\n display: \"" . $path . "\";\n}"; } protected function concatenateAssets() diff --git a/core/Plugin/ThemeStyles.php b/core/Plugin/ThemeStyles.php index 5d4f81d870..af225643ab 100644 --- a/core/Plugin/ThemeStyles.php +++ b/core/Plugin/ThemeStyles.php @@ -224,7 +224,7 @@ class ThemeStyles $result = ''; foreach (get_object_vars($this) as $name => $value) { $varName = isset(self::$propertyNamesToLessVariableNames[$name]) ? self::$propertyNamesToLessVariableNames[$name] : $this->getGenericThemeVarName($name); - $result .= "@$varName = $value;\n"; + $result .= "@$varName: $value;\n"; } return $result; } diff --git a/tests/PHPUnit/Unit/AssetManager/stylesheets/ExpectedMergeResult.css b/tests/PHPUnit/Unit/AssetManager/stylesheets/ExpectedMergeResult.css index 6637cea7b7..f97cd83fe0 100644 --- a/tests/PHPUnit/Unit/AssetManager/stylesheets/ExpectedMergeResult.css +++ b/tests/PHPUnit/Unit/AssetManager/stylesheets/ExpectedMergeResult.css @@ -1,15 +1,19 @@ /* compile_me_once={{{CACHE-BUSTER-JS}}} */ /* Matomo CSS file is compiled with Less. You may be interested in writing a custom Theme for Matomo! */ -#page #header { color:white; } -#footer { color:red; } +#page #header { + color: #ffffff; +} +#footer { + color: #ff0000; +} .box { - color:#fe33ac; - border-color:#fdcdea; + color: #fe33ac; + border-color: #fdcdea; } .box div { - -webkit-box-shadow:0 0 5px rgba(0,0,0,0.3); - -moz-box-shadow:0 0 5px rgba(0,0,0,0.3); - box-shadow:0 0 5px rgba(0,0,0,0.3); + -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); + -moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); + box-shadow: 0 0 5px rgba(0, 0, 0, 0.3); } h1 { color: orange; diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_customdirplugin.png b/tests/UI/expected-screenshots/UIIntegrationTest_customdirplugin.png index 86a42940bd..f68e9c08a7 100644 --- a/tests/UI/expected-screenshots/UIIntegrationTest_customdirplugin.png +++ b/tests/UI/expected-screenshots/UIIntegrationTest_customdirplugin.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0bc4b9daec61538351c25e762b14dccc22a97f0e40d8afc0f0dbc94a987bd0c7 -size 63086 +oid sha256:917fbf5c20023818a29b0683ff4030d11eeb18d6438d59241a5c11e26fc0ae54 +size 63120 -- cgit v1.2.3