Skip to content

Commit

Permalink
Add 'commit' property to play info data when available
Browse files Browse the repository at this point in the history
  • Loading branch information
cmil committed Apr 19, 2024
1 parent f97040e commit ad4175c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
15 changes: 15 additions & 0 deletions api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,18 @@ components:
type: string
Play:
type: object
required:
- id
- name
- corpus
- title
- authors
- characters
- segments
- yearNormalized
- allInSegment
- libretto
- uri
properties:
wikidataId:
type: string
Expand Down Expand Up @@ -1584,6 +1596,9 @@ components:
nullable: true
originalSource:
type: string
uri:
type: string
format: url
NodeInPlayMetrics:
type: object
properties:
Expand Down
5 changes: 3 additions & 2 deletions modules/api.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,14 @@ function api:corpus-index($corpusname) {
map:entry("plays", array {
for $tei in $col//tei:TEI
let $paths := dutil:filepaths(base-uri($tei))
let $sha := doc($paths?files?git)/git/sha/text()
let $name := $paths?playname
let $id := dutil:get-dracor-id($tei)
let $titles := dutil:get-titles($tei)
let $titlesEng := dutil:get-titles($tei, 'eng')
let $years := dutil:get-years-iso($tei)
let $authors := dutil:get-authors($tei)
let $play-uri :=
$config:api-base || "/corpora/" || $corpusname || "/plays/" || $name
let $play-uri := $paths?uri
let $metrics-url := $paths?files?metrics
let $network-size := doc($metrics-url)//network/size/text()
let $yearNormalized := dutil:get-normalized-year($tei)
Expand All @@ -437,6 +437,7 @@ function api:corpus-index($corpusname) {
return map:merge((
map:entry("id", $id),
map:entry("uri", $play-uri),
if ($sha) then map:entry("commit", $sha) else (),
map:entry("name", $name),
map:entry("title", $titles?main),
if ($titles?sub) then map:entry("subtitle", $titles?sub) else (),
Expand Down
10 changes: 8 additions & 2 deletions modules/util.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ declare function dutil:filepaths (
) as map() {
let $playpath := $config:corpora-root || "/" || $corpusname || "/" || $playname
let $url := $playpath || "/" || $filename
let $uri :=
$config:api-base || "/corpora/" || $corpusname || "/plays/" || $playname
return map {
"uri": $uri,
"url": $url,
"filename": $filename,
"playname": $playname,
Expand All @@ -68,6 +71,7 @@ declare function dutil:filepaths (
"tei": $playpath || "/tei.xml",
"metrics": $playpath || "/metrics.xml",
"rdf": $playpath || "/rdf.xml",
"git": $playpath || "/git.xml",
"sitelinks": $playpath || "/sitelinks.xml"
}
}
Expand Down Expand Up @@ -948,10 +952,11 @@ declare function dutil:get-play-info(
return if (not($doc)) then
()
else
let $paths := dutil:filepaths($corpusname, $playname)
let $sha := doc($paths?files?git)/git/sha/text()
let $tei := $doc//tei:TEI
let $id := dutil:get-dracor-id($tei)
let $uri :=
$config:api-base || "/corpora/" || $corpusname || "/plays/" || $playname
let $uri := $paths?uri
let $titles := dutil:get-titles($tei)
let $titlesEn := dutil:get-titles($tei, 'eng')
let $source := dutil:get-source($tei)
Expand Down Expand Up @@ -1036,6 +1041,7 @@ declare function dutil:get-play-info(
if($titlesEn?main) then map:entry("titleEn", $titlesEn?main) else (),
if($titles?sub) then map:entry("subtitle", $titles?sub) else (),
if($titlesEn?sub) then map:entry("subtitleEn", $titlesEn?sub) else (),
if($sha) then map:entry("commit", $sha) else (),
if($wikidata-id) then
map:entry("wikidataId", $wikidata-id)
else (),
Expand Down

0 comments on commit ad4175c

Please sign in to comment.