Cleanup license page generation
* Provide JSON output * Improve webpage aesthetics
This commit is contained in:
parent
6b473c2ad5
commit
d97c4fdd86
|
@ -0,0 +1,45 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<link rel="stylesheet" media="all" href="../../style.css" />
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
<script src="../../script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<% editions = {"gitlab-ce" => "GitLab Community Edition", "gitlab-ee" => "GitLab Enterprise Edition"} %>
|
||||
<h1><%=" #{editions[@edition]} #{@current_version}" %></h1>
|
||||
<h4><a href='<%= "#{@current_version}.json" %>'>Get JSON file</a></h4>
|
||||
<div style="margin-left:10%;margin-right:10%;width:80%;">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr class="header table-head">
|
||||
<td style="width:30%"><b>Library</b></td>
|
||||
<td style="width:25%"><b>Version</b></td>
|
||||
<td><b>License</b></td>
|
||||
<td><b>Status</b></td>
|
||||
<td><b>Reason</b></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<% @json_data.each do |library, details| %>
|
||||
<tr class="header <% if details['reason'] == 'Whitelisted software' %>warning<% end %> <% unless details['dependencies'].empty? %>clickable<% end %>">
|
||||
<td><%= library %></td>
|
||||
<td><%= details['version'] %></td>
|
||||
<td><%= details['license'] %></td>
|
||||
<td><%= details['status'] %></td>
|
||||
<td <% unless details['dependencies'].empty? %>class="deps" <% end %> ><%= details['reason'] %></td>
|
||||
</tr>
|
||||
<% details['dependencies'].each do |dep, dep_details| %>
|
||||
<tr class="<% if dep_details['reason'] == 'Whitelisted software' %>warning<% end %>">
|
||||
<td><%= dep %></td>
|
||||
<td><%= dep_details['version'] %></td>
|
||||
<td><%= dep_details['license'] %></td>
|
||||
<td><%= dep_details['status'] %></td>
|
||||
<td><%= dep_details['reason'] %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
<body>
|
||||
</html>
|
|
@ -8,14 +8,18 @@ module License
|
|||
@edition = Build::Info.package
|
||||
@license_bucket = ENV['LICENSE_S3_BUCKET']
|
||||
@licenses_path = File.absolute_path(@license_bucket)
|
||||
@current_minor_version = Build::Info.release_version.split(".")[0, 2].join(".")
|
||||
@current_version = Build::Info.release_version
|
||||
@current_minor_version = @current_version.split(".")[0, 2].join(".")
|
||||
@license_bucket_region = "eu-west-1"
|
||||
@json_data = nil
|
||||
end
|
||||
|
||||
def execute
|
||||
s3_fetch
|
||||
copy_license
|
||||
generate_html
|
||||
load_data
|
||||
generate_package_webpage
|
||||
generate_edition_webpage
|
||||
s3_upload
|
||||
end
|
||||
|
||||
|
@ -54,11 +58,28 @@ module License
|
|||
#
|
||||
dest_dir = File.join(@licenses_path, @edition, @current_minor_version)
|
||||
FileUtils.mkdir_p(dest_dir)
|
||||
FileUtils.cp("pkg/ubuntu-bionic/license-status.txt", "#{dest_dir}/#{Build::Info.release_version}.license.txt")
|
||||
FileUtils.cp("pkg/ubuntu-bionic/license-status.json", "#{dest_dir}/#{@current_version}.json")
|
||||
end
|
||||
|
||||
def generate_html
|
||||
template = File.read(File.join(File.dirname(__FILE__), "output.html.erb"))
|
||||
def load_data
|
||||
dest_dir = File.join(@licenses_path, @edition, @current_minor_version)
|
||||
@json_data = JSON.parse(File.read("#{dest_dir}/#{@current_version}.json")).sort
|
||||
end
|
||||
|
||||
def generate_package_webpage
|
||||
template = File.read(File.join(File.dirname(__FILE__), "package.html.erb"))
|
||||
output_text = ERB.new(template).result(binding)
|
||||
|
||||
output_path = File.join(@licenses_path, @edition, @current_minor_version, "#{@current_version}.html")
|
||||
FileUtils.mkdir_p(File.dirname(output_path))
|
||||
|
||||
File.open(output_path, "w") do |f|
|
||||
f.write(output_text)
|
||||
end
|
||||
end
|
||||
|
||||
def generate_edition_webpage
|
||||
template = File.read(File.join(File.dirname(__FILE__), "edition.html.erb"))
|
||||
output_text = ERB.new(template).result(binding)
|
||||
|
||||
output_path = File.join(@licenses_path, "#{@edition}.html")
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Thanks to Andreas Eracleous at https://codepen.io/Sp00ky/pen/akVkyV
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
//Fixing jQuery Click Events for the iPad
|
||||
var ua = navigator.userAgent,
|
||||
event = (ua.match(/iPad/i)) ? "touchstart" : "click";
|
||||
if ($('.table').length > 0) {
|
||||
$('.table .header').on(event, function() {
|
||||
$(this).toggleClass("active", "").nextUntil('.header').css('display', function(i, v) {
|
||||
return this.style.display === 'table-row' ? 'none' : 'table-row';
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
|
@ -1,8 +1,68 @@
|
|||
h1, h2 {
|
||||
h1, h2, h3, h4 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.content {
|
||||
margin-left: 5%;
|
||||
width: 90%;
|
||||
body {
|
||||
color: #6a6c6f;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
/*
|
||||
* Thanks to Andreas Eracleous at https://codepen.io/Sp00ky/pen/akVkyV
|
||||
*/
|
||||
|
||||
.table tr.header {
|
||||
font-weight: bold;
|
||||
-webkit-user-select: none;
|
||||
/* Chrome all / Safari all */
|
||||
-moz-user-select: none;
|
||||
/* Firefox all */
|
||||
-ms-user-select: none;
|
||||
/* IE 10+ */
|
||||
user-select: none;
|
||||
/* Likely future */
|
||||
}
|
||||
|
||||
.table tr.clickable{
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
-webkit-user-select: none;
|
||||
/* Chrome all / Safari all */
|
||||
-moz-user-select: none;
|
||||
/* Firefox all */
|
||||
-ms-user-select: none;
|
||||
/* IE 10+ */
|
||||
user-select: none;
|
||||
/* Likely future */
|
||||
}
|
||||
|
||||
.table tr:not(.header) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.table .header td.deps:after {
|
||||
content: "\002b";
|
||||
position: relative;
|
||||
top: 1px;
|
||||
display: inline-block;
|
||||
font-family: 'Glyphicons Halflings';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
line-height: 1;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
float: right;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
padding: 3px;
|
||||
transition: transform .25s linear;
|
||||
-webkit-transition: -webkit-transform .25s linear;
|
||||
}
|
||||
|
||||
.table .header.active td.deps:after {
|
||||
content: "\2212";
|
||||
}
|
||||
|
||||
tr.table-head > td {
|
||||
font-size: larger;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue