Merge pull request #6577 from marc1706/ticket/17279

[ticket/17279] Use only needed iconify icon packages
This commit is contained in:
Marc Alexander 2023-12-29 22:10:34 +01:00 committed by GitHub
commit b6951fa44a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 107188 additions and 69 deletions

View file

@ -67,8 +67,26 @@ function watch() {
gulp.watch(paths.styles.src, styles);
}
function copyIconifyIcons() {
return gulp.src([
'node_modules/@iconify/json/json/fa.json',
'node_modules/@iconify/json/json/ic.json',
'node_modules/@iconify/json/json/mdi.json',
])
.pipe(gulp.dest('phpBB/assets/iconify'));
}
function copyIconifyJs() {
return gulp.src([
'node_modules/@iconify/iconify/dist/iconify.without-api.min.js',
])
.pipe(rename('iconify.min.js'))
.pipe(gulp.dest('phpBB/assets/iconify'));
}
exports.style = styles;
exports.minify = minify;
exports.watch = watch;
exports.copyIconify = gulp.parallel(copyIconifyJs, copyIconifyIcons);
exports.default = gulp.series(styles, minify, watch);

67
package-lock.json generated
View file

@ -9,6 +9,8 @@
"version": "4.0.0-dev",
"license": "GPL-2.0",
"devDependencies": {
"@iconify/iconify": "^3.1.1",
"@iconify/json": "^2.2.163",
"autoprefixer": "^10.4.4",
"cssnano": "^5.1.7",
"eslint": "^8.13.0",
@ -263,6 +265,34 @@
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==",
"dev": true
},
"node_modules/@iconify/iconify": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@iconify/iconify/-/iconify-3.1.1.tgz",
"integrity": "sha512-1nemfyD/OJzh9ALepH7YfuuP8BdEB24Skhd8DXWh0hzcOxImbb1ZizSZkpCzAwSZSGcJFmscIBaBQu+yLyWaxQ==",
"dev": true,
"dependencies": {
"@iconify/types": "^2.0.0"
},
"funding": {
"url": "https://github.com/sponsors/cyberalien"
}
},
"node_modules/@iconify/json": {
"version": "2.2.163",
"resolved": "https://registry.npmjs.org/@iconify/json/-/json-2.2.163.tgz",
"integrity": "sha512-cBca9e8x6Bp5qN2++sl54OUbME/Y20OhXJEdkpFFvvHvt8UfQLiBKzz7q3uZ1l3EQjc8JoKgDB/n8nqfNqEWig==",
"dev": true,
"dependencies": {
"@iconify/types": "*",
"pathe": "^1.1.0"
}
},
"node_modules/@iconify/types": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz",
"integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==",
"dev": true
},
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -5102,6 +5132,12 @@
"node": ">=8"
}
},
"node_modules/pathe": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.1.tgz",
"integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==",
"dev": true
},
"node_modules/picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
@ -8397,6 +8433,31 @@
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==",
"dev": true
},
"@iconify/iconify": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@iconify/iconify/-/iconify-3.1.1.tgz",
"integrity": "sha512-1nemfyD/OJzh9ALepH7YfuuP8BdEB24Skhd8DXWh0hzcOxImbb1ZizSZkpCzAwSZSGcJFmscIBaBQu+yLyWaxQ==",
"dev": true,
"requires": {
"@iconify/types": "^2.0.0"
}
},
"@iconify/json": {
"version": "2.2.163",
"resolved": "https://registry.npmjs.org/@iconify/json/-/json-2.2.163.tgz",
"integrity": "sha512-cBca9e8x6Bp5qN2++sl54OUbME/Y20OhXJEdkpFFvvHvt8UfQLiBKzz7q3uZ1l3EQjc8JoKgDB/n8nqfNqEWig==",
"dev": true,
"requires": {
"@iconify/types": "*",
"pathe": "^1.1.0"
}
},
"@iconify/types": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz",
"integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==",
"dev": true
},
"@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -12213,6 +12274,12 @@
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"dev": true
},
"pathe": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.1.tgz",
"integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==",
"dev": true
},
"picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",

View file

