From 4573b5568b096c9512d926cf28a3c28c954a6ced Mon Sep 17 00:00:00 2001 From: Seth Fitzsimmons Date: Fri, 25 Jan 2019 16:35:24 -0800 Subject: [PATCH] Handle proprietary licenses Refs https://github.com/radiantearth/stac-spec/issues/378#issuecomment-457772747 --- src/components/Catalog.vue | 22 ++++++++++++++++++++-- src/components/Item.vue | 26 ++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/components/Catalog.vue b/src/components/Catalog.vue index e87a1a049..18c4a90c0 100644 --- a/src/components/Catalog.vue +++ b/src/components/Catalog.vue @@ -363,8 +363,7 @@ export default { // recommended identifier: this.catalog.id, keywords: this._keywords, - license: - this._license && `https://spdx.org/licenses/${this._license}.html`, + license: this.licenseUrl, isBasedOn: this.url, version: this.version, url: this.path, @@ -429,8 +428,27 @@ export default { ); }, license() { + if (this._license === "proprietary") { + if (this.licenseUrl != null) { + return `${this._license}`; + } + + return this._license; + } + return spdxToHTML(this._license); }, + licenseUrl() { + if (this._license === "proprietary") { + return this.links + .concat((this.rootCatalog && this.rootCatalog.links) || []) + .filter(x => x.rel === "license") + .map(x => x.href) + .pop(); + } + + return `https://spdx.org/licenses/${this._license}.html`; + }, links() { // REQUIRED return this.catalog.links; diff --git a/src/components/Item.vue b/src/components/Item.vue index ce52e3351..f36bb6e9c 100644 --- a/src/components/Item.vue +++ b/src/components/Item.vue @@ -267,8 +267,7 @@ export default { // recommended identifier: this.item.id, keywords: this.keywords, - license: - this._license && `https://spdx.org/licenses/${this._license}.html`, + license: this.licenseUrl, isBasedOn: this.url, url: this.path, includedInDataCatalog: [this.collectionLink, this.parentLink].filter(x => !!x).map( @@ -396,8 +395,31 @@ export default { ); }, license() { + if (this._license === "proprietary") { + if (this.licenseUrl != null) { + return `${this._license}`; + } + + return this._license; + } + return spdxToHTML(this._license); }, + licenseUrl() { + if (this._license === "proprietary") { + return this.links + .concat( + ((this.collection && this.collection.links) || []).concat( + (this.rootCatalog && this.rootCatalog.links) || [] + ) + ) + .filter(x => x.rel === "license") + .map(x => x.href) + .pop(); + } + + return `https://spdx.org/licenses/${this._license}.html`; + }, licensor() { return this.providers .filter(x => x.roles.includes("licensor"))