-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtemplate.html
More file actions
757 lines (680 loc) · 20.8 KB
/
template.html
File metadata and controls
757 lines (680 loc) · 20.8 KB
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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>
{{ data.ids[data.entryPoint].props["http://schema.org/name"].fwd[0].value if data.ids[data.entryPoint].props["http://schema.org/name"] }}
</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 1vw;
margin: 0;
}
h3 {
font-size: 0.6em;
line-height: 0;
margin-bottom: 4px;
margin-top: 2em;
}
h2.id {
font-size: 0.5em;
margin-top: 1.25em;
font-weight: lighter;
}
.long {
overflow: scroll;
max-height: 10em;
}
.entity {
display: none;
position: static;
top: 0;
width: 100%;
z-index: 1000;
padding: 0px;
scroll-margin-top: 600px;
}
.entity:target {
display: block;
}
.entity a {
text-decoration: underline dotted 2px;
line-height: 2em;
text-underline-offset: 5px;
color: #000;
}
.entity-grid {
margin: 0px auto;
display: flex;
flex-direction: column;
gap: 0px;
width: 100%;
}
/* .roots {
margin-bottom: 100vh; /* Adds a whole screen of blank space
}
*/
.entity:target {
display: block;
scroll-margin-top: 0; /* Ensures the entity is at the top of the viewport */
}
span.type {
padding: 0px 5px;
margin-right: 5px;
font-size: 0.6em;
font-weight: lighter;
display: inline-block;
}
span.type::after {
content: "\a";
white-space: pre;
}
.entity-header-row span.type::after {
content: "";
}
span.info a {
text-decoration: none;
font-size: 0.9em;
}
.button-left,
.button-right {
margin-bottom: 10px;
padding: 2px 10px;
padding: 0;
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 5px;
}
.button-left:hover,
.button-right:hover {
color: #4e4e4e;
}
.button-left a::before {
content: "⏴";
font-size: 1.2em;
}
.button-right a::after {
content: "⏵";
font-size: 1.2em;
}
.button-left a,
.button-right a {
text-decoration: underline dotted 2px;
line-height: 2em;
text-underline-offset: 5px;
transition: all 0.3s ease-in;
color: #000000;
}
.button-left a:hover,
.button-right a:hover {
color: #4e4e4e;
}
.property-grid {
margin: 0px auto;
display: flex;
flex-direction: column;
gap: 0px;
width: 60%;
}
.property-row {
display: flex;
justify-content: center;
align-items: center;
padding: 15px 50px;
}
.property-row a {
text-decoration: underline dotted 2px;
line-height: 2em;
text-underline-offset: 5px;
transition: all 0.3s ease-in;
color: #000000;
}
.entity-header-row {
width: 100%;
padding: 15px;
padding-bottom: 25px;
background-color: rgb(0, 0, 0);
color: #fff;
font-size: 2em;
font-weight: bold;
text-align: center;
}
.entity-header-row h2 {
align-items: center;
text-align: center;
line-height: 1.1em;
margin-bottom: 0px;
justify-content: center; /* Center horizontally */
}
.entity-header-row .info {
text-decoration: none;
font-size: 0.75em;
}
.entity-header-row a {
color: #fff;
text-decoration: none;
font-size: 0.5em;
font-weight: bold;
line-height: 1.25;
margin-top: 0;
padding-top: 0;
text-decoration: underline dotted 2px;
text-underline-offset: 5px;
}
.entity-header-row p {
font-size: 0.6em;
display: inline;
}
.property-header-row {
display: flex;
justify-content: left; /* Center horizontally */
align-items: center;
text-align: center;
padding: 25px 50px;
margin-top: 20px;
border-radius: 10px 10px 0 0;
background-color: rgb(0, 0, 0);
color: #fff;
font-size: 1.5vw;
font-weight: bold;
text-transform: capitalize;
}
.property-row:nth-child(odd) {
background-color: #f9fbf9;
}
.property-row:nth-child(even) {
height: 20%;
background-color: #f0f0ee;
}
.property-row:last-child {
margin-bottom: 25px;
}
.property-name {
flex: 1;
font-weight: bold;
}
.property-name a {
color: #000000;
text-decoration: none;
transition: all 0.2s ease-in;
font-size: 1em;
}
.property-name a:hover {
color: #000000;
}
.property-value {
flex: 2;
gap: 5px;
align-items: left;
}
.section_head {
width: 100%;
display: flex;
padding: 5px 0px;
background-color: #6c6a6a;
}
.section_head h2 {
width: 60%;
margin: 0 auto;
font-size: 1.5em;
color: #fff;
}
.browse {
display: flex;
flex-direction: column;
width: 60%;
margin: 0 auto;
justify-content: center;
align-items: center;
margin-bottom: 20px;
margin-top: 10px;
}
.browse nav {
width: 100%;
padding-top: 10px;
}
.browse p {
display: inline;
margin-left: 5px;
}
.find_button {
background-color: #000000;
color: white !important;
padding: 14px 25px;
text-align: center;
border-radius: 4px;
text-decoration: none !important;
display: inline-block;
margin-left: 5px;
}
.centered-files {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
width: 100vw;
}
.centered-files a {
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
select {
all: unset;
max-width: 35%;
line-height: 1.5em;
padding: 0.5em 3.5em 0.5em 1em;
border-bottom: 1px solid #4e4e4e;
background-color: #f1f1f1;
/*This is the arrow */
background-image:
linear-gradient(45deg, transparent 50%, rgb(111, 111, 111) 50%),
linear-gradient(135deg, rgb(111, 111, 111) 50%, transparent 50%);
background-position:
calc(100% - 20px) calc(1em + 0px),
calc(100% - 15px) calc(1em + 0px),
100% 0;
background-size:
5px 5px,
5px 5px,
2.5em 2.5em;
background-repeat: no-repeat;
}
.drop-down {
display: none;
position: static;
top: 0;
width: 100%;
z-index: 1000;
padding: 0px;
scroll-margin-top: 600px;
}
.drop-down:target {
display: block;
}
.drop-down a {
text-decoration: underline dotted 2px;
line-height: 2em;
text-underline-offset: 5px;
color: #000;
}
iframe {
background-color: #f5f5f5;
border: none;
padding: 35px;
}
.home-link {
font-size: 0.5em !important;
}
.home-link a {
font-weight: 100 !important;
font-size: 14px !important;
}
/*-- this is a test comment*/
/*.property-value button {
margin-bottom: 5px;
padding: 2px 10px;
border: none;
border-bottom: dotted 2px;
cursor: pointer;
transition: all .2s ease-in;
color: #000000;
}
.property-value button a {
text-decoration: none;
font-weight: bold;
color: #000000;
}
.property-value button a:hover {
color: #4e4e4e;
} */
</style>
<script>
function search(input) {
li = input.parentNode.getElementsByTagName("div");
filter = input.value.toUpperCase();
count = li.length;
found = 0;
for (i = 0; i < li.length; i++) {
txtValue = li[i].textContent.toUpperCase() || "";
if (txtValue.indexOf(filter) > -1) {
li[i].style.display = "";
found++;
} else {
li[i].style.display = "none";
}
}
input.parentNode.getElementsByClassName("count")[0].innerText =
`${found - 1} / ${count - 1}`;
}
</script>
</head>
<body>
{%- macro infoLink(url) %}
{%- if url %}
{%- if data.ids[url] %}
<a
href="#{{ url }}"
title="See definiton for {{ url }} in this RO-Crate"
>
ⓘ
</a>
{% else %}
<a
href="{{ url }}"
title="Look up definiton for {{ url }}"
target="_blank"
>
ⓘ
</a>
{%- endif %}
{%- endif %}
{%- endmacro %}
{%- macro diplayLabel(propData) %}
{{ propData.label | replace(r/.*:/, "") }}
{{ infoLink(propData.url) }}
{%- endmacro %}
{%- macro infoLink(url) %}
{%- if url %}
{%- if data.ids[url] %}
<span class="info"><a href="#{{ url }}">ⓘ</a></span>
{%- else %}
<span class="info"> <a href="{{ url }}" target="_blank">ⓘ</a></span>
{%- endif %}
{%- endif %}
{%- endmacro %}
{%- macro displayProp(prop, propData) %}
<div class="property-row">
<div class="property-name">{{ diplayLabel(propData) }}</div>
<div class="property-value">
{%- set isLong = propData.fwd.length + propData.rev.length > 9 %}
{%- if isLong %}
<input class="border" onkeyup="res = search(this)" />
<span class="count">
({{ propData.fwd.length + propData.rev.length }} /
{{ propData.fwd.length + propData.rev.length }})</span
>
{%- endif %}
<div class="{{ 'long' if isLong else 'short' }}">
{%- for val in propData.fwd %}
<div>
{%- if val is string %}
{{ val | urlize | safe }}
{%- elif val["url"] %}
<a href="{{ val["url"] }}"> {{ val["url"] }}</a>
{%- else %}
{%- if val["target_id"] %}
<span class="button-right">
<a href="#{{ val["target_id"] | urlencode }}">
{{ val["target_name"] }}
</a>
</span>
{%- elif val.value is string %}
{{ val.value | urlize | safe }}
{%- elif val.value %}
{{ val.value }}
{%- else %}
WARNING SOMETHING WENT WRONG {{ val | dump }}
{%- endif %}
{%- endif %}
{%- if val["mapImage"] %}
<p>Map images:</p>
<img
src="{{ val["mapImage"]["world"] }}"
alt="World Map"
style="width: 100%; height: auto;"
/>
<img
src="{{ val["mapImage"]["main"] }}"
alt="Localized Map"
style="width: 100%; height: auto;"
/>
{%- endif %}
</div>
{%- endfor %}
{%- for val in propData.rev %}
<div>
{%- if val["target_id"] %}
<span class="button-left">
<a href="#{{ val["target_id"] | urlencode }}">
{{ val["target_name"] }}
</a>
</span>
{%- else %}
WARNING SOMETHING WENT WRONG {{ val | dump }} ⬅
{%- endif %}
</div>
{%- endfor %}
</div>
</div>
</div>
{%- endmacro %}
{%- macro typeNav() %}
<select onchange="location.href=this.value">
<option value="disabled selected">Select a type</option>
{%- for type, list in data.types %}
{%- if type != "File" %}
<option value="#types_{{ type }}">{{ type }}</option>
{%- endif %}
{%- endfor %}
</select>
{%- endmacro %}
{%- macro crateNav() %}
<div class="nav">
<p>Browse by type of entity:</p>
{{ typeNav() }}
<p>OR</p>
{%- if data.types["File"] %}
<a href="#types_File" class="find_button">Files in this crate</a>
{%- endif %}
<!--
{%- if data.types["Dataset"] and data.types["Dataset"].length > 2 %}
<a href="#types_Dataset">Datasets in this crate</a>
{%- endif %}
-->
</div>
{%- endmacro %}
{%- macro schemaElements() %}
{%- if data.types["DefinedTerm"] or data.types["rdf:Property"] or data.types["rdfs:Class"] %}
<h3>Custom schema elements</h3>
{%- if data.types["rdf:Property"] %}
<a href="#types_rdf:Property">Properties</a>
{%- endif %}
{%- if data.types["rdfs:Class"] %}
<p>|</p>
<a href="#types_rdfs:Class">Classes</a>
{%- endif %}
{%- if data.types["DefinedTerm"] %}
<p>|</p>
<a href="#types_DefinedTerm">DefinedTerms</a>
{%- endif %}
{%- endif %}
{%- endmacro %}
{%- macro root() %}
<div class="home-link">
<a href="#{{ data.entryPoint | urlencode }}" class="root">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-house-door-fill"
viewBox="0 0 16 16"
>
<path
d="M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5"
/>
</svg>
Go home:
{{ data.ids[data.entryPoint].props["http://schema.org/name"].fwd[0].value }}
</a>
</div>
{%- endmacro %}
{%- macro showType(type) %}
<!--<a href="#types_{{ type }}" class="type"></a>-->
{{ type | replace(r/.*:/) }}
{{ infoLink(data.typeUrls[type]) }}
{%- endmacro %}
{%- macro setProp(prop) %}
{%- if prop is string %}
{{ prop }}
{% else %}
{{ prop | merge({ prop: true }) }}
{%- endif %}
{%- endmacro %}
{%- macro display(item, class) %}
<!-- Heading Section -->
<div id="{{ item.id | urlencode }}" class="{{ class }}">
<div class="entity-header-row">
{{ root () }}
<h2>
{%- if item.props and "http://schema.org/name" in item.props and item.props["http://schema.org/name"].fwd %}
{{ item.props["http://schema.org/name"].fwd[0].value }}
{% else %}
<!-- Use ID if name isn't available, e.g. files -->
{{ item.id }}
{%- endif %}
</h2>
{%- for type in item.type %}
<span class="type">{{ showType(type) }}</span
>{%- if not loop.last %}<p>|</p>{%- endif %}
{%- endfor %}
<h3>Identifier</h3>
<h2 class="id">{{ item.id }}</h2>
{{ schemaElements() }}
</div>
<!-- Browse Collection section -->
<div class="section_head">
<h2>Browse collection</h2>
</div>
<section class="browse">
{{ crateNav() }}
<!-- Think this is where the function for displaying selected item of drop down list should go but not sure -->
{%- if item == data.ids[data.entryPoint] %}
{%- for type, list in data.types %}
<div id="types_{{ type }}" class="drop-down">
<div class="entity-grid">
<h2>{{ type }} ({{ list.length }})</h2>
{%- set isLong = list.length > 9 %}
{%- if isLong %}
<input class="border" onkeyup="res = search(this)" />
<span class="count">
({{ list.length }} / {{ list.length }})</span
>
{%- endif %}
<div class="{{ 'long' if isLong else 'short' }}">
{%- for id in list %}
{%- if id != data.entryPoint %}
<div>
<a href="#{{ id | urlencode }}">
{%- if data.ids[id].props["http://schema.org/name"].fwd[0].value %}
{{ data.ids[id].props["http://schema.org/name"].fwd[0].value }}
{%- else %}
{{ id }}
{%- endif %}
</a>
</div>
{%- endif %}
{%- endfor %}
</div>
</div>
</div>
{%- endfor %}
{%- endif %}
</section>
<!--Section for files if they are avails-->
{%- set htmlRegex = r/(\.txt)$|(\.html?)$/i %}
{%- set mdRegex = r/\.md$/i %}
{%- set audioRegex = r/(\.mp3)|(\.ogg?)|(\.wav)$/i %}
{%- set imgRegex = r/(\.jpe?g)|(\.png|(\.giff?))$/i %}
{%- set vidRegex = r/(\.mp4)|(\.mov)$/i %}
{%- set pdfRegex = r/pdf$/i %}
{%- if item.type.includes("File") %}
<div class="centered-files">
{%- if htmlRegex.test(item.id) %}
<!-- TODO: fix these width="80%"s, they are not valid -->
<iframe
src="{{ item.id }}"
type="text/plain"
width="80%"
height="500"
loading="lazy"
></iframe>
{% elif audioRegex.test(item.id) %}
<audio controls width="80%">
<source src="{{ item.id }}" />
</audio>
{% elif vidRegex.test(item.id) %}
<video io controls>
<source src="{{ item.id }}" />
</video>
{% elif imgRegex.test(item.id) %}
<img
width="80%"
style="object-fit: contain"
src="{{ item.id }}"
loading="lazy"
/>
{% elif mdRegex.test(item.id) %}
{%- if item.content %}
{{ item.content | renderMarkdown | safe }}
{%- else %}
<p>Markdown content not available. <a href="{{ item.id | urlencode }}">View file</a></p>
{%- endif %}
{% elif pdfRegex.test(item.id) %}
<!-- <iframe src="{{ item.id }}" type="application/pdf" width="100%" height="600px" loading="lazy" />-->
{%- endif %}
<a href="{{ item.id | urlencode }}">Open file location</a>
</div>
{%- endif %}
<!-- Properties section -->
<div class="section_head">
<h2>Details</h2>
</div>
<div class="property-grid">
{%- set seenProps = {"@id": true,"@type": true} %}
{%- for group in layout %}
{%- set hasContent = false %}
{%- for input in group.inputs %}
{%- if item.props[input] %}
{%- set hasContent = true %}
{%- set seenProps = seenProps | setProp(input) %}
{%- endif %}
{%- endfor %}
{%- if hasContent %}
<div class="property-header-row">{{ group.name }}</div>
{%- endif %}
{%- for input in group.inputs %}
{%- if item.props[input] %}
{{ displayProp(input, item.props[input]) }}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- set hasContent = false %}
{%- for input, val in item.props %}
{%- if not seenProps[input] %}
{%- set hasContent = true %}
{%- endif %}
{%- endfor %}
{%- if hasContent %}
<div class="property-header-row">Other properties</div>
{%- endif %}
{%- for input, val in item.props %}
{%- if not seenProps[input] %}
{{ displayProp(input, item.props[input]) }}
{%- endif %}
{%- endfor %}
</div>
</div>
{%- endmacro %}
{{ display(data.ids[data.entryPoint], "root") }}
{%- for id, entity in data.ids %}
{%- if id != data.entryPoint %}
{{ display(entity, "entity") }}
{%- endif %}
{%- endfor %}
</body>
</html>