@ -56,11 +56,7 @@
"always"
],
"no-lonely-if": "off",
"unicorn/prefer-module": "off",
"space-before-function-paren": [
"error",
"never"
]
"unicorn/prefer-module": "off"
},
"env": {
"es6": true,
@ -103,6 +99,8 @@
},
"homepage": "https://www.phpbb.com",
"devDependencies": {
"@iconify/iconify": "^3.1.1",
"@iconify/json": "^2.2.163",
"autoprefixer": "^10.4.4",
"cssnano": "^5.1.7",
"eslint": "^8.13.0",

4003
phpBB/assets/iconify/fa.json Normal file

File diff suppressed because it is too large Load diff

46779
phpBB/assets/iconify/ic.json Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

56273
phpBB/assets/iconify/mdi.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -40,7 +40,6 @@
"google/recaptcha": "~1.1",
"guzzlehttp/guzzle": "~6.3",
"iconify/json-tools": "^1.0",
"iconify/json": "^2.2",
"marc1706/fast-image-size": "^1.1",
"s9e/text-formatter": "^2.0",
"symfony/config": "^6.3",

34
phpBB/composer.lock generated
View file

@ -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": "063704733ec296bc16753ef1e07b9c8f",
"content-hash": "214f00dfc71ef3bf2c81d6e3f7b579e5",
"packages": [
{
"name": "bantu/ini-get-wrapper",
@ -1781,38 +1781,6 @@
],
"time": "2023-04-17T16:00:37+00:00"
},
{
"name": "iconify/json",
"version": "2.2.140",
"source": {
"type": "git",
"url": "https://github.com/iconify/icon-sets.git",
"reference": "9815726deffc97bcfebc19acc697ef93bd8cbaf4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/iconify/icon-sets/zipball/9815726deffc97bcfebc19acc697ef93bd8cbaf4",
"reference": "9815726deffc97bcfebc19acc697ef93bd8cbaf4",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-4": {
"Iconify\\IconsJSON\\": "lib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Iconify icons collection in JSON format",
"homepage": "https://iconify.design/icon-sets/",
"support": {
"issues": "https://github.com/iconify/icon-sets/issues",
"source": "https://github.com/iconify/icon-sets/tree/2.2.140"
},
"time": "2023-11-10T07:05:40+00:00"
},
{
"name": "iconify/json-tools",
"version": "1.0.10",

View file

@ -10,3 +10,4 @@ services:
shared: false
arguments:
- '@log'
- '%core.root_path%'

View file

@ -20,6 +20,7 @@ services:
shared: false
arguments:
- ~
- '%core.root_path%'
cache.driver:
class: '%cache.driver.class%'

View file

@ -18,8 +18,8 @@ use phpbb\log\log_interface;
class iconify_bundler
{
/** @var log_interface */
protected $log;
/** @var string Icons path */
protected string $icons_path;
/** @var string[] Icons list */
protected $icons_list = [];
@ -28,10 +28,11 @@ class iconify_bundler
* Constructor for iconify bundler
*
* @param log_interface|null $log Logger
* @param string $root_path phpBB root path
*/
public function __construct(?log_interface $log)
public function __construct(protected ?log_interface $log, string $root_path)
{
$this->log = $log;
$this->icons_path = $root_path . 'assets/iconify/';
}
/**
@ -206,6 +207,17 @@ class iconify_bundler
return null;
}
/**
* Get collection path for prefix
*
* @param string $prefix Icon collection prefix
* @return string Icon collection path
*/
protected function get_collection_path(string $prefix): string
{
return $this->icons_path . $prefix . '.json';
}
/**
* Load icons date for supplied icons array
*
@ -220,7 +232,7 @@ class iconify_bundler
{
// Load icon set
$collection = new Collection($prefix);
$collection_file = Collection::findIconifyCollection($prefix);
$collection_file = $this->get_collection_path($prefix);
if (!file_exists($collection_file) || !$collection->loadFromFile($collection_file))
{
$this->log?->add('critical', ANONYMOUS, '', 'LOG_ICON_COLLECTION_INVALID', false, [$prefix]);

View file

@ -23,6 +23,8 @@ class iconify_bundler_test extends \phpbb_test_case
public function setUp(): void
{
global $phpbb_root_path;
$log = $this->getMockBuilder('\phpbb\log\dummy')
->onlyMethods(['add'])
->getMock();
@ -31,7 +33,7 @@ class iconify_bundler_test extends \phpbb_test_case
$this->log_content[] = $log_operation;
});
$this->bundler = new \phpbb\assets\iconify_bundler($log);
$this->bundler = new \phpbb\assets\iconify_bundler($log, $phpbb_root_path);
}
public function data_test_generate_bundle()
@ -42,8 +44,8 @@ class iconify_bundler_test extends \phpbb_test_case
['"prefix":"fa"', '"address-card-o"'],
],
[
['fa:address-card-o', 'fa-regular:credit-card'],
['"prefix":"fa"', '"address-card-o"', '"prefix":"fa-regular"', '"credit-card"'],
['fa:address-card-o', 'ic:baseline-credit-card'],
['"prefix":"fa"', '"address-card-o"', '"prefix":"ic"', '"baseline-credit-card"'],
],
[
['fa:address-card-o', 'fa:foo-bar'],
@ -51,16 +53,16 @@ class iconify_bundler_test extends \phpbb_test_case
['LOG_ICON_INVALID'],
],
[
['fa:address-card-o', 'fa-regular:credit-card', 'fa-regular:credit-card'],
['"prefix":"fa"', '"address-card-o"', '"prefix":"fa-regular"', '"credit-card"'],
['fa:address-card-o', 'ic:baseline-credit-card', 'ic:baseline-credit-card'],
['"prefix":"fa"', '"address-card-o"', '"prefix":"ic"', '"baseline-credit-card"'],
],
[
['fa:address-card-o', 'fa-regular:credit-card', 'fa-regular:angry'],
['"prefix":"fa"', '"address-card-o"', '"prefix":"fa-regular"', '"credit-card"', '"angry"'],
['fa:address-card-o', 'ic:baseline-credit-card', 'ic:baseline-add-ic-call'],
['"prefix":"fa"', '"address-card-o"', '"prefix":"ic"', '"baseline-credit-card"', '"baseline-add-ic-call"'],
],
[
['fa:address-card-o', 'fa:bell', 'fa-regular:credit-card', 'fa-regular:angry'],
['"prefix":"fa"', '"address-card-o"', '"bell"', '"prefix":"fa-regular"', '"credit-card"', '"angry"'],
['fa:address-card-o', 'fa:bell', 'ic:baseline-credit-card', 'ic:baseline-add-ic-call'],
['"prefix":"fa"', '"address-card-o"', '"bell"', '"prefix":"ic"', '"baseline-credit-card"', '"baseline-add-ic-call"'],
],
[
['@test'],

View file

@ -117,7 +117,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$container->setParameter('core.environment', PHPBB_ENVIRONMENT);
$cache_path = $phpbb_root_path . 'cache/twig';
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$iconify_bundler = new \phpbb\assets\iconify_bundler($log, $phpbb_root_path);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader('');

View file

@ -67,7 +67,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
$phpbb_container->set('ext.manager', $extension_manager);
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$iconify_bundler = new \phpbb\assets\iconify_bundler($log, $phpbb_root_path);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$phpbb_container->set('assets.bag', $assets_bag);

View file

@ -67,7 +67,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->phpEx
);
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$iconify_bundler = new \phpbb\assets\iconify_bundler($log, $this->phpbb_root_path);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$twig = new \phpbb\template\twig\environment(
$assets_bag,

View file

@ -96,7 +96,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
$context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader([]);
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$iconify_bundler = new \phpbb\assets\iconify_bundler($log, $phpbb_root_path);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$twig = new \phpbb\template\twig\environment(
$assets_bag,

View file

@ -59,7 +59,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
$context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader('');
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$iconify_bundler = new \phpbb\assets\iconify_bundler($log, $phpbb_root_path);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$twig = new \phpbb\template\twig\environment(
$assets_bag,

View file

@ -153,7 +153,7 @@ Zeta test event in all',
$context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader('');
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$iconify_bundler = new \phpbb\assets\iconify_bundler($log, $phpbb_root_path);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$twig = new \phpbb\template\twig\environment(
$assets_bag,

View file

@ -45,7 +45,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
$context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader('');
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$iconify_bundler = new \phpbb\assets\iconify_bundler($log, $phpbb_root_path);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$twig = new \phpbb\template\twig\environment(
$assets_bag,

View file

@ -96,7 +96,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
$context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader('');
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$iconify_bundler = new \phpbb\assets\iconify_bundler($log, $phpbb_root_path);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$twig = new \phpbb\template\twig\environment(
$assets_bag,

View file

@ -46,7 +46,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader('');
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$iconify_bundler = new \phpbb\assets\iconify_bundler($log, $phpbb_root_path);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$twig = new \phpbb\template\twig\environment(
$assets_bag,

View file

@ -64,7 +64,7 @@ class twig_test extends \phpbb_test_case
$context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader('');
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$iconify_bundler = new \phpbb\assets\iconify_bundler($log, $phpbb_root_path);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$twig = new \phpbb\template\twig\environment(
$assets_bag,