Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Websites
KDE.org Applications Subsite
Commits
f94fef0f
Commit
f94fef0f
authored
Sep 09, 2020
by
Carl Schwan
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the url considerably
parent
8e925b04
Pipeline
#33723
canceled with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
20 deletions
+39
-20
index.php
index.php
+1
-1
src/Controller/MainController.php
src/Controller/MainController.php
+29
-10
templates/category.html.twig
templates/category.html.twig
+4
-4
templates/main/application.html.twig
templates/main/application.html.twig
+5
-5
No files found.
index.php
View file @
f94fef0f
...
@@ -26,7 +26,7 @@ if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false
...
@@ -26,7 +26,7 @@ if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false
Request
::
setTrustedHosts
([
$trustedHosts
]);
Request
::
setTrustedHosts
([
$trustedHosts
]);
}
}
$kernel
=
new
Kernel
(
'
prod'
,
fals
e
);
$kernel
=
new
Kernel
(
'
dev'
,
tru
e
);
$request
=
Request
::
createFromGlobals
();
$request
=
Request
::
createFromGlobals
();
$response
=
$kernel
->
handle
(
$request
);
$response
=
$kernel
->
handle
(
$request
);
$response
->
send
();
$response
->
send
();
...
...
src/Controller/MainController.php
View file @
f94fef0f
...
@@ -48,7 +48,7 @@ class MainController extends AbstractController
...
@@ -48,7 +48,7 @@ class MainController extends AbstractController
/**
/**
* @Route("/{category}", defaults={"_locale": "en"})
* @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 Request $request
* @param string $_locale
* @param string $_locale
* @param string $category
* @param string $category
...
@@ -82,33 +82,52 @@ class MainController extends AbstractController
...
@@ -82,33 +82,52 @@ class MainController extends AbstractController
}
}
/**
/**
* @Route("/{
category}/{
application}", requirements={"_locale": "%app.locales%"}, defaults={"_locale": "en"})
* @Route("/{application}", requirements={"_locale": "%app.locales%"}, defaults={"_locale": "en"})
* @Route("/{_locale}/{
category}/{
application}", name="app_main_application_intl", requirements={"_locale": "%app.locales%"})
* @Route("/{_locale}/{application}", name="app_main_application_intl", requirements={"_locale": "%app.locales%"})
* @param Request $request
* @param Request $request
* @param string $_locale
* @param string $_locale
* @param string $category
* @param string $category
* @param string $application
* @param string $application
* @return Response
* @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'
))
{
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'
)))
{
if
(
!
$applicationObj
)
{
return
$this
->
redirectToRoute
(
'app_main_application_intl'
,
[
'_locale'
=>
$_locale
,
'category'
=>
$category
,
'application'
=>
'org.kde.'
.
$application
]);
}
else
if
(
!
$applicationObj
)
{
throw
$this
->
createNotFoundException
(
'The product does not exist'
);
throw
$this
->
createNotFoundException
(
'The product does not exist'
);
}
}
return
$this
->
render
(
'main/application.html.twig'
,
[
return
$this
->
render
(
'main/application.html.twig'
,
[
'application'
=>
$applicationObj
,
'application'
=>
$applicationObj
,
'category'
=>
$category
,
'locale'
=>
$_locale
,
'locale'
=>
$_locale
,
'translations'
=>
$this
->
getParameter
(
'app.translations'
),
'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
,
]);
}
}
}
templates/category.html.twig
View file @
f94fef0f
...
@@ -31,13 +31,13 @@ SPDX-License-Identifier: AGPL-3.0-or-later
...
@@ -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=
"app text-center col-12 col-sm-6 col-md-4 col-lg-3 p-2"
>
<div
class=
"p-3 h-100"
>
<div
class=
"p-3 h-100"
>
<div
aria-hidden=
"true"
>
<div
aria-hidden=
"true"
>
<a
href=
"
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
locale
,
'category'
:
category.name
|
lower
,
'application'
:
application.
i
d
}
)
}}
"
>
<a
href=
"
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
locale
,
'application'
:
application.
simplifiedI
d
}
)
}}
"
>
<img
width=
"48"
height=
"48"
src=
"
{{
asset
(
'icons/'
~
application.icon
)
}}
"
<img
width=
"48"
height=
"48"
src=
"
{{
asset
(
'icons/'
~
application.icon
)
}}
"
loading=
"lazy"
loading=
"lazy"
alt=
"
{{
application.name
|
l10n
(
locale
)
}}
"
title=
"
{{
application.name
|
l10n
(
locale
)
}}
"
/>
alt=
"
{{
application.name
|
l10n
(
locale
)
}}
"
title=
"
{{
application.name
|
l10n
(
locale
)
}}
"
/>
</a>
</a>
</div>
</div>
<a
href=
"
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
locale
,
'category'
:
category.name
|
lower
,
'application'
:
application.
i
d
}
)
}}
"
>
<a
href=
"
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
locale
,
'application'
:
application.
simplifiedI
d
}
)
}}
"
>
{{
application.name
|
l10n
(
locale
)
}}
{{
application.name
|
l10n
(
locale
)
}}
</a>
</a>
<p>
{{
application.genericName
|
l10n
(
locale
)
}}
</p>
<p>
{{
application.genericName
|
l10n
(
locale
)
}}
</p>
...
@@ -53,12 +53,12 @@ SPDX-License-Identifier: AGPL-3.0-or-later
...
@@ -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=
"app text-center col-12 col-sm-6 col-md-4 col-lg-3 p-2"
>
<div
class=
"p-3 h-100"
>
<div
class=
"p-3 h-100"
>
<div
aria-hidden=
"true"
>
<div
aria-hidden=
"true"
>
<a
href=
"
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
locale
,
'category'
:
category.name
|
lower
,
'application'
:
application.
i
d
}
)
}}
"
>
<a
href=
"
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
locale
,
'application'
:
application.
simplifiedI
d
}
)
}}
"
>
<img
width=
"48"
height=
"48"
src=
"
{{
asset
(
'icons/'
~
application.icon
)
}}
"
<img
width=
"48"
height=
"48"
src=
"
{{
asset
(
'icons/'
~
application.icon
)
}}
"
alt=
"
{{
application.name
|
l10n
(
locale
)
}}
"
title=
"
{{
application.name
|
l10n
(
locale
)
}}
"
/>
alt=
"
{{
application.name
|
l10n
(
locale
)
}}
"
title=
"
{{
application.name
|
l10n
(
locale
)
}}
"
/>
</a>
</a>
</div>
</div>
<a
href=
"
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
locale
,
'category'
:
category.name
|
lower
,
'application'
:
application.
i
d
}
)
}}
"
>
<a
href=
"
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
locale
,
'category'
:
category.name
|
lower
,
'application'
:
application.
simplifiedI
d
}
)
}}
"
>
{{
application.name
|
l10n
(
locale
)
}}
{{
application.name
|
l10n
(
locale
)
}}
</a>
</a>
<p>
{{
application.genericName
|
l10n
(
locale
)
}}
</p>
<p>
{{
application.genericName
|
l10n
(
locale
)
}}
</p>
...
...
templates/main/application.html.twig
View file @
f94fef0f
...
@@ -11,13 +11,13 @@ SPDX-License-Identifier: AGPL-3.0-or-later
...
@@ -11,13 +11,13 @@ SPDX-License-Identifier: AGPL-3.0-or-later
{%
block
title
%}{{
name
}}{%
endblock
%}
{%
block
title
%}{{
name
}}{%
endblock
%}
{%
block
description
%}{{
application.summary
|
l10n
(
locale
)
}}{%
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
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.
i
d
}
)
}}{%
endblock
%}
{%
block
canonical
%}
https://kde.org
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
locale
,
'application'
:
application.
simplifiedI
d
}
)
}}{%
endblock
%}
{%
block
donation
%}
#
{{
name
}}{%
endblock
%}
{%
block
donation
%}
#
{{
name
}}{%
endblock
%}
{%
block
hreflang
%}
{%
block
hreflang
%}
<link
rel=
"alternate"
href=
"https://kde.org
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
'en'
,
'category'
:
category
|
lower
,
'application'
:
application.
i
d
}
)
}}
"
hreflang=
"en"
/>
<link
rel=
"alternate"
href=
"https://kde.org
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
'en'
,
'application'
:
application.
simplifiedI
d
}
)
}}
"
hreflang=
"en"
/>
{%
for
translation
in
translations
%}
{%
for
translation
in
translations
%}
<link
rel=
"alternate"
href=
"https://kde.org
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
translation
,
'category'
:
category
,
'application'
:
application.
i
d
}
)
}}
"
hreflang=
"
{{
translation
}}
"
/>
<link
rel=
"alternate"
href=
"https://kde.org
{{
path
(
'app_main_application_intl'
,
{
'_locale'
:
translation
,
'application'
:
application.
simplifiedI
d
}
)
}}
"
hreflang=
"
{{
translation
}}
"
/>
{%
endfor
%}
{%
endfor
%}
{%
endblock
%}
{%
endblock
%}
...
@@ -37,7 +37,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
...
@@ -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>
<a
href=
"
{{
path
(
'app_main_index'
,
{
'_locale'
:
locale
}
)
}}
"
>
{%
trans
%}
KDE's Applications
{%
endtrans
%}
</a>
{{
name
}}
{{
name
}}
</h1>
</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
}}
{{
application.primaryCategory
|
trans
}}
</a>
</a>
</div>
</div>
...
@@ -171,7 +171,7 @@ AppStream application stores. You can also use your distribution's package manag
...
@@ -171,7 +171,7 @@ AppStream application stores. You can also use your distribution's package manag
<h2
class=
"mb-0"
>
{%
trans
%}
Releases
{%
endtrans
%}
</h2>
<h2
class=
"mb-0"
>
{%
trans
%}
Releases
{%
endtrans
%}
</h2>
{%
endif
%}
{%
endif
%}
{%
for
release
in
application.releases
%}
{%
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>
<summary
class=
"mt-1 h5"
>
{{
release.version
}}
<small
class=
"text-muted"
>
{{
release.timestamp
|
format_date
(
'long'
,
locale
=
locale
)
}}
</small></summary>
{%
if
release.description
%}
{%
if
release.description
%}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment