Commit 2ca160e0 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

Merge branch 'release/corrected-uris'

parents d85c48af b727f227
......@@ -29,7 +29,7 @@
<target name="productive">
<replace file="${basedir}/post-install.xql" token="$notebooks := $notebooks" value="$notebooks := ('textgrid:16b00', 'textgrid:zzdb', 'textgrid:zzdq')"/>
<replace file="${basedir}/post-install.xql" token="$notebooks := $notebooks" value="$notebooks := ('textgrid:16b00', 'textgrid:1zzdb', 'textgrid:1zzdq')"/>
<antcall target="xar"/>
<!-- and undo this stuff -->
<replace file="${basedir}/post-install.xql" token="$notebooks := '$notebooks := ('textgrid:16b00', 'textgrid:zzdb', 'textgrid:zzdq')'" value="$notebooks := $notebooks"/>
xquery version "3.1";
import module namespace console="";
import module namespace fontaneTransfo="" at "/db/apps/SADE/modules/multiviewer/fontane.xqm";
import module namespace xqjson="";
declare default element namespace "";
(:declare namespace output = "";:)
(:declare namespace json="";:)
declare namespace tei="";
declare namespace digilib="digilib:digilib";
declare namespace svg="";
declare namespace xlink="";
declare option exist:serialize "method=text media-type=application/json omit-xml-declaration=yes";
(: see: :)
(:declare option output:method "json";:)
(:declare option output:media-type "application/json";:)
(:declare option output:indent "yes";:)
(:declare option exist:serialize "indent=yes";:)
declare variable $tei := request:get-parameter("tei", "textgrid:16b00");
declare variable $img := request:get-parameter("img", "textgrid:164h2.1");
declare variable $surfaces := collection('/db/sade-projects/textgrid/data/xml/data/')//tei:sourceDoc/tei:surface[ends-with(@facs, substring-before($img, "."))];
declare variable $xywh :=
for $surface in $surfaces
let $dstringarr := fontaneTransfo:digilib($surface) => tokenize('&amp;')
let $wx := $dstringarr[starts-with(., 'wx')] => substring(4) cast as xs:float
let $wy := $dstringarr[starts-with(., 'wy')] => substring(4) cast as xs:float
let $wh := $dstringarr[starts-with(., 'wh')] => substring(4) cast as xs:float
let $ww := $dstringarr[starts-with(., 'ww')] => substring(4) cast as xs:float
let $ix := doc("/db/sade-projects/textgrid/data/xml/data/217qs.xml")//digilib:image[@uri=$img]
let $ixw := $ix/@width cast as xs:integer
let $ixh := $ix/@height cast as xs:integer
$x := $wx * $ixw,
$y := $wy * $ixh,
$w := $ww * $ixw,
$h := $wh * $ixh
map:entry(string($surface/@n), ($x, $y, $w, $h))
declare variable $dpcm := 236.2205;
declare function local:dispatch($node as node()) as item()* {
let $sf := string($node/ancestor-or-self::tei:surface[parent::tei:sourceDoc]/@n)
$x := $xywh($sf)[1],
$y := $xywh($sf)[2],
$w := $xywh($sf)[3],
$h := $xywh($sf)[4]
(: case element(tei:zone):)
(: return <div>{local:passthru($node)}</div>:)
case element(tei:zone)
let $style := data($node/@style)
let $bla := console:log($style)
let $ulx := if($node/@ulx) then number($node/@ulx) else 0
let $zx := $x + floor( ( $ulx * $dpcm ) )
let $uly := if($node/@uly) then number($node/@uly) else 0
let $zy := $y + floor( ( $uly * $dpcm ) )
let $zw := if( $node/@lrx ) then $w - $zx - number($node/@lrx) * $dpcm else $zx - $w
let $zh := if( $node/@lry ) then $h - $zy - number($node/@lry) * $dpcm else $h - $zy
<item type="object">
<pair name="@id" type="string">_:N{util:uuid()}</pair>
<pair name="@type" type="string">oa:Annotation</pair>
<pair name="motivation" type="string">sc:painting</pair>
<pair name="resource" type="object">
<pair name="@id" type="string">_:N{util:uuid()}</pair>
<pair name="@type" type="string">cnt:ContentAsText</pair>
<pair name="format" type="string">text/plain</pair>
<pair name="chars" type="string">{local:passthru($node)}</pair>
<pair name="language" type="string">de</pair>
<pair name="on" type="string">{$tei}/canvas/{$img}.json#xywh={$zx},{$zy},{$zw},{$zh}</pair>
case text()
return replace($node, '"', "&quot;")
return local:passthru($node)
declare function local:passthru($nodes as node()*) as item()* {
for $node in $nodes/node() return local:dispatch($node)
let $imgurl := ""||$img
let $xml :=
<json type="object">
<pair name="@context" type="string"></pair>
<pair name="@id" type="string">http://localhost:8080/exist/rest/apps/SADE/modules/fontane/anno.xq?tei={$tei}&amp;img={$img}</pair>
<pair name="@type" type="string">sc:AnnotationList</pair>
<pair name="resources" type="array">
{$surfaces//tei:zone ! local:dispatch(.)}
<!-- {$surfaces//tei:zone[@uly][contains(., "STAATSBIBLIOTHEK")] ! local:dispatch(.)}
let $egal := response:set-header("Access-Control-Allow-Origin", "*")
(:let $xml := :)
(:<json type="object">:)
(:<pair name="@context" type="string"></pair>:)
(:<pair name="@id" type="string">http://localhost/iiif/ann1.json</pair>:)
(:<pair name="@type" type="string">sc:AnnotationList</pair>:)
(:<pair name="resources" type="array">:)
(:<item type="object">:)
(:<pair name="@id" type="string">_:N9ffd445be244485d9cbff9fcdc9dcbd4</pair>:)
(:<pair name="@type" type="string">oa:Annotation</pair>:)
(:<pair name="motivation" type="string">sc:painting</pair>:)
(:<pair name="resource" type="object">:)
(:<pair name="@id" type="string">_:N3dbab1b51a6646c390ab3fae21c4c3af</pair>:)
(:<pair name="@type" type="string">cnt:ContentAsText</pair>:)
(:<pair name="format" type="string">text/plain</pair>:)
(:<pair name="chars" type="string">no[n] habetis Nondu[m] cognoscitis</pair>:)
(:<pair name="language" type="string">lat</pair>:)
(:<pair name="on" type="string">,557,1208,224</pair>:)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment