Skip to content

Commit

Permalink
Merge pull request #452 from Edirom/issue-451
Browse files Browse the repository at this point in the history
Switch Beacon Link provider
  • Loading branch information
peterstadler authored Jan 26, 2024
2 parents b1a0682 + ad86696 commit 99ccfba
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 118 deletions.
2 changes: 0 additions & 2 deletions catalogues/options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
<entry xml:id="munich-stadtmuseum">https://stadtmuseum.bayerische-landesbibliothek-online.de/pnd/</entry>
<entry xml:id="adb">http://tools.wmflabs.org/persondata/redirect/gnd/ws-adb/</entry>
<entry xml:id="dnb">http://d-nb.info/gnd/</entry>
<entry xml:id="beacon">http://beacon.findbuch.de/seealso/pnd-aks?format=seealso&amp;id=</entry>
<entry xml:id="gnd-beacon">http://beacon.findbuch.de/seemore/gnd-aks?format=seealso&amp;id=</entry>
</div>
<div xml:id="beaconFileURIs">
<entry xml:id="adbBeacon">http://www.historische-kommission-muenchen-editionen.de/beacon_adb.txt</entry>
Expand Down
7 changes: 3 additions & 4 deletions modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -894,11 +894,10 @@ declare
else map {}
return
map { 'beaconLinks':
for $i in map:keys($beaconMap)
order by $beaconMap($i)[2]
for $i in $beaconMap?*
order by $i?text => lower-case() collation "?lang=de;strength=primary"
return
(: replacement in @href for invalid links from www.sbn.it :)
<a xmlns="http://www.w3.org/1999/xhtml" title="{$i}" href="{replace($beaconMap($i)[1], '\\', '%5C')}">{$beaconMap($i)[2]}</a>
<a xmlns="http://www.w3.org/1999/xhtml" title="{map:keys($i)}" href="{$i?link}">{$i?text}</a>
}
};

Expand Down
48 changes: 26 additions & 22 deletions modules/external-requests.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -338,29 +338,33 @@ declare function er:translate-authority-id($idno as element(), $to as xs:string)
) ! str:normalize-space(.)
};

(:~
: Fetch linked resources from a Beacon aggregator service for a given GND
: At present https://data.deutsche-biographie.de/beta/beacon-open/ is used
:
: @param $gnd a GND identifier
: @param $docType the document type (e.g., letters, writings, persons)
: @return a map object like { "providerA": {"link": $link, "text": $text }, "providerB": {"link": $link, "text": $text } }
:)
declare function er:beacon-map($gnd as xs:string, $docType as xs:string) as map(*) {
let $findbuchResponse :=
switch($docType)
case 'persons' return er:grabExternalResource('beacon', $gnd, 'de')
default return er:grabExternalResource('gnd-beacon', $gnd, 'de')
(:let $log := util:log-system-out($gnd):)
let $jxml :=
if(exists($findbuchResponse)) then
if($findbuchResponse/er:body/@encoding = 'Base64Encoded') then parse-json(util:binary-to-string($findbuchResponse))
else parse-json($findbuchResponse)
else ()
return
if(exists($jxml)) then
map:merge(
for $i in 1 to array:size($jxml?2)
let $link := str:normalize-space($jxml?4?($i))
let $title := str:normalize-space($jxml?3?($i))
let $text := str:normalize-space($jxml?2?($i))
return
if(matches($link,"weber-gesamtausgabe.de")) then ()
else map:entry($title, ($link, $text))
)
else map {}
let $fileName := $gnd || '.xml'
let $localFilePath := str:join-path-elements(($config:tmp-collection-path, 'beacon', $fileName))
let $uri := 'https://data.deutsche-biographie.de/rest/bd/gnd/' || $gnd || '/alle_de'
let $response as element(er:response)? :=
if(er:bot-present() or not($gnd))
then map {}
else er:cached-external-request($uri, $localFilePath)
return
map:merge(
for $item in $response//item[ref]
let $link := str:normalize-space($item/ref/@target)
let $title := str:normalize-space($item/@type)
let $text := str:normalize-space($item/ref)
return
if(matches($link, "weber-gesamtausgabe.de|#adbcontent") or not(starts-with($link, "http")))
then ()
else map { $title: map {"link": $link, "text": $text }}
)
};

