Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
docs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
docs
Commits
e8611aec
Commit
e8611aec
authored
Apr 15, 2017
by
Tobias Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render tarball sha256 checksum if available for release
parent
5f38896b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
19 deletions
+55
-19
docs.css
content/css/docs.css
+3
-2
download.html
content/download.html
+7
-12
download.rb
lib/helpers/download.rb
+45
-5
No files found.
content/css/docs.css
View file @
e8611aec
...
@@ -233,8 +233,9 @@ footer {
...
@@ -233,8 +233,9 @@ footer {
}
}
.downloads
.checksum
{
.downloads
.checksum
{
color
:
#aaa
;
font-family
:
monospace
;
font-style
:
italic
;
font-size
:
.6em
;
vertical-align
:
bottom
;
}
}
/* Docs-related styles. */
/* Docs-related styles. */
...
...
content/download.html
View file @
e8611aec
...
@@ -29,11 +29,6 @@ title: Download
...
@@ -29,11 +29,6 @@ title: Download
the
<a
href=
"/docs/introduction/getting_started/"
>
installation instructions
</a>
.
the
<a
href=
"/docs/introduction/getting_started/"
>
installation instructions
</a>
.
</p>
</p>
<div
class=
"alert alert-info"
role=
"alert"
>
<strong>
Work in progress!
</strong>
We will provide more precompiled binary versions as well as checksums soon.
</div>
<div
class=
"panel panel-default download-selection"
>
<div
class=
"panel panel-default download-selection"
>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
Operating system
<
%=
dropdown
(
:os
,
Downloads
.
operating_systems
,
:popular
,
popular:
%
w
(
darwin
linux
windows
))
%
>
Operating system
<
%=
dropdown
(
:os
,
Downloads
.
operating_systems
,
:popular
,
popular:
%
w
(
darwin
linux
windows
))
%
>
...
@@ -64,13 +59,13 @@ title: Download
...
@@ -64,13 +59,13 @@ title: Download
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
<
%
release
.
assets
.
each
do
|
asset
|
%
>
<
%
release
.
binaries
.
each
do
|
binary
|
%
>
<tr
data-os=
"<%=
asset.os %>"
data-arch=
"<%= asset
.arch %>"
>
<tr
data-os=
"<%=
binary.os %>"
data-arch=
"<%= binary
.arch %>"
>
<td
class=
"filename"
><a
class=
"download"
href=
"<%=
asset.url %>"
><
%=
asset
.
name
%
></a></td>
<td
class=
"filename"
><a
class=
"download"
href=
"<%=
binary.url %>"
><
%=
binary
.
name
%
></a></td>
<td><
%=
asset
.
os
%
></td>
<td><
%=
binary
.
os
%
></td>
<td><
%=
asset
.
arch
%
></td>
<td><
%=
binary
.
arch
%
></td>
<td><
%=
format_bytes
asset
.
size
%
></td>
<td><
%=
format_bytes
binary
.
size
%
></td>
<td
class=
"checksum"
>
not available yet
</td>
<td
class=
"checksum"
>
<
%=
Downloads
.
checksum
(
release
,
binary
.
name
)
%
>
</td>
</tr>
</tr>
<
%
end
%
>
<
%
end
%
>
</tbody>
</tbody>
...
...
lib/helpers/download.rb
View file @
e8611aec
require
'fileutils'
require
'json'
require
'json'
require
'open-uri'
module
Downloads
module
Downloads
# repositories returns a list of all repositories with releases.
# repositories returns a list of all repositories with releases.
def
self
.
repositories
def
self
.
repositories
@repositories
||=
begin
@
_
repositories
||=
begin
repos
=
Dir
.
glob
(
'downloads/*'
).
map
{
|
dir
|
Repository
.
new
(
dir
)
}
repos
=
Dir
.
glob
(
'downloads/*'
).
map
{
|
dir
|
Repository
.
new
(
dir
)
}
repos
.
sort_by
{
|
r
|
r
.
name
==
'prometheus'
?
'0'
:
r
.
name
}
repos
.
sort_by
{
|
r
|
r
.
name
==
'prometheus'
?
'0'
:
r
.
name
}
end
end
...
@@ -13,7 +15,7 @@ module Downloads
...
@@ -13,7 +15,7 @@ module Downloads
# provided for.
# provided for.
def
self
.
operating_systems
def
self
.
operating_systems
repositories
.
inject
([])
do
|
list
,
repo
|
repositories
.
inject
([])
do
|
list
,
repo
|
list
+=
repo
.
releases
.
map
{
|
r
|
r
.
asset
s
.
map
(
&
:os
)
}.
flatten
list
+=
repo
.
releases
.
map
{
|
r
|
r
.
binarie
s
.
map
(
&
:os
)
}.
flatten
end
.
uniq
.
sort
end
.
uniq
.
sort
end
end
...
@@ -21,10 +23,38 @@ module Downloads
...
@@ -21,10 +23,38 @@ module Downloads
# provided for.
# provided for.
def
self
.
architectures
def
self
.
architectures
repositories
.
inject
([])
do
|
list
,
repo
|
repositories
.
inject
([])
do
|
list
,
repo
|
list
+=
repo
.
releases
.
map
{
|
r
|
r
.
asset
s
.
map
(
&
:arch
)
}.
flatten
list
+=
repo
.
releases
.
map
{
|
r
|
r
.
binarie
s
.
map
(
&
:arch
)
}.
flatten
end
.
uniq
.
sort
end
.
uniq
.
sort
end
end
# checksum returns the checksum for a given filename of a given release. It
# might try to download the sha256sums.txt from the given release if available
# and not already cached.
def
self
.
checksum
(
release
,
name
)
@_checksums
||=
{}
@_checksums
[
release
.
id
]
||=
begin
asset
=
release
.
assets
.
find
{
|
a
|
a
[
'name'
]
==
'sha256sums.txt'
}
if
asset
cache
=
[
'downloads'
,
'.cache'
,
release
.
id
,
'sha256sums.txt'
].
join
(
'/'
)
unless
File
.
exists?
(
cache
)
FileUtils
.
mkdir_p
(
File
.
dirname
(
cache
))
File
.
open
(
cache
,
'wb'
)
do
|
file
|
file
.
write
(
URI
.
parse
(
asset
[
'browser_download_url'
]).
read
)
end
end
File
.
readlines
(
cache
).
each_with_object
({})
do
|
line
,
memo
|
checksum
,
filename
=
line
.
split
(
/\s+/
)
memo
[
filename
]
=
checksum
end
else
{}
end
end
@_checksums
[
release
.
id
][
name
]
end
class
Repository
class
Repository
def
initialize
(
dir
)
def
initialize
(
dir
)
@repo
=
JSON
.
parse
(
File
.
read
(
File
.
join
(
dir
,
'repo.json'
)))
@repo
=
JSON
.
parse
(
File
.
read
(
File
.
join
(
dir
,
'repo.json'
)))
...
@@ -66,6 +96,10 @@ module Downloads
...
@@ -66,6 +96,10 @@ module Downloads
@data
=
data
@data
=
data
end
end
def
id
@data
[
'id'
]
end
def
name
def
name
@data
[
'name'
]
@data
[
'name'
]
end
end
...
@@ -79,11 +113,17 @@ module Downloads
...
@@ -79,11 +113,17 @@ module Downloads
end
end
def
assets
def
assets
@data
[
'assets'
].
map
{
|
d
|
Asset
.
new
(
d
)
}
@data
[
'assets'
]
end
def
binaries
assets
.
select
{
|
d
|
d
[
'name'
]
&&
%w[.tar.gz .zip]
.
any?
{
|
ext
|
d
[
'name'
].
end_with?
(
ext
)
}
}.
map
{
|
d
|
Binary
.
new
(
d
)
}
end
end
end
end
class
Asset
class
Binary
def
initialize
(
data
)
def
initialize
(
data
)
@data
=
data
@data
=
data
end
end
...
...
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