Commit 93b76ce4 authored by Moritz Schepp's avatar Moritz Schepp
Browse files

Merge branch 'staging' into search

parents 356d6773 78990580
## Summary ##
(Summarize the issue encountered concisely)
## Where did you encounter the issue? ##
(How one can reproduce the issue - this is very important! Please provide
links or at least an expressive reference like "see: Harrach, p.9". Try to be
as precise as possible)
## What is the current behavior? ##
(What you actually see)
## What is the expected correct behavior? ##
(What you should see instead)
## Relevant logs and/or screenshots ##
(If you have any relevant error messages, please include them here.
Please add three backticks (```) before and after your error message)
## Further information ##
(Should you desire to include any additional information regarding the issue,
include it here)
(Please select the priority of this issue: low, medium, or high.
To do so, simply remove two of the three following lines, leaving only the one
containing the priority you want to assign the label)
/label ~"priority::high"
/label ~"priority::medium"
/label ~"priority::low"
......@@ -105,7 +105,7 @@ declare
%output:method("json")
function registerapi:get-persons-in-works($id as xs:string*) as element(response) {
let $doc := doc("/db/apps/sade-architrave/templates/register/works.xml")
let $persons := $doc//tei:text//tei:persName[@ref='textgrid:'||$id]
let $persons := $doc//tei:text//tei:persName[@ref='psn:textgrid:'||$id]
return <resp>
{for $node in $persons return
element tei:persName {
......@@ -128,5 +128,153 @@ declare
%output:media-type("application/json")
%output:method("json")
function registerapi:get-places-in-works($id as xs:string*) as element(response) {
<resp>{doc("/db/apps/sade-architrave/templates/register/works.xml")//tei:text//tei:placeName[@ref='textgrid:'||$id]}</resp>
};
\ No newline at end of file
let $doc := doc("/db/apps/sade-architrave/templates/register/works.xml")
let $places := $doc//tei:text//tei:placeName[@ref='textgrid:'||$id]
return <resp>
{for $node in $places return
element tei:placeName {
attribute ref {$node/@ref},
attribute ancestor {$node/[ancestor::tei:item/@xml:id]},
attribute ancestorNameCurrentDE {$node/[ancestor::tei:item/tei:name[@xml:lang='de']]},
attribute ancestorNameCurrentFRA {$node/[ancestor::tei:item/tei:name[@xml:lang='fra']]}
}
}
</resp>
};
(:~
: query to find occurences of places in persons by textgridID
: :)
declare
%rest:GET
%rest:path("/get-places-in-persons/{$id}")
%rest:produces("application/json")
%output:media-type("application/json")
%output:method("json")
function registerapi:get-places-in-persons($id as xs:string*) as element(response) {
let $doc := doc("/db/apps/sade-architrave/templates/register/persons.xml")
let $places := $doc//tei:text//tei:placeName[@ref='textgrid:'||$id]
return <resp>
{for $node in $places return
element tei:placeName {
attribute ref {$node/@ref},
attribute ancestor {$node/[ancestor::tei:item/@xml:id]},
attribute ancestorNameCurrentDE {$node/[ancestor::tei:item/tei:name[@xml:lang='de']]},
attribute ancestorNameCurrentFRA {$node/[ancestor::tei:item/tei:name[@xml:lang='fra']]}
}
}
</resp>
};
(:~
: query to find occurences of places in works by textgridID
: :)
declare
%rest:GET
%rest:path("/get-persons-in-text/{$text}/{$id}")
%rest:produces("application/json")
%output:media-type("application/json")
%output:method("json")
function registerapi:get-persons-in-text($text as xs:string, $id as xs:string) as element(response) {
let $doc :=
try {doc("/db/apps/sade-architrave/textgrid/data/" || $text || ".xml")}
catch * {""}
let $personsXML := doc("/db/apps/sade-architrave/templates/register/persons.xml")
let $persons := $doc//tei:persName[@ref='psn:textgrid:'||$id]
return <resp>
{for $node in $persons return
element tei:persName {
attribute ref {$node/@ref},
attribute refNameDE {
$personsXML//tei:person[@xml:id='textgrid:'||$id]/tei:persName[@xml:lang='de']
},
attribute refNameFR {
$personsXML//tei:person[@xml:id='textgrid:'||$id]/tei:persName[@xml:lang='fra']
},
attribute editionID {$text},
attribute editionPage {$node/[preceding::tei:pb[1]/@n]}
}
}
</resp>
};
(:~
: query to find occurences of places in works by textgridID
: :)
declare
%rest:GET
%rest:path("/get-places-in-text/{$text}/{$id}")
%rest:produces("application/json")
%output:media-type("application/json")
%output:method("json")
function registerapi:get-places-in-text($text as xs:string, $id as xs:string) as element(response) {
let $doc :=
try {doc("/db/apps/sade-architrave/textgrid/data/" || $text || ".xml")}
catch * {""}
let $placesXML := doc("/db/apps/sade-architrave/templates/register/places.xml")
let $places := $doc//tei:placeName[@ref='plc:textgrid:'||$id]
let $geogNames := $doc//tei:geogName[@ref='plc:textgrid:'||$id]
return <resp>
{for $node in $places return
element tei:placeName {
attribute ref {$node/@ref},
attribute refNameDE {
$placesXML//tei:place[@xml:id='textgrid:'||$id]/tei:placeName[@xml:lang='de']
},
attribute refNameFR {
$placesXML//tei:place[@xml:id='textgrid:'||$id]/tei:placeName[@xml:lang='fra']
},
attribute editionID {$text},
attribute editionPage {$node/[preceding::tei:pb[1]/@n]}
}
}
{for $node in $geogNames return
element tei:placeName {
attribute ref {$node/@ref},
attribute refNameDE {
$placesXML//tei:place[@xml:id='textgrid:'||$id]/tei:placeName[@xml:lang='de']
},
attribute refNameFR {
$placesXML//tei:place[@xml:id='textgrid:'||$id]/tei:placeName[@xml:lang='fra']
},
attribute editionID {$text},
attribute editionPage {$node/[preceding::tei:pb[1]/@n]}
}
}
</resp>
};
(:~
: query to find occurences of places in works by textgridID
: :)
declare
%rest:GET
%rest:path("/get-works-in-text/{$text}/{$id}")
%rest:produces("application/json")
%output:media-type("application/json")
%output:method("json")
function registerapi:get-works-in-text($text as xs:string, $id as xs:string) as element(response) {
let $doc :=
try {doc("/db/apps/sade-architrave/textgrid/data/" || $text || ".xml")}
catch * {""}
let $worksXML := doc("/db/apps/sade-architrave/templates/register/works.xml")
let $works := $doc//tei:rs[@ref='wrk:textgrid:'||$id]
return <resp>
{for $node in $works return
element tei:item {
attribute ref {$node/@ref},
attribute refNameDE {
$worksXML//tei:item[@xml:id='textgrid:'||$id]/tei:name[@xml:lang='de']
},
attribute refNameFR {
$worksXML//tei:item[@xml:id='textgrid:'||$id]/tei:name[@xml:lang='fra']
},
attribute editionID {$text},
attribute editionPage {$node/[preceding::tei:pb[1]/@n]}
}
}
</resp>
};
This diff is collapsed.
xquery version "3.1";
(:~
: This skript is launched on each click on a button of the register.html
: @author Florian Barth
:)
declare namespace tei = "http://www.tei-c.org/ns/1.0";
declare namespace xhtml="http://www.w3.org/1999/xhtml";
declare option exist:serialize "method=xhtml media-type=text/html";
(:
declare variable $button_parameter := "persons";
declare variable $language_parameter := "de";
declare variable $letter_value := "button_unnamed";
declare variable $letter_text := "unnamed";
:)
declare variable $button_parameter := request:get-parameter("button_parameter", ());
declare variable $language_parameter := request:get-parameter("language_parameter", ());
declare variable $letter_value := request:get-parameter("letter_value_parameter", ());
declare variable $letter_text := request:get-parameter("letter_text_parameter", ());
declare variable $language :=
if ($language_parameter = "de") then "de"
else if ($language_parameter = "fr") then "fra"
else ();
declare variable $EntityNames :=
if ($button_parameter = "persons") then doc("/db/apps/sade-architrave/templates/register/persons.xml")//tei:person//tei:persName[@xml:lang=$language]
else if ($button_parameter = "places") then doc("/db/apps/sade-architrave/templates/register/places.xml")//tei:place//tei:placeName[@xml:lang=$language and @type='current']
else if ($button_parameter = "works") then doc("/db/apps/sade-architrave/templates/register/works.xml")//tei:item/tei:name[@xml:lang=$language]
else();
(:
declare variable $Text4notIdentified :=
if ($button_parameter = "persons") then <span data-template="lang:translate" data-template-content="unidentifiedPerson"/>
else if ($button_parameter = "places") then <span data-template="lang:translate" data-template-content="unidentifiedPlace"/>
else if ($button_parameter = "works") then <span data-template="lang:translate" data-template-content="unidentifiedWork"/>
else();
:)
declare variable $entityClass :=
if ($button_parameter = "persons") then "persName"
else if ($button_parameter = "places") then "placeName"
else if ($button_parameter = "works") then "ArtWork"
else();
declare variable $entityAbbr :=
if ($button_parameter = "persons") then "psn"
else if ($button_parameter = "places") then "plc"
else if ($button_parameter = "works") then "wrk"
else();
declare variable $openEntity :=
if ($button_parameter = "persons") then "openPersName"
else if ($button_parameter = "places") then "openPlaceName"
else if ($button_parameter = "works") then "openArtWork"
else();
declare variable $entityElements :=
if ($button_parameter = "persons") then doc("/db/apps/sade-architrave/templates/register/persons.xml")//tei:person
else if ($button_parameter = "places") then doc("/db/apps/sade-architrave/templates/register/places.xml")//tei:place
else if ($button_parameter = "works") then doc("/db/apps/sade-architrave/templates/register/works.xml")//tei:item
else();
declare variable $letter_query :=
if ($letter_value = "button_other") then "^[^A-Za-zÄäÖöÜüÉéÎîÈè]"
else "^[" || $letter_value || "]";
<div id="register_ul_css">
<ul>
<h2>{string($letter_text)}</h2>
{
if ($letter_value = "button_unnamed") then
for $EntityName at $pos in $EntityNames
(:
VARIABLE $tgUri DOESNT WORK HERE IN CONTRAST TO THE ELSE STATEMENT BELOW
let $tgUri := data($entityElements[$pos]/@xml:id)
:)
where $EntityName[not(text())]
return
element xhtml:li
{
element xhtml:a
{
attribute class {$entityClass},
attribute href {"#/"},
attribute onclick {$openEntity || "('" || $entityAbbr || ":" || data($entityElements[$pos]/@xml:id) || "')"},
attribute textgriduri {"('" || $entityAbbr || ":" || data($entityElements[$pos]/@xml:id) || "')"},
(: $Text4notIdentified :)
string($letter_text)
}
}
else
for $EntityName at $pos in $EntityNames
let $tgUri := data($entityElements[$pos]/@xml:id)
where matches(string($EntityNames[$pos]), $letter_query)
order by $EntityName/text()
return
element xhtml:li
{
element xhtml:a
{
attribute class {$entityClass},
attribute href {"#/"},
attribute onclick {$openEntity || "('" || $entityAbbr || ":" || $tgUri || "')"},
attribute textgriduri {"('" || $entityAbbr || ":" || $tgUri || "')"},
$EntityName
}
}
}
</ul>
</div>
\ No newline at end of file
......@@ -10,6 +10,10 @@ module namespace tgconnect="https://sade.textgrid.de/ns/connect";
import module namespace config="https://sade.textgrid.de/ns/config" at "../config.xqm";
import module namespace templates="http://exist-db.org/xquery/templates";
import module namespace tgclient="https://sade.textgrid.de/ns/tgclient" at "client.xqm";
import module namespace transformXML="https://sade.textgrid.de/ns/transform" at "/db/apps/sade-architrave/modules/architrave/transform.xqm";
import module namespace console="http://exist-db.org/xquery/console";
declare namespace http="http://expath.org/ns/http-client";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
......@@ -26,17 +30,7 @@ declare namespace xhtml="http://www.w3.org/1999/xhtml";
: :)
declare function tgconnect:publish( $uri as xs:string, $sid as xs:string )
{
tgconnect:publish
(
$uri,
$sid,
$target,
$user,
$password,
$project,
$surface,
false()
)
console:log("Hello world!")
};
(:~ The main function for the publisher.
......@@ -63,25 +57,30 @@ declare function tgconnect:publish( $uri as xs:string,
$surface as xs:string,
$login as xs:boolean) {
let $targetPath := $config:app-root || "/" || config:get("project-id")
let $temp := console:log("Hello world!")
(: let $targetPath := $config:app-root || "/" || config:get("project-id"):)
let $targetPath := '/db/apps/sade-architrave/textgrid'
(: we try to log in at the collection at first, so we can raise an error, if the
: valid credentials are missing :)
let $log as xs:boolean :=
if($login = false())
then xmldb:login($config:app-root , $user, $password )
then xmldb:login("/db/apps/sade-architrave" , $user, $password )
else true()
return
if ( $log )
(: we are logged in, so we can proceed :)
then
let $temp := console:log("logged in")
let $prepare as xs:boolean := local:prepare()
let $tgcrudUrl as xs:string := config:get("textgrid.tgcrud") => string()
let $preserveRevisions := config:get("textgrid.preserveRevisions") = "true"
let $metadataContainer as element( tgmd:MetadataContainerType ) := tgclient:getMeta($uri, $tgcrudUrl, $sid)
let $tguri := $metadataContainer//tgmd:textgridUri => string()
let $temp := console:log($tguri)
let $rdfstoreUrl :=
if ($metadataContainer//tgmd:generated/tgmd:availability = "public")
......@@ -120,7 +119,7 @@ declare function tgconnect:publish( $uri as xs:string,
let $data :=
try { tgclient:getData($pubUri, $tgcrudUrl, $sid) }
catch * { error( QName("https://sade.textgrid.de/ns/error", "PUBLISH03"),
"getData failed with " || $err:code || ": " || $err:description
"getData failed for " || $pubUri || " with " || $err:code || ": " || $err:description
|| "Is your file conform to XML standard?") }
let $name := (: JING requires :)
if($data/*/namespace-uri() = "http://relaxng.org/ns/structure/1.0")
......@@ -129,9 +128,15 @@ declare function tgconnect:publish( $uri as xs:string,
let $store :=
try { xmldb:store($targetPath||"/data", $name, $data, "text/xml") }
catch * { error( QName("https://sade.textgrid.de/ns/error", "PUBLISH04"),
"storing the data failed with " || $err:code || ": " || $err:description
"storing the data for "|| $name ||" failed with " || $err:code || ": " || $err:description
|| "Is your file conform to XML standard? Typical mistakes are empty xml:id attributes.") }
let $temp := console:log("transforming from XML to HTML...")
let $uriname := substring-before($targetUri,'.')
let $transform :=
try { transformXML:importFromTGLab($uriname) }
catch * { error( QName("https://sade.textgrid.de/ns/error", "PUBLISH07"),
"transforming the data for "|| $name ||" failed with " || $err:code || ": " || $err:description
|| "Is your file conform to XML standard?") }
let $render := (: this is where you can start with prerendering.
it is recommended to call a function placed
at the bottom or in a separat module. :)
......@@ -166,12 +171,12 @@ declare function tgconnect:publish( $uri as xs:string,
let $data :=
try { tgclient:getData($pubUri, $tgcrudUrl, $sid) }
catch * { error( QName("https://sade.textgrid.de/ns/error", "PUBLISH05"),
"get data failed with " || $err:code || ": " || $err:description
"get data failed " || $pubUri || " with " || $err:code || ": " || $err:description
)}
let $store :=
try { xmldb:store($targetPath || '/tile', $targetUri, $data) }
catch * { error( QName("https://sade.textgrid.de/ns/error", "PUBLISH06"),
"get data failed with " || $err:code || ": " || $err:description
"get data for " || $pubUri || " failed with " || $err:code || ": " || $err:description
) }
return $targetUri
......@@ -201,25 +206,10 @@ declare function tgconnect:publish( $uri as xs:string,
let $path := system:get-exist-home() || util:system-property("file.separator")
let $name := replace($targetUri, "xml", "txt")
let $title := string($meta//tgmd:title)
let $store :=
if( $title = ("synonyms.txt", "charmap.txt") )
then
let $do := try { file:serialize-binary( $base64, $path || $title ) }
catch * { error(
QName("https://sade.textgrid.de/ns/error", "PUBLISH07"),
"storing lucene configuration failed with " || $err:code || ": " || $err:description)
},
$reindex := xmldb:reindex( $targetPath || "/data" )
return
$path || $title
else
xmldb:store($targetPath || "/data", $name, $text, "text/plain")
let $store := xmldb:store($targetPath || "/data", $name, $text, "text/plain")
return $name
default return
error(
QName("https://sade.textgrid.de/ns/error", "PUBLISH08"),
"The publisher does not know how to handle " || string($meta//tgmd:format) || "."
)
"The publisher does not know how to handle " || string($meta//tgmd:format) || "."
else
error(
......@@ -236,15 +226,15 @@ else
declare function local:prepare() as xs:boolean {
let $project-id := config:get("project-id")
return
if( xmldb:collection-available(xs:anyURI($config:app-root || "/" || $project-id)) ) then true()
if( xmldb:collection-available(xs:anyURI("/db/apps/sade-architrave" || "/" || $project-id)) ) then true()
else
let $do :=
(xmldb:create-collection($config:app-root, $project-id),
xmldb:create-collection($config:app-root || "/" || $project-id, "data"),
xmldb:create-collection($config:app-root || "/" || $project-id, "meta"),
xmldb:create-collection($config:app-root || "/" || $project-id, "agg"),
xmldb:create-collection($config:app-root || "/" || $project-id, "tile"),
xmldb:create-collection($config:app-root || "/" || $project-id, "rdf")
(xmldb:create-collection("/db/apps/sade-architrave", $project-id),
xmldb:create-collection("/db/apps/sade-architrave" || "/" || $project-id, "data"),
xmldb:create-collection("/db/apps/sade-architrave" || "/" || $project-id, "meta"),
xmldb:create-collection("/db/apps/sade-architrave" || "/" || $project-id, "agg"),
xmldb:create-collection("/db/apps/sade-architrave" || "/" || $project-id, "tile"),
xmldb:create-collection("/db/apps/sade-architrave" || "/" || $project-id, "rdf")
)
return true()
};
......
xquery version "3.1";
(:~
: Provides the endpoint for SADE Publish process
:)
......@@ -18,9 +17,11 @@ let $uri as xs:string := request:get-parameter("uri", ""),
return
if( $uri = "" ) then
error(QName("https://sade.textgrid.de/ns/error", "PUBLISH01"), "no URI provided")
else
else if (contains($uri, '34zmq') or contains($uri, '3r3nn') or contains($uri, '34zs7') or contains($uri, '3ptwg') or contains($uri, '3qr4f') or contains($uri, '34znb') or contains($uri, '3czfj') or contains($uri, '3q4rq') or contains($uri, '3r0fv') or contains($uri, '350mg') or contains($uri, '3c0m2') or contains($uri, '3czn9') ) then
<div>{
for $i in tgconnect:publish($uri,$sid,$target,$user,$password,$project,$surface,$login)
return
<ok>{$uri} » {$i}</ok>
<ok>{ $uri } » { $i }</ok>
}</div>
else
error(QName("https://sade.textgrid.de/ns/error", "PUBLISH09"), "Please publish only the xml files of the 12 editions/translations.")
......@@ -17,19 +17,16 @@
<item label-en="Sturm" label-de="Sturm" label="Sturm" link="view.html?edition=34zs7&amp;page=1&amp;translation=3q4rq"/>
<item label-en="Neumann" label-de="Neumann" label="Neumann" link="view.html?edition=3qr4f&amp;page=1&amp;translation=3r3nn"/>
<item class="divider"/>
<item label-en="Registers" label-de="Register" label="Index" link=""/>
<item label-en="Registers" label-de="Register" label="Index" link="register.html"/>
<item label-en="Guidelines" label-de="Editionsrichtlinien" label="Normes éditoriales" link="guidelines.html"/>
</submenu>
<submenu label-en="Visualization" label-de="Visualisierungen" label="Visualisations">
<item label-en="itinerary" label-de="Reiseverläufe" label="Itinéraires des voyageurs" link=""/>
<item label-en="plan of paris" label-de="Plan von Paris" label="Plan de Paris" link=""/>
<item label-en="castle of versailles" label-de="Schloss von Versailles" label="Château de Versailles" link=""/>
<item label-en="garden of versailles" label-de="Garten von Versailles" label="Jardins de Versailles" link=""/>
<item label-en="timeline" label-de="Timeline" label="Frise chronologique" link=""/>
<item label-en="itinerary" label-de="Reiseverläufe" label="Itinéraires des voyageurs" link="itinerary.html"/>
<item label-en="timeline" label-de="Timeline" label="Frise chronologique" link="timeline.html"/>
</submenu>
<submenu label-en="Activities" label-de="Aktivitäten" label="Activités">
<item label-en="Workshop2017" label-de="Workshop 2017" label="Journée d'études 2017" link="content.html?id=58499644"/>
<item label-en="Workshop2018" label-de="Workshop 2018" label="Journée d'études 2018" link="content.html?id=58499640"/>
<item label-en="colloquium2020" label-de="Tagung 2020" label="Colloque 2020" link="content.html?id=64974546"/>
</submenu>
</navigation>
</navigation>
\ No newline at end of file
......@@ -314,6 +314,12 @@ body .lm_content {
color: #c90057;
}
.error {
color: #ff0000;
font-size: smaller;
font-style: italic;
}
body footer {
margin-top:12px;
}
......@@ -70,3 +70,64 @@ button:focus {
filter: gray; /* Internet Explorer IE6-9 */
-webkit-filter: grayscale(1); /* Old WebKit Browsers */
}
.latin {
font-family: "ModernAntiqua", sans-serif;
font-size: 0.85em;
}
.italic {
font-style: italic;
}
.underline {
text-decoration: underline;
}
table {
width: 100%;
}
caption {
caption-side: top;
color: inherit;
padding: 0;
}
.horizontalRule {
border-bottom: 1px solid black;
display: inline-block;
top: -0.5rem;
position: relative;
width: 20%;
}
.tei-item {
display: list-item;
list-style: none;
margin-left: 1rem;
}
.topRight {
float: right;
}
.centeredText {
display: flow-root;
margin: auto;
width: 50%;
}
.tei-figDesc {
margin-top: 0.5rem;
display: inline-block;
}
.tei-figDesc:last-of-type {
margin-bottom: 0.5rem;
}
.tei-figure {
display: block;
margin-top: 1rem;
}
\ No newline at end of file
#droptarget {
overflow: auto;
}
.drop_enabled {
border: #e9e9e9 1px dotted;
}
.drop_enabled:hover {
background-color: #e9e9e9;
}
#droptarget .panel-body{
height: 150px;
display: flex;
justify-content: space-between;