Skip to content

Commit 3a3b978

Browse files
authored
Merge pull request #472 from SpineEventEngine/improve-dependency-reports
Improve dependency reports
2 parents a8eb392 + 89ec1d6 commit 3a3b978

File tree

2 files changed

+53
-53
lines changed

2 files changed

+53
-53
lines changed

js/oss-licenses.js

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
2-
* This is a JavaScript file which loads `license-report` md-files from the external repositories.
2+
* This is a JavaScript file which loads Markdown content from the dependency report files
3+
* via Spine public repositories.
34
*
4-
* Please see `/oss-licenses/index.html` for usage.
5+
* See `/oss-licenses/index.html` for usage.
56
*/
67
'use strict';
78

@@ -12,8 +13,25 @@ $(
1213
const repoAttr = 'repo';
1314
const repoName = 'repo-name';
1415

16+
// Spine repositories are migrated being migrated to listing their deps in this file.
17+
const reportFilePath = '/master/dependencies.md';
18+
19+
// Previously used report file path, as a fallback for non-migrated repos.
20+
const legacyFilePath = '/master/license-report.md';
21+
1522
/**
16-
* Loads `license-report` file from the repository.
23+
* Loads the dependency report file from the repository.
24+
*
25+
* <p>There may be one of two report files present in the repo:
26+
* `license-report.md` or `dependencies.md`.
27+
* The latter is a newer version of the report, so it is loaded
28+
* as a priority. In case it is missing, `license-report.md` is loaded, as a fallback.
29+
* Eventually, all Spine repositories will migrate to having `dependencies.md`.
30+
*
31+
* <p>The report sections describing the terms of use for dual-licensed dependencies,
32+
* and another one with the credits paid to the author of Gradle plugin
33+
* we use for reporting, are removed from DOM, as they are now moved
34+
* to the static part of the page (see `/oss-licenses.index.html`).
1735
*
1836
* <p>Executes by clicking on the corresponding link. The destination `div` element
1937
* should have the `id` like `md-destination-REPO_NAME`.
@@ -26,20 +44,25 @@ $(
2644

2745
if (loaded === 'false') {
2846
const repositoryUrl = clickedElement.attr(repoAttr);
29-
$.get(
30-
repositoryUrl + '/master/license-report.md',
31-
function (data) {
32-
const html = converter.makeHtml(data);
33-
mdDestinationEl.html(html);
34-
clickedElement.attr(loadedAttr, 'true');
35-
makeCollapsibleTitle(mdDestinationEl, clickedElRepoName);
36-
}
37-
);
47+
let processLoadedContent = function (data) {
48+
const html = converter.makeHtml(data);
49+
mdDestinationEl.html(html);
50+
clickedElement.attr(loadedAttr, 'true');
51+
makeCollapsibleTitle(mdDestinationEl, clickedElRepoName);
52+
};
53+
54+
let reportUrl = repositoryUrl + reportFilePath;
55+
let legacyReportUrl = repositoryUrl + legacyFilePath;
56+
57+
$.get(reportUrl, processLoadedContent)
58+
.fail(function () {
59+
$.get(legacyReportUrl, processLoadedContent)
60+
});
3861
}
3962
});
4063

4164
/**
42-
* Makes a `license-report` content collapsible.
65+
* Makes the report content collapsible.
4366
*
4467
* @param mdDestinationEl `div` with the markdown content
4568
* @param clickedElRepoName repository name from the link attribute
@@ -68,7 +91,7 @@ $(
6891
});
6992

7093
/**
71-
* Makes all markdown links external.
94+
* Makes all Markdown links external.
7295
*/
7396
linkElements.addClass('external');
7497
linkElements.attr('target', '_blank');
@@ -81,6 +104,7 @@ $(
81104
const titleID = clickedElRepoName + '-' + this.id + '-md';
82105
const collapsibleContent = $(element).next('ol');
83106
const reportInfoContent = collapsibleContent.next('p');
107+
const whenGeneratedContent = reportInfoContent.next('p');
84108

85109
$(element).addClass('collapse-link collapsed');
86110
$(element).attr('href', '#' + titleID);
@@ -89,35 +113,8 @@ $(
89113
collapsibleContent.addClass('dependencies-container collapse');
90114
collapsibleContent.attr('id', titleID);
91115

92-
reportInfoContent.addClass('report-info collapse');
93-
reportInfoContent.attr('id', titleID + '-p');
94-
});
95-
96-
makeReportInfoCollapsible(mdDestinationEl);
97-
}
98-
99-
/**
100-
* Makes report information content collapsible.
101-
*
102-
* <p>Report information contains a generation date and the name of the plugin.
103-
*
104-
* @param mdDestinationEl it is a `div` with a markdown content
105-
*/
106-
function makeReportInfoCollapsible(mdDestinationEl) {
107-
const reportInfoContent = mdDestinationEl.find('.report-info');
108-
109-
/**
110-
* Inserts a new collapsible title for the paragraph with a report information.
111-
*/
112-
const reportInfoTitleEl = "<h2 class='report-info-title collapse-link collapsed'>Report info</h2>";
113-
$(reportInfoTitleEl).insertBefore(reportInfoContent);
114-
115-
reportInfoContent.each(function (index, element) {
116-
const reportInfoID = this.id;
117-
const reportInfoTitle = $(element).prev('.report-info-title');
118-
119-
reportInfoTitle.attr('href', '#' + reportInfoID);
120-
reportInfoTitle.attr('data-toggle', 'collapse');
116+
reportInfoContent.remove();
117+
whenGeneratedContent.remove();
121118
});
122119
}
123120
}

oss-licenses/index.html

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@
77

88
<div class="row">
99
<div class="col-lg-7">
10-
<p class="page-description">The framework has a number of third-party dependencies. We respect the licensing
11-
term of each library we rely on. Below is a full list of all dependencies along with their licenses,
10+
<p class="page-description">The framework has a number of third-party dependencies.
11+
We respect the licensing term of each library we rely on.
12+
Below is a full list of all dependencies along with their licenses,
1213
grouped by Spine artifact.</p>
14+
15+
<p class="page-description">The dependencies distributed under several licenses,
16+
are used according <br/>to their commercial-use-friendly license.</p>
17+
18+
<p class="page-description">The reports are generated using
19+
<a href="https://github.com/jk1/Gradle-License-Report" class="external"
20+
target="_blank">Gradle-License-Report plugin</a> by Evgeny Naumenko, <br/>
21+
licensed under
22+
<a href="https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE"
23+
class="external" target="_blank">Apache 2.0 License</a>.</p>
1324
</div>
1425
</div>
1526

@@ -94,14 +105,6 @@
94105
aria-controls="md-destination">Spine Money</a>
95106
<div class="collapse license-content" id="md-destination-money">{% include loader.html %}</div>
96107

97-
<a class="collapsible-panel-title collapsed"
98-
repo="https://raw.githubusercontent.com/SpineEventEngine/users"
99-
repo-name="users"
100-
loaded="false"
101-
href="#md-destination-users"
102-
data-toggle="collapse"
103-
aria-expanded="false"
104-
aria-controls="md-destination">Spine Users</a>
105108
<div class="collapse license-content" id="md-destination-users">{% include loader.html %}</div>
106109
</div>
107110

0 commit comments

Comments
 (0)