(:~
Expand Down
16 changes: 10 additions & 6 deletions templates/work.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,24 @@ <h2 data-template="lang:translate">documents</h2>
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="nav-item gradient-light">
<a class="nav-link active" data-toggle="tab" href="#wegaText">WeGA Text</a>
<a class="nav-link active" data-toggle="tab" href="#wegaText">WeGA Text</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#wikipediaText" data-template="app:ajax-tab">wikipedia-article</a>
<a class="nav-link" data-toggle="tab" href="#wikipediaText" data-template="app:ajax-tab">wikipedia-article</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#gndText" data-template="app:ajax-tab">gnd-entry</a>
<a class="nav-link" data-toggle="tab" href="#gndText" data-template="app:ajax-tab">gnd-entry</a>
</li>
<!--
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#gnd-beacon" data-template="app:ajax-tab">gnd-beacon</a>
<a class="nav-link" data-toggle="tab" href="#gnd-beacon" data-template="app:ajax-tab">gnd-beacon</a>
</li>
-->
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#XMLPreview" data-template="app:ajax-tab">XML-Preview</a>
<a class="nav-link" data-toggle="tab" href="#XMLPreview" data-template="app:ajax-tab">XML-Preview</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" href="#" data-toggle="modal" data-target="#downloadModal">Download</a>
<a class="nav-link" href="#" data-toggle="modal" data-target="#downloadModal">Download</a>
</li>
</ul>
</div>
Expand Down Expand Up @@ -162,9 +164,11 @@ <h2>Wikipedia</h2>
<div class="tab-pane fade" id="gndText">
<h2>GND</h2>
</div>
<!--
<div class="tab-pane fade" id="gnd-beacon">
<h2>GND Beacon Links</h2>
</div>
-->
<div class="tab-pane fade" id="XMLPreview">
<h2>XML</h2>
<!--<pre class="prettyprint"><code class="language-xml"><![CDATA[<element xmlns="http://bla.org"><foo>some text</foo></element>]]></code></pre>-->
Expand Down
6 changes: 0 additions & 6 deletions testing/expected-results/works/A020002.html
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,6 @@ <h2>Dokumente</h2>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#gndText" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020002/dnb.html">GND Eintrag</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#gnd-beacon" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020002/beacon.html">GND Beacon Links</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#XMLPreview" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020002/xml.html">XML-Vorschau</a>
</li>
Expand Down Expand Up @@ -378,9 +375,6 @@ <h2>Wikipedia</h2>
<div class="tab-pane fade" id="gndText">
<h2>GND</h2>
</div>
<div class="tab-pane fade" id="gnd-beacon">
<h2>GND Beacon Links</h2>
</div>
<div class="tab-pane fade" id="XMLPreview">
<h2>XML</h2>

Expand Down
6 changes: 0 additions & 6 deletions testing/expected-results/works/A020010.html
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,6 @@ <h2>Dokumente</h2>
<li class="nav-item gradient-light">
<a class="nav-link deactivated"></a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link deactivated"></a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#XMLPreview" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020010/xml.html">XML-Vorschau</a>
</li>
Expand Down Expand Up @@ -381,9 +378,6 @@ <h2>Wikipedia</h2>
<div class="tab-pane fade" id="gndText">
<h2>GND</h2>
</div>
<div class="tab-pane fade" id="gnd-beacon">
<h2>GND Beacon Links</h2>
</div>
<div class="tab-pane fade" id="XMLPreview">
<h2>XML</h2>

Expand Down
6 changes: 0 additions & 6 deletions testing/expected-results/works/A020034.html
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,6 @@ <h2>Dokumente</h2>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#gndText" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020034/dnb.html">GND Eintrag</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#gnd-beacon" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020034/beacon.html">GND Beacon Links</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#XMLPreview" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020034/xml.html">XML-Vorschau</a>
</li>
Expand Down Expand Up @@ -380,9 +377,6 @@ <h2>Wikipedia</h2>
<div class="tab-pane fade" id="gndText">
<h2>GND</h2>
</div>
<div class="tab-pane fade" id="gnd-beacon">
<h2>GND Beacon Links</h2>
</div>
<div class="tab-pane fade" id="XMLPreview">
<h2>XML</h2>

Expand Down
6 changes: 0 additions & 6 deletions testing/expected-results/works/A020072.html
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,6 @@ <h2>Dokumente</h2>
<li class="nav-item gradient-light">
<a class="nav-link deactivated"></a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link deactivated"></a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#XMLPreview" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020072/xml.html">XML-Vorschau</a>
</li>
Expand Down Expand Up @@ -381,9 +378,6 @@ <h2>Wikipedia</h2>
<div class="tab-pane fade" id="gndText">
<h2>GND</h2>
</div>
<div class="tab-pane fade" id="gnd-beacon">
<h2>GND Beacon Links</h2>
</div>
<div class="tab-pane fade" id="XMLPreview">
<h2>XML</h2>

Expand Down
6 changes: 0 additions & 6 deletions testing/expected-results/works/A020081.html
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,6 @@ <h2>Dokumente</h2>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#gndText" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020081/dnb.html">GND Eintrag</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#gnd-beacon" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020081/beacon.html">GND Beacon Links</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#XMLPreview" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020081/xml.html">XML-Vorschau</a>
</li>
Expand Down Expand Up @@ -381,9 +378,6 @@ <h2>Wikipedia</h2>
<div class="tab-pane fade" id="gndText">
<h2>GND</h2>
</div>
<div class="tab-pane fade" id="gnd-beacon">
<h2>GND Beacon Links</h2>
</div>
<div class="tab-pane fade" id="XMLPreview">
<h2>XML</h2>

Expand Down
6 changes: 0 additions & 6 deletions testing/expected-results/works/A020209.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,6 @@ <h2>Dokumente</h2>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#gndText" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020209/dnb.html">GND Eintrag</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#gnd-beacon" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020209/beacon.html">GND Beacon Links</a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#XMLPreview" data-tab-url="/exist/apps/WeGA-WebApp/de/A002068/Werke/A020209/xml.html">XML-Vorschau</a>
</li>
Expand Down Expand Up @@ -381,9 +378,6 @@ <h2>Wikipedia</h2>
<div class="tab-pane fade" id="gndText">
<h2>GND</h2>
</div>
<div class="tab-pane fade" id="gnd-beacon">
<h2>GND Beacon Links</h2>
</div>
<div class="tab-pane fade" id="XMLPreview">
<h2>XML</h2>

Expand Down
6 changes: 0 additions & 6 deletions testing/expected-results/works/A020456.html
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,6 @@ <h2>Dokumente</h2>
<li class="nav-item gradient-light">
<a class="nav-link deactivated"></a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link deactivated"></a>
</li>
<li class="nav-item gradient-light">
<a class="nav-link" data-toggle="tab" href="#XMLPreview" data-tab-url="/exist/apps/WeGA-WebApp/de/A000584/Werke/A020456/xml.html">XML-Vorschau</a>
</li>
Expand Down Expand Up @@ -360,9 +357,6 @@ <h2>Wikipedia</h2>
<div class="tab-pane fade" id="gndText">
<h2>GND</h2>
</div>
<div class="tab-pane fade" id="gnd-beacon">
<h2>GND Beacon Links</h2>
</div>
<div class="tab-pane fade" id="XMLPreview">
<h2>XML</h2>

Expand Down
Loading

0 comments on commit 99ccfba

Please sign in to comment.