From d0cb64b1c91ec0b3ff1729274430c7a6c41410ea Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Tue, 16 Apr 2024 16:28:16 -0400 Subject: [PATCH 1/3] [Site] upgrade to PHP 8.3 --- .github/workflows/ux.symfony.com.yaml | 2 +- ux.symfony.com/.platform.app.yaml | 2 +- ux.symfony.com/composer.json | 2 +- ux.symfony.com/composer.lock | 142 ++++++++++++++------------ 4 files changed, 78 insertions(+), 70 deletions(-) diff --git a/.github/workflows/ux.symfony.com.yaml b/.github/workflows/ux.symfony.com.yaml index fd34e9cc509..30bbb0f9ea3 100644 --- a/.github/workflows/ux.symfony.com.yaml +++ b/.github/workflows/ux.symfony.com.yaml @@ -21,7 +21,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: 8.3 - name: Install dependencies uses: ramsey/composer-install@v3 diff --git a/ux.symfony.com/.platform.app.yaml b/ux.symfony.com/.platform.app.yaml index c68f8673b19..d52d81c3843 100644 --- a/ux.symfony.com/.platform.app.yaml +++ b/ux.symfony.com/.platform.app.yaml @@ -1,6 +1,6 @@ name: app -type: php:8.1 +type: php:8.3 dependencies: php: diff --git a/ux.symfony.com/composer.json b/ux.symfony.com/composer.json index b66c9d58091..efdfc1f55b0 100644 --- a/ux.symfony.com/composer.json +++ b/ux.symfony.com/composer.json @@ -4,7 +4,7 @@ "prefer-stable": true, "minimum-stability": "dev", "require": { - "php": ">=8.1", + "php": ">=8.3", "ext-ctype": "*", "ext-iconv": "*", "babdev/pagerfanta-bundle": "^3.8", diff --git a/ux.symfony.com/composer.lock b/ux.symfony.com/composer.lock index b15c839f6f8..c179d00870e 100644 --- a/ux.symfony.com/composer.lock +++ b/ux.symfony.com/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": "c34ee0dd61e76792adc9adb6ac8e27c6", + "content-hash": "63672427aa7fe4d557346c2c86b7216b", "packages": [ { "name": "babdev/pagerfanta-bundle", @@ -426,16 +426,16 @@ }, { "name": "doctrine/common", - "version": "3.4.3", + "version": "3.4.4", "source": { "type": "git", "url": "https://github.com/doctrine/common.git", - "reference": "8b5e5650391f851ed58910b3e3d48a71062eeced" + "reference": "0aad4b7ab7ce8c6602dfbb1e1a24581275fb9d1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/common/zipball/8b5e5650391f851ed58910b3e3d48a71062eeced", - "reference": "8b5e5650391f851ed58910b3e3d48a71062eeced", + "url": "https://api.github.com/repos/doctrine/common/zipball/0aad4b7ab7ce8c6602dfbb1e1a24581275fb9d1a", + "reference": "0aad4b7ab7ce8c6602dfbb1e1a24581275fb9d1a", "shasum": "" }, "require": { @@ -497,7 +497,7 @@ ], "support": { "issues": "https://github.com/doctrine/common/issues", - "source": "https://github.com/doctrine/common/tree/3.4.3" + "source": "https://github.com/doctrine/common/tree/3.4.4" }, "funding": [ { @@ -513,7 +513,7 @@ "type": "tidelift" } ], - "time": "2022-10-09T11:47:59+00:00" + "time": "2024-04-16T13:35:33+00:00" }, { "name": "doctrine/dbal", @@ -1319,16 +1319,16 @@ }, { "name": "doctrine/orm", - "version": "2.19.3", + "version": "2.19.4", "source": { "type": "git", "url": "https://github.com/doctrine/orm.git", - "reference": "1a5a4c674a416b4fdf76833c627c5e7f58bbb890" + "reference": "b27489348658cd718d18005de37b94f7f8561467" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/orm/zipball/1a5a4c674a416b4fdf76833c627c5e7f58bbb890", - "reference": "1a5a4c674a416b4fdf76833c627c5e7f58bbb890", + "url": "https://api.github.com/repos/doctrine/orm/zipball/b27489348658cd718d18005de37b94f7f8561467", + "reference": "b27489348658cd718d18005de37b94f7f8561467", "shasum": "" }, "require": { @@ -1414,9 +1414,9 @@ ], "support": { "issues": "https://github.com/doctrine/orm/issues", - "source": "https://github.com/doctrine/orm/tree/2.19.3" + "source": "https://github.com/doctrine/orm/tree/2.19.4" }, - "time": "2024-03-21T11:01:42+00:00" + "time": "2024-04-15T13:11:10+00:00" }, { "name": "doctrine/persistence", @@ -7495,12 +7495,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/ux-autocomplete.git", - "reference": "59b439043de587c9dece82fd9c9030ea7478aa19" + "reference": "702ef828126616625362f578060e6bc181658e50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ux-autocomplete/zipball/59b439043de587c9dece82fd9c9030ea7478aa19", - "reference": "59b439043de587c9dece82fd9c9030ea7478aa19", + "url": "https://api.github.com/repos/symfony/ux-autocomplete/zipball/702ef828126616625362f578060e6bc181658e50", + "reference": "702ef828126616625362f578060e6bc181658e50", "shasum": "" }, "require": { @@ -7580,7 +7580,7 @@ "type": "tidelift" } ], - "time": "2024-04-09T17:53:19+00:00" + "time": "2024-04-14T16:02:56+00:00" }, { "name": "symfony/ux-chartjs", @@ -7914,12 +7914,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/ux-live-component.git", - "reference": "37135a2d2d3d532b846d828396c3bc5e542730ba" + "reference": "3aff6da74c882347d51ad8124fc3d3c52391a4a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ux-live-component/zipball/37135a2d2d3d532b846d828396c3bc5e542730ba", - "reference": "37135a2d2d3d532b846d828396c3bc5e542730ba", + "url": "https://api.github.com/repos/symfony/ux-live-component/zipball/3aff6da74c882347d51ad8124fc3d3c52391a4a5", + "reference": "3aff6da74c882347d51ad8124fc3d3c52391a4a5", "shasum": "" }, "require": { @@ -7999,7 +7999,7 @@ "type": "tidelift" } ], - "time": "2024-04-09T07:57:23+00:00" + "time": "2024-04-16T14:29:27+00:00" }, { "name": "symfony/ux-notify", @@ -8570,12 +8570,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/ux-twig-component.git", - "reference": "52f7830aeefb07e7e3018f968f4804569f2a83c1" + "reference": "7ae4ce4083560b0400fa03673a3e04e2969549c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ux-twig-component/zipball/52f7830aeefb07e7e3018f968f4804569f2a83c1", - "reference": "52f7830aeefb07e7e3018f968f4804569f2a83c1", + "url": "https://api.github.com/repos/symfony/ux-twig-component/zipball/7ae4ce4083560b0400fa03673a3e04e2969549c6", + "reference": "7ae4ce4083560b0400fa03673a3e04e2969549c6", "shasum": "" }, "require": { @@ -8647,7 +8647,7 @@ "type": "tidelift" } ], - "time": "2024-04-10T11:16:37+00:00" + "time": "2024-04-14T16:38:15+00:00" }, { "name": "symfony/ux-typed", @@ -9372,34 +9372,34 @@ }, { "name": "twig/extra-bundle", - "version": "v3.8.0", + "version": "v3.9.0", "source": { "type": "git", "url": "https://github.com/twigphp/twig-extra-bundle.git", - "reference": "32807183753de0388c8e59f7ac2d13bb47311140" + "reference": "3a68ffc7747ecc25823cabe2127710ced516a16a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/twig-extra-bundle/zipball/32807183753de0388c8e59f7ac2d13bb47311140", - "reference": "32807183753de0388c8e59f7ac2d13bb47311140", + "url": "https://api.github.com/repos/twigphp/twig-extra-bundle/zipball/3a68ffc7747ecc25823cabe2127710ced516a16a", + "reference": "3a68ffc7747ecc25823cabe2127710ced516a16a", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/framework-bundle": "^5.4|^6.0|^7.0", - "symfony/twig-bundle": "^5.4|^6.0|^7.0", + "symfony/framework-bundle": "^5.4|^6.4|^7.0", + "symfony/twig-bundle": "^5.4|^6.4|^7.0", "twig/twig": "^3.0" }, "require-dev": { "league/commonmark": "^1.0|^2.0", "symfony/phpunit-bridge": "^6.4|^7.0", "twig/cache-extra": "^3.0", - "twig/cssinliner-extra": "^2.12|^3.0", - "twig/html-extra": "^2.12|^3.0", - "twig/inky-extra": "^2.12|^3.0", - "twig/intl-extra": "^2.12|^3.0", - "twig/markdown-extra": "^2.12|^3.0", - "twig/string-extra": "^2.12|^3.0" + "twig/cssinliner-extra": "^3.0", + "twig/html-extra": "^3.0", + "twig/inky-extra": "^3.0", + "twig/intl-extra": "^3.0", + "twig/markdown-extra": "^3.0", + "twig/string-extra": "^3.0" }, "type": "symfony-bundle", "autoload": { @@ -9430,7 +9430,7 @@ "twig" ], "support": { - "source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.8.0" + "source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.9.0" }, "funding": [ { @@ -9442,25 +9442,26 @@ "type": "tidelift" } ], - "time": "2023-11-21T14:02:01+00:00" + "time": "2024-02-07T08:24:24+00:00" }, { "name": "twig/html-extra", - "version": "v3.8.0", + "version": "v3.9.0", "source": { "type": "git", "url": "https://github.com/twigphp/html-extra.git", - "reference": "c04603bb3b71d8d2ece9e583dbf7bd77811df1f2" + "reference": "8d8bf63a958bec84dbbf12d6c9958319bbaa2eea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/html-extra/zipball/c04603bb3b71d8d2ece9e583dbf7bd77811df1f2", - "reference": "c04603bb3b71d8d2ece9e583dbf7bd77811df1f2", + "url": "https://api.github.com/repos/twigphp/html-extra/zipball/8d8bf63a958bec84dbbf12d6c9958319bbaa2eea", + "reference": "8d8bf63a958bec84dbbf12d6c9958319bbaa2eea", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/mime": "^5.4|^6.0|^7.0", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/mime": "^5.4|^6.4|^7.0", "twig/twig": "^3.0" }, "require-dev": { @@ -9468,6 +9469,9 @@ }, "type": "library", "autoload": { + "files": [ + "Resources/functions.php" + ], "psr-4": { "Twig\\Extra\\Html\\": "" }, @@ -9494,7 +9498,7 @@ "twig" ], "support": { - "source": "https://github.com/twigphp/html-extra/tree/v3.8.0" + "source": "https://github.com/twigphp/html-extra/tree/v3.9.0" }, "funding": [ { @@ -9506,25 +9510,25 @@ "type": "tidelift" } ], - "time": "2023-11-21T14:02:01+00:00" + "time": "2024-02-10T08:52:03+00:00" }, { "name": "twig/intl-extra", - "version": "v3.8.0", + "version": "v3.9.0", "source": { "type": "git", "url": "https://github.com/twigphp/intl-extra.git", - "reference": "7b3db67c700735f473a265a97e1adaeba3e6ca0c" + "reference": "89781f6d97981397c8c8a13ca679919f39628c75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/intl-extra/zipball/7b3db67c700735f473a265a97e1adaeba3e6ca0c", - "reference": "7b3db67c700735f473a265a97e1adaeba3e6ca0c", + "url": "https://api.github.com/repos/twigphp/intl-extra/zipball/89781f6d97981397c8c8a13ca679919f39628c75", + "reference": "89781f6d97981397c8c8a13ca679919f39628c75", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/intl": "^5.4|^6.0|^7.0", + "symfony/intl": "^5.4|^6.4|^7.0", "twig/twig": "^3.0" }, "require-dev": { @@ -9558,7 +9562,7 @@ "twig" ], "support": { - "source": "https://github.com/twigphp/intl-extra/tree/v3.8.0" + "source": "https://github.com/twigphp/intl-extra/tree/v3.9.0" }, "funding": [ { @@ -9570,24 +9574,25 @@ "type": "tidelift" } ], - "time": "2023-11-21T17:27:48+00:00" + "time": "2024-04-03T15:08:24+00:00" }, { "name": "twig/markdown-extra", - "version": "v3.8.0", + "version": "v3.9.0", "source": { "type": "git", "url": "https://github.com/twigphp/markdown-extra.git", - "reference": "b6e4954ab60030233df5d293886b5404558daac8" + "reference": "a03cfd2920200e7f187e4eb837e3f231bd33a128" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/markdown-extra/zipball/b6e4954ab60030233df5d293886b5404558daac8", - "reference": "b6e4954ab60030233df5d293886b5404558daac8", + "url": "https://api.github.com/repos/twigphp/markdown-extra/zipball/a03cfd2920200e7f187e4eb837e3f231bd33a128", + "reference": "a03cfd2920200e7f187e4eb837e3f231bd33a128", "shasum": "" }, "require": { "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.5|^3", "twig/twig": "^3.0" }, "require-dev": { @@ -9599,6 +9604,9 @@ }, "type": "library", "autoload": { + "files": [ + "Resources/functions.php" + ], "psr-4": { "Twig\\Extra\\Markdown\\": "" }, @@ -9626,7 +9634,7 @@ "twig" ], "support": { - "source": "https://github.com/twigphp/markdown-extra/tree/v3.8.0" + "source": "https://github.com/twigphp/markdown-extra/tree/v3.9.0" }, "funding": [ { @@ -9638,25 +9646,25 @@ "type": "tidelift" } ], - "time": "2023-11-21T14:02:01+00:00" + "time": "2024-02-10T08:52:03+00:00" }, { "name": "twig/string-extra", - "version": "v3.8.0", + "version": "v3.9.0", "source": { "type": "git", "url": "https://github.com/twigphp/string-extra.git", - "reference": "b0c9037d96baff79abe368dc092a59b726517548" + "reference": "5ff1c41366aa003d45f6e2707c5d698c1b37ff99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/string-extra/zipball/b0c9037d96baff79abe368dc092a59b726517548", - "reference": "b0c9037d96baff79abe368dc092a59b726517548", + "url": "https://api.github.com/repos/twigphp/string-extra/zipball/5ff1c41366aa003d45f6e2707c5d698c1b37ff99", + "reference": "5ff1c41366aa003d45f6e2707c5d698c1b37ff99", "shasum": "" }, "require": { "php": ">=7.2.5", - "symfony/string": "^5.4|^6.0|^7.0", + "symfony/string": "^5.4|^6.4|^7.0", "symfony/translation-contracts": "^1.1|^2|^3", "twig/twig": "^3.0" }, @@ -9693,7 +9701,7 @@ "unicode" ], "support": { - "source": "https://github.com/twigphp/string-extra/tree/v3.8.0" + "source": "https://github.com/twigphp/string-extra/tree/v3.9.0" }, "funding": [ { @@ -9705,7 +9713,7 @@ "type": "tidelift" } ], - "time": "2023-11-21T14:02:01+00:00" + "time": "2024-02-10T08:52:03+00:00" }, { "name": "twig/twig", @@ -12483,7 +12491,7 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=8.1", + "php": ">=8.3", "ext-ctype": "*", "ext-iconv": "*" }, From ba283242a14c9c633c1e2f3e22fa5c251a9634c4 Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Tue, 16 Apr 2024 16:35:00 -0400 Subject: [PATCH 2/3] [Site] update flex recipes --- ux.symfony.com/bin/console | 4 +++ ux.symfony.com/config/packages/doctrine.yaml | 5 +++- ux.symfony.com/config/packages/monolog.yaml | 1 + .../config/packages/translation.yaml | 10 +------ ux.symfony.com/symfony.lock | 30 +++++++++---------- ux.symfony.com/tests/bootstrap.php | 4 +-- 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/ux.symfony.com/bin/console b/ux.symfony.com/bin/console index c933dc535d0..d8d530e2c36 100755 --- a/ux.symfony.com/bin/console +++ b/ux.symfony.com/bin/console @@ -4,6 +4,10 @@ use App\Kernel; use Symfony\Bundle\FrameworkBundle\Console\Application; +if (!is_dir(dirname(__DIR__).'/vendor')) { + throw new LogicException('Dependencies are missing. Try running "composer install".'); +} + if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); } diff --git a/ux.symfony.com/config/packages/doctrine.yaml b/ux.symfony.com/config/packages/doctrine.yaml index 40b00d2d8bc..75ec9e8410a 100644 --- a/ux.symfony.com/config/packages/doctrine.yaml +++ b/ux.symfony.com/config/packages/doctrine.yaml @@ -4,9 +4,10 @@ doctrine: # IMPORTANT: You MUST configure your server version, # either here or in the DATABASE_URL env var (see .env file) - #server_version: '14' + #server_version: '16' profiling_collect_backtrace: '%kernel.debug%' + use_savepoints: true orm: auto_generate_proxy_classes: true enable_lazy_ghost_objects: true @@ -21,6 +22,8 @@ doctrine: dir: '%kernel.project_dir%/src/Entity' prefix: 'App\Entity' alias: App + controller_resolver: + auto_mapping: true when@test: doctrine: diff --git a/ux.symfony.com/config/packages/monolog.yaml b/ux.symfony.com/config/packages/monolog.yaml index 8c9efa91e02..9db7d8a7f1d 100644 --- a/ux.symfony.com/config/packages/monolog.yaml +++ b/ux.symfony.com/config/packages/monolog.yaml @@ -59,3 +59,4 @@ when@prod: type: stream channels: [deprecation] path: php://stderr + formatter: monolog.formatter.json diff --git a/ux.symfony.com/config/packages/translation.yaml b/ux.symfony.com/config/packages/translation.yaml index 24eb08454fb..32783ea0407 100644 --- a/ux.symfony.com/config/packages/translation.yaml +++ b/ux.symfony.com/config/packages/translation.yaml @@ -5,12 +5,4 @@ framework: default_path: '%kernel.project_dir%/translations' fallbacks: - en -# providers: -# crowdin: -# dsn: '%env(CROWDIN_DSN)%' -# loco: -# dsn: '%env(LOCO_DSN)%' -# lokalise: -# dsn: '%env(LOKALISE_DSN)%' -# phrase: -# dsn: '%env(PHRASE_DSN)%' + providers: diff --git a/ux.symfony.com/symfony.lock b/ux.symfony.com/symfony.lock index 24f01537cec..b6517753147 100644 --- a/ux.symfony.com/symfony.lock +++ b/ux.symfony.com/symfony.lock @@ -24,12 +24,12 @@ "version": "v1.0.0" }, "doctrine/doctrine-bundle": { - "version": "2.11", + "version": "2.12", "recipe": { "repo": "github.com/symfony/recipes", "branch": "main", - "version": "2.10", - "ref": "0b4a11ee7e60b36227502ed26874edd7e8b66353" + "version": "2.12", + "ref": "32f890075233ac4a1176e848a0f8e932ac6536d6" }, "files": [ "config/packages/doctrine.yaml", @@ -238,7 +238,7 @@ "repo": "github.com/symfony/recipes", "branch": "main", "version": "6.4", - "ref": "568d44f71388f41f49dc382768fee20d52569359" + "ref": "6c28c471640cc2c6e60812ebcb961c526ef8997f" }, "files": [ "assets/app.js", @@ -260,12 +260,12 @@ "version": "v6.0.7" }, "symfony/console": { - "version": "6.0", + "version": "6.4", "recipe": { "repo": "github.com/symfony/recipes", - "branch": "master", + "branch": "main", "version": "5.3", - "ref": "da0c8be8157600ad34f10ff0c9cc91232522e047" + "ref": "1781ff40d8a17d87cf53f8d4cf0c8346ed2bb461" }, "files": [ "bin/console" @@ -380,7 +380,7 @@ "repo": "github.com/symfony/recipes", "branch": "main", "version": "0.3", - "ref": "851667ac03fd113c5bd2215fb743974f6709bc62" + "ref": "d097c114aae82c5bc88d48ac164fe523f1003292" }, "files": [ "config/packages/mercure.yaml" @@ -399,12 +399,12 @@ "version": "v6.0.3" }, "symfony/monolog-bundle": { - "version": "3.7", + "version": "3.10", "recipe": { "repo": "github.com/symfony/recipes", - "branch": "master", + "branch": "main", "version": "3.7", - "ref": "213676c4ec929f046dfde5ea8e97625b81bc0578" + "ref": "aff23899c4440dd995907613c1dd709b6f59503f" }, "files": [ "config/packages/monolog.yaml" @@ -431,7 +431,7 @@ "repo": "github.com/symfony/recipes", "branch": "main", "version": "6.3", - "ref": "1f5830c331065b6e4c9d5fa2105e322d29fcd573" + "ref": "a411a0480041243d97382cac7984f7dce7813c08" }, "files": [ ".env.test", @@ -509,7 +509,7 @@ "repo": "github.com/symfony/recipes", "branch": "main", "version": "6.3", - "ref": "64fe617084223633e1dedf9112935d8c95410d3e" + "ref": "e28e27f53663cc34f0be2837aba18e3a1bef8e7b" }, "files": [ "config/packages/translation.yaml", @@ -527,8 +527,8 @@ "recipe": { "repo": "github.com/symfony/recipes", "branch": "main", - "version": "6.3", - "ref": "b7772eb20e92f3fb4d4fe756e7505b4ba2ca1a2c" + "version": "6.4", + "ref": "cab5fd2a13a45c266d45a7d9337e28dee6272877" }, "files": [ "config/packages/twig.yaml", diff --git a/ux.symfony.com/tests/bootstrap.php b/ux.symfony.com/tests/bootstrap.php index b67fb82499e..1d3a12b1074 100644 --- a/ux.symfony.com/tests/bootstrap.php +++ b/ux.symfony.com/tests/bootstrap.php @@ -13,9 +13,7 @@ require dirname(__DIR__).'/vendor/autoload.php'; -if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) { - require dirname(__DIR__).'/config/bootstrap.php'; -} elseif (method_exists(Dotenv::class, 'bootEnv')) { +if (method_exists(Dotenv::class, 'bootEnv')) { (new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); } From c5397fc7790f4111de0397e1efbc77a0a6c6e900 Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Tue, 16 Apr 2024 16:25:12 -0400 Subject: [PATCH 3/3] [Site] replace `highlight.js` with `tempest/highlight` --- .../code-highlighter-controller.js | 29 ------- .../assets/styles/vendor/_highlight.scss | 76 +++++++++++++++++++ ux.symfony.com/composer.json | 1 + ux.symfony.com/composer.lock | 55 +++++++++++++- ux.symfony.com/config/services.yaml | 6 +- .../CommonMark/TempestHighlightExtension.php | 31 ++++++++ .../src/Twig/HighlightExtension.php | 20 +++++ .../templates/components/CodeBlock.html.twig | 5 +- .../templates/components/CodeLine.html.twig | 6 +- .../components/Icon/IconModal.html.twig | 2 +- .../ux_packages/translator.html.twig | 32 ++++++-- 11 files changed, 217 insertions(+), 46 deletions(-) delete mode 100644 ux.symfony.com/assets/controllers/code-highlighter-controller.js create mode 100644 ux.symfony.com/src/Service/CommonMark/TempestHighlightExtension.php create mode 100644 ux.symfony.com/src/Twig/HighlightExtension.php diff --git a/ux.symfony.com/assets/controllers/code-highlighter-controller.js b/ux.symfony.com/assets/controllers/code-highlighter-controller.js deleted file mode 100644 index d556dc1d86c..00000000000 --- a/ux.symfony.com/assets/controllers/code-highlighter-controller.js +++ /dev/null @@ -1,29 +0,0 @@ -import { Controller } from '@hotwired/stimulus'; -import hljs from 'highlight.js/lib/core'; -import hljs_javascript from 'highlight.js/lib/languages/javascript'; -import hljs_php from 'highlight.js/lib/languages/php'; -import hljs_xml from 'highlight.js/lib/languages/xml'; -import hljs_twig from 'highlight.js/lib/languages/twig'; - -hljs.registerLanguage('javascript', hljs_javascript); -hljs.registerLanguage('php', hljs_php); -hljs.registerLanguage('twig', hljs_twig); -// xml is the language used for HTML -hljs.registerLanguage('xml', hljs_xml); - - -/* stimulusFetch: 'lazy' */ -export default class extends Controller { - static targets = ['codeBlock']; - - codeBlockTargetConnected() { - this.codeBlockTargets.forEach(this.#highlightCodeBlock) - } - - #highlightCodeBlock(codeBlock) { - if (codeBlock.dataset.highlighted) { - return; - } - hljs.highlightElement(codeBlock); - } -} diff --git a/ux.symfony.com/assets/styles/vendor/_highlight.scss b/ux.symfony.com/assets/styles/vendor/_highlight.scss index ef4a8847af8..cfc758f5e47 100644 --- a/ux.symfony.com/assets/styles/vendor/_highlight.scss +++ b/ux.symfony.com/assets/styles/vendor/_highlight.scss @@ -1,3 +1,79 @@ +/** tempest/highlight theme (https://github.com/tempestphp/highlight/blob/main/src/Themes/Css/dracula.css) */ +.hl-keyword { + color: #FF79C6; +} + +.hl-property { + color: #50FA7B; +} + +.hl-attribute { + font-style: italic; +} + +.hl-type { + color: #8BE9FD; +} + +.hl-generic { + color: #9d3af6; +} + +.hl-value { + color: #F1FA8C; +} + +.hl-variable { + color: #F8F8F2; +} + +.hl-comment { + color: #6272A4; +} + +.hl-blur { + filter: blur(2px); +} + +.hl-strong { + font-weight: bold; +} + +.hl-em { + font-style: italic; +} + +.hl-addition { + display: inline-block; + min-width: 100%; + background-color: #00FF0022; +} + +.hl-deletion { + display: inline-block; + min-width: 100%; + background-color: #FF000011; +} + +.hl-gutter { + display: inline-block; + font-size: 0.9em; + color: #555; + padding: 0 1ch; + user-select: none; +} + +.hl-gutter-addition { + background-color: #34A853; + color: #fff; +} + +.hl-gutter-deletion { + background-color: #EA4334; + color: #fff; +} + +/** highlight.js theme */ .hljs-comment, .hljs-prompt { color: #8b949e; user-select: none; diff --git a/ux.symfony.com/composer.json b/ux.symfony.com/composer.json index efdfc1f55b0..19f369d1d57 100644 --- a/ux.symfony.com/composer.json +++ b/ux.symfony.com/composer.json @@ -55,6 +55,7 @@ "symfony/yaml": "6.4.*", "symfonycasts/dynamic-forms": "^0.1.0", "symfonycasts/sass-bundle": "^0.2.0", + "tempest/highlight": "^2.0", "twbs/bootstrap": "^5.3", "twig/extra-bundle": "^2.12|^3.6.1", "twig/html-extra": "^3.8", diff --git a/ux.symfony.com/composer.lock b/ux.symfony.com/composer.lock index c179d00870e..b9c0c156e9a 100644 --- a/ux.symfony.com/composer.lock +++ b/ux.symfony.com/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": "63672427aa7fe4d557346c2c86b7216b", + "content-hash": "ee38e7313281847631ede94b062bb12a", "packages": [ { "name": "babdev/pagerfanta-bundle", @@ -9320,6 +9320,59 @@ }, "time": "2023-11-17T10:32:54+00:00" }, + { + "name": "tempest/highlight", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/tempestphp/highlight.git", + "reference": "93d40fad805b320fb5f3a77599911388400ce20e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tempestphp/highlight/zipball/93d40fad805b320fb5f3a77599911388400ce20e", + "reference": "93d40fad805b320fb5f3a77599911388400ce20e", + "shasum": "" + }, + "require": { + "php": "^8.3" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.21", + "larapack/dd": "^1.1", + "league/commonmark": "^2.4", + "phpstan/phpstan": "^1.10.0", + "phpunit/phpunit": "^10.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Tempest\\Highlight\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brent Roose", + "email": "brendt@stitcher.io" + } + ], + "description": "Fast, extensible, server-side code highlighting", + "support": { + "issues": "https://github.com/tempestphp/highlight/issues", + "source": "https://github.com/tempestphp/highlight/tree/2.0.0" + }, + "funding": [ + { + "url": "https://github.com/brendt", + "type": "github" + } + ], + "time": "2024-04-16T07:35:42+00:00" + }, { "name": "twbs/bootstrap", "version": "v5.3.3", diff --git a/ux.symfony.com/config/services.yaml b/ux.symfony.com/config/services.yaml index 09ff8240e1d..11af71642d9 100644 --- a/ux.symfony.com/config/services.yaml +++ b/ux.symfony.com/config/services.yaml @@ -24,7 +24,11 @@ services: # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones - Highlight\Highlighter: ~ + Tempest\Highlight\Highlighter: + tags: ['twig.runtime'] + + App\Service\CommonMark\TempestHighlightExtension: + tags: ['twig.markdown.league_extension'] League\CommonMark\Extension\ExternalLink\ExternalLinkExtension: tags: ['twig.markdown.league_extension'] diff --git a/ux.symfony.com/src/Service/CommonMark/TempestHighlightExtension.php b/ux.symfony.com/src/Service/CommonMark/TempestHighlightExtension.php new file mode 100644 index 00000000000..5e3182df6ca --- /dev/null +++ b/ux.symfony.com/src/Service/CommonMark/TempestHighlightExtension.php @@ -0,0 +1,31 @@ + + */ +final class TempestHighlightExtension implements ExtensionInterface +{ + public function __construct(private Highlighter $highlighter) + { + } + + public function register(EnvironmentBuilderInterface $environment): void + { + $environment + ->addRenderer(FencedCode::class, new CodeBlockRenderer($this->highlighter), 10) + ->addRenderer(Code::class, new InlineCodeBlockRenderer($this->highlighter), 10) + ; + } +} diff --git a/ux.symfony.com/src/Twig/HighlightExtension.php b/ux.symfony.com/src/Twig/HighlightExtension.php new file mode 100644 index 00000000000..8a4528119aa --- /dev/null +++ b/ux.symfony.com/src/Twig/HighlightExtension.php @@ -0,0 +1,20 @@ + + */ +final class HighlightExtension extends AbstractExtension +{ + public function getFilters(): array + { + return [ + new TwigFilter('highlight', [Highlighter::class, 'parse'], ['is_safe' => ['html']]), + ]; + } +} diff --git a/ux.symfony.com/templates/components/CodeBlock.html.twig b/ux.symfony.com/templates/components/CodeBlock.html.twig index c95941a46dd..f9a2651eedf 100644 --- a/ux.symfony.com/templates/components/CodeBlock.html.twig +++ b/ux.symfony.com/templates/components/CodeBlock.html.twig @@ -19,12 +19,11 @@ {% endif %}
{% for piece in this.prepareSource %} {% if piece.highlight ?? true %} -

-                        {{- piece.content -}}
+                    

+                        {{- piece.content|highlight(this.language)  -}}
                     
{% else %} {{- piece.content|raw -}} diff --git a/ux.symfony.com/templates/components/CodeLine.html.twig b/ux.symfony.com/templates/components/CodeLine.html.twig index 012e2bc9ca6..873184ae8b6 100644 --- a/ux.symfony.com/templates/components/CodeLine.html.twig +++ b/ux.symfony.com/templates/components/CodeLine.html.twig @@ -1,8 +1,8 @@ -{% props highlight = false, code = '', height = null %} +{% props code = '', height = null %}
{% set __code -%} {% block content -%} @@ -13,7 +13,7 @@
{{ __code ? __code|trim|raw : code }}
+ >{{ __code ? __code|trim|raw : code }}