-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathconfig.xqm
More file actions
1328 lines (1256 loc) · 67.6 KB
/
Copy pathconfig.xqm
File metadata and controls
1328 lines (1256 loc) · 67.6 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
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
xquery version "3.1";
(:~
: A set of helper functions to access the application context from
: within a module.
:)
module namespace config="http://history.state.gov/ns/site/hsg/config";
import module namespace pages="http://history.state.gov/ns/site/hsg/pages" at "pages.xqm";
import module namespace tu="http://history.state.gov/ns/site/hsg/tei-util" at "tei-util.xqm";
import module namespace frus-history = "http://history.state.gov/ns/site/hsg/frus-history-html" at "frus-history-html.xqm";
import module namespace pm-frus='http://www.tei-c.org/pm/models/frus/web/module' at "../resources/odd/compiled/frus-web-module.xql";
declare namespace templates="http://exist-db.org/xquery/html-templating";
declare namespace expath="http://expath.org/ns/pkg";
declare namespace repo="http://exist-db.org/xquery/repo";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace request="http://exist-db.org/xquery/request";
declare namespace response="http://exist-db.org/xquery/response";
declare namespace a="http://www.w3.org/2005/Atom";
declare namespace xhtml="http://www.w3.org/1999/xhtml";
(: editorial date - the earliest possible "last-modified" time applied to all pages on the site
: to ensure any pages that were cached before this date are refreshed when requested after
: this date :)
declare variable $config:EDITORIAL_DATE_TIME := xs:dateTime("2025-12-20T00:00:00-00:00");
(:
Determine the application root collection from the current module load path.
:)
declare variable $config:app-root :=
let $rawPath := system:get-module-load-path()
let $modulePath :=
(: strip the xmldb: part :)
if (starts-with($rawPath, "xmldb:exist://")) then
if (starts-with($rawPath, "xmldb:exist://embedded-eXist-server")) then
substring($rawPath, 36)
else
substring($rawPath, 15)
else
$rawPath
return
substring-before($modulePath, "/modules")
;
declare variable $config:data-root := $config:app-root || "/data";
declare variable $config:repo-descriptor := doc(concat($config:app-root, "/repo.xml"))/repo:meta;
declare variable $config:expath-descriptor := doc(concat($config:app-root, "/expath-pkg.xml"))/expath:package;
declare variable $config:default-odd := "frus.odd";
declare variable $config:odd := $config:default-odd;
declare variable $config:odd-root := $config:app-root || "/resources/odd";
declare variable $config:odd-source := $config:odd-root || "/source";
declare variable $config:odd-compiled := "/transform";
declare variable $config:output := "transform";
declare variable $config:output-root := $config:app-root || "/" || $config:output;
(: Default transformation function: calls tei simple pm using frus.odd :)
declare variable $config:odd-transform-default := function($xml, $parameters) {
pm-frus:transform($xml, $parameters)
};
declare variable $config:module-config := doc($config:odd-source || "/configuration.xml")/*;
(:
: The default to use for determining the amount of content to be shown
: on a single page. Possible values: 'div' for showing entire divs (see
: the parameters below for further configuration), or 'page' to browse
: a document by actual pages determined by TEI pb elements.
:)
declare variable $config:default-view := "div";
declare variable $config:IGNORED_DIVS := ("toc");
declare variable $config:epoch-start := xs:dateTime("1970-01-01T00:00:00-00:00");
declare variable $config:x-forwarded-host := request:get-header("X-Forwarded-Host");
declare variable $config:x-forwarded-proto := request:get-header("X-Forwarded-Proto");
declare variable $config:is-proxied := not(empty($config:x-forwarded-host));
declare variable $config:exist-path-to-root := request:get-context-path() || substring-after($config:app-root, "/db");
declare variable $config:proxy-url :=
if ($config:is-proxied)
then ($config:x-forwarded-proto || "://" || substring-before($config:x-forwarded-host,":"))
else ($config:exist-path-to-root);
(: S3 configuration :)
declare variable $config:S3_BUCKET := "static.history.state.gov.v3";
declare variable $config:S3_DOMAIN := "static.history.state.gov";
declare variable $config:S3_URL := 'https://' || $config:S3_DOMAIN;
(: HSG Project data repositories :)
declare variable $config:ADMINISTRATIVE_TIMELINE_COL := "/db/apps/administrative-timeline";
declare variable $config:ADMINISTRATIVE_TIMELINE_DATA_COL := $config:ADMINISTRATIVE_TIMELINE_COL || "/timeline";
declare variable $config:ARCHIVES_COL := "/db/apps/wwdai";
declare variable $config:ARCHIVES_COL_ARTICLES := $config:ARCHIVES_COL || "/articles";
declare variable $config:CAROUSEL_COL := "/db/apps/carousel";
declare variable $config:CONFERENCES_COL := "/db/apps/conferences";
declare variable $config:CONFERENCES_COL_ARTICLES := $config:CONFERENCES_COL || "/data";
declare variable $config:COUNTRIES_COL := "/db/apps/rdcr";
declare variable $config:COUNTRIES_COL_ARTICLES := $config:COUNTRIES_COL || "/articles";
declare variable $config:FRUS_COL := "/db/apps/frus";
declare variable $config:FRUS_COL_CODE_TABLES := $config:FRUS_COL || "/shared";
(: TODO: Create post-install task for `toc:generate-frus-tocs()` to create this folder, if not available :)
declare variable $config:FRUS_COL_TOC := $config:FRUS_COL || "/frus-toc/";
declare variable $config:FRUS_COL_VOLUMES := $config:FRUS_COL || "/volumes";
declare variable $config:FRUS_HISTORY_COL := '/db/apps/frus-history';
declare variable $config:FRUS_HISTORY_COL_ARTICLES := $config:FRUS_HISTORY_COL || '/articles';
declare variable $config:FRUS_HISTORY_COL_DOCUMENTS := $config:FRUS_HISTORY_COL || '/documents';
declare variable $config:FRUS_HISTORY_COL_EVENTS := $config:FRUS_HISTORY_COL || '/events';
declare variable $config:FRUS_HISTORY_COL_MONOGRAPH := $config:FRUS_HISTORY_COL || '/monograph';
declare variable $config:HAC_COL := "/db/apps/hac";
declare variable $config:HIST_DOCS := "/db/apps/hsg-shell/pages/historicaldocuments";
declare variable $config:MILESTONES_COL := "/db/apps/milestones";
declare variable $config:MILESTONES_COL_CHAPTERS := $config:MILESTONES_COL || "/chapters";
declare variable $config:NEWS_COL := "/db/apps/hsg-shell/tests/data/news";
declare variable $config:OP_COL := "/db/apps/other-publications";
declare variable $config:OP_BUILDINGS_COL := $config:OP_COL || "/buildings";
declare variable $config:OP_EDUCATION_COL := $config:OP_COL || "/education/introductions";
declare variable $config:OP_FAQ_COL := $config:OP_COL || "/faq";
declare variable $config:OP_SECRETARY_BIOS_COL := $config:OP_COL || "/secretary-bios";
declare variable $config:OP_SHORT_HISTORY_COL := $config:OP_COL || "/short-history";
declare variable $config:OP_VIETNAM_GUIDE_COL := $config:OP_COL || "/vietnam-guide";
declare variable $config:OP_VIEWS_FROM_EMBASSY_COL := $config:OP_COL || "/views-from-the-embassy";
declare variable $config:POCOM_COL := '/db/apps/pocom';
declare variable $config:POCOM_COL_PEOPLE := $config:POCOM_COL || '/people';
declare variable $config:TAGS_COL := '/db/apps/tags';
declare variable $config:TRAVELS_COL := "/db/apps/travels";
declare variable $config:TRAVELS_COL_PRESIDENTS := $config:TRAVELS_COL || "/presidents";
declare variable $config:TRAVELS_COL_PRESIDENTS_TRAVELS := $config:TRAVELS_COL || "/president-travels";
declare variable $config:TRAVELS_COL_SECRETARIES_TRAVELS := $config:TRAVELS_COL || '/secretary-travels';
declare variable $config:TUMBLR_COL := "/db/apps/tumblr/data/HistoryAtState";
declare variable $config:TWITTER_COL := "/db/apps/twitter/data/HistoryAtState";
declare variable $config:VISITS_COL := "/db/apps/visits";
declare function config:last-modified-from-repo-xml ($collection as xs:string) as function(*) {
function () {
let $ts := doc($collection || "/repo.xml")/repo:meta/@commit-time/string()
let $last-modified-date-time := $config:epoch-start + xs:dayTimeDuration("PT" || substring($ts, 1, 10) || "S")
let $_ := util:log("debug", "config:last-modified-from-repo-xml: " || $last-modified-date-time)
return
$last-modified-date-time
}
};
declare function config:last-modified-from-git ($path-to-xar as xs:string) as function(*) {
function ($document-id as xs:string?) {
let $path-to-resource := $document-id || '.xml'
let $_ := util:log("debug", "config:last-modified-from-git $path-to-xar: "|| $path-to-xar || " path-to-resource: " || $path-to-resource)
let $id := replace($path-to-resource, "/", "0x2F")
let $last-modified-date-time := collection($path-to-xar || "/.last-modified")/id($id)/text()
let $_ := util:log("debug", "config:last-modified-from-git-path: " || $last-modified-date-time)
return
$last-modified-date-time
}
};
declare function config:last-modified-from-git ($path-to-xar as xs:string, $collection as xs:string?) as function(*) {
function ($document-id as xs:string?) {
let $path-to-resource := $collection || "/" || $document-id || '.xml'
let $_ := util:log("debug", "config:last-modified-from-git $path-to-xar: "|| $path-to-xar || " path-to-resource: " || $path-to-resource)
let $id := replace($path-to-resource, "/", "0x2F")
let $last-modified-date-time := collection($path-to-xar || "/.last-modified")/id($id)/text()
let $_ := util:log("debug", "config:last-modified-from-git-path: " || $last-modified-date-time)
return
$last-modified-date-time
}
};
declare function config:pocom-people-last-modified() as xs:dateTime {
collection($config:POCOM_COL_PEOPLE)//last-modified-date
=> sort() => reverse() => head()
=> concat("T00:00:00Z") => xs:dateTime()
};
declare variable $config:PUBLICATIONS :=
map {
"app": map {
"publication-last-modified": config:last-modified-from-repo-xml($config:app-root)
},
"frus": map {
"collection": $config:FRUS_COL_VOLUMES,
"document-last-modified": config:last-modified-from-git($config:FRUS_COL, "volumes"),
"select-document": function($document-id) { doc($config:FRUS_COL_VOLUMES || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) {
let $node := doc($config:FRUS_COL_VOLUMES || '/' || $document-id || '.xml')/id($section-id)
let $some-published := root($node)//tei:revisionDesc[@status = ("published", "partially-published")]
return
(: return 404s for interior divs from volumes that are not yet at least partially published,
since we may need to publish TEI containing just chapter titles,
when publication of a chapter is anticipated :)
if (not($some-published)) then
()
(: most requests will be for divs :)
else if ($node instance of element(tei:div)) then
$node
(: catch requests for TEI/@xml:id :)
else if ($node instance of element(tei:TEI)) then
let $requested-url := request:get-parameter("requested-url", ())
let $new-url := replace($requested-url, "/" || $document-id || "$", "")
return
response:redirect-to(xs:anyURI($new-url))
(: catch requests for footnotes :)
else if ($node instance of element(tei:note)) then
let $parent-doc := $node/ancestor::tei:div[1]
let $requested-url := request:get-parameter("requested-url", ())
let $new-url := replace($requested-url, $section-id || "$", $parent-doc/@xml:id || "#fn:" || util:node-id($node))
return
response:redirect-to(xs:anyURI($new-url))
(: catch requests for index cross-references :)
else if ($node instance of element(tei:item)) then
let $parent-doc := $node/ancestor::tei:div[1]
let $requested-url := request:get-parameter("requested-url", ())
let $new-url := replace($requested-url, $section-id || "$", $parent-doc/@xml:id || "#" || $node/@xml:id)
return
response:redirect-to(xs:anyURI($new-url))
else
$node
},
"html-href": function($document-id, $section-id) { "$app/historicaldocuments/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform":
(: Called to transform content based on the odd using tei simple pm :)
function($xml, $parameters) { pm-frus:transform($xml, map:merge(($parameters, map:entry("document-list", true())), map{"duplicates": "use-last"})) },
"title": "Historical Documents",
"next": tu:get-next#1,
"previous": tu:get-previous#1,
"base-path": function($document-id, $section-id) { "frus/" || $document-id },
"open-graph": map{
"og:type": function($node as node()?, $model as map(*)?) {'document'}
},
"citation-meta": function($node as node()?, $model as map(*)?) as map(*) {
config:tei-citation-meta($node, $model)
},
"breadcrumb-title":
function($parameters as map(*)) as xs:string? {
config:tei-full-breadcrumb-title(
$parameters?publication-id,
$parameters?document-id,
$parameters?section-id,
$parameters?truncate
)
}
},
(: commented out in urls.xml and controller.xql
- see https://github.com/HistoryAtState/hsg-shell/commit/7584921c69c722c6c40b2418af19d3f551f7f5ef
- note that the referenced collection was the old bibliography collection
:)
(:
"frus-list": map{
"collection": $config:FRUS_COL_METADATA,
"publication-last-modified": config:last-modified-from-repo-xml($config:FRUS_COL)
},
:)
(: used in urls.xml for loading frus administration listings and processed by pages.xqm for breadcrumbs :)
"frus-administrations": map {
"select-section": function($administration-id) {
doc($config:FRUS_COL_CODE_TABLES || '/frus-production.xml')/id('frus-administrations')//tei:category[@xml:id eq $administration-id]
},
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
let $admin := $config:PUBLICATIONS?frus-administration?select-section($parameters?administration-id)
return $admin/tei:catDesc/tei:term/string()
},
"publication-last-modified": config:last-modified-from-repo-xml($config:FRUS_COL)
},
"buildings": map {
"collection": $config:OP_BUILDINGS_COL,
"publication-last-modified": config:last-modified-from-repo-xml($config:OP_COL) ,
"document-last-modified": config:last-modified-from-git($config:OP_COL, "buildings"),
"select-document": function($document-id) { doc($config:OP_BUILDINGS_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:OP_BUILDINGS_COL || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/departmenthistory/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, $parameters) },
"title": "Buildings - Department History",
"next": tu:get-next#1,
"previous": tu:get-previous#1,
"base-path": function($document-id, $section-id) { "buildings" },
"breadcrumb-title": function($parameters as map(*)) {
config:tei-full-breadcrumb-title-from-section('buildings', 'buildings', $parameters?section-id, false())
}
},
"historicaldocuments": map {
"title": "Historical Documents",
"publication-last-modified": config:last-modified-from-repo-xml($config:FRUS_COL)
},
"about-frus": map {
"title": "About the Foreign Relations Series - Historical Documents",
"publication-last-modified": config:last-modified-from-repo-xml($config:app-root)
},
"conferences": map {
"collection": $config:CONFERENCES_COL_ARTICLES,
"document-last-modified": config:last-modified-from-git($config:CONFERENCES_COL, "data"),
"select-document": function($document-id) { doc($config:CONFERENCES_COL_ARTICLES || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:CONFERENCES_COL_ARTICLES || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/conferences/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, map:merge(($parameters, map:entry("document-list", true())), map{"duplicates": "use-last"})) },
"title": "Conferences",
"next": tu:get-next#1,
"previous": tu:get-previous#1,
"base-path": function($document-id, $section-id) { "conferences" },
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
config:tei-full-breadcrumb-title(
$parameters?publication-id,
$parameters?document-id,
$parameters?section-id,
$parameters?truncate
)
}
},
"status-of-the-series": map {
"title": "Foreign Relations of the United States: Status of the Series - Historical Documents",
"publication-last-modified": config:last-modified-from-repo-xml($config:FRUS_COL)
},
"ebooks": map {
"publication-last-modified": config:last-modified-from-repo-xml($config:FRUS_COL)
},
"quarterly-releases": map {
"publication-last-modified": config:last-modified-from-repo-xml($config:app-root)
},
"citing-frus": map {
"title": "Citing the Foreign Relations series - Historical Documents",
"publication-last-modified": config:last-modified-from-repo-xml($config:app-root)
},
"other-electronic-resources": map {
"title": "Electronic Resources for U.S. Foreign Relations - Historical Documents",
"publication-last-modified": config:last-modified-from-repo-xml($config:app-root)
},
"countries": map {
"collection": $config:COUNTRIES_COL_ARTICLES,
"publication-last-modified": config:last-modified-from-repo-xml($config:COUNTRIES_COL) ,
"document-last-modified": config:last-modified-from-git($config:COUNTRIES_COL, "articles"),
"select-document": function($document-id) { doc($config:COUNTRIES_COL_ARTICLES || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:COUNTRIES_COL_ARTICLES || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/countries/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, $parameters) },
"title": "Countries",
"base-path": function($document-id, $section-id) { "countries" },
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
config:tei-full-breadcrumb-title(
$parameters?publication-id,
$parameters?document-id,
$parameters?section-id,
$parameters?truncate
)
}
},
"countries-other": map {
"publication-last-modified": config:last-modified-from-repo-xml($config:COUNTRIES_COL)
},
"archives": map {
"collection": $config:ARCHIVES_COL_ARTICLES,
"publication-last-modified": config:last-modified-from-repo-xml($config:ARCHIVES_COL) ,
"document-last-modified": config:last-modified-from-git($config:ARCHIVES_COL, "articles"),
"select-document": function($document-id) { doc($config:ARCHIVES_COL_ARTICLES || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:ARCHIVES_COL_ARTICLES || '/' || $document-id || '.xml')//tei:body },
"html-href": function($document-id, $section-id) { "$app/countries/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, $parameters) },
"title": "World Wide Diplomatic Archives Index",
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
config:tei-full-breadcrumb-title(
$parameters?publication-id,
$parameters?document-id,
$parameters?section-id,
$parameters?truncate
)
}
},
"frus-history": map {
"publication-last-modified": config:last-modified-from-repo-xml($config:FRUS_HISTORY_COL)
},
"frus-history-articles": map {
"collection": $config:FRUS_HISTORY_COL_ARTICLES,
"publication-last-modified": config:last-modified-from-repo-xml($config:FRUS_HISTORY_COL) ,
"document-last-modified": config:last-modified-from-git($config:FRUS_HISTORY_COL, "articles"),
"select-document": function($document-id) { doc($config:FRUS_HISTORY_COL_ARTICLES || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:FRUS_HISTORY_COL_ARTICLES || '/' || $document-id || '.xml')/id($section-id) },
"next": frus-history:get-next-article#1,
"previous": frus-history:get-previous-article#1,
"html-href": function($document-id, $section-id) { "$app/frus-history/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, $parameters) },
"base-path": function($document-id, $section-id) { "frus150" },
"breadcrumb-title":
function($parameters as map(*)) as xs:string? {
config:tei-short-breadcrumb-title($parameters?publication-id, $parameters?document-id)
}
},
"departmenthistory": map {
"title": "Department History",
"publication-last-modified": config:last-modified-from-repo-xml($config:app-root)
},
"diplomatic-couriers": map {
"title": "U.S. Diplomatic Couriers - Department History"
},
"people": map {
"collection": $config:OP_SECRETARY_BIOS_COL,
"publication-last-modified": config:last-modified-from-repo-xml($config:OP_COL) ,
"document-last-modified": config:last-modified-from-git($config:OP_COL, "secretary-bios"),
"select-document": function($document-id) { doc($config:OP_SECRETARY_BIOS_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:OP_SECRETARY_BIOS_COL || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/departmenthistory/people/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform":
(: Called to transform content based on the odd using tei simple pm :)
function($xml, $parameters) { pm-frus:transform($xml, map:merge(($parameters, map:entry("document-list", true())), map{"duplicates": "use-last"})) },
"title": "People - Department History",
"base-path": function($document-id, $section-id) { "secretaries" },
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
let $role as element(org-mission)? := collection('/db/apps/pocom/missions-orgs')/org-mission[id eq $parameters?role-or-country-id]
let $country as element(country)? := collection('/db/apps/gsh/data/countries-old')/country[id eq $parameters?role-or-country-id]
let $person as element(person)? := collection('/db/apps/pocom/people')/person[id eq $parameters?person-id]
return
if (exists($role)) then
$role/names/plural/string()
else if (exists($country)) then
$country/label/string()
else if (exists($person)) then
$person/persName/string-join((forename, surname, genName), ' ')
else ()
}
},
"secretaries": map {
"title": "Biographies of the Secretaries of State - Department History",
"publication-last-modified": config:last-modified-from-repo-xml($config:POCOM_COL)
},
"principals-chiefs": map {
"title": "Principal Officers and Chiefs of Mission - Department History",
"publication-last-modified": config:last-modified-from-repo-xml($config:app-root)
},
"people-by-alpha": map {
"title": "Principal Officers and Chiefs of Mission Alphabetical Listing - Department History",
"breadcrumb-title":
function($parameters as map(*)) as xs:string? {
"Starting with " || upper-case($parameters?letter)
},
"publication-last-modified": config:pocom-people-last-modified#0
},
"people-by-year": map {
"title": "Principal Officers and Chiefs of Mission Chronological Listing - Department History",
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
$parameters?year
},
"publication-last-modified": config:pocom-people-last-modified#0
},
"people-by-role": map {
"title": "Principal Officers and Chiefs of Mission Alphabetical Listing - Department History",
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
collection('/db/apps/pocom/positions-principals')/principal-position[id eq $parameters?role-id]/names/plural/string()
},
"publication-last-modified": config:pocom-people-last-modified#0
},
"tags": map {
"title": "Tags",
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
collection($config:TAGS_COL || '/taxonomy')//*[id eq $parameters?tag-id]/label/string()
},
"publication-last-modified": config:last-modified-from-repo-xml($config:TAGS_COL)
},
"travels": map {
"title": "Presidents and Secretaries of State Foreign Travels - Department History",
"publication-last-modified": config:last-modified-from-repo-xml($config:TRAVELS_COL)
},
"travels-president": map {
"title": "Travels of the President - Department History",
"breadcrumb-title":
function($parameters as map(*)) as xs:string? {
let $key := $parameters?person-or-country-id
let $current-country-name :=
let $trips :=
for $trip in collection($config:TRAVELS_COL_PRESIDENTS_TRAVELS)//trip[country/@id eq $key]
order by $trip/start-date
return $trip
return
$trips[last()]/country
let $president-name := head(collection($config:TRAVELS_COL_PRESIDENTS)//president[id eq $key])/name
return
if (exists($current-country-name)) then
$current-country-name/string()
else (: if (exists($president-name)) then :)
$president-name/string()
},
"publication-last-modified": config:last-modified-from-repo-xml($config:TRAVELS_COL)
},
"travels-secretary": map {
"title": "Travels of the Secretary of State - Department History",
"breadcrumb-title":
function($parameters as map(*)) as xs:string? {
let $key := $parameters?person-or-country-id
let $current-country-name :=
let $trips :=
for $trip in collection($config:TRAVELS_COL_SECRETARIES_TRAVELS)//trip[country/@id eq $key]
order by $trip/start-date
return $trip
return
$trips[last()]/country
let $secretary-name := head(collection($config:TRAVELS_COL_SECRETARIES_TRAVELS)//trip[@who eq $key])/name
return
if (exists($current-country-name)) then
$current-country-name/string()
else (: if (exists($secretary-name)) then :)
$secretary-name/string()
},
"publication-last-modified": config:last-modified-from-repo-xml($config:TRAVELS_COL)
},
"visits": map {
"title": "Visits of Foreign Leaders and Heads of State - Department History",
"publication-last-modified": config:last-modified-from-repo-xml($config:VISITS_COL) ,
"breadcrumb-title":
function($parameters as map(*)) as xs:string? {
let $key := $parameters?country-or-year
let $current-country-name :=
let $visits :=
for $visit in collection($config:VISITS_COL)//visit[from/@id eq $key]
order by $visit/start-date
return $visit
return
$visits[last()]/from
return
if (exists($current-country-name)) then
$current-country-name/string()
else
(: $key is a year :)
$key
}
},
"wwi": map {
"title": "World War I - Department History",
"publication-last-modified": config:last-modified-from-repo-xml($config:app-root)
},
"milestones": map {
"collection": $config:MILESTONES_COL_CHAPTERS,
"publication-last-modified": config:last-modified-from-repo-xml($config:MILESTONES_COL) ,
"document-last-modified": config:last-modified-from-git($config:MILESTONES_COL, "chapters"),
"select-document": function($document-id) { doc($config:MILESTONES_COL_CHAPTERS || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:MILESTONES_COL_CHAPTERS || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/milestones/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, $parameters) },
"title": "Milestones in the History of U.S. Foreign Relations",
"next": tu:get-next#1,
"previous": tu:get-previous#1,
"base-path": function($document-id, $section-id) { "milestones" },
"breadcrumb-title": function($parameters as map(*)) {
if (exists($parameters?section-id)) then
$config:PUBLICATIONS?($parameters?publication-id)?select-section($parameters?document-id, $parameters?section-id)/tei:head[1]/string()
else $parameters?document-id
}
},
"short-history": map {
"collection": $config:OP_SHORT_HISTORY_COL,
"publication-last-modified": config:last-modified-from-repo-xml($config:OP_COL) ,
"document-last-modified": config:last-modified-from-git($config:OP_COL, "short-history"),
"select-document": function($document-id) { doc($config:OP_SHORT_HISTORY_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:OP_SHORT_HISTORY_COL || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/departmenthistory/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, map:merge(($parameters, map:entry("document-list", true())), map{"duplicates": "use-last"})) },
"title": "Short History - Department History",
"next": tu:get-next#1,
"previous": tu:get-previous#1,
"base-path": function($document-id, $section-id) { "short-history" },
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
config:tei-full-breadcrumb-title(
$parameters?publication-id,
$parameters?document-id,
$parameters?section-id,
$parameters?truncate
)
}
},
"timeline": map {
"collection": $config:ADMINISTRATIVE_TIMELINE_DATA_COL,
"publication-last-modified": config:last-modified-from-repo-xml($config:ADMINISTRATIVE_TIMELINE_COL),
"document-last-modified": config:last-modified-from-git($config:ADMINISTRATIVE_TIMELINE_COL, "timeline"),
"select-document": function($document-id) { doc($config:ADMINISTRATIVE_TIMELINE_DATA_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:ADMINISTRATIVE_TIMELINE_DATA_COL || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/departmenthistory/" || string-join(($document-id, substring-after($section-id, 'chapter_')), '/') },
"url-fragment": function($div) { if (starts-with($div/@xml:id, 'chapter_')) then substring-after($div/@xml:id, 'chapter_') else $div/@xml:id/string() },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, map:merge(($parameters, map:entry("document-list", true())), map{"duplicates": "use-last"})) },
"title": "Administrative Timeline - Department History",
"next": tu:get-next#1,
"previous": tu:get-previous#1,
"base-path": function($document-id, $section-id) { "timeline" },
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
config:tei-full-breadcrumb-title(
$parameters?publication-id,
$parameters?document-id,
$parameters?section-id,
$parameters?truncate
)
}
},
"faq": map {
"collection": $config:OP_FAQ_COL,
"publication-last-modified": config:last-modified-from-repo-xml($config:OP_COL) ,
"document-last-modified": config:last-modified-from-git($config:OP_COL, "faq"),
"select-document": function($document-id) { doc($config:OP_FAQ_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:OP_FAQ_COL || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/about/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, map:merge(($parameters, map:entry("document-list", true())), map{"duplicates": "use-last"})) },
"title": "FAQ - About Us",
"next": tu:get-next#1,
"previous": tu:get-previous#1,
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
config:tei-full-breadcrumb-title(
$parameters?publication-id,
$parameters?document-id,
$parameters?section-id,
$parameters?truncate
)
}
},
"hac": map {
"collection": $config:HAC_COL,
"publication-last-modified": config:last-modified-from-repo-xml($config:HAC_COL),
"document-last-modified": config:last-modified-from-git($config:HAC_COL),
"select-document": function($document-id) { doc($config:HAC_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:HAC_COL || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/about/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, map:merge(($parameters, map:entry("document-list", true())), map{"duplicates": "use-last"})) },
"title": "Historical Advisory Committee - About Us",
"next": tu:get-next#1,
"previous": tu:get-previous#1,
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
config:tei-full-breadcrumb-title(
$parameters?publication-id,
$parameters?document-id,
$parameters?section-id,
$parameters?truncate
)
}
},
"education": map {
"collection": $config:OP_EDUCATION_COL,
"document-last-modified": config:last-modified-from-git($config:OP_COL, "education/introductions"),
"select-document": function($document-id) { doc($config:OP_EDUCATION_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:OP_EDUCATION_COL || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/education/modules/" || string-join(($document-id, $section-id), '#') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, $parameters) },
"title": "Education Resources",
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
config:tei-full-breadcrumb-title(
$parameters?publication-id,
$parameters?document-id,
$parameters?section-id,
$parameters?truncate
)
}
},
"education-modules": map {
"title": "Curriculum Modules - Education Resources"
},
"frus-history-monograph": map {
"collection": $config:FRUS_HISTORY_COL_MONOGRAPH,
"publication-last-modified": config:last-modified-from-repo-xml($config:FRUS_HISTORY_COL) ,
"document-last-modified": config:last-modified-from-git($config:FRUS_HISTORY_COL, "monograph"),
"select-document": function($document-id) { doc($config:FRUS_HISTORY_COL_MONOGRAPH || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) {
let $target-section-id :=
(: catch xlink requests :)
if (starts-with($section-id, "range(")) then
substring-before(substring-after($section-id, "range("), ",")
else
$section-id
let $node := doc($config:FRUS_HISTORY_COL_MONOGRAPH || '/' || $document-id || '.xml')/id($target-section-id)
return
(: most requests will be for divs :)
if ($node instance of element(tei:div)) then
$node
(: catch requests for TEI/@xml:id :)
else if ($node instance of element(tei:TEI)) then
let $requested-url := request:get-parameter("requested-url", ())
let $new-url := replace($requested-url, "/" || $document-id || "$", "")
return
response:redirect-to(xs:anyURI($new-url))
(: catch requests for footnotes :)
else if ($node instance of element(tei:note)) then
let $parent-doc := $node/ancestor::tei:div[1]
let $requested-url := request:get-parameter("requested-url", ())
let $new-url := replace($requested-url, $section-id || "$", $parent-doc/@xml:id || "#fn:" || util:node-id($node))
return
response:redirect-to(xs:anyURI($new-url))
(: catch requests for index cross-references and anchors :)
else if ($node instance of element(tei:item) or $node instance of element(tei:anchor)) then
let $parent-doc := $node/ancestor::tei:div[1]
let $requested-url := request:get-parameter("requested-url", ())
let $new-url := replace($requested-url, $section-id, $parent-doc/@xml:id || "#" || $node/@xml:id, "q")
return
response:redirect-to(xs:anyURI($new-url))
else
$node
},
"html-href": function($document-id, $section-id) { "$app/historicaldocuments/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) {
pm-frus:transform($xml, map:merge(($parameters, map:entry("document-list", true())), map{"duplicates": "use-last"}))
},
"title": "History of the Foreign Relations Series",
"next": tu:get-next#1,
"previous": tu:get-previous#1,
"base-path": function($document-id, $section-id) { "frus-history" },
"open-graph": map{
"og:type": function($node as node()?, $model as map(*)?) {'document'}
},
"citation-meta": function($node as node()?, $model as map(*)?) as map(*)* {
config:tei-citation-meta($node, $model)
},
"breadcrumb-title": function($parameters as map(*)) {
config:tei-full-breadcrumb-title(
$parameters?publication-id,
$parameters?document-id,
$parameters?section-id,
$parameters?truncate
)
}
},
"frus-history-documents": map {
"collection": $config:FRUS_HISTORY_COL_DOCUMENTS,
"publication-last-modified": config:last-modified-from-repo-xml($config:FRUS_HISTORY_COL),
"document-last-modified": config:last-modified-from-git($config:FRUS_HISTORY_COL, "documents"),
"next": frus-history:get-next-doc#1,
"previous": frus-history:get-previous-doc#1,
"select-document": function($document-id) { doc($config:FRUS_HISTORY_COL_DOCUMENTS || "/" || $document-id || ".xml") },
"breadcrumb-title": function($parameters as map(*)) as xs:string? {
config:tei-short-breadcrumb-title($parameters?publication-id, $parameters?document-id)
}
},
"vietnam-guide": map {
"collection": $config:OP_VIETNAM_GUIDE_COL,
"publication-last-modified": config:last-modified-from-repo-xml($config:OP_COL) ,
"document-last-modified": config:last-modified-from-git($config:OP_COL, "vietnam-guide"),
"select-document": function($document-id) { doc($config:OP_VIETNAM_GUIDE_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:OP_VIETNAM_GUIDE_COL || '/' || $document-id || '.xml') },
"html-href": function($document-id, $section-id) { "$app/historicaldocuments/" || string-join(($document-id, $section-id), '/') },
"odd": "frus.odd",
"transform": function($xml, $parameters) { pm-frus:transform($xml, $parameters) },
"title": "Guide to Sources on Vietnam, 1969-1975"
},
"views-from-the-embassy": map {
"collection": $config:OP_VIEWS_FROM_EMBASSY_COL,
"document-last-modified": config:last-modified-from-git($config:OP_COL, "views-from-the-embassy"),
"select-document": function($document-id) { doc($config:OP_VIEWS_FROM_EMBASSY_COL || '/' || $document-id || '.xml') },
"select-section": function($document-id, $section-id) { doc($config:OP_VIEWS_FROM_EMBASSY_COL || '/' || $document-id || '.xml')/id($section-id) },
"html-href": function($document-id, $section-id) { "$app/departmenthistory/wwi" },
"title": "World War I and the Department - Department History"
},
"other-publications": map{
"publication-last-modified": config:last-modified-from-repo-xml($config:OP_COL)
},
"serial-set": map{
"breadcrumb-title": function($parameters as map(*)) as xs:string* {
let $subject as xs:string? := $parameters?subject
let $region as xs:string? := $parameters?region
return
if (exists($subject)) then $subject
else if (exists($region)) then $region
else ()
}
},
"search": map{
"publication-last-modified": config:search-last-modified#0
},
"news": map{
"collection": $config:NEWS_COL,
"select-document": function($document-id) {
collection($config:NEWS_COL)/*[.//a:id eq $document-id] => root()
},
"document-last-modified": function($document-id) {
let $uri := collection($config:NEWS_COL)/*[.//a:id eq $document-id] => document-uri()
let $col-name := replace($uri, '(.+)/.+', '$1')
let $doc-name := replace($uri, '.+/(.+)', '$1')
return xmldb:last-modified($col-name, $doc-name)
},
"breadcrumb-title":
function($parameters as map(*)) {
collection($config:NEWS_COL)/a:entry[a:id eq $parameters?document-id]/a:title/xhtml:div/node()
}
}
};
(:
: collections that are part of the full-text search
: in order to calculate the cacheing time they all
: need be taken into consideration
:)
declare variable $config:search-collection-names := (
"conferences",
"other-publications",
"hac",
"frus",
"frus-history",
"rdcr",
"wwdai",
"pocom",
"travels",
"visits",
"milestones"
);
declare function config:search-last-modified() {
max(
for $collection-name in $config:search-collection-names
return config:last-modified-from-repo-xml("/db/apps/" || $collection-name)()
)
};
declare variable $config:PUBLICATION-COLLECTIONS :=
map {
$config:FRUS_COL_VOLUMES: "frus",
$config:OP_BUILDINGS_COL: "buildings",
$config:OP_SHORT_HISTORY_COL: "short-history",
$config:ADMINISTRATIVE_TIMELINE_DATA_COL: "timeline",
$config:OP_FAQ_COL: "faq",
$config:HAC_COL: "hac",
$config:OP_EDUCATION_COL: "education",
$config:FRUS_HISTORY_COL_MONOGRAPH: "frus-history-monograph",
$config:CONFERENCES_COL_ARTICLES: "conferences",
$config:MILESTONES_COL_CHAPTERS: "milestones",
$config:FRUS_HISTORY_COL_ARTICLES: "articles",
$config:OP_SECRETARY_BIOS_COL: "people",
$config:OP_VIETNAM_GUIDE_COL: "vietnam-guide",
$config:OP_VIEWS_FROM_EMBASSY_COL: "views-from-the-embassy",
$config:COUNTRIES_COL_ARTICLES: "countries",
$config:ARCHIVES_COL_ARTICLES: "archives",
$config:NEWS_COL: "news"
};
declare variable $config:OPEN_GRAPH_KEYS := ("og:type", "twitter:card", "twitter:site", "og:site_name", "og:title", "og:description", "og:image", "og:url", "citation");
declare variable $config:OPEN_GRAPH as map(xs:string, function(*)) := map{
"twitter:card": function($node, $model) {
<meta property='twitter:card' content='summary'/>
},
"twitter:site": function($node, $model) {
<meta property='twitter:site' content='@HistoryAtState'/>
},
"og:site_name": function($node, $model) {
<meta property='og:site_name' content='Office of the Historian'/>
},
"og:image": function($node, $model) {
for $img in $model?data//tei:graphic
return
<meta property="og:image" content="https://static.history.state.gov/{$model?base-path}/{$img/@url}"/>,
<meta property="og:image" content="https://static.history.state.gov/images/avatar_big.jpg"/>,
<meta property="og:image:width" content="400"/>,
<meta property="og:image:height" content="400"/>,
<meta property="og:image:alt" content="Office of the Historian social media avatar"/>
},
"og:type": function($node, $model) {
<meta property="og:type" content="{
let $publication-id := $model?publication-id
let $pub-type := $config:PUBLICATIONS?($publication-id)?open-graph?("og:type")
return
($pub-type ! .($node, $model), 'website')[1]
}"/>
},
"og:title": function($node, $model) {
<meta property="og:title" content="{pages:generate-short-title($node, $model)}"/>
},
"og:description": function($node, $model) {
<meta property="og:description" content="Office of the Historian"/>
},
"og:url": function($node, $model) {
<meta property="og:url" content="{$model?url}"/>
},
"citation": function ($node, $model) as element(meta)* {
let $citation-meta as function(*)? := $config:PUBLICATIONS?($model?publication-id)?citation-meta
let $cls as array(*) := array {
if (exists($model?citation-meta)) then
$model?citation-meta
else if (exists($citation-meta)) then
$citation-meta($node, $model)
else
config:default-citation-meta($node, $model)
}
return config:cls-to-html($cls)
}
};
(:~
: Resolve the given path using the current application context.
: If the app resides in the file system,
:)
declare function config:resolve($relPath as xs:string) {
if (starts-with($config:app-root, "/db")) then
doc(concat($config:app-root, "/", $relPath))
else
doc(concat("file://", $config:app-root, "/", $relPath))
};
(:~
: Returns the repo.xml descriptor for the current application.
:)
declare function config:repo-descriptor() as element(repo:meta) {
$config:repo-descriptor
};
(:~
: Returns the expath-pkg.xml descriptor for the current application.
:)
declare function config:expath-descriptor() as element(expath:package) {
$config:expath-descriptor
};
declare %templates:wrap function config:app-title($node as node(), $model as map(*)) as text() {
$config:expath-descriptor/expath:title/text()
};
declare function config:app-meta($node as node(), $model as map(*)) as element()* {
<meta xmlns="http://www.w3.org/1999/xhtml" name="description" content="{$config:repo-descriptor/repo:description/text()}"/>,
(:
config:open-graph(
$node,
map:merge(
(
map{
"open-graph-keys": $config:OPEN_GRAPH_KEYS,
"open-graph": $config:OPEN_GRAPH,
"url": request:get-url()
},
$model
),
map{"duplicates": "use-last"}
)
),
:)
for $author in $config:repo-descriptor/repo:author[fn:normalize-space(.) ne '']
return
<meta xmlns="http://www.w3.org/1999/xhtml" name="creator" content="{$author/text()}"/>
};
(:~
: This function creates Open Graph metadata for page templates.
: See https://github.com/HistoryAtState/hsg-project/wiki/social-media-cards.
:)
declare function config:open-graph($node as node()?, $model as map(*)?) as element()* {
for $key in $model?open-graph-keys
for $fn in $model?open-graph($key)
return $fn($node, $model)
};
(:~
: For debugging: generates a table showing all properties defined
: in the application descriptors.
:)
declare function config:app-info($node as node(), $model as map(*)) {
let $expath := config:expath-descriptor()
let $repo := config:repo-descriptor()
return
<table class="app-info">
<tr>
<td>app collection:</td>
<td>{$config:app-root}</td>
</tr>
{
for $attr in ($expath/@*, $expath/*, $repo/*)
return
<tr>
<td>{node-name($attr)}:</td>
<td>{$attr/string()}</td>
</tr>
}
<tr>
<td>Controller:</td>
<td>{ request:get-attribute("$exist:controller") }</td>
</tr>
</table>
};
(:
: Function for generating short titles from TEI content
:)
declare function config:tei-short-breadcrumb-title($publication-id as xs:string?, $document-id as xs:string?) as xs:string? {
let $article := $config:PUBLICATIONS?($publication-id)?select-document($document-id)
return $article//tei:title[@type='short']/string()
};