diff --git a/index.php b/index.php index 72d34bda395d6bcd55c871b237c67938f5120e26..123b97136730a14c7e154d4fbaa23665ff6e85df 100644 --- a/index.php +++ b/index.php @@ -26,7 +26,7 @@ if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false Request::setTrustedHosts([$trustedHosts]); } -$kernel = new Kernel('prod', false); +$kernel = new Kernel('dev', true); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 5752177f9afad7b35361e44c065711c346e24ff8..505a2779d086b6a34cc4f916786aade4ac665e0d 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -48,7 +48,7 @@ class MainController extends AbstractController /** * @Route("/{category}", defaults={"_locale": "en"}) - * @Route("/{_locale}/{category}", name="app_main_category_intl", requirements={"_locale": "%app.locales%"}) + * @Route("/{_locale}/{category}", name="app_main_category_intl", requirements={"_locale": "%app.locales%", "category": "development|education|games|graphics|internet|multimedia|office|system|utilities|unmaintained"}) * @param Request $request * @param string $_locale * @param string $category @@ -82,33 +82,52 @@ class MainController extends AbstractController } /** - * @Route("/{category}/{application}", requirements={"_locale": "%app.locales%"}, defaults={"_locale": "en"}) - * @Route("/{_locale}/{category}/{application}", name="app_main_application_intl", requirements={"_locale": "%app.locales%"}) + * @Route("/{application}", requirements={"_locale": "%app.locales%"}, defaults={"_locale": "en"}) + * @Route("/{_locale}/{application}", name="app_main_application_intl", requirements={"_locale": "%app.locales%"}) * @param Request $request * @param string $_locale * @param string $category * @param string $application * @return Response */ - public function application(Request $request, string $_locale, string $category, string $application): Response + public function application(Request $request, string $_locale, string $application): Response { if ($request->query->get('site_locale')) { - return $this->redirectToRoute('app_main_application_intl', ['_locale' => $request->query->get('site_locale'), 'category' => $category, 'application' => $application]); + return $this->redirectToRoute('app_main_application_intl', [ + '_locale' => $request->query->get('site_locale'), + 'application' => $application, + ]); } - $applicationObj = AppData::fromName($application); + if (startsWith($application, 'org.kde')) { + return $this->redirectToRoute('app_main_application_intl', [ + '_locale' => $_locale, + 'application' => substr($application, 8), + ]); + } + + $applicationObj = AppData::fromName('org.kde.' . $application); - if (!($applicationObj || startsWith($application, 'org'))) { - return $this->redirectToRoute('app_main_application_intl', ['_locale' => $_locale, 'category' => $category, 'application' => 'org.kde.' . $application]); - } else if (!$applicationObj) { + if (!$applicationObj) { throw $this->createNotFoundException('The product does not exist'); } return $this->render('main/application.html.twig', [ 'application' => $applicationObj, - 'category' => $category, 'locale' => $_locale, 'translations' => $this->getParameter('app.translations'), ]); } + + /** + * @Route("/{category}/{application}", requirements={"_locale": "%app.locales%"}, defaults={"_locale": "en"}) + * @Route("/{_locale}/{category}/{application}", name="riuehiiuhiu", requirements={"_locale": "%app.locales%"}) + */ + public function redirectOldCategory(Request $request, string $_locale, string $category, string $application): Response + { + return $this->redirectToRoute('app_main_application_intl', [ + '_locale' => $_locale, + 'application' => $application, + ]); + } } diff --git a/templates/category.html.twig b/templates/category.html.twig index 5f9c80f9f2952a27ceafd8483bd1d00e96e9676a..7027d8b8944cea0a5d1e4594bc62c412794498b5 100644 --- a/templates/category.html.twig +++ b/templates/category.html.twig @@ -31,13 +31,13 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- + {{ application.name | l10n(locale) }}

{{ application.genericName | l10n(locale) }}

@@ -53,12 +53,12 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- + {{ application.name | l10n(locale) }}

{{ application.genericName | l10n(locale) }}

diff --git a/templates/main/application.html.twig b/templates/main/application.html.twig index f734d9c2c88e7b867f72a7c6e51fdbadc642a57e..a47d5b3af9afc432d62758d65ad4adf960834d97 100644 --- a/templates/main/application.html.twig +++ b/templates/main/application.html.twig @@ -11,13 +11,13 @@ SPDX-License-Identifier: AGPL-3.0-or-later {% block title %}{{ name }}{% endblock %} {% block description %}{{ application.summary | l10n(locale) }}{% endblock %} {% block image %}{% if application.screenshots | length > 0 %}{{ application.screenshots[0].sourceImage }}{% else %}https://kde.org/products/apps.png{% endif %}{% endblock %} -{% block canonical %}https://kde.org{{ path('app_main_application_intl', {'_locale': locale, 'category': category, 'application': application.id}) }}{% endblock %} +{% block canonical %}https://kde.org{{ path('app_main_application_intl', {'_locale': locale, 'application': application.simplifiedId}) }}{% endblock %} {% block donation %}#{{ name }}{% endblock %} {% block hreflang %} - + {% for translation in translations %} - + {% endfor %} {% endblock %} @@ -37,7 +37,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later {% trans %}KDE's Applications{% endtrans %} {{ name }} - + {{ application.primaryCategory | trans }}
@@ -171,7 +171,7 @@ AppStream application stores. You can also use your distribution's package manag

{% trans %}Releases{% endtrans %}

{% endif %} {% for release in application.releases %} -
+
{{ release.version }} {{ release.timestamp | format_date('long', locale=locale) }} {% if release.description %}