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
202f5ce9
Commit
202f5ce9
authored
Jul 07, 2020
by
Carl Schwan
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add information about artifacts in release
parent
3926df67
Pipeline
#26259
passed with stage
in 4 minutes and 23 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
4 deletions
+102
-4
src/Model/Release.php
src/Model/Release.php
+25
-3
src/Twig/AppTransExtension.php
src/Twig/AppTransExtension.php
+21
-1
templates/main/application.html.twig
templates/main/application.html.twig
+56
-0
No files found.
src/Model/Release.php
View file @
202f5ce9
<?php
/**
* SPDX-FileCopyrightText: 2020 David Barchiesi <david@barchie.si>
* SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
...
...
@@ -15,20 +16,26 @@ class Release
/** @var ReleaseType */
private
$type
;
private
$timestamp
=
null
;
private
$artifacts
=
[];
private
$url
;
public
function
__construct
(
string
$version
,
int
$type
,
string
$timestamp
)
public
function
__construct
(
string
$version
,
int
$type
,
string
$timestamp
,
string
$url
=
null
,
array
$artifacts
=
[]
)
{
$this
->
version
=
$version
;
$this
->
type
=
$type
;
$this
->
timestamp
=
$timestamp
;
$this
->
url
=
$url
;
$this
->
artifacts
=
$artifacts
;
}
public
static
function
fromData
(
array
$release
):
?Release
{
$url
=
isset
(
$release
[
'url'
])
&&
isset
(
$release
[
'url'
][
'details'
])
?
$release
[
'url'
][
'details'
]
:
null
;
$artifacts
=
isset
(
$release
[
'artifacts'
])
?
$release
[
'artifacts'
]
:
[];
if
(
$release
[
'type'
]
===
'stable'
)
{
return
new
Release
(
$release
[
'version'
],
ReleaseType
::
Stable
,
$release
[
'unix-timestamp'
]);
return
new
Release
(
$release
[
'version'
],
ReleaseType
::
Stable
,
$release
[
'unix-timestamp'
]
,
$url
,
$artifacts
);
}
else
if
(
$release
[
'type'
]
===
'development'
)
{
return
new
Release
(
$release
[
'version'
],
ReleaseType
::
Development
,
$release
[
'unix-timestamp'
]);
return
new
Release
(
$release
[
'version'
],
ReleaseType
::
Development
,
$release
[
'unix-timestamp'
]
,
$url
,
$artifacts
);
}
else
{
return
null
;
}
...
...
@@ -58,4 +65,19 @@ class Release
return
$this
->
timestamp
;
}
/**
* @return array
*/
public
function
getArtifacts
():
array
{
return
$this
->
artifacts
;
}
/**
* @return string|null
*/
public
function
getUrl
():
?string
{
return
$this
->
url
;
}
}
src/Twig/AppTransExtension.php
View file @
202f5ce9
...
...
@@ -17,7 +17,8 @@ class AppTransExtension extends AbstractExtension
public
function
getFilters
()
{
return
[
new
TwigFilter
(
'l10n'
,
[
$this
,
'l10n'
])
new
TwigFilter
(
'l10n'
,
[
$this
,
'l10n'
]),
new
TwigFilter
(
'size'
,
[
$this
,
'size'
]),
];
}
...
...
@@ -48,4 +49,23 @@ class AppTransExtension extends AbstractExtension
}
return
$array
[
'C'
];
}
/**
* @param int $bytes
* @param int $precision
* @return string
* @throws Error
*/
public
function
size
(
int
$bytes
,
int
$precision
=
2
):
string
{
$units
=
array
(
'B'
,
'KB'
,
'MB'
,
'GB'
,
'TB'
);
$bytes
=
max
(
$bytes
,
0
);
$pow
=
floor
((
$bytes
?
log
(
$bytes
)
:
0
)
/
log
(
1024
));
$pow
=
min
(
$pow
,
count
(
$units
)
-
1
);
$bytes
/=
pow
(
1024
,
$pow
);
return
round
(
$bytes
,
$precision
)
.
' '
.
$units
[
$pow
];
}
}
templates/main/application.html.twig
View file @
202f5ce9
...
...
@@ -102,6 +102,52 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<div>
{{
application.description
|
l10n
(
locale
)
|
raw
}}
</div>
{%
if
application.releases
|
length
>
0
%}
<h2>
{%
trans
%}
Releases
{%
endtrans
%}
</h2>
{%
endif
%}
{%
for
release
in
application.releases
%}
<div
class=
"release
{%
if
not
loop.first
%}
d-none
{%
endif
%}
"
>
<h3>
{{
release.version
}}
<small>
{{
release.timestamp
|
format_date
(
'long'
,
locale
=
locale
)
}}
</small></h3>
{%
if
release.url
%}
<div><a
href=
"
{{
release.url
}}
"
>
Learn more...
</a></div>
{%
endif
%}
{%
if
release.artifacts
|
length
>
0
%}
{%
for
artifact
in
release.artifacts
%}
<div
class=
"mb-2 "
>
{%
set
size
=
""
%}
{%
if
artifact.size
is
defined
and
artifact.size.download
%}
{%
set
size
=
" ("
~
artifact.size.download
|
size
~
")"
%}
{%
endif
%}
{%
if
artifact.type
==
"binary"
%}
<h4
class=
"mb-0"
>
{%
if
artifact.platform
==
"x86_64-appimage"
or
artifact.platform
==
"x86_64-linux-gnu"
%}
{%
trans
%}
AppImage
{%
endtrans
%}
-
<small>
x86_64
{{
size
}}
</small>
{%
elseif
artifact.platform
==
"macOS"
%}
{%
trans
%}
macOS
{%
endtrans
%}
-
<small>
x86_64
{{
size
}}
</small>
{%
elseif
artifact.platform
==
"win64"
%}
{%
trans
%}
Windows
{%
endtrans
%}
-
<small>
win64
{{
size
}}
</small>
{%
elseif
artifact.platform
==
"win32"
%}
{%
trans
%}
Windows
{%
endtrans
%}
-
<small>
win32
{{
size
}}
</small>
{%
endif
%}
</h4>
<div><a
href=
"
{{
artifact.locations
[
0
]
}}
"
>
{{
artifact.locations
[
0
]
}}
</a></div>
{%
for
algo
,
checksum
in
artifact.checksum
%}
<div><strong>
{{
algo
}}
:
</strong>
{{
checksum
}}
</div>
{%
endfor
%}
{%
else
%}
<h4
class=
"mb-0"
>
Source
</h4>
<div><a
href=
"
{{
artifact.locations
[
0
]
}}
"
>
{{
artifact.locations
[
0
]
}}
</a></div>
{%
for
algo
,
checksum
in
artifact.checksum
%}
<strong>
{{
algo
}}
:
</strong>
{{
checksum
}}
{%
endfor
%}
{%
endif
%}
</div>
{%
endfor
%}
{%
endif
%}
</div>
{%
endfor
%}
<a
class=
"show-more-release"
href=
"#"
>
Show more releases...
</a>
</section>
<aside
class=
"details col-12 col-md-4 col-lg-3"
>
<h3>
{%
trans
%}
Details for %name%
{%
endtrans
%}
</h3>
...
...
@@ -266,6 +312,16 @@ AppStream application stores. You can also use your distribution's package manag
</div>
</div>
</main>
<script>
document
.
querySelector
(
'
.show-more-release
'
).
addEventListener
(
'
click
'
,
function
(
e
)
{
event
.
preventDefault
();
console
.
log
(
event
.
target
);
event
.
target
.
classList
.
add
(
'
d-none
'
);
document
.
querySelectorAll
(
'
.release
'
).
forEach
(
function
(
release
)
{
release
.
classList
.
remove
(
'
d-none
'
);
});
});
</script>
{%
endblock
%}
{%
block
donation
%}
#
{{
name
}}{%
endblock
%}
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