Commit f94fef0f authored by Carl Schwan's avatar Carl Schwan 🚴

Simplify the url considerably

parent 8e925b04
Pipeline #33723 canceled with stage
......@@ -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();
......
......@@ -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,
]);
}
}
......@@ -31,13 +31,13 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<div class="app text-center col-12 col-sm-6 col-md-4 col-lg-3 p-2">
<div class="p-3 h-100">
<div aria-hidden="true">
<a href="{{ path('app_main_application_intl', {'_locale': locale, 'category': category.name | lower, 'application' : application.id }) }}">
<a href="{{ path('app_main_application_intl', {'_locale': locale, 'application' : application.simplifiedId }) }}">
<img width="48" height="48" src="{{ asset('icons/' ~ application.icon) }}"
loading="lazy"
alt="{{ application.name | l10n(locale) }}" title="{{ application.name | l10n(locale) }}"/>
</a>
</div>
<a href="{{ path('app_main_application_intl', {'_locale': locale, 'category': category.name | lower, 'application' : application.id }) }}">
<a href="{{ path('app_main_application_intl', {'_locale': locale, 'application' : application.simplifiedId }) }}">
{{ application.name | l10n(locale) }}
</a>
<p>{{ application.genericName | l10n(locale) }}</p>
......@@ -53,12 +53,12 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<div class="app text-center col-12 col-sm-6 col-md-4 col-lg-3 p-2">
<div class="p-3 h-100">
<div aria-hidden="true">
<a href="{{ path('app_main_application_intl', {'_locale': locale, 'category': category.name | lower, 'application' : application.id }) }}">
<a href="{{ path('app_main_application_intl', {'_locale': locale, 'application' : application.simplifiedId }) }}">
<img width="48" height="48" src="{{ asset('icons/' ~ application.icon) }}"
alt="{{ application.name | l10n(locale) }}" title="{{ application.name | l10n(locale) }}"/>
</a>
</div>
<a href="{{ path('app_main_application_intl', {'_locale': locale, 'category': category.name | lower, 'application' : application.id }) }}">
<a href="{{ path('app_main_application_intl', {'_locale': locale, 'category': category.name | lower, 'application' : application.simplifiedId }) }}">
{{ application.name | l10n(locale) }}
</a>
<p>{{ application.genericName | l10n(locale) }}</p>
......
......@@ -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 %}
<link rel="alternate" href="https://kde.org{{ path('app_main_application_intl', {'_locale': 'en', 'category': category | lower, 'application' : application.id }) }}" hreflang="en" />
<link rel="alternate" href="https://kde.org{{ path('app_main_application_intl', {'_locale': 'en', 'application' : application.simplifiedId }) }}" hreflang="en" />
{% for translation in translations %}
<link rel="alternate" href="https://kde.org{{ path('app_main_application_intl', {'_locale': translation, 'category': category, 'application' : application.id }) }}" hreflang="{{ translation }}" />
<link rel="alternate" href="https://kde.org{{ path('app_main_application_intl', {'_locale': translation, 'application' : application.simplifiedId }) }}" hreflang="{{ translation }}" />
{% endfor %}
{% endblock %}
......@@ -37,7 +37,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<a href="{{ path('app_main_index', {'_locale': locale}) }}">{% trans %}KDE's Applications{% endtrans %}</a>
{{ name }}
</h1>
<a href="{{ path('app_main_category_intl', {'_locale': locale, 'category': category}) }}">
<a href="{{ path('app_main_category_intl', {'_locale': locale, 'category': application.primaryCategory | lower }) }}">
{{ application.primaryCategory | trans }}
</a>
</div>
......@@ -171,7 +171,7 @@ AppStream application stores. You can also use your distribution's package manag
<h2 class="mb-0">{% trans %}Releases{% endtrans %}</h2>
{% endif %}
{% for release in application.releases %}
<details class="release mb-5" {% if loop.first %}open="true"{% endif %}>
<details class="release" {% if loop.first %}open="true"{% endif %}>
<summary class="mt-1 h5">{{ release.version }} <small class="text-muted">{{ release.timestamp | format_date('long', locale=locale) }}</small></summary>
{% if release.description %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment