@matdata/yasr 4.6.1
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/CHANGELOG.md +150 -0
- package/build/ts/src/bindingsToCsv.d.ts +2 -0
- package/build/ts/src/defaults.d.ts +2 -0
- package/build/ts/src/helpers/addCSS.d.ts +1 -0
- package/build/ts/src/helpers/addScript.d.ts +1 -0
- package/build/ts/src/helpers/index.d.ts +3 -0
- package/build/ts/src/helpers/sanitize.d.ts +2 -0
- package/build/ts/src/imgs.d.ts +4 -0
- package/build/ts/src/index.d.ts +130 -0
- package/build/ts/src/parsers/csv.d.ts +2 -0
- package/build/ts/src/parsers/index.d.ts +68 -0
- package/build/ts/src/parsers/json.d.ts +2 -0
- package/build/ts/src/parsers/tsv.d.ts +2 -0
- package/build/ts/src/parsers/turtleFamily.d.ts +4 -0
- package/build/ts/src/parsers/xml.d.ts +2 -0
- package/build/ts/src/plugins/boolean/index.d.ts +13 -0
- package/build/ts/src/plugins/error/index.d.ts +13 -0
- package/build/ts/src/plugins/index.d.ts +19 -0
- package/build/ts/src/plugins/response/index.d.ts +28 -0
- package/build/ts/src/plugins/table/index.d.ts +49 -0
- package/build/yasr.html +32 -0
- package/build/yasr.min.css +2 -0
- package/build/yasr.min.css.map +1 -0
- package/build/yasr.min.js +3 -0
- package/build/yasr.min.js.LICENSE.txt +34 -0
- package/build/yasr.min.js.map +1 -0
- package/package.json +56 -0
- package/src/bin/takeScreenshot.js +373 -0
- package/src/bindingsToCsv.ts +18 -0
- package/src/defaults.ts +28 -0
- package/src/helpers/addCSS.ts +7 -0
- package/src/helpers/addScript.ts +12 -0
- package/src/helpers/index.ts +3 -0
- package/src/helpers/sanitize.ts +11 -0
- package/src/imgs.ts +7 -0
- package/src/index.ts +688 -0
- package/src/jquery/extendJquery.js +1 -0
- package/src/jquery/tableToCsv.js +88 -0
- package/src/main.scss +229 -0
- package/src/parsers/csv.ts +30 -0
- package/src/parsers/index.ts +311 -0
- package/src/parsers/json.ts +22 -0
- package/src/parsers/tsv.ts +43 -0
- package/src/parsers/turtleFamily.ts +60 -0
- package/src/parsers/xml.ts +79 -0
- package/src/plugins/boolean/index.scss +11 -0
- package/src/plugins/boolean/index.ts +42 -0
- package/src/plugins/error/index.scss +57 -0
- package/src/plugins/error/index.ts +124 -0
- package/src/plugins/index.ts +24 -0
- package/src/plugins/response/index.scss +63 -0
- package/src/plugins/response/index.ts +170 -0
- package/src/plugins/table/index.scss +154 -0
- package/src/plugins/table/index.ts +437 -0
- package/src/scss/global.scss +10 -0
- package/src/scss/variables.scss +2 -0
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@matdata/yasr",
|
|
3
|
+
"description": "Yet Another SPARQL Resultset GUI",
|
|
4
|
+
"version": "4.6.1",
|
|
5
|
+
"main": "build/yasr.min.js",
|
|
6
|
+
"types": "build/ts/src/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Triply <info@triply.cc>",
|
|
9
|
+
"homepage": "https://github.com/Matdata-eu/Yasgui",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">= 8"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"JavaScript",
|
|
15
|
+
"SPARQL",
|
|
16
|
+
"Editor",
|
|
17
|
+
"Semantic Web",
|
|
18
|
+
"Linked Data"
|
|
19
|
+
],
|
|
20
|
+
"bugs": "https://github.com/Matdata-eu/Yasgui/issues/",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/Matdata-eu/Yasgui.git",
|
|
24
|
+
"directory": "packages/yasr"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@fortawesome/free-solid-svg-icons": "^5.14.0",
|
|
28
|
+
"@json2csv/plainjs": "^7.0.4",
|
|
29
|
+
"@matdata/yasgui-utils": "^4.6.1",
|
|
30
|
+
"@matdata/yasqe": "^4.6.1",
|
|
31
|
+
"codemirror": "^5.51.0",
|
|
32
|
+
"colors": "^1.4.0",
|
|
33
|
+
"column-resizer": "^1.4.0",
|
|
34
|
+
"datatables.net": "^2.0.5",
|
|
35
|
+
"datatables.net-dt": "^2.0.5",
|
|
36
|
+
"dompurify": "^3.2.4",
|
|
37
|
+
"jquery": "^3.7.1",
|
|
38
|
+
"lodash-es": "^4.17.15",
|
|
39
|
+
"n3": "^1.3.5",
|
|
40
|
+
"papaparse": "^5.3.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/codemirror": "0.0.100",
|
|
44
|
+
"@types/jquery": "^3.5.32",
|
|
45
|
+
"@types/lodash-es": "^4.17.3",
|
|
46
|
+
"@types/n3": "^1.1.5",
|
|
47
|
+
"@types/node": "^22.5.4",
|
|
48
|
+
"@types/papaparse": "^5.3.2",
|
|
49
|
+
"@types/sanitize-html": "^1.20.2",
|
|
50
|
+
"better-npm-run": "^0.1.1",
|
|
51
|
+
"ts-essentials": "^7.0.1"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
const puppeteer = require("puppeteer");
|
|
2
|
+
const static = require("node-static");
|
|
3
|
+
const http = require("http");
|
|
4
|
+
const PORT = 40001;
|
|
5
|
+
|
|
6
|
+
// const endpoint = "https://api.nightly.triply.cc/datasets/gerwinbosch/Triply-pets/services/Triply-pets/sparql";
|
|
7
|
+
// const plugin = "gallery";
|
|
8
|
+
// const query = `
|
|
9
|
+
//
|
|
10
|
+
//
|
|
11
|
+
// PREFIX wrongrdfs: <https://www.w3.org/2000/01/rdf-schema#>
|
|
12
|
+
// PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
|
13
|
+
// PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
14
|
+
// PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
|
15
|
+
// SELECT Distinct ?cat ?image ?name ?widget WHERE {
|
|
16
|
+
// ?cat foaf:depiction ?image .
|
|
17
|
+
// bind('<div><img src="{{image}}"/></div>' as ?widget)
|
|
18
|
+
// } LIMIT 10
|
|
19
|
+
//
|
|
20
|
+
//
|
|
21
|
+
// `;
|
|
22
|
+
|
|
23
|
+
// const endpoint = "https://api.druid.datalegend.net/datasets/dataLegend/Catasto/services/Catasto/sparql";
|
|
24
|
+
// const plugin = "table";
|
|
25
|
+
// const query = `
|
|
26
|
+
//
|
|
27
|
+
//
|
|
28
|
+
// PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
29
|
+
// PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
30
|
+
// PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
|
31
|
+
// PREFIX catastodim: <https://iisg.amsterdam/catasto/dimension/>
|
|
32
|
+
// PREFIX catasto: <https://iisg.amsterdam/catasto/>
|
|
33
|
+
// PREFIX catastoregion: <https://iisg.amsterdam/catasto/code/NUMSER/>
|
|
34
|
+
//
|
|
35
|
+
// SELECT ?occupation (count(distinct ?sub) as ?n_hh) (round(avg(?wealth)) as ?avg_wealth_rounded) (avg(?hh_members) as ?avg_hh_members) WHERE
|
|
36
|
+
// { SELECT (count(?members) as ?hh_members) ?occupation ?sub ?wealth
|
|
37
|
+
//
|
|
38
|
+
// WHERE {
|
|
39
|
+
//
|
|
40
|
+
// ?sub catastodim:householdMember ?members ;
|
|
41
|
+
// catastodim:TOTAL ?wealth ;
|
|
42
|
+
// catastodim:DEDUCT ?debt ;
|
|
43
|
+
// catastodim:CREANCE ?pubcred ;
|
|
44
|
+
// catastodim:CREDPUB ?privcred ;
|
|
45
|
+
// catastodim:NUMSER catastoregion:1 .
|
|
46
|
+
// ?sub catastodim:METIER ?occ .
|
|
47
|
+
// ?occ skos:altLabel ?occupationlabel .
|
|
48
|
+
//
|
|
49
|
+
// BIND(STR(?occupationlabel) as ?occupation)
|
|
50
|
+
// FILTER(?wealth > 1500)
|
|
51
|
+
// }}
|
|
52
|
+
//
|
|
53
|
+
// ORDER BY DESC(?n_hh)
|
|
54
|
+
// LIMIT 10
|
|
55
|
+
//
|
|
56
|
+
//
|
|
57
|
+
//
|
|
58
|
+
// `;
|
|
59
|
+
|
|
60
|
+
const endpoint =
|
|
61
|
+
"https://api.druid.datalegend.net/datasets/netwerk-maritieme-bronnen/demo-netwerk-maritieme-bronnen/services/demo-netwerk-maritieme-bronnen/sparql";
|
|
62
|
+
const plugin = "geo";
|
|
63
|
+
const query = `
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
prefix dce: <http://purl.org/dc/elements/1.1/>
|
|
67
|
+
prefix das: <https://demo.triply.cc/huygens-ing/dutch-asiatic-shipping/>
|
|
68
|
+
prefix edm: <http://www.europeana.eu/schemas/edm/>
|
|
69
|
+
prefix foaf: <http://xmlns.com/foaf/0.1/>
|
|
70
|
+
prefix geo: <http://www.opengis.net/ont/geosparql#>
|
|
71
|
+
prefix misc: <https://demo.triply.cc/huygens-ing/graph/misc/>
|
|
72
|
+
prefix owl: <http://www.w3.org/2002/07/owl#>
|
|
73
|
+
prefix ship: <https://demo.triply.cc/huygens-ing/dutch-asiatic-shipping/id/ship/>
|
|
74
|
+
prefix wgs84: <http://www.w3.org/2003/01/geo/wgs84_pos#>
|
|
75
|
+
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
|
|
76
|
+
select * {
|
|
77
|
+
bind(ship:DAS_ship0010 as ?ship)# 't Vliegend Hart' == DAS_ship0010
|
|
78
|
+
?voyage
|
|
79
|
+
das:shipid ?ship;
|
|
80
|
+
das:voyarrivalplaceid [
|
|
81
|
+
das:toponym_original ?arrivalName;
|
|
82
|
+
owl:sameAs [ wgs84:lat ?arrivalLat; wgs84:long ?arrivalLong]];
|
|
83
|
+
das:voydepartureplaceid [
|
|
84
|
+
das:toponym_original ?departureName;
|
|
85
|
+
owl:sameAs [ wgs84:lat ?departureLat; wgs84:long ?departureLong]].
|
|
86
|
+
bind(strdt(concat('Point(',?arrivalLong,' ',?arrivalLat,')'),geo:wktLiteral) as ?arrivalShape)
|
|
87
|
+
bind(strdt(concat('Point(',?departureLong,' ',?departureLat,')'),geo:wktLiteral) as ?departureShape)
|
|
88
|
+
optional {
|
|
89
|
+
[ dce:creator ?departureImageCreator;
|
|
90
|
+
dce:description ?departureImageDescription;
|
|
91
|
+
foaf:depiction ?departureImage1;
|
|
92
|
+
misc:place ?departureName;
|
|
93
|
+
misc:year ?departureImageYear].
|
|
94
|
+
optional {
|
|
95
|
+
[ edm:isShownAt ?departureImage1;
|
|
96
|
+
edm:isShownBy ?departureImage2;
|
|
97
|
+
edm:provider ?departureProvider].
|
|
98
|
+
}
|
|
99
|
+
bind(if(bound(?departureImage1)&&strends(str(?departureImage1),'.jpg'),?departureImage1,?departureImage2) as ?departureImageUrl)
|
|
100
|
+
}
|
|
101
|
+
bind(if(bound(?departureImageUrl),'<img src="{{departureImageUrl}}" style="width:300px;height:300px;">','') as ?departureImg)
|
|
102
|
+
optional {
|
|
103
|
+
[ dce:creator ?arrivalImageCreator;
|
|
104
|
+
dce:description ?arrivalImageDescription;
|
|
105
|
+
foaf:depiction ?arrivalImage1;
|
|
106
|
+
misc:place ?arrivalName;
|
|
107
|
+
misc:year ?arrivalImageYear].
|
|
108
|
+
optional {
|
|
109
|
+
[ edm:isShownAt ?arrivalImage1;
|
|
110
|
+
edm:isShownBy ?arrivalImage2].
|
|
111
|
+
}
|
|
112
|
+
bind(if(bound(?arrivalImage1),?arrivalImage1,?arrivalImage2) as ?arrivalImageUrl)
|
|
113
|
+
}
|
|
114
|
+
bind(if(bound(?arrivalImageUrl),'<img src="{{arrivalImageUrl}}" style="width:300px;height:300px;">','') as ?arrivalImg)
|
|
115
|
+
bind(<http://sws.geonames.org/3367577/> as ?kaap)
|
|
116
|
+
?kaap wgs84:lat ?latKaap; wgs84:long ?longKaap.
|
|
117
|
+
bind(strdt(concat('Point(',?longKaap,' ',?latKaap,')'),geo:wktLiteral) as ?restShape)
|
|
118
|
+
optional {
|
|
119
|
+
[ dce:creator ?restImageCreator;
|
|
120
|
+
dce:description ?restImageDescription;
|
|
121
|
+
foaf:depiction ?restImage;
|
|
122
|
+
misc:ExternalGeoIdentifier ?kaap;
|
|
123
|
+
misc:place ?restName;
|
|
124
|
+
misc:year ?restImageYear].
|
|
125
|
+
filter(strends(str(?restImage),'.jpg'))
|
|
126
|
+
}
|
|
127
|
+
bind(strdt(if(xsd:integer(?departureLat)>45,
|
|
128
|
+
concat('LineString(',?departureLong,' ',?departureLat,',3.07966 51.77924,1.34205 50.87258,-2.08131 49.93115,-5.33326 48.67037,-9.77174 43.27050,-11.44166 36.68907,-14.78151 28.71317,-19.00026 18.92025,-23.87345 12.6475,-30.5023 -10.39992,-33.11856 -18.33260,-31.73428 -27.76883,-29.9325 -32.07113,-27.9500 -34.08019,-26.13816 -35.75632,-23.80906 -37.13492,-20.90867 -37.65861,-15.32761 -37.86705,-6.80222 -37.41468,2.64602 -36.71335,8.0073 -36.1831,12.36839 -36.07712,',?longKaap,' ',?latKaap,',18.35680 -35.39930,20.55277 -36.59887,26.11185 -37.56297,36.15953 -37.76297,44.45902 -38.03175,72.07865 -38.13552,97.47012 -38.35985,100.16931 -37.15799,102.45447 -35.40458,103.81677 -33.19029,104.45398 -29.83812,105.09119 -24.40449,104.82752 -17.17519,103.15760 -11.10593,',?arrivalLong,' ',?arrivalLat,')'),
|
|
129
|
+
concat('LineString(',?departureLong,' ',?departureLat,',74.5229 7.69870,71.78581 7.03825,69.14909 5.55316,65.91911 2.85805,62.66716 -0.83214,60.38200 -4.60650,57.21794 -11.21877,54.93278 -16.42287,52.82341 -21.89969,49.25455 -27.66664,42.75065 -31.18710,36.07096 -33.70848,28.51237 -36.15797,21.65690 -37.14512,',?longKaap,' ',?latKaap,',17.03490 -34.35846,14.92553 -30.50223,11.11303 -23.29844,5.65209 -15.34412,-8.80494 2.39809,-17.59401 10.08075,-22.00026 16.52025,-28.7247 30.78764,-26.85550 37.54813,-21.58206 43.00792,-17.01175 46.65251,-12.0898 48.75189,-6.03727 49.37919,-0.956103 50.02224,2.53750 51.63169,',?arrivalLong,' ',?arrivalLat,')')),
|
|
130
|
+
geo:wktLiteral) as ?shape3)
|
|
131
|
+
?voyage
|
|
132
|
+
das:voydepartureedtf ?departureDate;
|
|
133
|
+
das:voycapedepartureedtf ?depCapeDate;
|
|
134
|
+
das:voyarrivaldateedtf ?arrivalDate;
|
|
135
|
+
das:voycapearrivaledtf ?arrCapeDate.
|
|
136
|
+
bind((?arrivalDate-?departureDate) / (24*60*60) as ?days)
|
|
137
|
+
bind('''
|
|
138
|
+
Vertrokken van {{departureName}}: {{departureDate}}<br>
|
|
139
|
+
Aangekomen op {{restName}}: {{arrCapeDate}}<br>
|
|
140
|
+
Vertrokken van {{restName}}: {{depCapeDate}}<br>
|
|
141
|
+
Aangekomen in {{arrivalName}}: {{arrivalDate}}<br>
|
|
142
|
+
Duur van de reis: {{days}} dagen
|
|
143
|
+
''' as ?shape3Label)
|
|
144
|
+
bind(if(bound(?departureImageDescription),
|
|
145
|
+
'''
|
|
146
|
+
<h3>{{departureName}}</h3>
|
|
147
|
+
<p>Vertrokken op {{departureDate}}</p>
|
|
148
|
+
<figure>
|
|
149
|
+
{{departureImg}}
|
|
150
|
+
<figcaption>
|
|
151
|
+
“{{departureImageDescription}}” door {{departureImageCreator}}, {{departureImageYear}} [Herkomstcollectie: {{departureProvider}}].
|
|
152
|
+
</figcaption>
|
|
153
|
+
</figure>
|
|
154
|
+
''',
|
|
155
|
+
'''<h3>{{departureName}}</h3>
|
|
156
|
+
<p>Vertrokken op {{departureDate}}</p>
|
|
157
|
+
''') as ?departureShapeLabel)
|
|
158
|
+
bind('''
|
|
159
|
+
<h3>{{arrivalName}}</h3>
|
|
160
|
+
<p>Aangekomen op {{arrivalDate}}</p>
|
|
161
|
+
<figure>
|
|
162
|
+
{{arrivalImg}}
|
|
163
|
+
<figcaption>
|
|
164
|
+
{{arrivalImageDescription}} door {{arrivalImageCreator}}, {{arrivalImageYear}} [Herkomstcollectie: Nationaal Archief].
|
|
165
|
+
</figcaption>
|
|
166
|
+
</figure>
|
|
167
|
+
''' as ?arrivalShapeLabel)
|
|
168
|
+
bind('''
|
|
169
|
+
<h3>{{restName}}</h3>
|
|
170
|
+
<p>Aangekomen op {{arrCapeDate}}</br>Vertrokken op {{depCapeDate}}</p>
|
|
171
|
+
<figure>
|
|
172
|
+
<img src="{{restImage}}" style="width:300px;height:300px;">
|
|
173
|
+
<figcaption>
|
|
174
|
+
“{{restImageDescription}}” door {{restImageCreator}}, {{restImageYear}} [Herkomstcollectie: Nationaal Archief].
|
|
175
|
+
</figcaption>
|
|
176
|
+
</figure>
|
|
177
|
+
''' as ?restShapeLabel)
|
|
178
|
+
bind(if(strends(str(?voyage),'6'),'green','red') as ?shape3Color)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
`;
|
|
184
|
+
|
|
185
|
+
// const endpoint = "http://dbpedia.org/sparql";
|
|
186
|
+
// const plugin = "geo";
|
|
187
|
+
// const query = `
|
|
188
|
+
//
|
|
189
|
+
//
|
|
190
|
+
// prefix geo: <http://www.opengis.net/ont/geosparql#>
|
|
191
|
+
// select * {
|
|
192
|
+
// #Testing points and polygons with a tooltip
|
|
193
|
+
// bind("Point(5.89118305 50.94279662)"^^geo:wktLiteral as ?tooltip_point)
|
|
194
|
+
// bind("Polygon((5.86118305 50.99279662, 5.96118305 50.99279662, 5.86118305 50.89279662))"^^geo:wktLiteral as ?tooltip_polygon)
|
|
195
|
+
// bind("Polygon((5.88118305 50.99279662, 5.96118305 50.99279662, 5.86118305 50.89279662))"^^geo:wktLiteral as ?tooltip_smallerPolygon)
|
|
196
|
+
// bind("tooltip_pointTooltip" as ?tooltip_pointTooltip)
|
|
197
|
+
// bind("tooltip_polygonTooltip" as ?tooltip_polygonTooltip)
|
|
198
|
+
// bind("tooltip_smallerPolygonTooltip" as ?tooltip_smallerPolygonTooltip)
|
|
199
|
+
//
|
|
200
|
+
// #Testing points and polygons with a label
|
|
201
|
+
// bind("Point(6.19118305 50.94279662)"^^geo:wktLiteral as ?label_point)
|
|
202
|
+
// bind("Polygon((6.16118305 50.99279662, 6.96118305 50.99279662, 6.16118305 50.89279662))"^^geo:wktLiteral as ?label_polygon)
|
|
203
|
+
// bind("Polygon((6.18118305 50.99279662, 6.96118305 50.99279662, 6.16118305 50.89279662))"^^geo:wktLiteral as ?label_smallerPolygon)
|
|
204
|
+
// bind("label_pointLabel" as ?label_pointLabel)
|
|
205
|
+
// bind("rgb(255, 0, 0)" as ?label_pointColor)
|
|
206
|
+
// bind("label_polygonLabel" as ?label_polygonLabel)
|
|
207
|
+
// bind("rgb(221, 208, 0)" as ?label_polygonColor)
|
|
208
|
+
// bind("label_smallerPolygonLabel" as ?label_smallerPolygonLabel)
|
|
209
|
+
// bind("rgb(176, 153, 153)" as ?label_smallerPolygonColor)
|
|
210
|
+
// }
|
|
211
|
+
//
|
|
212
|
+
//
|
|
213
|
+
// `;
|
|
214
|
+
|
|
215
|
+
const getHtml = (plugin) => `
|
|
216
|
+
|
|
217
|
+
<!DOCTYPE html>
|
|
218
|
+
<html lang="en">
|
|
219
|
+
|
|
220
|
+
<head>
|
|
221
|
+
<meta charset="utf-8" />
|
|
222
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
223
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
224
|
+
<title>YASR</title>
|
|
225
|
+
<link rel="icon" type="image/png" href="doc/imgs/favicon.png" />
|
|
226
|
+
|
|
227
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill.js"></script>
|
|
228
|
+
<style>
|
|
229
|
+
body {
|
|
230
|
+
font-family: 'Roboto', sans-serif;
|
|
231
|
+
}
|
|
232
|
+
</style>
|
|
233
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" />
|
|
234
|
+
<link rel="stylesheet" href="build/yasr.min.css" />
|
|
235
|
+
<link rel="stylesheet" href="build/pro-gallery.min.css">
|
|
236
|
+
<link rel="stylesheet" href="build/pro-geo.min.css">
|
|
237
|
+
<link rel="stylesheet" href="build/pro-geo3d.min.css">
|
|
238
|
+
<link rel="stylesheet" href="build/pro-gchart.min.css">
|
|
239
|
+
<link href="./node_modules/@zazuko/yasqe/build/yasqe.min.css" rel="stylesheet">
|
|
240
|
+
</head>
|
|
241
|
+
|
|
242
|
+
<body>
|
|
243
|
+
<div id="yasqe"></div>
|
|
244
|
+
<div id="yasr"></div>
|
|
245
|
+
|
|
246
|
+
<script src="build/yasr.min.js"></script>
|
|
247
|
+
<script src="build/pro-gallery.min.js"></script>
|
|
248
|
+
<script src="build/pro-geo.min.js"></script>
|
|
249
|
+
<script src="build/pro-geo3d.min.js"></script>
|
|
250
|
+
<script src="build/pro-gchart.min.js"></script>
|
|
251
|
+
<script src="./node_modules/@zazuko/yasqe/build/yasqe.min.js"></script>
|
|
252
|
+
<script type="text/javascript">
|
|
253
|
+
window.onload = function () {
|
|
254
|
+
console.log('onload')
|
|
255
|
+
window.yasqe = Yasqe(document.getElementById("yasqe"), {
|
|
256
|
+
requestConfig: {
|
|
257
|
+
endpoint: "${endpoint}"
|
|
258
|
+
},
|
|
259
|
+
value: \`
|
|
260
|
+
${query}
|
|
261
|
+
\`
|
|
262
|
+
});
|
|
263
|
+
yasqe.on("queryResponse", function (yasqe, response, duration) {
|
|
264
|
+
|
|
265
|
+
console.log({
|
|
266
|
+
response: response
|
|
267
|
+
})
|
|
268
|
+
window.yasr.setResponse(response, duration);
|
|
269
|
+
});
|
|
270
|
+
yasqe.query();
|
|
271
|
+
window.yasr = Yasr(document.getElementById("yasr"), {
|
|
272
|
+
prefixes: function () {
|
|
273
|
+
yasqe.getPrefixesFromQuery();
|
|
274
|
+
},
|
|
275
|
+
defaultPlugin: "${plugin}",
|
|
276
|
+
//Disable persisting settings. Makes it easier to use this file for our puppeteer tests
|
|
277
|
+
persistenceId: null,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
};
|
|
281
|
+
</script>
|
|
282
|
+
</body>
|
|
283
|
+
|
|
284
|
+
</html>
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
`;
|
|
290
|
+
|
|
291
|
+
const getScreenWidth = (plugin) => {
|
|
292
|
+
switch (plugin) {
|
|
293
|
+
case "geo":
|
|
294
|
+
// case "table":
|
|
295
|
+
return 1200;
|
|
296
|
+
// return 831;
|
|
297
|
+
case "gallery":
|
|
298
|
+
return 900;
|
|
299
|
+
default:
|
|
300
|
+
return 1920;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
let staticFileServer = new static.Server("./");
|
|
305
|
+
function setupServer () {
|
|
306
|
+
return new Promise((resolve, reject) => {
|
|
307
|
+
var server = http
|
|
308
|
+
.createServer(function (request, response) {
|
|
309
|
+
if (request.url === "/") return response.end(getHtml(plugin));
|
|
310
|
+
request
|
|
311
|
+
.addListener("end", function () {
|
|
312
|
+
staticFileServer.serve(request, response);
|
|
313
|
+
})
|
|
314
|
+
.resume();
|
|
315
|
+
})
|
|
316
|
+
.listen(PORT, "localhost", () => {
|
|
317
|
+
resolve(server);
|
|
318
|
+
})
|
|
319
|
+
.on("error", (e) => reject(e));
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
function wait (time) {
|
|
323
|
+
return new Promise((resolve) => setTimeout(resolve, time));
|
|
324
|
+
}
|
|
325
|
+
function waitForImagesToLoad (page) {
|
|
326
|
+
return page.evaluate(() => {
|
|
327
|
+
const selectors = Array.from(document.querySelectorAll("img"));
|
|
328
|
+
return Promise.all(
|
|
329
|
+
selectors.map((img) => {
|
|
330
|
+
if (img.complete) return;
|
|
331
|
+
return new Promise((resolve, reject) => {
|
|
332
|
+
img.addEventListener("load", resolve);
|
|
333
|
+
img.addEventListener("error", reject);
|
|
334
|
+
});
|
|
335
|
+
})
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
(async () => {
|
|
341
|
+
const server = await setupServer();
|
|
342
|
+
const browser = await puppeteer.launch({
|
|
343
|
+
headless: false,
|
|
344
|
+
// devtools: true,
|
|
345
|
+
args: [process.env["NO_SANDBOX"] ? "--no-sandbox" : ""],
|
|
346
|
+
});
|
|
347
|
+
const page = await browser.newPage();
|
|
348
|
+
await page.setViewport({ width: getScreenWidth(plugin), height: 1200 });
|
|
349
|
+
await page.goto(`http://localhost:${PORT}`, { waitUntil: ["load", "domcontentloaded", "networkidle0"] });
|
|
350
|
+
//Wait for results to be drawn
|
|
351
|
+
// await page.waitForFunction('document.getElementsByClassName("yasr_results")[0].childElementCount > 0');
|
|
352
|
+
// await waitForImagesToLoad(page);
|
|
353
|
+
// await wait(100);
|
|
354
|
+
const clip = await page.evaluate(() => {
|
|
355
|
+
const rect = document.querySelector(".yasr_results").getBoundingClientRect();
|
|
356
|
+
return {
|
|
357
|
+
x: rect.left,
|
|
358
|
+
y: rect.top,
|
|
359
|
+
width: rect.width,
|
|
360
|
+
height: rect.height,
|
|
361
|
+
};
|
|
362
|
+
});
|
|
363
|
+
// eslint-disable-next-line no-console
|
|
364
|
+
console.log(clip);
|
|
365
|
+
await page.screenshot({
|
|
366
|
+
path: "screenshot.png",
|
|
367
|
+
fullPage: false,
|
|
368
|
+
clip: clip,
|
|
369
|
+
});
|
|
370
|
+
await page.close();
|
|
371
|
+
await browser.close();
|
|
372
|
+
await server.close();
|
|
373
|
+
})();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Parser from "./parsers";
|
|
2
|
+
import * as json2csv from "@json2csv/plainjs";
|
|
3
|
+
import { mapValues } from "lodash-es";
|
|
4
|
+
export default function (result: Parser.SparqlResults) {
|
|
5
|
+
const variables = result.head.vars;
|
|
6
|
+
|
|
7
|
+
const querySolutions = result.results?.bindings;
|
|
8
|
+
|
|
9
|
+
const json2csvParser = new json2csv.Parser({ fields: variables });
|
|
10
|
+
|
|
11
|
+
return json2csvParser.parse(
|
|
12
|
+
querySolutions
|
|
13
|
+
? querySolutions.map((s) => {
|
|
14
|
+
return mapValues(s, (binding) => binding.value);
|
|
15
|
+
})
|
|
16
|
+
: []
|
|
17
|
+
);
|
|
18
|
+
}
|
package/src/defaults.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Config } from "./";
|
|
2
|
+
export default function get(): Config {
|
|
3
|
+
return {
|
|
4
|
+
persistenceId: function (yasr) {
|
|
5
|
+
//Traverse parents untl we've got an id
|
|
6
|
+
// Get matching parent elements
|
|
7
|
+
var id = "";
|
|
8
|
+
var elem: any = yasr.rootEl;
|
|
9
|
+
if ((<any>elem).id) id = (<any>elem).id;
|
|
10
|
+
for (; elem && elem !== <any>document; elem = elem.parentNode) {
|
|
11
|
+
if (elem) {
|
|
12
|
+
if ((<any>elem).id) id = (<any>elem).id;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return "yasr_" + id;
|
|
17
|
+
},
|
|
18
|
+
getPlainQueryLinkToEndpoint: undefined,
|
|
19
|
+
persistencyExpire: 60 * 60 * 24 * 30,
|
|
20
|
+
persistenceLabelResponse: "response",
|
|
21
|
+
persistenceLabelConfig: "config",
|
|
22
|
+
maxPersistentResponseSize: 100000,
|
|
23
|
+
prefixes: {},
|
|
24
|
+
plugins: {},
|
|
25
|
+
pluginOrder: ["table", "response"], // Default plugins, others are sorted alphabetically
|
|
26
|
+
defaultPlugin: "table",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export default function addCss(href: string) {
|
|
2
|
+
var link = document.createElement("link");
|
|
3
|
+
link.setAttribute("rel", "stylesheet");
|
|
4
|
+
link.setAttribute("type", "text/css");
|
|
5
|
+
link.setAttribute("href", href);
|
|
6
|
+
document.getElementsByTagName("head")[0].appendChild(link);
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default function addScript(src: string, text?: string): Promise<void> {
|
|
2
|
+
return new Promise<void>((resolve, _reject) => {
|
|
3
|
+
var s = document.createElement("script");
|
|
4
|
+
s.setAttribute("type", "text/javascript");
|
|
5
|
+
s.setAttribute("async", "");
|
|
6
|
+
s.setAttribute("src", src);
|
|
7
|
+
|
|
8
|
+
if (text) s.innerHTML = text;
|
|
9
|
+
s.onload = () => resolve();
|
|
10
|
+
document.getElementsByTagName("head")[0].appendChild(s);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DOMPurify from "dompurify";
|
|
2
|
+
DOMPurify.addHook("afterSanitizeAttributes", (node) => {
|
|
3
|
+
if (node instanceof HTMLAnchorElement) {
|
|
4
|
+
node.target = "_blank";
|
|
5
|
+
node.rel = "noopener noreferrer";
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
//Casting to simple function. That way, any lib that depends on us
|
|
10
|
+
//wont have to require installing dompurify types
|
|
11
|
+
export default DOMPurify.sanitize as (val: string | Node) => string;
|
package/src/imgs.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var download =
|
|
2
|
+
'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="tiny" x="0" y="0" width="100%" height="100%" viewBox="0 0 100 100" xml:space="preserve"><g id="Captions"/><g id="Your_Icon"><path d="M88,84v-2c0-2.961-0.859-4-4-4H16c-2.961,0-4,0.98-4,4v2c0,3.102,1.039,4,4,4h68 C87.02,88,88,87.039,88,84z M58,12H42c-5,0-6,0.941-6,6v22H16l34,34l34-34H64V18C64,12.941,62.939,12,58,12z"/></g></svg>';
|
|
3
|
+
export var pivot = `<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" height="100%" width="100%" version="1.1" y="0px" x="0px" viewBox="-949 951 122.65 124.00456"><switch transform="matrix(-1 0 0 1 -1741 23.496)"><foreignObject y="0" x="0" requiredExtensions="http://ns.adobe.com/AdobeIllustrator/10.0/" width="1" height="1"/><g transform="matrix(.68779 .053686 -.048647 .75904 -208.42 303.24)"><path d="m-851.8 1025.3c-0.3-0.7-0.8-1.2-1.4-1.6l-28.9-18.3c-2.6-1.6-5.8 0.7-5.1 3.6l2.3 10.1c-17.7-0.4-32-14.6-32.5-32.3l10 2.3c2.9 0.7 5.2-2.5 3.6-5.1l-18.3-28.9c-0.9-1.4-2.6-2-4.2-1.3-0.7 0.3-1.2 0.8-1.6 1.4l-18.3 28.9c-1.6 2.6 0.7 5.8 3.6 5.1l10.1-2.3c0.5 25.9 21.5 46.9 47.5 47.3l-2.3 10c-0.7 2.9 2.5 5.2 5.1 3.6l28.9-18.3c1.6-0.8 2.2-2.6 1.5-4.2z"/></g><g><rect transform="scale(-1,1)" height="182.73" width="58.263" y="943.58" x="789.91"/><path d="m-555.88 62.924v-374.47h1252.1v748.94h-1252.1zm596.4 34.428c1.3908-1.3908 1.3477-2.0517-0.52029-7.9711-0.8688-2.7531-1.5838-5.0324-1.589-5.0651-0.0053-0.03273 1.2924-0.21249 2.8835-0.3995 6.1211-0.71941 14.098-3.8308 19.883-7.7551 12.823-8.6993 21.186-24.002 21.186-38.765 0-3.59 0.04131-3.7083 1.1917-3.425 0.65546 0.16137 3.3047 0.59645 5.8872 0.96682l4.6954 0.67342 1.3092-1.522c0.813-0.945 1.224-1.965 1.085-2.692-0.363-1.901-21.135-29.783-22.678-30.441-2.901-1.2375-3.406-0.57737-12.545 16.409-4.7338 8.7985-8.607 16.462-8.607 17.031 0 1.1765 2.2399 3.6338 3.3124 3.6338 0.39179 0 2.9648-0.71083 5.718-1.5796 2.7531-0.86879 5.0652-1.5838 5.138-1.589 0.36716-0.02595 0.04608 3.5333-0.65244 7.2269-2.3628 12.497-12.327 22.931-24.781 25.95-1.9718 0.47792-3.7039 0.75004-3.8492 0.6047-0.14534-0.14533 0.12002-2.6906 0.58972-5.6561 0.78639-4.9651 0.78618-5.4954-0.0053-6.6999-0.63994-0.98013-1.3213-1.308-2.7159-1.308-1.5863 0-3.9896 1.5653-16.275 10.6-15.151 11.143-16.136 12.125-14.661 14.622 0.9789 1.657 31.34 18.146 33.483 18.184 0.80111 0.01425 1.9333-0.45076 2.5159-1.0334z" transform="matrix(-1,0,0,1,-849.24,951)"/><rect transform="scale(-1,1)" height="134" width="5.8263" y="926.47" x="830.3"/><rect transform="matrix(0,1,1,0,0,0)" height="134" width="5.8263" y="-925.77" x="961.98"/></g></switch><rect height="122.65" width="11.491" y="951" x="-915.98" stroke-width="1.2986"/><rect transform="rotate(90)" height="122.65" width="11.491" y="826.35" x="985.27" stroke-width="1.2986"/></svg>`;
|
|
4
|
+
export var fullscreen =
|
|
5
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg>';
|
|
6
|
+
export var fullscreenExit =
|
|
7
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/></svg>';
|