diff --git a/catalogues/options.xml b/catalogues/options.xml
index c374ab696..8658e195c 100644
--- a/catalogues/options.xml
+++ b/catalogues/options.xml
@@ -40,6 +40,7 @@
http://www.portraitindex.de/dokumente/pnd/
http://www.tripota.uni-trier.de/beacon.php?ID=
+ https://stadtmuseum.bayerische-landesbibliothek-online.de/pnd/
http://tools.wmflabs.org/persondata/redirect/gnd/ws-adb/
http://d-nb.info/gnd/
http://beacon.findbuch.de/seealso/pnd-aks?format=seealso&id=
diff --git a/modules/img.xqm b/modules/img.xqm
index ebcf5ab21..ad18ba548 100644
--- a/modules/img.xqm
+++ b/modules/img.xqm
@@ -58,7 +58,10 @@ declare
let $tripota-images :=
if(count(map:keys($beaconMap)[contains(., 'GND-Zuordnung')]) gt 0) then img:tripota-images($model, $lang)
else ()
- let $iconographyImages := ($local-image, $wikipedia-images, $portraitindex-images, $tripota-images)
+ let $munich-stadtmuseum-images :=
+ if(count(map:keys($beaconMap)[contains(., 'Porträtsammlung')]) gt 0) then img:munich-stadtmuseum-images($model, $lang)
+ else ()
+ let $iconographyImages := ($local-image, $wikipedia-images, $portraitindex-images, $tripota-images, $munich-stadtmuseum-images)
let $portrait :=
if($suppressExternalPortrait) then img:get-generic-portrait($model, $lang)
else ($iconographyImages, img:get-generic-portrait($model, $lang))[1]
@@ -93,6 +96,7 @@ declare %private function img:wikipedia-images($model as map(*), $lang as xs:str
else ()
(: Look for images in wikipedia infobox (for organizations) and thumbnails :)
let $pics := $wikiArticle//xhtml:table[contains(@class,'toptextcells')] | $wikiArticle//xhtml:div[@class='thumbinner']
+ let $errorLog := if(count($pics) = 0) then core:logToFile('info', 'img:wikipedia-images(): no images found for GND ' || $gnd) else ()
return
for $div in $pics
let $tmpPicURI := ($div//xhtml:img[@class='thumbimage']/@src | $div[self::xhtml:table]//xhtml:img[not(@class='thumbimage')]/@src)[1]
@@ -155,6 +159,7 @@ declare %private function img:portraitindex-images($model as map(*), $lang as xs
if($gnd) then wega-util:grabExternalResource('portraitindex', $gnd, config:get-doctype-by-id($model('docID')), $lang)
else ()
let $pics := $page//xhtml:div[@class='listItemThumbnail']
+ let $errorLog := if(count($pics) = 0) then core:logToFile('info', 'img:portraitindex-images(): no images found for GND ' || $gnd) else ()
return
for $div in $pics
let $picURI := $div//xhtml:img/data(@src)
@@ -185,6 +190,7 @@ declare %private function img:tripota-images($model as map(*), $lang as xs:strin
if($gnd) then wega-util:grabExternalResource('tripota', $gnd, config:get-doctype-by-id($model('docID')), $lang)
else ()
let $pics := $page//xhtml:td
+ let $errorLog := if(count($pics) = 0) then core:logToFile('info', 'img:tripota-images(): no images found for GND ' || $gnd) else ()
return
for $div in $pics
let $picURI := concat('http://www.tripota.uni-trier.de/', $div//xhtml:img[starts-with(@src, 'portraits')]/data(@src))
@@ -201,6 +207,36 @@ declare %private function img:tripota-images($model as map(*), $lang as xs:strin
else ()
};
+(:~
+ : Helper function for grabbing images from the Münchner Stadtmuseum
+ :
+ : @author Peter Stadler
+ : @param
+ : @param $lang the language variable (de|en)
+ : @return
+ :)
+declare %private function img:munich-stadtmuseum-images($model as map(*), $lang as xs:string) as map(*)* {
+ let $gnd := query:get-gnd($model('doc'))
+ let $page :=
+ if($gnd) then wega-util:grabExternalResource('munich-stadtmuseum', $gnd, config:get-doctype-by-id($model('docID')), $lang)
+ else ()
+ let $pics := $page//xhtml:a[@class='imagelink'][ancestor::xhtml:div[@id='main']]
+ let $errorLog := if(count($pics) = 0) then core:logToFile('info', 'img:munich-stadtmuseum-images(): no images found for GND ' || $gnd) else ()
+ return
+ for $a in $pics
+ let $picURI := concat('https://stadtmuseum.bayerische-landesbibliothek-online.de', $a/xhtml:img/@src)
+ return
+ if($picURI castable as xs:anyURI) then
+ map {
+ 'caption' := str:normalize-space($a/xhtml:img/@title) || ' (Quelle: Münchner Stadtmuseum)',
+ 'linkTarget' := 'https://stadtmuseum.bayerische-landesbibliothek-online.de/pnd/' || $gnd,
+ 'source' := 'Münchner Stadtmuseum',
+ 'url' := function($size) {
+ $picURI
+ }
+ }
+ else ()
+};
(:~
: Helper function for adding local (= from the WeGA) images
diff --git a/modules/wega-util.xqm b/modules/wega-util.xqm
index 2de4efd82..d4339c43b 100644
--- a/modules/wega-util.xqm
+++ b/modules/wega-util.xqm
@@ -48,7 +48,11 @@ import module namespace lang="http://xquery.weber-gesamtausgabe.de/modules/lang"
case 'deutsche-biographie' return 'https://www.deutsche-biographie.de/gnd' || $gnd || '.html'
default return config:get-option($resource) || $gnd
let $fileName := string-join(($gnd, $lang, 'xml'), '.')
- let $response := core:cache-doc(str:join-path-elements(($config:tmp-collection-path, $resource, $fileName)), wega-util:http-get#1, xs:anyURI($url), $lease)
+ let $response :=
+ (: Because the EXPath http client is very picky about HTTPS certificates, we need to use the standard httpclient module for the munich-stadtmuseum which uses HTTPS :)
+ switch($resource)
+ case 'munich-stadtmuseum' return core:cache-doc(str:join-path-elements(($config:tmp-collection-path, $resource, $fileName)), wega-util:httpclient-get#1, xs:anyURI($url), $lease)
+ default return core:cache-doc(str:join-path-elements(($config:tmp-collection-path, $resource, $fileName)), wega-util:http-get#1, xs:anyURI($url), $lease)
return
if($response//httpclient:response/@statusCode eq '200') then $response//httpclient:response
else ()
@@ -85,6 +89,28 @@ declare function wega-util:http-get($url as xs:anyURI) as element(wega:externalR
};
+(:~
+ : Helper function for wega:grabExternalResource()
+ :
+ : @author Peter Stadler
+ : @param $url the URL as xs:anyURI
+ : @return element wega:externalResource, a wrapper around httpclient:response
+ :)
+declare function wega-util:httpclient-get($url as xs:anyURI) as element(wega:externalResource) {
+ let $req :=
+ let $response :=
+ try { httpclient:get($url, true(), ) }
+ catch * {core:logToFile('warn', string-join(('wega-util:httpclient-get', $err:code, $err:description, 'URL: ' || $url), ' ;; '))}
+ (:let $response :=
+ if($response/httpclient:body[matches(@mimetype,"text/html")]) then wega:changeNamespace($response,'http://www.w3.org/1999/xhtml', 'http://exist-db.org/xquery/httpclient')
+ else $response:)
+(: let $statusCode := $response[1]/data(@status):)
+ return
+
+ { $response }
+
+};
+
declare function wega-util:beacon-map($gnd as xs:string, $docType as xs:string) as map(*) {
let $findbuchResponse :=
switch($docType)