diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2023-06-06 14:52:09 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2023-06-06 14:52:09 +0200 |
| commit | 47bd75f4c7cd17989cf60c46d621ca1af44b186f (patch) | |
| tree | 157e99fab8e7066cb80784d5406b9bbe54508a53 | |
| parent | cd36e99958024cc33431f76f35099a71e26e3bce (diff) | |
replace mishal/iless with mediawiki/less.php, increase php platform to most current 7.2.34, fixes #2381
| -rw-r--r-- | composer.json | 6 | ||||
| -rw-r--r-- | composer.lock | 136 | ||||
| -rw-r--r-- | lib/classes/assets/LESSCompiler.php | 33 | ||||
| -rw-r--r-- | lib/plugins/core/PluginAssetsTrait.php | 2 | ||||
| -rw-r--r-- | resources/assets/stylesheets/mixins/studip.less | 4 |
5 files changed, 93 insertions, 88 deletions
diff --git a/composer.json b/composer.json index 101d770..359e9b2 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "config": { "vendor-dir": "composer", "platform": { - "php": "7.2.5" + "php": "7.2.34" } }, "require-dev": { @@ -25,7 +25,6 @@ "tecnickcom/tcpdf": "^6.3", "scssphp/scssphp": "^1.4", "symfony/yaml": "^5.0", - "mishal/iless": "^2.2", "ezyang/htmlpurifier": "^4.13", "davefx/phplot": "^6.2", "jasig/phpcas": "^1.3", @@ -59,7 +58,8 @@ "symfony/polyfill-php74": "^1.27", "symfony/polyfill-php80": "^1.27", "symfony/polyfill-php81": "^1.27", - "phpowermove/docblock": "^2.0" + "phpowermove/docblock": "^2.0", + "wikimedia/less.php": "^3" }, "replace": { "symfony/polyfill-php54": "*", diff --git a/composer.lock b/composer.lock index 5119b01..53fa0dc 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": "b208b63a6fc53d453c263420fa7350da", + "content-hash": "b57262021a4cc6cbcfb893719b5b3edc", "packages": [ { "name": "algo26-matthias/idna-convert", @@ -1114,63 +1114,6 @@ "time": "2021-06-28T04:27:21+00:00" }, { - "name": "mishal/iless", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/mishal/iless.git", - "reference": "d75af501ab0ca411efd041faa53e6652f1602553" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mishal/iless/zipball/d75af501ab0ca411efd041faa53e6652f1602553", - "reference": "d75af501ab0ca411efd041faa53e6652f1602553", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "bin": [ - "bin/iless" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, - "autoload": { - "psr-4": { - "ILess\\": "lib/ILess" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "ILess contributors", - "homepage": "https://github.com/mishal/iless/wiki/Contributors" - } - ], - "description": "Less.js port to PHP", - "homepage": "http://github.com/mishal/iless", - "keywords": [ - "compiler", - "css", - "less", - "less.js", - "lesscss", - "parser" - ], - "support": { - "issues": "https://github.com/mishal/iless/issues", - "source": "https://github.com/mishal/iless/tree/master" - }, - "time": "2016-04-25T07:03:37+00:00" - }, - { "name": "monolog/monolog", "version": "2.9.1", "source": { @@ -4394,6 +4337,81 @@ "time": "2021-09-14T12:46:25+00:00" }, { + "name": "wikimedia/less.php", + "version": "v3.2.1", + "source": { + "type": "git", + "url": "https://github.com/wikimedia/less.php.git", + "reference": "0d5b30ba792bdbf8991a646fc9c30561b38a5559" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wikimedia/less.php/zipball/0d5b30ba792bdbf8991a646fc9c30561b38a5559", + "reference": "0d5b30ba792bdbf8991a646fc9c30561b38a5559", + "shasum": "" + }, + "require": { + "php": ">=7.2.9" + }, + "require-dev": { + "mediawiki/mediawiki-codesniffer": "40.0.1", + "mediawiki/mediawiki-phan-config": "0.12.0", + "mediawiki/minus-x": "1.1.1", + "php-parallel-lint/php-console-highlighter": "1.0.0", + "php-parallel-lint/php-parallel-lint": "1.3.2", + "phpunit/phpunit": "^8.5" + }, + "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": "Timo Tijhof", + "homepage": "https://timotijhof.net" + }, + { + "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 LESS processor", + "homepage": "https://gerrit.wikimedia.org/g/mediawiki/libs/less.php", + "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/v3.2.1" + }, + "time": "2023-02-03T06:43:41+00:00" + }, + { "name": "willdurand/negotiation", "version": "3.1.0", "source": { @@ -7144,7 +7162,7 @@ }, "platform-dev": [], "platform-overrides": { - "php": "7.2.5" + "php": "7.2.34" }, "plugin-api-version": "2.3.0" } diff --git a/lib/classes/assets/LESSCompiler.php b/lib/classes/assets/LESSCompiler.php index f5d1b9f..2302e1e 100644 --- a/lib/classes/assets/LESSCompiler.php +++ b/lib/classes/assets/LESSCompiler.php @@ -2,16 +2,13 @@ namespace Assets; use Assets; +use Less_Autoloader; use StudipCacheFactory; -use ILess\Autoloader; -use ILess\Importer\FileSystemImporter; -use ILess\Parser; - /** * LESS Compiler for assets. * - * Uses ILess by mishal <https://github.com/mishal/iless>. + * Uses less.php by wikimedia <https://github.com/wikimedia/less.php>. * * @author Jan-Hendrik Willms <tleilax+studip@gmail.com> * @license GPL2 or any later version @@ -40,7 +37,7 @@ class LESSCompiler implements Compiler */ private function __construct() { - Autoloader::register(); + Less_Autoloader::register(); } /** @@ -58,23 +55,15 @@ class LESSCompiler implements Compiler $variables['image-path'] = '"' . Assets::url('images') . '"'; - // Disable warnings since we currently have no other means to get rid - // of them - // TODO: Look again into this (2022-06-23) - $error_reporting = error_reporting(); - error_reporting($error_reporting & ~E_WARNING); - - $parser = new Parser(['strictMath' => true], null, [ - new FileSystemImporter(["{$GLOBALS['STUDIP_BASE_PATH']}/resources/"]) + $parser = new \Less_Parser([ + 'strictMath' => true, + 'compress' => \Studip\ENV === 'production', + 'sourceMap' => \Studip\ENV !== 'production', ]); - $parser->setVariables($variables); - $parser->parseString($less); - $css = $parser->getCSS(); - - // Restore error reporting - error_reporting($error_reporting); - - return $css; + $parser->SetImportDirs(["{$GLOBALS['STUDIP_BASE_PATH']}/resources/"]); + $parser->ModifyVars($variables); + $parser->parse($less); + return $parser->getCSS(); } /** diff --git a/lib/plugins/core/PluginAssetsTrait.php b/lib/plugins/core/PluginAssetsTrait.php index 7313661..60d29e5 100644 --- a/lib/plugins/core/PluginAssetsTrait.php +++ b/lib/plugins/core/PluginAssetsTrait.php @@ -252,7 +252,7 @@ trait PluginAssetsTrait $extension = pathinfo($filename, PATHINFO_EXTENSION); if ($extension === 'less') { $contents = Assets\LESSCompiler::getInstance()->compile($contents, $variables + [ - 'plugin-path' => $this->getPluginURL(), + 'plugin-path' => '"' . $this->getPluginURL() . '"', ]); } elseif ($extension === 'scss') { $contents = Assets\SASSCompiler::getInstance()->compile($contents, $variables + [ diff --git a/resources/assets/stylesheets/mixins/studip.less b/resources/assets/stylesheets/mixins/studip.less index 5f0418d..69aa429 100644 --- a/resources/assets/stylesheets/mixins/studip.less +++ b/resources/assets/stylesheets/mixins/studip.less @@ -203,7 +203,7 @@ /******************** ** Widget actions ** ********************/ -.widget-action(@action, @icon: @action, @role: 'clickable', @rules: {}) { +.widget-action(@action, @icon: @action, @role: 'clickable') { .widget-action[data-action="@{action}"] { .hide-text(); .square(16px); @@ -213,7 +213,5 @@ cursor: pointer; display: block; // vertical-align: middle; - - @rules(); } } |
