From 2a936820be12ec18d4c7659ed63261c2ddecc104 Mon Sep 17 00:00:00 2001 From: Tobias Steiner Date: Tue, 9 Jul 2019 17:20:14 +0200 Subject: [PATCH 1/4] Hide the widget if we do not have any links --- examlpe/index.html | 7 +++++-- src/histhub-widget.js | 46 ++++++++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/examlpe/index.html b/examlpe/index.html index bf94e8c..17fa1fc 100644 --- a/examlpe/index.html +++ b/examlpe/index.html @@ -22,12 +22,15 @@

Example 2: Links from orgalinker dodis: Lombard, Odier & Cie

- +

Example 3: Links (sameas) from geolinker dodis: Diedenhofen

- +

Example 4: Links (similarto) from geolinker dodis: Diedenhofen

+ +

Example 5: No links (sameas) from geolinker

+
diff --git a/src/histhub-widget.js b/src/histhub-widget.js index e880111..ea556db 100644 --- a/src/histhub-widget.js +++ b/src/histhub-widget.js @@ -119,28 +119,34 @@ if (this.loading) { this._linksSlot.innerHTML = `Loading data...`; } else { - // small util to build the links - const buildLinks = () => this.links.map((link) => { - let anchor = null; - let href = null; - // check f we get an array or an object - if (typeof link === "object") { - const provider = Object.keys(link)[0]; - // often we do not have information about the provider - if (typeof provider === "string" && provider !== "") { - anchor = provider; + if(this.links.length === 0) { + // hide if there is no data + this._linksSlot.style.display = 'none'; + this._titleSlot.style.display = 'none'; + } else { + // small util to build the links + const buildLinks = () => this.links.map((link) => { + let anchor = null; + let href = null; + // check f we get an array (v1) or an object (v1.1) + if (typeof link === "object") { + const provider = Object.keys(link)[0]; + // often we do not have information about the provider + if (typeof provider === "string" && provider !== "") { + anchor = provider; + } else { + anchor = link[provider]; + } + href = link[provider]; } else { - anchor = link[provider]; + href = link; + anchor = link; } - href = link[provider]; - } else { - href = link; - anchor = link; - } - // build the list - return `
  • ${anchor}
  • `; - }); - this._linksSlot.innerHTML = `
      ${buildLinks().join("")}
    `; + // build the list + return `
  • ${anchor}
  • `; + }); + this._linksSlot.innerHTML = `
      ${buildLinks().join("")}
    `; + } } } } -- GitLab From c793e610571f12b9b05ee8c9a60c90f8acb5fa4e Mon Sep 17 00:00:00 2001 From: Tobias Steiner Date: Tue, 9 Jul 2019 17:21:47 +0200 Subject: [PATCH 2/4] Update the readme with the new geolinker api --- Readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Readme.md b/Readme.md index 53606dd..8ae408a 100644 --- a/Readme.md +++ b/Readme.md @@ -22,6 +22,8 @@ The endpoint defines the restapi, where the widget makes the call to get the lin * Tagcloud https://api.tagcloud.histhub.ch/v1/sameas/ * Geolinker https://api.geolinker.histhub.ch/v1/sameas/ * Geolinker https://api.geolinker.histhub.ch/v1/similarto/ +* Geolinker https://api.geolinker.histhub.ch/v1-1/sameas/ (newer apis) +* Geolinker https://api.geolinker.histhub.ch/v1-1/similarto/ (newer apis) * Orgalinker https://api.orgalinker.histhub.ch/v1/sameas/ Choose one of the endpoint to get links for your resource -- GitLab From f3198292fdfe3154a9318319be63602abcd69202 Mon Sep 17 00:00:00 2001 From: Tobias Steiner Date: Tue, 6 Aug 2019 14:07:16 +0200 Subject: [PATCH 3/4] Change title --- examlpe/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examlpe/index.html b/examlpe/index.html index 17fa1fc..63f1eb0 100644 --- a/examlpe/index.html +++ b/examlpe/index.html @@ -2,7 +2,7 @@ - Example of the histhub widget (beta) + Example of the histHub-Net widget (beta)