@lindas/trifid-plugin-spex 7.0.1 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -40
- package/index.js +2 -2
- package/package.json +6 -7
- package/views/index.hbs +79 -79
package/README.md
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
# trifid-plugin-spex
|
|
2
|
-
|
|
3
|
-
[SPEX](https://github.com/zazuko/spex) for Trifid.
|
|
4
|
-
|
|
5
|
-
This plugin does the static file hosting for all SPEX files and renders a view page that points to the configured endpoint URL.
|
|
6
|
-
|
|
7
|
-
## Quick start
|
|
8
|
-
|
|
9
|
-
Install this Trifid plugin using:
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
npm install trifid-plugin-spex
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
And then add in the `config.yaml` file the following part:
|
|
16
|
-
|
|
17
|
-
```yaml
|
|
18
|
-
plugins:
|
|
19
|
-
# […] your other plugins
|
|
20
|
-
spex:
|
|
21
|
-
module: trifid-plugin-spex
|
|
22
|
-
paths: # by default
|
|
23
|
-
- /spex
|
|
24
|
-
- /spex/
|
|
25
|
-
config:
|
|
26
|
-
prefixes:
|
|
27
|
-
- prefix: ex
|
|
28
|
-
namespace: http://example.org/
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Configuration
|
|
32
|
-
|
|
33
|
-
The following options are supported (all of them optional):
|
|
34
|
-
|
|
35
|
-
- `url`: URL to the SPARQL endpoint which will be used in the SPEX interface
|
|
36
|
-
- `user`: User to connect to the SPARQL endpoint
|
|
37
|
-
- `password`: Password to connect to the SPARQL endpoint
|
|
38
|
-
- `graph`: Default graph to display
|
|
39
|
-
- `prefixes`: List of custom prefixes (e.g. `[{ prefix: 'ex', namespace: 'http://example.org' }]`)
|
|
40
|
-
- `forceIntrospection`: force introspection
|
|
1
|
+
# trifid-plugin-spex
|
|
2
|
+
|
|
3
|
+
[SPEX](https://github.com/zazuko/spex) for Trifid.
|
|
4
|
+
|
|
5
|
+
This plugin does the static file hosting for all SPEX files and renders a view page that points to the configured endpoint URL.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
Install this Trifid plugin using:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install trifid-plugin-spex
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then add in the `config.yaml` file the following part:
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
plugins:
|
|
19
|
+
# […] your other plugins
|
|
20
|
+
spex:
|
|
21
|
+
module: trifid-plugin-spex
|
|
22
|
+
paths: # by default
|
|
23
|
+
- /spex
|
|
24
|
+
- /spex/
|
|
25
|
+
config:
|
|
26
|
+
prefixes:
|
|
27
|
+
- prefix: ex
|
|
28
|
+
namespace: http://example.org/
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
The following options are supported (all of them optional):
|
|
34
|
+
|
|
35
|
+
- `url`: URL to the SPARQL endpoint which will be used in the SPEX interface
|
|
36
|
+
- `user`: User to connect to the SPARQL endpoint
|
|
37
|
+
- `password`: Password to connect to the SPARQL endpoint
|
|
38
|
+
- `graph`: Default graph to display
|
|
39
|
+
- `prefixes`: List of custom prefixes (e.g. `[{ prefix: 'ex', namespace: 'http://example.org' }]`)
|
|
40
|
+
- `forceIntrospection`: force introspection
|
package/index.js
CHANGED
|
@@ -40,9 +40,9 @@ const createPlugin = async (server, config, render) => {
|
|
|
40
40
|
config = { ...defaults, ...config, spexOptions }
|
|
41
41
|
|
|
42
42
|
// Serve static files from SPEX dist folder
|
|
43
|
-
const distPath =
|
|
43
|
+
const distPath = fileURLToPath(resolve('@lindas/spex', import.meta.url))
|
|
44
44
|
server.register(fastifyStatic, {
|
|
45
|
-
root: distPath
|
|
45
|
+
root: dirname(distPath),
|
|
46
46
|
prefix: '/spex/static/',
|
|
47
47
|
decorateReply: false,
|
|
48
48
|
})
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Trifid SPEX plugin",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"version": "7.0.
|
|
6
|
+
"version": "7.0.2",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"homepage": "https://github.com/SwissFederalArchives/lindas-trifid",
|
|
9
9
|
"repository": {
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@fastify/static": "^8.2.0",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"import-meta-resolve": "^4.2.0",
|
|
23
|
+
"@lindas/spex": "^0.2.2"
|
|
24
24
|
},
|
|
25
25
|
"author": {
|
|
26
26
|
"name": "Swiss Federal Archives / Lindas",
|
|
@@ -36,11 +36,10 @@
|
|
|
36
36
|
"views/"
|
|
37
37
|
],
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
39
|
+
"c8": "^10.1.3",
|
|
40
|
+
"@lindas/trifid-core": "^7.0.2"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
|
-
"access": "public"
|
|
44
|
-
"provenance": false
|
|
43
|
+
"access": "public"
|
|
45
44
|
}
|
|
46
45
|
}
|
package/views/index.hbs
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
<div id="container">
|
|
2
|
-
<div id="spex"></div>
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
<script type="text/javascript" src="static/spex.umd.cjs"></script>
|
|
6
|
-
<style type="text/css">
|
|
7
|
-
html,
|
|
8
|
-
body {
|
|
9
|
-
height: 100%;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
body {
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
#container {
|
|
18
|
-
flex-grow: 1;
|
|
19
|
-
|
|
20
|
-
display: flex;
|
|
21
|
-
flex-direction: column;
|
|
22
|
-
|
|
23
|
-
overflow: hidden;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
#container > * {
|
|
27
|
-
flex-grow: 1;
|
|
28
|
-
|
|
29
|
-
overflow: hidden;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
#spex {
|
|
33
|
-
min-height: 100vh;
|
|
34
|
-
}
|
|
35
|
-
</style>
|
|
36
|
-
|
|
37
|
-
<script type="text/javascript">
|
|
38
|
-
//<![CDATA[
|
|
39
|
-
window.onload = function () {
|
|
40
|
-
// where to mount the SPEX app (it will be put in a shodow element)
|
|
41
|
-
const mountPoint = document.createElement("div");
|
|
42
|
-
|
|
43
|
-
// create style element in the shadow element to avoid any style conflicts
|
|
44
|
-
const style = document.createElement("style");
|
|
45
|
-
style.type = "text/css";
|
|
46
|
-
style.innerHTML = "@import url('static/spex.css');"
|
|
47
|
-
|
|
48
|
-
// create the shadow element and put the style element and the mount point
|
|
49
|
-
const spexContainer = document.getElementById("spex");
|
|
50
|
-
const shadowContainer = spexContainer.attachShadow({ mode: "open" });
|
|
51
|
-
shadowContainer.appendChild(style)
|
|
52
|
-
shadowContainer.appendChild(mountPoint);
|
|
53
|
-
|
|
54
|
-
// render the app with the expected options
|
|
55
|
-
const options = JSON.parse('{{{ options }}}');
|
|
56
|
-
window.spex.render(mountPoint, options);
|
|
57
|
-
const spexApp = shadowContainer.querySelector('div');
|
|
58
|
-
|
|
59
|
-
// render the app with a minimal height
|
|
60
|
-
spexApp.style.setProperty('position', 'absolute');
|
|
61
|
-
spexApp.style.setProperty('top', '0');
|
|
62
|
-
spexApp.style.setProperty('bottom', '0');
|
|
63
|
-
spexApp.style.setProperty('left', '0');
|
|
64
|
-
spexApp.style.setProperty('right', '0');
|
|
65
|
-
|
|
66
|
-
// specify some values for colors
|
|
67
|
-
spexApp.style.setProperty('--color-primary-50', '#ffefde');
|
|
68
|
-
spexApp.style.setProperty('--color-primary-100', '#ffe2c4');
|
|
69
|
-
spexApp.style.setProperty('--color-primary-200', '#ffca91');
|
|
70
|
-
spexApp.style.setProperty('--color-primary-300', '#ffb15e');
|
|
71
|
-
spexApp.style.setProperty('--color-primary-400', '#ff982b');
|
|
72
|
-
spexApp.style.setProperty('--color-primary-500', '#f77f00');
|
|
73
|
-
spexApp.style.setProperty('--color-primary-600', '#c46500');
|
|
74
|
-
spexApp.style.setProperty('--color-primary-700', '#914b00');
|
|
75
|
-
spexApp.style.setProperty('--color-primary-800', '#5e3000');
|
|
76
|
-
spexApp.style.setProperty('--color-primary-900', '#2b1600');
|
|
77
|
-
};
|
|
78
|
-
//]]>
|
|
79
|
-
</script>
|
|
1
|
+
<div id="container">
|
|
2
|
+
<div id="spex"></div>
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<script type="text/javascript" src="static/spex.umd.cjs"></script>
|
|
6
|
+
<style type="text/css">
|
|
7
|
+
html,
|
|
8
|
+
body {
|
|
9
|
+
height: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
body {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#container {
|
|
18
|
+
flex-grow: 1;
|
|
19
|
+
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#container > * {
|
|
27
|
+
flex-grow: 1;
|
|
28
|
+
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#spex {
|
|
33
|
+
min-height: 100vh;
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
36
|
+
|
|
37
|
+
<script type="text/javascript">
|
|
38
|
+
//<![CDATA[
|
|
39
|
+
window.onload = function () {
|
|
40
|
+
// where to mount the SPEX app (it will be put in a shodow element)
|
|
41
|
+
const mountPoint = document.createElement("div");
|
|
42
|
+
|
|
43
|
+
// create style element in the shadow element to avoid any style conflicts
|
|
44
|
+
const style = document.createElement("style");
|
|
45
|
+
style.type = "text/css";
|
|
46
|
+
style.innerHTML = "@import url('static/spex.css');"
|
|
47
|
+
|
|
48
|
+
// create the shadow element and put the style element and the mount point
|
|
49
|
+
const spexContainer = document.getElementById("spex");
|
|
50
|
+
const shadowContainer = spexContainer.attachShadow({ mode: "open" });
|
|
51
|
+
shadowContainer.appendChild(style)
|
|
52
|
+
shadowContainer.appendChild(mountPoint);
|
|
53
|
+
|
|
54
|
+
// render the app with the expected options
|
|
55
|
+
const options = JSON.parse('{{{ options }}}');
|
|
56
|
+
window.spex.render(mountPoint, options);
|
|
57
|
+
const spexApp = shadowContainer.querySelector('div');
|
|
58
|
+
|
|
59
|
+
// render the app with a minimal height
|
|
60
|
+
spexApp.style.setProperty('position', 'absolute');
|
|
61
|
+
spexApp.style.setProperty('top', '0');
|
|
62
|
+
spexApp.style.setProperty('bottom', '0');
|
|
63
|
+
spexApp.style.setProperty('left', '0');
|
|
64
|
+
spexApp.style.setProperty('right', '0');
|
|
65
|
+
|
|
66
|
+
// specify some values for colors
|
|
67
|
+
spexApp.style.setProperty('--color-primary-50', '#ffefde');
|
|
68
|
+
spexApp.style.setProperty('--color-primary-100', '#ffe2c4');
|
|
69
|
+
spexApp.style.setProperty('--color-primary-200', '#ffca91');
|
|
70
|
+
spexApp.style.setProperty('--color-primary-300', '#ffb15e');
|
|
71
|
+
spexApp.style.setProperty('--color-primary-400', '#ff982b');
|
|
72
|
+
spexApp.style.setProperty('--color-primary-500', '#f77f00');
|
|
73
|
+
spexApp.style.setProperty('--color-primary-600', '#c46500');
|
|
74
|
+
spexApp.style.setProperty('--color-primary-700', '#914b00');
|
|
75
|
+
spexApp.style.setProperty('--color-primary-800', '#5e3000');
|
|
76
|
+
spexApp.style.setProperty('--color-primary-900', '#2b1600');
|
|
77
|
+
};
|
|
78
|
+
//]]>
|
|
79
|
+
</script>
|