Skip to content

Commit

Permalink
added images from portraitindex.de
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Jan 22, 2016
1 parent 53d27a5 commit d0bd037
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
1 change: 1 addition & 0 deletions catalogues/options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
</div>
<div xml:id="externalPNDResources">
<entry xml:id="wikipedia">http://tools.wmflabs.org/persondata/redirect/gnd/</entry>
<entry xml:id="portraitindex">http://www.portraitindex.de/dokumente/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>
Expand Down
43 changes: 35 additions & 8 deletions modules/img.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ import module namespace functx="http://www.functx.com";
: @author Peter Stadler
: @param $pnd the PND number
: @param $lang the language variable (de|en)
: @return element the local path to the stored file
: @return
:)
declare function img:wikipedia-images($model as map(*), $lang as xs:string) as map(*)* {
let $pnd := query:get-gnd($model('doc'))
let $docID := $model('docID')
let $wikiArticle :=
if($pnd) then wega-util:grabExternalResource('wikipedia', $pnd, $lang)
else ()
Expand All @@ -90,8 +89,35 @@ declare function img:wikipedia-images($model as map(*), $lang as xs:string) as m
if($picURI castable as xs:anyURI) then
map {
'caption' := $caption,
'orgURI' := $picURI,
'docID' := $model('docID')
'thumbURI' := $picURI,
'origURI' := '',
'docID' := $model('docID'),
'source' := 'Wikimedia'
}
else ()
};

declare function img:portraitindex-images($model as map(*), $lang as xs:string) as map(*)* {
let $pnd := query:get-gnd($model('doc'))
let $page :=
if($pnd) then wega-util:grabExternalResource('portraitindex', $pnd, $lang)
else ()
let $pics := $page//xhtml:div[@class='listItemThumbnail']
let $log := util:log-system-out(count($pics))
return
for $div in $pics
let $caption := normalize-space($div/following-sibling::xhtml:p/xhtml:a) || ', ' || replace(normalize-space(string-join($div/following-sibling::xhtml:p/text(), ' ')), '&#65533;', ' ') || ' (Quelle: Digitaler Portraitindex)'
let $picURI := $div//xhtml:img/data(@src)
let $origURI := $div/xhtml:a/data(@href)
let $log := util:log-system-out($caption)
return
if($picURI castable as xs:anyURI) then
map {
'caption' := $caption,
'thumbURI' := $picURI,
'origURI' := $origURI,
'docID' := $model('docID'),
'source' := 'Digitaler Portraitindex'
}
else ()
};
Expand All @@ -101,13 +127,14 @@ declare
%templates:wrap
function img:iconography($node as node(), $model as map(*), $lang as xs:string) as map(*)* {
let $local-image := ()
let $portraitindex-images := img:portraitindex-images($model, $lang)
let $wikipedia-images := img:wikipedia-images($model, $lang)
return
map { 'iconographyImages' := $wikipedia-images }
map { 'iconographyImages' := ($portraitindex-images, $wikipedia-images) }
};

declare function img:iconographyImage($node as node(), $model as map(*)) as element(img) {
<img alt="{$model('iconographyImage')('caption')}" src="{$model('iconographyImage')('orgURI')}"/>
declare function img:iconographyImage($node as node(), $model as map(*)) as element(a) {
<a href="{$model('iconographyImage')('origURI')}"><img title="{$model('iconographyImage')('caption')}" alt="{$model('iconographyImage')('caption')}" src="{$model('iconographyImage')('thumbURI')}"/></a>
};


Expand Down Expand Up @@ -318,7 +345,7 @@ declare function img:get-wikipedia-portrait($model as map(*), $lang as xs:string
map {
'src' := (:controller:map-local-image-path-to-external(img:get-local-image-path($portrait, $size)):)
(: simply refer to the wikipedia image source and adjust the thumbnail size :)
replace($portrait('orgURI'), '/\d+px\-', '/260px-'),
replace($portrait('thumbURI'), '/\d+px\-', '/260px-'),
'alt' := $portrait('caption'),
'title' := $portrait('caption')
}
Expand Down

0 comments on commit d0bd037

Please sign in to comment.