Commit f087f49e authored by Tobinsk's avatar Tobinsk
Browse files

Merge branch '3-change-name' into 'master'

Resolve "Change name"

Closes #3

See merge request !4
parents 3f68dfcb 102cadab
# Histhub widget
The histhub widget can display sameas resources from histhub linking services. You can integrate it into your site and display links to other providers. __The widget and the apis are in beta status. They may change in the future.__
# Histhub-net widget
The histhub-net widget can display sameas resources from histhub linking services. You can integrate it into your site and display links to other providers.
__The widget and the api's are in beta status. They may change in the future.__
## Webcomponent
The widget itself is a [webc omponent](https://en.wikipedia.org/wiki/Web_Components). It integrates smoothly into an existing website. You just need to add some markup and load a javascript file.
The widget itself is a [webcomponent](https://en.wikipedia.org/wiki/Web_Components). It integrates smoothly into an existing website. You just need to add some markup and load a javascript file.
## Integration
Just have a look at the examp,e folder. There you can find a set of working examples.
Just have a look at the example folder. There you can find a set of working examples.
```html
<html>
<head>
......@@ -22,6 +24,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
......@@ -30,11 +34,11 @@ The endpoint uses different technologies to generate the links. Those technologi
__Tagcloud and Orgalinker__
For those two services we provide the `resolvermanual` . The links provided by this resolver are done by humans. See examle 1 and example 2
For those two services we provide the `resolvermanual` . The links provided by this resolver are done by humans. See example 1 and example 2
__Geolinker__
The geolinker provides for the `sameas` endpoint the `resolverneo4j` resolver. The links provided by this resolver are done semiautomatical. See example 3
The geolinker provides for the `sameas` endpoint the `resolverneo4j` resolver. The links provided by this resolver are done semi-automatically. See example 3
For the `similarto` endpoint the geolinker provides a `elasticsearchresolver`. The data are guessed based on a matching algorithm. See example 4
......
......@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of the histhub widget (beta) </title>
<title>Example of the histHub-Net widget (beta) </title>
<script src="../src/histhub-widget.js"></script>
<style>
.container {
......@@ -14,7 +14,7 @@
</head>
<body>
<div class="container">
<h1>Example of the histhub widget (beta)</h1>
<h1>Example of the histHub-Net widget (beta)</h1>
<p>The histhub widget can fetch sameas resources for different resoucrces. It makes a simple http request to one of the backends and gets a list of links from there. It finally renders the links in a list and display them.</p>
<histhub-widget endpoint="//api.tagcloud.histhub.ch/v1/sameas/" resolver="resolvermanual" location="https://dodis.ch/T171">
<h3 slot="title">Example 1: Links from tagcloud dodis: Aussenpolitik (allg.)</h3>
......@@ -22,12 +22,15 @@
<histhub-widget endpoint="//api.orgalinker.histhub.ch/v1/sameas/" resolver="resolvermanual" location="https://dodis.ch/R20">
<h3 slot="title">Example 2: Links from orgalinker dodis: Lombard, Odier & Cie</h3>
</histhub-widget>
<histhub-widget endpoint="//api.geolinker.histhub.ch/v1/sameas/" resolver="resolverneo4j" location="https://dodis.ch/G82">
<histhub-widget endpoint="//api.geolinker.histhub.ch/v1-1/sameas/" resolver="resolverneo4j" location="https://dodis.ch/G82">
<h3 slot="title">Example 3: Links (sameas) from geolinker dodis: Diedenhofen</h3>
</histhub-widget>
<histhub-widget endpoint="//api.geolinker.histhub.ch/v1/similarto/" resolver="resolverelasticsearch" location="https://dodis.ch/G82">
<histhub-widget endpoint="//api.geolinker.histhub.ch/v1-1/similarto/" resolver="resolverelasticsearch" location="https://dodis.ch/G82">
<h3 slot="title">Example 4: Links (similarto) from geolinker dodis: Diedenhofen</h3>
</histhub-widget>
<histhub-widget endpoint="//api.geolinker.histhub.ch/v1-1/sameas/" resolver="resolverneo4j" location="https://dodis.ch/G82000000000000">
<h3 slot="title">Example 5: No links (sameas) from geolinker</h3>
</histhub-widget>
</div>
</body>
</html>
......@@ -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 `<li><a href="${href}"> ${anchor}</a></li>`;
});
this._linksSlot.innerHTML = `<ul>${buildLinks().join("")}</ul>`;
// build the list
return `<li><a href="${href}"> ${anchor}</a></li>`;
});
this._linksSlot.innerHTML = `<ul>${buildLinks().join("")}</ul>`;
}
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment