-
Notifications
You must be signed in to change notification settings - Fork 3
/
index-A.html
479 lines (390 loc) · 18.9 KB
/
index-A.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Sparnatural Archives Nationales : démonstrateur</title>
<meta content="" name="description">
<meta content="" name="keywords">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500,700|Open+Sans:300,300i,400,400i,700,700i" rel="stylesheet">
<!-- Vendor CSS Files -->
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
<!-- Template Main CSS File -->
<link href="assets/css/style.css" rel="stylesheet">
<link href="assets/css/timeline.css" rel="stylesheet">
<!-- Sparnatural-specific -->
<!-- Vis.js for timeline -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="assets/fa/css/all.min.css" />
<!-- YASGUI CSS -->
<link href="https://unpkg.com/@triply/yasgui/build/yasgui.min.css" rel="stylesheet" type="text/css" />
<!-- Sparnatural CSS -->
<link href="sparnatural.css" rel="stylesheet" />
<style>
.yasqe .CodeMirror {
font-size: 0.8em;
}
#sparnatural-section {
padding-top: 115px;
height: auto;
overflow: visible;
}
#sparnatural-container {
}
#yasqe {
display: none;
}
#yasr-section {
}
#contact {
margin-top:40px;
padding: 0px;
padding-top: 20px;
}
</style>
<!-- /Sparnatural-specific -->
</head>
<body>
<!-- ======= Header ======= -->
<header id="header" class="fixed-top d-flex align-items-center">
<div class="container d-flex justify-content-between align-items-center">
<div id="logo">
</div>
<nav id="navbar" class="navbar">
<ul>
<li><a class="nav-link" href="index.html"><span data-i18n="menu.home"></span></a></li>
<li><a class="nav-link" href="index-A.html"><span data-i18n="menu.demonstrateur-A"></span></a></li>
<li><a class="nav-link" href="index-B.html"><span data-i18n="menu.demonstrateur-B"></span></a></li>
<li class="dropdown"><a href="#"><i style="font-size:25px;" class="fad fa-book"></i> <span>Documentation</span> <i class="bi bi-chevron-down"></i></a>
<ul style="width:80%;">
<li><a href="presentation-fr.html">Français</a></li>
<li><a href="presentation-en.html">English</a></li>
</ul>
</li>
<li class="dropdown"><a href="#"><i style="font-size:25px;" class="fad fa-globe-africa"></i> <span>Lang.</span> <i class="bi bi-chevron-down"></i></a>
<ul style="width:80%;">
<li><a href="?lang=fr">Français</a></li>
<li><a href="?lang=en">English</a></li>
</ul>
</li>
<li><a class="nav-link" href="mentions-legales.html"><span data-i18n="menu.mentions-legales"></span></a></li>
<li><a class="nav-link" href="http://sparnatural.eu"><span data-i18n="menu.sparnatural"></span> <i style="font-size:15px;" class="fad fa-external-link-alt"></i></a></li>
<li><a href="https://www.archives-nationales.culture.gouv.fr/"><img src="assets/img/archives-nationales.png" style="width:200px;" /></a></li>
</ul>
<i class="bi bi-list mobile-nav-toggle"></i>
</nav><!-- .navbar -->
</div>
</header><!-- End Header -->
<!-- ======= Sparnatural Section ======= -->
<section id="sparnatural-section">
<div class="container">
<div class="row">
<h1 data-i18n="page.title"></h1>
<div class="col-md">
<p>Le formulaire de recherche disponible sur la présente page propose <b>une interface simple et généraliste d'exploration dans ces métadonnées</b>, qui pourrait être utilisée pour d'autres métadonnées archivistiques.</p>
</div>
</div>
<div class="row" style="padding-bottom:10px;">
<div class="col-md-6">
<form>
<select class="form-control" style="width:100%; appearance: auto !important;" id="select-examples">
<option value="none" data-i18n="example.placeholder" selected></option>
<option value="example.1" data-i18n="example.A.1.title"></option>
<option value="example.2" data-i18n="example.A.2.title"></option>
</select>
</form>
</div>
<div class="col-md-6">
<div style="text-align:right;">
<span style="font-size:90%; font-style: italic;">
<span data-i18n="endpoint.querying"></span> <a id="endpoint" href="https://proxy.sparnatural.eu/sparql-proxy/sparql?endpoint=http%3A%2F%2F51.159.140.210%2Fgraphdb%2Frepositories%2Fsparnatural-demo-anf">https://proxy.sparnatural.eu/sparql-proxy/sparql?endpoint=http%3A%2F%2F51.159.140.210%2Fgraphdb%2Frepositories%2Fsparnatural-demo-anf</a>
</span>
</div>
</div>
</div>
<!-- This is where Sparnatural is inserted -->
<div class="row">
<div id="sparnatural-container"></div>
<input type="hidden" id="query-json"></input>
</div>
<!-- -->
<div class="row">
<div class="col-md">
<div style="font-style: italic; font-size:0.9em; padding-top:0.3em; padding-left:0.3em;">
<a href="#" id="sparql-toggle"><i id="sparql-toggle-icon" class="fad fa-eye fa-fw"></i> <span data-i18n="actions.toggle"></span></a> | <a href="#" id="share"><i id="share-icon" class="fad fa-share-square"></i> <span data-i18n="actions.share"></span></a> | <a href="#" id="export"><i id="export-icon" class="fad fa-file-export"></i> <span data-i18n="actions.export"></span></a>
</div>
</div>
</div>
<div class="row">
<div class="col-md">
<div class="float-end"></div>
</div>
</div>
</div>
</section><!-- End Sparnatural Section -->
<!-- ======= YASQE Section ======= -->
<section id="yasqe-section">
<div class="container">
<div id="yasqe" style="display:none; " />
</div>
</section>
<!-- End YASQE Section -->
<!-- ======= YASR Section ======= -->
<section id="yasr-section">
<div class="container">
<div id="yasr">
</div>
</div>
</section><!-- End YASR Section -->
<!-- ======= Contact Section ======= -->
<section id="contact">
<div class="container" data-aos="fade-up">
<div class="row">
<div class="col-lg-2 col-md-2">
<div class="contact-about">
<a href="https://www.archives-nationales.culture.gouv.fr/"><img src="assets/img/archives-nationales.png" style="width:100%;" /></a>
</div>
</div>
<div class="col-lg-2 col-md-2">
<div class="contact-about">
<a href="http://sparna.fr"><img src="assets/img/sparna.png" style="width:100%;" /></a>
</div>
</div>
<div class="col-lg-3 col-md-4">
<div class="social-links">
<a href="mailto:thomas.francart@sparna.fr" ><i class="bi bi-envelope-fill"></i></a>
<a href="http://sparna.fr" ><i class="bi bi-building"></i></a>
<a href="http://blog.sparna.fr"><i class="bi bi-journal-text"></i></a>
<a href="https://github.com/sparna-git/Sparnatural"><i class="bi bi-github"></i></a>
</div>
</div>
</div>
</div>
</section><!-- End Contact Section -->
</main><!-- End #main -->
<!-- Modal -->
<div class="modal fade" id="shareModal" tabindex="-1" role="dialog" aria-labelledby="shareModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="shareModalLabel" data-i18n="share.modal.title"></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" style="overflow:hidden;">
<a id="share-link" href="#"></a>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" data-i18n="share.modal.close"></button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="exportModal" tabindex="-1" role="dialog" aria-labelledby="jsonModelLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="jsonModelLabel" data-i18n="export.modal.title"></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" style="overflow:hidden;">
<textarea class="form-control" rows="20" id="export-json" style="width:100%" readonly="readonly"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" data-i18n="export.modal.close"></button>
</div>
</div>
</div>
</div>
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-chevron-up"></i></a>
<!-- Vendor JS Files -->
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/timeline.js"></script>
<script src="sampleQueries-A.js"></script>
<!-- Sparnatural-specific -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<!-- YASGUI stuff -->
<script src="https://unpkg.com/@triply/yasgui/build/yasgui.min.js"></script>
<!-- vis.js for the timeline -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.21.0/vis.min.js"></script>
<!-- Sparnatural Javascript -->
<script type="text/javascript" src="./sparnatural.js"></script>
<script type="text/javascript" src="./sparnatural-yasgui-plugins.js"></script>
<!-- Json url (Compression) -->
<script src="https://cdn.jsdelivr.net/gh/masotime/json-url@master/dist/browser/json-url.js"></script>
<!-- /Sparnatural-specific -->
<!-- i18n -->
<script src="assets/vendor/jquery.i18n/jquery.i18n.js"></script>
<script src="assets/vendor/jquery.i18n/jquery.i18n.messagestore.js"></script>
<script src="assets/vendor/jquery.i18n/jquery.i18n.fallbacks.js"></script>
<script src="assets/vendor/jquery.i18n/jquery.i18n.language.js"></script>
<script src="assets/vendor/jquery.i18n/jquery.i18n.parser.js"></script>
<script src="assets/vendor/jquery.i18n/jquery.i18n.emitter.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/demo.js"></script>
<script src="assets/js/i18n.js"></script>
<script>
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if(results == null) { return null; }
return results[1] || 0;
}
var lang = ($.urlParam('lang') != null)?$.urlParam('lang'):'fr';
// set the locale
$.i18n( { locale: lang } );
$('body').i18n();
var sparnatural;
$( document ).ready(function($) {
sparnatural = document.getElementById('sparnatural-container').Sparnatural({
config: "sparnatural-config-A.ttl",
language: lang,
maxDepth: 4,
addDistinct: true,
sendQueryOnFirstClassSelected: true,
backgroundBaseColor: '29,224,153',
// backgroundBaseColor: '33,177,236',
autocomplete : null,
list : null,
defaultEndpoint : $('#endpoint').text(),
onQueryUpdated: function(queryString, queryJson) {
queryString = semanticPostProcess(queryString);
queryString = displayLabelPostProcess(queryString);
queryString = orderByPostProcess(queryString);
$('#sparql code').html(queryString.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"));
yasqe.setValue(queryString);
// yasqe.query();
// save query
document.getElementById('query-json').value = JSON.stringify(queryJson);
},
// triggered when "play" button is clicked
onSubmit: function(form) {
// enable loader on button
form.sparnatural.enableLoading() ;
// trigger the query from YasQE
yasqe.query();
}
});
// load ?query= param if present
var UrlString = window.location.search;
var urlParams = new URLSearchParams(UrlString);
if (urlParams.has("query") === true) {
var compressedJson = urlParams.get("query") ;
var compressCodec = JsonUrl('lzma');
compressCodec.decompress(compressedJson).then(json => {
sparnatural.loadQuery(JSON.parse(json)) ;
});
}
}) ;
prefixesPostProcess = function(queryString) {
if(queryString.indexOf("rdf-schema#") == -1) {
queryString = queryString.replace("SELECT ", "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \nSELECT ");
}
queryString = queryString.replace("SELECT ", "PREFIX skos: <http://www.w3.org/2004/02/skos/core#> \nSELECT ");
return queryString;
}
displayLabelPostProcess = function(queryString) {
// queryString = queryString.replace(new RegExp('}$'), " ?this rdfs:label ?theLabel FILTER(lang(?theLabel) = 'fr') \n}");
// queryString = queryString.replace(new RegExp('}$'), " ?this rdfs:label ?theLabel FILTER(lang(?theLabel) = 'fr') \n}");
/*
if(queryString.includes("?this WHERE")) {
queryString = queryString.replace(new RegExp('}$'), " OPTIONAL { ?this rdfs:label ?rdfsLabel FILTER(lang(?rdfsLabel) = 'fr') }\n OPTIONAL { ?this skos:prefLabel ?skosPrefLabel FILTER(lang(?skosPrefLabel) = 'fr') }\n BIND(COALESCE(?rdfsLabel, ?skosPrefLabel) AS ?theLabel) \n}");
queryString = queryString.replace("SELECT DISTINCT ?this", "SELECT DISTINCT ?this (STR(?theLabel) AS ?label)");
}
*/
// queryString = queryString.replace(new RegExp('}$'), " FILTER(isIRI(?this)) \n}");
// Builds the URL to the page :
// http://data.archives-nationales.culture.gouv.fr/agent/005080
// http://sparnatural-demo-anf.huma-num.fr/lodview/agent/005080.html
/*
queryString = queryString.replace(new RegExp('SELECT DISTINCT \\?this'), "SELECT DISTINCT ((IRI((CONCAT('https://sparnatural-demo-anf.huma-num.fr/lodview/', STRAFTER(STR(?this), 'http://data.archives-nationales.culture.gouv.fr/'))))) AS ?page)");
*/
return queryString;
}
orderByPostProcess = function(queryString) {
// queryString = queryString.replace(new RegExp('}$'), "}\nORDER BY ?label LIMIT 100");
// queryString = queryString.replace("SELECT DISTINCT ?this", "SELECT DISTINCT (STR(?theLabel) AS ?label) ?this");
queryString = queryString.replace(new RegExp('}$'), "}\nLIMIT 10000");
return queryString;
}
semanticPostProcess = function(queryString) {
queryString = prefixesPostProcess(queryString);
queryString = sparnatural.expandSparql(queryString);
return queryString;
}
const yasqe = new Yasqe(document.getElementById("yasqe"), {
requestConfig: {
endpoint: $('#endpoint').text(),
method: "GET",
header: {}
},
copyEndpointOnNewTab: false
});
Yasr.registerPlugin("LabelledUriTable",SparnaturalYasguiPlugins.TableX);
Yasr.registerPlugin("Timeline",Timeline);
Yasr.plugins.LabelledUriTable.defaults.uriHrefAdapter = function(uri) {
if(uri.startsWith("http://data.archives-nationales.culture.gouv.fr/")) {
return "http://51.159.140.210/lodview/" + uri.substring("http://data.archives-nationales.culture.gouv.fr/".length);
} else {
return uri;
}
};
delete Yasr.plugins['table'];
delete Yasr.plugins['response'];
const yasr = new Yasr(document.getElementById("yasr"), {
pluginOrder: ["LabelledUriTable", "Timeline"],
// disable persistency
persistencyExpire: 0,
maxPersistentResponseSize: 0
});
// link yasqe and yasr
yasqe.on("queryResponse", function(_yasqe, response, duration) {
yasr.setResponse(response, duration);
sparnatural.disableLoading() ;
});
document.getElementById('sparql-toggle').onclick = function() {
if(document.getElementById('yasqe').style.display == 'none') {
document.getElementById('yasqe').style.display = 'block';
yasqe.setValue(yasqe.getValue());
yasqe.refresh();
document.getElementById('sparql-toggle-icon').className = 'fad fa-eye-slash fa-fw';
} else {
document.getElementById('yasqe').style.display = 'none';
document.getElementById('sparql-toggle-icon').className = 'fad fa-eye fa-fw';
}
return false;
} ;
document.getElementById('share').onclick = function() {
var compressCodec = JsonUrl('lzma');
compressCodec.compress(document.getElementById('query-json').value).then(result => {
var url = window.location.href.split(/[?#]/)[0];
url += '?query='+result ;
$('#share-link').text(url);
$('#share-link').attr('href', url);
$('#shareModal').modal('show');
});
}
document.getElementById('export').onclick = function() {
var jsonString = JSON.stringify(
JSON.parse(document.getElementById('query-json').value),
null,
2
);
$('#export-json').val(jsonString);
$('#exportModal').modal('show');
}
document.getElementById('select-examples').onclick = function() {
var key = $('#select-examples option:selected').val();
if(sampleQueries.hasOwnProperty(key)) {
sparnatural.loadQuery(sampleQueries[key]) ;
}
}
</script>
</script>
</body>
</html>