Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow for different authors in the URL, closes #316 #333

Merged
merged 13 commits into from
Nov 28, 2019
Prev Previous commit
Next Next commit
improve jsonld output for multiple authors #316
and the landing page
  • Loading branch information
peterstadler committed Nov 15, 2019
commit 7ae91b9ebdac837cc4c94eaa200a5c4a88c83f20
36 changes: 25 additions & 11 deletions modules/lod.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ declare function lod:jsonld($model as map(*), $lang as xs:string) as map(*) {
let $schema.org-type := lod:schema.org-type($model)
let $identifier := lod:DC.identifier($model)
let $url :=
if($model?doc) then core:permalink(controller:path-to-resource($model?doc, $lang)[1])
(: multiple URLs are generated when the document features multiple authors :)
if($model?doc) then controller:path-to-resource($model?doc, $lang) ! core:permalink(.)
else $identifier
let $jsonld-common := map {
'@id': $identifier,
Expand All @@ -97,14 +98,24 @@ declare function lod:jsonld($model as map(*), $lang as xs:string) as map(*) {
(:array {
distinct-values(($model?doc//tei:text//tei:*[@key] | $model?doc/tei:ab//tei:*[@key])/@key) ! lod:jsonld-entity(<tei:rs key="{.}"/>, $lang)
}:)
let $image :=
if($model?docID = 'home') then core:permalink('resources/img/logo_weber.png')
let $homepageSpecials :=
if($model?docID = 'home') then map {
'image': core:permalink('resources/img/logo_weber.png'),
'logo': core:permalink('resources/favicons/mstile-150x150.png'),
"potentialAction": array {
map {
"@type": "SearchAction",
"target": core:permalink('de/Suche?q={search_term_string}'),
"query-input": "required name=search_term_string"
}
}
}
else ()
return
map:merge((
$jsonld-common, (: always included :)

if($image) then map { 'image': $image } else (), (: include image if available :)
$homepageSpecials, (: specials for the landing page :)

if($schema.org-type = ('CreativeWork', 'Article', 'NewsArticle')) then map:merge((
$jsonld-common,
Expand All @@ -126,13 +137,16 @@ declare function lod:jsonld($model as map(*), $lang as xs:string) as map(*) {
: Helper function for setting a schema.org type
:)
declare %private function lod:schema.org-type($model as map(*)) as xs:string {
switch(config:get-doctype-by-id($model?docID))
case 'news' return 'NewsArticle'
case 'persons' return 'Person'
case 'orgs' return 'Organization'
case 'places' return 'Place'
case 'addenda' case 'thematicCommentary' return 'Article'
default return 'CreativeWork'
if($model?docID = 'home')
then 'WebSite'
else
switch(config:get-doctype-by-id($model?docID))
case 'news' return 'NewsArticle'
case 'persons' return 'Person'
case 'orgs' return 'Organization'
case 'places' return 'Place'
case 'addenda' case 'thematicCommentary' return 'Article'
default return 'CreativeWork'
};

(:~
Expand Down